Adding tny_folder_get_folder_store and some other minor things
- From: Sergio Villar Senin <svillar igalia com>
- To: tinymail-devel-list gnome org
- Subject: Adding tny_folder_get_folder_store and some other minor things
- Date: Thu, 15 Feb 2007 10:07:12 +0100
Hi,
this is a patch for adding tny_folder_get_folder_store() functionality
to the TnyFolder. This function allow us to retrieve the TnyFolderStore
where a folder is located, if exists.
This patch fixes also other two issues. The first one is related to
folder creation. The create_folder implementation in camel-imap-store.c
does not set the pointers from/to the parent and from/to the siblings of
the newly created folder unless the parent does not allow children (?).
Anyway I put some code in the create folder method of TnyCamelFolder to
fix it, despite it works I don't feel very comfortable with it, because
other providers different than IMAP.
And the other little fix is located in the receive strategies, they
didn't set the folder in the camel header.
Br.
Index: libtinymail-camel/tny-camel-folder.c
===================================================================
--- libtinymail-camel/tny-camel-folder.c (revision 1639)
+++ libtinymail-camel/tny-camel-folder.c (working copy)
@@ -2078,7 +2078,8 @@
TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
CamelException ex = CAMEL_EXCEPTION_INITIALISER;
CamelStore *store; gchar *folname;
- TnyFolder *folder; CamelFolderInfo *info;
+ TnyFolder *folder;
+ CamelFolderInfo *info;
if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), err,
TNY_FOLDER_STORE_ERROR, TNY_FOLDER_STORE_ERROR_CREATE_FOLDER))
@@ -2130,9 +2131,24 @@
return NULL;
}
+ /* Update family pointers */
+ if (!info->parent) {
+ CamelFolderInfo *parent_info, *tail;
+
+ parent_info = (CamelFolderInfo *) priv->iter;
+ tail = (CamelFolderInfo *) parent_info->child;
+ if (tail) {
+ while (tail->next)
+ tail = tail->next;
+ tail->next = info;
+ } else {
+ parent_info->child = info;
+ }
+ info->parent = parent_info;
+ }
+
folder = _tny_camel_folder_new ();
tny_camel_folder_set_folder_info (self, TNY_CAMEL_FOLDER (folder), info);
- _tny_camel_folder_set_subscribed (TNY_CAMEL_FOLDER (folder), FALSE);
_tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv));
@@ -2538,8 +2554,42 @@
return;
}
+static TnyFolderStore*
+tny_camel_folder_get_folder_store (TnyFolder *self)
+{
+ return TNY_CAMEL_FOLDER_GET_CLASS (self)->get_folder_store_func (self);
+}
+static TnyFolderStore*
+tny_camel_folder_get_folder_store_default (TnyFolder *self)
+{
+ TnyCamelFolderPriv *priv, *fpriv;
+ TnyFolderStore *retval;
+ CamelFolderInfo *parent_info;
+ priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self);
+
+ parent_info = (CamelFolderInfo *) priv->iter->parent;
+ if (!parent_info)
+ return NULL;
+
+ retval = _tny_camel_folder_new ();
+ _tny_camel_folder_set_id (TNY_CAMEL_FOLDER (retval), parent_info->full_name);
+ _tny_camel_folder_set_folder_type (TNY_CAMEL_FOLDER (retval), parent_info);
+ _tny_camel_folder_set_unread_count (TNY_CAMEL_FOLDER (retval), parent_info->unread);
+ _tny_camel_folder_set_all_count (TNY_CAMEL_FOLDER (retval), parent_info->total);
+ _tny_camel_folder_set_name (TNY_CAMEL_FOLDER (retval), parent_info->name);
+ _tny_camel_folder_set_iter (TNY_CAMEL_FOLDER (retval), parent_info);
+ _tny_camel_folder_set_account (TNY_CAMEL_FOLDER (retval), priv->account);
+
+ fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (retval);
+ camel_object_ref (CAMEL_OBJECT (priv->store));
+ fpriv->store = priv->store;
+
+ return retval;
+}
+
+
static void
tny_camel_folder_store_add_observer (TnyFolderStore *self, TnyFolderStoreObserver *observer)
{
@@ -2685,6 +2735,7 @@
klass->poke_status_func = tny_camel_folder_poke_status;
klass->add_observer_func = tny_camel_folder_add_observer;
klass->remove_observer_func = tny_camel_folder_remove_observer;
+ klass->get_folder_store_func = tny_camel_folder_get_folder_store;
return;
}
@@ -2740,6 +2791,7 @@
class->poke_status_func = tny_camel_folder_poke_status_default;
class->add_observer_func = tny_camel_folder_add_observer_default;
class->remove_observer_func = tny_camel_folder_remove_observer_default;
+ class->get_folder_store_func = tny_camel_folder_get_folder_store_default;
class->get_folders_async_func = tny_camel_folder_get_folders_async_default;
class->get_folders_func = tny_camel_folder_get_folders_default;
Index: libtinymail-camel/tny-camel-folder.h
===================================================================
--- libtinymail-camel/tny-camel-folder.h (revision 1639)
+++ libtinymail-camel/tny-camel-folder.h (working copy)
@@ -84,6 +84,7 @@
void (*get_folders_func) (TnyFolderStore *self, TnyList *list, TnyFolderStoreQuery *query, GError **err);
void (*remove_folder_func) (TnyFolderStore *self, TnyFolder *folder, GError **err);
TnyFolder* (*create_folder_func) (TnyFolderStore *self, const gchar *name, GError **err);
+ TnyFolderStore* (*get_folder_store_func) (TnyFolder *self);
void (*add_store_observer_func) (TnyFolderStore *self, TnyFolderStoreObserver *observer);
void (*remove_store_observer_func) (TnyFolderStore *self, TnyFolderStoreObserver *observer);
Index: libtinymail-camel/tny-camel-full-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-full-msg-receive-strategy.c (revision 1639)
+++ libtinymail-camel/tny-camel-full-msg-receive-strategy.c (working copy)
@@ -83,6 +83,7 @@
_tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message),
CAMEL_MIME_PART (camel_message));
_tny_camel_header_set_camel_mime_message (nheader, camel_message);
+ _tny_camel_header_set_folder (nheader, folder, priv);
_tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader);
g_object_unref (G_OBJECT (nheader));
}
Index: libtinymail-camel/tny-camel-partial-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-partial-msg-receive-strategy.c (revision 1639)
+++ libtinymail-camel/tny-camel-partial-msg-receive-strategy.c (working copy)
@@ -80,6 +80,7 @@
message = tny_camel_msg_new ();
_tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder);
+ _tny_camel_header_set_folder (nheader, folder, priv);
_tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message),
CAMEL_MIME_PART (camel_message));
_tny_camel_header_set_camel_mime_message (nheader, camel_message);
Index: libtinymail/tny-folder.c
===================================================================
--- libtinymail/tny-folder.c (revision 1639)
+++ libtinymail/tny-folder.c (working copy)
@@ -789,8 +789,30 @@
}
+/**
+ * tny_folder_get_folder_store:
+ * @self: a TnyFolder object
+ *
+ * Get a the parent account of this folder. You must unreference the
+ * return value after use. Note that not every folder strictly has to
+ * be inside a folder store.
+ *
+ * Return value: the folder store of this folder, or NULL if the
+ * folder is not inside a folder store
+ *
+ **/
+TnyFolderStore*
+tny_folder_get_folder_store (TnyFolder *self)
+{
+#ifdef DEBUG
+ if (!TNY_FOLDER_GET_IFACE (self)->get_folder_store_func)
+ g_critical ("You must implement tny_folder_get_folder_store\n");
+#endif
+ return TNY_FOLDER_GET_IFACE (self)->get_folder_store_func (self);
+}
+
static void
tny_folder_base_init (gpointer g_class)
{
Index: libtinymail/tny-folder.h
===================================================================
--- libtinymail/tny-folder.h (revision 1639)
+++ libtinymail/tny-folder.h (working copy)
@@ -103,6 +103,7 @@
void (*poke_status_func) (TnyFolder *self);
void (*add_observer_func) (TnyFolder *self, TnyFolderObserver *observer);
void (*remove_observer_func) (TnyFolder *self, TnyFolderObserver *observer);
+ TnyFolderStore* (*get_folder_store_func) (TnyFolder *self);
};
@@ -135,6 +136,7 @@
void tny_folder_poke_status (TnyFolder *self);
void tny_folder_add_observer (TnyFolder *self, TnyFolderObserver *observer);
void tny_folder_remove_observer (TnyFolder *self, TnyFolderObserver *observer);
+TnyFolderStore* tny_folder_get_folder_store (TnyFolder *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]