X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmaemo%2Fmodest-maemo-utils.c;h=6d50ee181155e65adb2eab198927c0d1b0769cd4;hb=6fb1323bf79f5fe514da3bbb44130fdfdbd8e46f;hp=0625b8f41dcf879fe093aee11ac65ebc8aef07d1;hpb=18d09c18a6d003857c7a3ff35fc403bff67386be;p=modest diff --git a/src/maemo/modest-maemo-utils.c b/src/maemo/modest-maemo-utils.c index 0625b8f..6d50ee1 100644 --- a/src/maemo/modest-maemo-utils.c +++ b/src/maemo/modest-maemo-utils.c @@ -75,7 +75,7 @@ modest_maemo_utils_menubar_to_menu (GtkUIManager *ui_manager) { GtkWidget *main_menu; GtkWidget *menubar; - GList *iter; + GList *children, *iter; g_return_val_if_fail (ui_manager, NULL); @@ -85,7 +85,7 @@ modest_maemo_utils_menubar_to_menu (GtkUIManager *ui_manager) /* Get the menubar from the UI manager */ menubar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar"); - iter = gtk_container_get_children (GTK_CONTAINER (menubar)); + iter = children = gtk_container_get_children (GTK_CONTAINER (menubar)); while (iter) { GtkWidget *menu; @@ -94,6 +94,7 @@ modest_maemo_utils_menubar_to_menu (GtkUIManager *ui_manager) iter = g_list_next (iter); } + g_list_free (children); return main_menu; } @@ -116,7 +117,6 @@ update_device_name_from_msg (DBusMessage *message) return; } dbus_message_iter_get_basic (&iter, &device_name); - g_warning ("update device name: %s", device_name); modest_conf_set_string (modest_runtime_get_conf(), MODEST_CONF_DEVICE_NAME, device_name, NULL); @@ -242,11 +242,12 @@ modest_maemo_utils_file_exists (const gchar *filename) } TnyFsStream * -modest_maemo_utils_create_temp_stream (const gchar *orig_name, gchar **path) +modest_maemo_utils_create_temp_stream (const gchar *orig_name, const gchar *hash_base, gchar **path) { gint fd; gchar *filepath = NULL; gchar *tmpdir; + guint hash_number; /* hmmm... maybe we need a modest_text_utils_validate_file_name? */ g_return_val_if_fail (orig_name || strlen(orig_name) == 0, NULL); @@ -263,8 +264,13 @@ modest_maemo_utils_create_temp_stream (const gchar *orig_name, gchar **path) } /* make a random subdir under /tmp or /var/tmp */ - tmpdir = g_strdup_printf ("%s/%d", g_get_tmp_dir (), (guint)random()); - if (g_mkdir (tmpdir, 0755) == -1) { + if (hash_base != NULL) { + hash_number = g_str_hash (hash_base); + } else { + hash_number = (guint) random (); + } + tmpdir = g_strdup_printf ("%s/%u", g_get_tmp_dir (), hash_number); + if ((g_access (tmpdir, R_OK) == -1) && (g_mkdir (tmpdir, 0755) == -1)) { g_warning ("%s: failed to create dir '%s': %s", __FUNCTION__, tmpdir, g_strerror(errno)); g_free (tmpdir); @@ -564,23 +570,6 @@ modest_maemo_utils_setup_images_filechooser (GtkFileChooser *chooser) } -static void -on_response (GtkDialog *dialog, gint response, gpointer user_data) -{ - /* Just destroy the dialog: */ - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -void -modest_maemo_show_information_note_and_forget (GtkWindow *parent_window, const gchar* message) -{ - GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, message)); - - /* Destroy the dialog when it is closed: */ - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (on_response), NULL); - gtk_widget_show (GTK_WIDGET (dialog)); -} - #if 0 static void on_hide (GtkDialog *dialog, gpointer user_data) @@ -611,7 +600,9 @@ on_idle_show_information(gpointer user_data) return FALSE; /* Don't call this again. */ } -void modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, const gchar* message) +void +modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, + const gchar* message) { ModestIdleNoteInfo *info = g_slice_new (ModestIdleNoteInfo); info->parent_window = parent_window; @@ -621,19 +612,26 @@ void modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *p } #endif -void modest_maemo_show_dialog_and_forget (GtkWindow *parent_window, GtkDialog *dialog) +void +modest_maemo_show_dialog_and_forget (GtkWindow *parent_window, + GtkDialog *dialog) { gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window); /* Destroy the dialog when it is closed: */ - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (on_response), NULL); + g_signal_connect_swapped (dialog, + "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + gtk_widget_show (GTK_WIDGET (dialog)); } void -modest_maemo_set_thumbable_scrollbar (GtkScrolledWindow *win, gboolean thumbable) +modest_maemo_set_thumbable_scrollbar (GtkScrolledWindow *win, + gboolean thumbable) { g_return_if_fail (GTK_IS_SCROLLED_WINDOW(win)); #ifdef MODEST_HAVE_HILDON1_WIDGETS @@ -663,3 +661,26 @@ modest_maemo_toggle_action_set_active_block_notify (GtkToggleAction *action, gbo } } + + + +FILE* +modest_maemo_open_mcc_mapping_file (void) +{ + FILE* result; + + /* Load the file one line at a time: */ +#ifdef MODEST_HILDON_VERSION_0 + const gchar* filepath = PROVIDER_DATA_DIR "/mcc_mapping"; +#else + const gchar* filepath = "/usr/share/operator-wizard/mcc_mapping"; +#endif /*MODEST_HILDON_VERSION_0*/ + + result = fopen (filepath, "r"); + if (!result) + g_printerr ("modest: failed to open mcc mapping file"); + + return result; +} + +