[evolution-data-server/imap-notify: 6/23] CamelIMAPXFolder: Add a "mailbox" property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/imap-notify: 6/23] CamelIMAPXFolder: Add a "mailbox" property.
- Date: Tue, 10 Sep 2013 14:06:01 +0000 (UTC)
commit a4661db396ed766f37a7939735beacaef9228d1d
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Aug 29 09:06:01 2013 -0400
CamelIMAPXFolder: Add a "mailbox" property.
Holds a weak reference to the corresponding CamelIMAPXMailbox for the
duration of the IMAP server connection.
New functions:
camel_imapx_folder_ref_mailbox()
camel_imapx_folder_set_mailbox()
camel/camel-imapx-folder.c | 75 +++++++++++++++++++++++++++++++
camel/camel-imapx-folder.h | 5 ++
docs/reference/camel/camel-sections.txt | 2 +
3 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-imapx-folder.c b/camel/camel-imapx-folder.c
index 7e9d134..4634551 100644
--- a/camel/camel-imapx-folder.c
+++ b/camel/camel-imapx-folder.c
@@ -45,6 +45,7 @@
struct _CamelIMAPXFolderPrivate {
GMutex property_lock;
+ GWeakRef mailbox;
gchar **quota_root_names;
GMutex move_to_hash_table_lock;
@@ -56,6 +57,7 @@ struct _CamelIMAPXFolderPrivate {
* It still identifies the property in state files. */
enum {
PROP_0,
+ PROP_MAILBOX,
PROP_QUOTA_ROOT_NAMES,
PROP_APPLY_FILTERS = 0x2501
};
@@ -139,6 +141,12 @@ imapx_folder_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_MAILBOX:
+ camel_imapx_folder_set_mailbox (
+ CAMEL_IMAPX_FOLDER (object),
+ g_value_get_object (value));
+ return;
+
case PROP_QUOTA_ROOT_NAMES:
camel_imapx_folder_set_quota_root_names (
CAMEL_IMAPX_FOLDER (object),
@@ -163,6 +171,13 @@ imapx_folder_get_property (GObject *object,
CAMEL_IMAPX_FOLDER (object)));
return;
+ case PROP_MAILBOX:
+ g_value_take_object (
+ value,
+ camel_imapx_folder_ref_mailbox (
+ CAMEL_IMAPX_FOLDER (object)));
+ return;
+
case PROP_QUOTA_ROOT_NAMES:
g_value_take_boxed (
value,
@@ -197,6 +212,8 @@ imapx_folder_dispose (GObject *object)
CAMEL_FOLDER (folder)->summary);
}
+ g_weak_ref_set (&folder->priv->mailbox, NULL);
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (camel_imapx_folder_parent_class)->dispose (object);
}
@@ -1012,6 +1029,17 @@ camel_imapx_folder_class_init (CamelIMAPXFolderClass *class)
g_object_class_install_property (
object_class,
+ PROP_MAILBOX,
+ g_param_spec_object (
+ "mailbox",
+ "Mailbox",
+ "IMAP mailbox for this folder",
+ CAMEL_TYPE_IMAPX_MAILBOX,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_QUOTA_ROOT_NAMES,
g_param_spec_boxed (
"quota-root-names",
@@ -1167,6 +1195,53 @@ camel_imapx_folder_new (CamelStore *store,
return folder;
}
+/**
+ * camel_imapx_folder_ref_mailbox:
+ * @folder: a #CamelIMAPXFolder
+ *
+ * Returns the #CamelIMAPXMailbox for @folder from the current IMAP server
+ * connection, or %NULL if @folder's #CamelFolder:parent-store is disconnected
+ * from the IMAP server.
+ *
+ * The returned #CamelIMAPXMailbox is referenced for thread-safety and
+ * should be unreferenced with g_object_unref() when finished with it.
+ *
+ * Returns: a #CamelIMAPXMailbox, or %NULL
+ *
+ * Since: 3.12
+ **/
+CamelIMAPXMailbox *
+camel_imapx_folder_ref_mailbox (CamelIMAPXFolder *folder)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAPX_FOLDER (folder), NULL);
+
+ return g_weak_ref_get (&folder->priv->mailbox);
+}
+
+/**
+ * camel_imapx_folder_set_mailbox:
+ * @folder: a #CamelIMAPXFolder
+ * @mailbox: a #CamelIMAPXMailbox
+ *
+ * Sets the #CamelIMAPXMailbox for @folder from the current IMAP server
+ * connection. Note that #CamelIMAPXFolder only holds a weak reference
+ * on its #CamelIMAPXMailbox so that when the IMAP server connection is
+ * lost, all mailbox instances are automatically destroyed.
+ *
+ * Since: 3.12
+ **/
+void
+camel_imapx_folder_set_mailbox (CamelIMAPXFolder *folder,
+ CamelIMAPXMailbox *mailbox)
+{
+ g_return_if_fail (CAMEL_IS_IMAPX_FOLDER (folder));
+ g_return_if_fail (CAMEL_IS_IMAPX_MAILBOX (mailbox));
+
+ g_weak_ref_set (&folder->priv->mailbox, mailbox);
+
+ g_object_notify (G_OBJECT (folder), "mailbox");
+}
+
gchar **
camel_imapx_folder_dup_quota_root_names (CamelIMAPXFolder *folder)
{
diff --git a/camel/camel-imapx-folder.h b/camel/camel-imapx-folder.h
index ccebbc4..0fefce3 100644
--- a/camel/camel-imapx-folder.h
+++ b/camel/camel-imapx-folder.h
@@ -33,6 +33,7 @@
#include <camel/camel-folder-search.h>
#include <camel/camel-store.h>
+#include <camel/camel-imapx-mailbox.h>
#include <camel/camel-imapx-status-response.h>
/* Standard GObject macros */
@@ -91,6 +92,10 @@ CamelFolder * camel_imapx_folder_new (CamelStore *parent,
const gchar *path,
const gchar *raw,
GError **error);
+CamelIMAPXMailbox *
+ camel_imapx_folder_ref_mailbox (CamelIMAPXFolder *folder);
+void camel_imapx_folder_set_mailbox (CamelIMAPXFolder *folder,
+ CamelIMAPXMailbox *mailbox);
gchar ** camel_imapx_folder_dup_quota_root_names
(CamelIMAPXFolder *folder);
void camel_imapx_folder_set_quota_root_names
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 0e58c3a..5089d77 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -776,6 +776,8 @@ camel_imapx_command_queue_ref_by_tag
<TITLE>CamelIMAPXFolder</TITLE>
CamelIMAPXFolder
camel_imapx_folder_new
+camel_imapx_folder_ref_mailbox
+camel_imapx_folder_set_mailbox
camel_imapx_folder_dup_quota_root_names
camel_imapx_folder_set_quota_root_names
camel_imapx_folder_add_move_to_real_junk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]