[evolution-data-server] CamelIMAPXJob: Split out "manage_subscriptions" data.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] CamelIMAPXJob: Split out "manage_subscriptions" data.
- Date: Tue, 31 Jan 2012 22:10:15 +0000 (UTC)
commit c570e131793eaf4adb4eaaec439e26baf016f0d4
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Jan 31 16:32:42 2012 -0500
CamelIMAPXJob: Split out "manage_subscriptions" data.
Define a standalone ManageSubscriptionsData struct and "free" function.
Use camel_imapx_job_set_data() to attach an allocated struct to a
CamelIMAPXJob such that it will be freed along with the job.
Use camel_imapx_job_get_data() to obtain a pointer to the allocated
struct as needed, always with a NULL check for safety.
camel/providers/imapx/camel-imapx-job.h | 5 ----
camel/providers/imapx/camel-imapx-server.c | 32 ++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-job.h b/camel/providers/imapx/camel-imapx-job.h
index 05347ed..d8f94d6 100644
--- a/camel/providers/imapx/camel-imapx-job.h
+++ b/camel/providers/imapx/camel-imapx-job.h
@@ -57,11 +57,6 @@ struct _CamelIMAPXJob {
union {
struct {
- const gchar *folder_name;
- gboolean subscribe;
- } manage_subscriptions;
-
- struct {
const gchar *ofolder_name;
const gchar *nfolder_name;
} rename_folder;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 22929d2..9779204 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -78,6 +78,7 @@ typedef struct _SyncChangesData SyncChangesData;
typedef struct _AppendMessageData AppendMessageData;
typedef struct _CopyMessagesData CopyMessagesData;
typedef struct _ListData ListData;
+typedef struct _ManageSubscriptionsData ManageSubscriptionsData;
struct _GetMessageData {
/* in: uid requested */
@@ -135,6 +136,11 @@ struct _ListData {
GHashTable *folders;
};
+struct _ManageSubscriptionsData {
+ gchar *folder_name;
+ gboolean subscribe;
+};
+
enum {
SELECT_CHANGED,
SHUTDOWN,
@@ -339,6 +345,14 @@ list_data_free (ListData *data)
g_slice_free (ListData, data);
}
+static void
+manage_subscriptions_data_free (ManageSubscriptionsData *data)
+{
+ g_free (data->folder_name);
+
+ g_slice_free (ManageSubscriptionsData, data);
+}
+
/*
this creates a uid (or sequence number) set directly into a command,
if total is set, then we break it up into total uids. (i.e. command time)
@@ -4378,12 +4392,16 @@ imapx_job_manage_subscription_start (CamelIMAPXJob *job,
CamelIMAPXServer *is)
{
CamelIMAPXCommand *ic;
+ ManageSubscriptionsData *data;
gchar *encoded_fname = NULL;
+ data = camel_imapx_job_get_data (job);
+ g_return_if_fail (data != NULL);
+
encoded_fname = imapx_encode_folder_name (
(CamelIMAPXStore *) is->store,
- job->u.manage_subscriptions.folder_name);
- if (job->u.manage_subscriptions.subscribe)
+ data->folder_name);
+ if (data->subscribe)
ic = camel_imapx_command_new (
is, "SUBSCRIBE", NULL,
"SUBSCRIBE %s", encoded_fname);
@@ -5846,14 +5864,20 @@ camel_imapx_server_manage_subscription (CamelIMAPXServer *is,
GError **error)
{
CamelIMAPXJob *job;
+ ManageSubscriptionsData *data;
gboolean success;
+ data = g_slice_new0 (ManageSubscriptionsData);
+ data->folder_name = g_strdup (folder_name);
+ data->subscribe = subscribe;
+
job = camel_imapx_job_new (cancellable);
job->type = IMAPX_JOB_MANAGE_SUBSCRIPTION;
job->start = imapx_job_manage_subscription_start;
job->pri = IMAPX_PRIORITY_MANAGE_SUBSCRIPTION;
- job->u.manage_subscriptions.subscribe = subscribe;
- job->u.manage_subscriptions.folder_name = folder_name;
+
+ camel_imapx_job_set_data (
+ job, data, (GDestroyNotify) manage_subscriptions_data_free);
success = imapx_submit_job (is, job, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]