X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-local-folders-account.c;h=3410305464cfb19200620dfca1c07f9e3a446fb0;hp=e16597e8fa8948d882e9cd2809621d6d504dc3b6;hb=HEAD;hpb=a3b6eb31e1ab5d5cd25b8e8b1492bbc7d30f3b3b diff --git a/src/modest-tny-local-folders-account.c b/src/modest-tny-local-folders-account.c index e16597e..3410305 100644 --- a/src/modest-tny-local-folders-account.c +++ b/src/modest-tny-local-folders-account.c @@ -57,13 +57,21 @@ struct _ModestTnyLocalFoldersAccountPrivate static void get_folders (TnyFolderStore *self, TnyList *list, - TnyFolderStoreQuery *query, + TnyFolderStoreQuery *query, + gboolean refresh, GError **err); static TnyFolder* create_folder (TnyFolderStore *self, const gchar *name, GError **err); +enum { + OUTBOX_DELETED_SIGNAL, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + static void modest_tny_local_folders_account_finalize (GObject *object) { @@ -81,11 +89,24 @@ static void modest_tny_local_folders_account_class_init (ModestTnyLocalFoldersAccountClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - + g_type_class_add_private (klass, sizeof (ModestTnyLocalFoldersAccountPrivate)); - + object_class->finalize = modest_tny_local_folders_account_finalize; - + + /* Signals */ + + /* Note that this signal is removed before unsetting my own + reference to outbox, this means that by the time of this + call, modest_tny_local_folders_account_get_merged_outbox is + still valid. The reason is that the listeners of the signal + might want to do something with the outbox instance */ + signals[OUTBOX_DELETED_SIGNAL] = g_signal_new + ("outbox-deleted", MODEST_TYPE_TNY_LOCAL_FOLDERS_ACCOUNT, + G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET + (ModestTnyLocalFoldersAccountClass, outbox_deleted), NULL, + NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /* Override virtual functions from the parent class: */ TNY_CAMEL_STORE_ACCOUNT_CLASS(klass)->get_folders = get_folders; TNY_CAMEL_STORE_ACCOUNT_CLASS(klass)->create_folder = create_folder; @@ -154,14 +175,18 @@ modest_tny_local_folders_account_query_passes (TnyFolderStoreQuery *query, TnyFo } static void -get_folders (TnyFolderStore *self, TnyList *list, TnyFolderStoreQuery *query, GError **err) +get_folders (TnyFolderStore *self, + TnyList *list, + TnyFolderStoreQuery *query, + gboolean refresh, + GError **err) { TnyCamelStoreAccountClass *parent_class; ModestTnyLocalFoldersAccountPrivate *priv; /* Call the base class implementation: */ parent_class = g_type_class_peek_parent (MODEST_TNY_LOCAL_FOLDERS_ACCOUNT_GET_CLASS (self)); - parent_class->get_folders (self, list, query, err); + parent_class->get_folders (self, list, query, refresh, err); /* Add our extra folder only if it passes the query */ priv = TNY_LOCAL_FOLDERS_ACCOUNT_GET_PRIVATE (self); @@ -243,10 +268,12 @@ modest_tny_local_folders_account_add_folder_to_outbox (ModestTnyLocalFoldersAcco /* Create on-demand */ if (!priv->outbox_folder) { - priv->outbox_folder = TNY_MERGE_FOLDER (tny_merge_folder_new_with_ui_locker (_("mcen_me_folder_outbox"), tny_gtk_lockable_new ())); - + priv->outbox_folder = (TnyMergeFolder *) + tny_merge_folder_new_with_ui_locker (_("mcen_me_folder_outbox"), + tny_gtk_lockable_new ()); /* Set type to outbox */ - tny_merge_folder_set_folder_type (priv->outbox_folder, TNY_FOLDER_TYPE_OUTBOX); + tny_merge_folder_set_folder_type (priv->outbox_folder, + TNY_FOLDER_TYPE_OUTBOX); } /* Add outbox to the global OUTBOX folder */ @@ -272,6 +299,10 @@ modest_tny_local_folders_account_remove_folder_from_outbox (ModestTnyLocalFolder merged_folders = tny_simple_list_new (); tny_merge_folder_get_folders (priv->outbox_folder, merged_folders); if (tny_list_get_length (merged_folders) == 0) { + /* Emit signal */ + g_signal_emit ((GObject *)self, signals[OUTBOX_DELETED_SIGNAL], 0); + + /* Unref my own reference */ g_object_unref (priv->outbox_folder); priv->outbox_folder = NULL; }