-2007-06-27 Murray Cumming,,, <murrayc@murrayc-desktop>
-
- reviewed by: <delete if not using a buddy>
-
- * src/modest-mail-operation.c: (update_account_thread),
- (get_msgs_full_thread):
-
* please check the svn log instead
2007-06-27 Murray Cumming <murrayc@murrayc.com
+ * src/modest-tny-account.h:
+ * src/modest-tny-account.c:
+ Added modest_tny_account_get_mmc_account_name(), to set the memory
+ card name asynchronously for the given account and then notify.
+ (modest_tny_account_new_for_local_folders): Use this new function instead
+ of using hildon_file_system_info_async_new() directly.
+
+ * src/widgets/modest-folder-view.c: (text_cell_data):
+ Use modest_tny_account_get_mmc_account_name() to get the real name, calling
+ gtk_tree_model_row_changed() when it is available.
+
+ This should fix projects.maemo.org bug NB#59301.
+
+2007-06-27 Murray Cumming <murrayc@murrayc.com
+
* src/modest-mail-operation.c: (update_account_thread),
(get_msgs_full_thread): Fix typo failures in the revert
to fix the build.
}
static gboolean
-on_secure_auth_finished (gpointer user_data)
+on_idle_secure_auth_finished (gpointer user_data)
{
ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
/* Operation has finished, close the dialog. Control continues after
printf("DEBUG: finished\n");
/* Close the dialog in a main thread */
- g_idle_add(on_secure_auth_finished, info);
+ g_idle_add(on_idle_secure_auth_finished, info);
}
gdk_threads_leave();
* specific dialog messages from Chapter 12 of the UI spec.
*/
case TNY_ACCOUNT_STORE_ERROR_UNKNOWN_ALERT:
-/* g_debug ("%s: Handling GError domain=%d, code=%d, message=%s", */
-/* __FUNCTION__, error->domain, error->code, error->message); */
+ /* This debug output is useful. Please keep it uncommented until
+ * we have fixed the problems in this function: */
+ g_debug ("%s: Handling GError domain=%d, code=%d, message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
/* TODO: Remove the internal error message for the real release.
* This is just so the testers can give us more information: */
g_object_set_data (G_OBJECT(tny_account), "account_store", (gpointer)astore);
tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (tny_account),
tny_device_is_online (device), &err);
- if (err)
- g_print ("Error connecting: %s\n", err->message);
+ if (err) {
+ g_print ("%s: tny_camel_account_set_online() failed: %s\n", __FUNCTION__, err->message);
+ g_error_free (err);
+ }
g_object_unref (device);
}
*/
return tny_account;
}
-/* TODO: Notify the treemodel somehow that the display name
- * is now available. We should probably request this from the cell_data_func
- * so we can provide a treerowreference. */
+typedef struct
+{
+ TnyStoreAccount *account;
+
+ ModestTnyAccountGetMmcAccountNameCallback callback;
+ gpointer user_data;
+} GetMmcAccountNameData;
+
+/* Gets the memory card name: */
static void
on_modest_file_system_info(HildonFileSystemInfoHandle *handle,
- HildonFileSystemInfo *info,
- const GError *error, gpointer data)
+ HildonFileSystemInfo *info,
+ const GError *error, gpointer data)
{
- TnyAccount *account = TNY_ACCOUNT (data);
+ GetMmcAccountNameData *callback_data = (GetMmcAccountNameData*)data;
+
+ if (error) {
+ g_warning ("%s: error=%s", __FUNCTION__, error->message);
+ }
if (error) {
/* printf (" DEBUG: %s: error=%s\n", __FUNCTION__, error->message); */
display_name = hildon_file_system_info_get_display_name(info);
}
- if (display_name) {
+ TnyAccount *account = TNY_ACCOUNT (callback_data->account);
+
+ const gchar * previous_display_name = tny_account_get_name (account);
+
+ /* Use the new name if it is different: */
+ if (display_name &&
+ (previous_display_name && (strcmp (display_name, previous_display_name) != 0))) {
/* printf ("DEBUG: %s: display name=%s\n", __FUNCTION__, display_name); */
tny_account_set_name (account, display_name);
+
+ /* Inform the application that the name is now ready: */
+ if (callback_data->callback)
+ (*(callback_data->callback)) (callback_data->account,
+ callback_data->user_data);
}
+
+ g_object_unref (callback_data->account);
+ g_slice_free (GetMmcAccountNameData, callback_data);
}
+void modest_tny_account_get_mmc_account_name (TnyStoreAccount* self, ModestTnyAccountGetMmcAccountNameCallback callback, gpointer user_data)
+{
+ gchar* uri = tny_account_get_url_string (TNY_ACCOUNT (self));
+ if (!uri)
+ return;
+
+ //This is freed in the callback:
+ GetMmcAccountNameData * callback_data = g_slice_new0(GetMmcAccountNameData);
+ callback_data->account = self;
+ g_object_ref (callback_data->account); /* Unrefed when we destroy the struct. */
+ callback_data->user_data = user_data;
+
+ /* TODO: gnome_vfs_volume_get_display_name() does not return
+ * the same string. But why not? Why does hildon needs its own
+ * function for this?
+ */
+ hildon_file_system_info_async_new(uri,
+ on_modest_file_system_info, callback_data /* user_data */);
+
+ g_free (uri);
+}
+
+
TnyAccount*
modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySessionCamel *session, const gchar* location_filepath)
g_error_free (error);
error = NULL;
} else if (uri) {
- /* TODO: gnome_vfs_volume_get_display_name() does not return
- * the same string. But why not? Why does hildon needs its own
- * function for this?
+ /* Get the account name asynchronously:
+ * This might not happen soon enough, so some UI code might
+ * need to call this again, specifying a callback.
*/
- hildon_file_system_info_async_new(uri,
- on_modest_file_system_info, tny_account /* user_data */);
+ modest_tny_account_get_mmc_account_name (tny_account, NULL, NULL);
g_free (uri);
uri = NULL;
}
+
+
* so it can be retrieved later with
* modest_tny_account_get_parent_modest_account_name_for_server_account().
*/
-void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *self, const gchar* parent_modest_acount_name);
+void modest_tny_account_set_parent_modest_account_name_for_server_account (TnyAccount *account, const gchar* parent_modest_acount_name);
+
+
+typedef void (*ModestTnyAccountGetMmcAccountNameCallback) (TnyStoreAccount* self, gpointer user_data);
+
+/** modest_tny_account_get_mmc_account_name:
+ * Asnchronously get the name of a memory card account and set it in the TnyAccount,
+ * calling the callback (if not NULL) to notify that the name is changed.
+ * if the name was changed. The callback will not be called if the name was not changed.
+ */
+void modest_tny_account_get_mmc_account_name (TnyStoreAccount* self, ModestTnyAccountGetMmcAccountNameCallback callback, gpointer user_data);
G_END_DECLS
#include <tny-folder.h>
#include <tny-camel-folder.h>
#include <tny-simple-list.h>
+#include <modest-tny-account.h>
#include <modest-tny-folder.h>
#include <modest-tny-local-folders-account.h>
#include <modest-tny-outbox-account.h>
G_TYPE_NONE, 1, G_TYPE_STRING);
}
+static gboolean on_model_foreach_set_name(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+ GObject *instance = NULL;
+
+ gtk_tree_model_get (model, iter,
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN, &instance,
+ -1);
+
+ if (!instance)
+ return FALSE; /* keep walking */
+
+ if (!TNY_IS_ACCOUNT (instance)) {
+ g_object_unref (instance);
+ return FALSE; /* keep walking */
+ }
+
+ /* Check if this is the looked-for account: */
+ TnyAccount *this_account = TNY_ACCOUNT (instance);
+ TnyAccount *account = TNY_ACCOUNT (data);
+
+ const gchar *this_account_id = tny_account_get_id(this_account);
+ const gchar *account_id = tny_account_get_id(account);
+ if (this_account_id && account_id &&
+ (strcmp (this_account_id, account_id) == 0)) {
+
+ /* Tell the model that the data has changed, so that
+ * it calls the cell_data_func callbacks again: */
+ gtk_tree_model_row_changed (model, path, iter);
+
+ g_object_unref (instance);
+ return TRUE; /* stop walking */
+ }
+
+ g_object_unref (instance);
+ return FALSE; /* keep walking */
+}
+
+void on_get_mmc_account_name (TnyStoreAccount* account, gpointer user_data)
+{
+ ModestFolderView *self = MODEST_FOLDER_VIEW (user_data);
+
+ /* If this has been called then it means that the account name has
+ * changed, so we tell the model that the data has changed, so that
+ * it calls the cell_data_func callbacks again: */
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
+ if (!model)
+ return;
+
+ gtk_tree_model_foreach(model, on_model_foreach_set_name, self);
+}
+
static void
text_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
return;
}
-
- priv = MODEST_FOLDER_VIEW_GET_PRIVATE (data);
+ ModestFolderView *self = MODEST_FOLDER_VIEW (data);
+ priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
gchar *item_name = NULL;
gint item_weight = 400;
}
+ /* If it is a Memory card account, make sure that we have the correct name: */
+ if (TNY_IS_STORE_ACCOUNT (instance) &&
+ modest_tny_account_is_memory_card_account (TNY_ACCOUNT (instance))) {
+ /* Get the account name asynchronously: */
+ modest_tny_account_get_mmc_account_name (TNY_STORE_ACCOUNT (instance),
+ on_get_mmc_account_name, self);
+ }
+
g_object_unref (G_OBJECT (instance));
g_free (fname);
}