[evolution-kolab/ek-wip-porting-imapx: 106/109] CamelIMAPXServer: friend API cleanup
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting-imapx: 106/109] CamelIMAPXServer: friend API cleanup
- Date: Thu, 2 Feb 2012 18:24:15 +0000 (UTC)
commit 4084820cd038218866ba34be1a3b77f14a86f308
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Thu Feb 2 19:05:04 2012 +0100
CamelIMAPXServer: friend API cleanup
* removed functions which are now publicly
accessible via CamelIMAPXCommand from
"friend" API (used by CamelIMAPXExtdServer)
* adapted friend API functions to upstream
changes (function params and return types)
* cleaned up the server definitions file
(this carries unavoidable dupes of types
and enums from CamelIMAPXServer, which
are used by CamelIMAPXExtdServer)
.../providers/imapx/camel-imapx-server-defs.h | 215 +++++++-------------
.../providers/imapx/camel-imapx-server-friend.h | 25 +--
src/camel/providers/imapx/camel-imapx-server.c | 56 +-----
3 files changed, 86 insertions(+), 210 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-server-defs.h b/src/camel/providers/imapx/camel-imapx-server-defs.h
index b00c5f0..a962fd2 100644
--- a/src/camel/providers/imapx/camel-imapx-server-defs.h
+++ b/src/camel/providers/imapx/camel-imapx-server-defs.h
@@ -58,161 +58,90 @@ struct _refresh_info {
CamelFlag *server_user_flags;
};
-struct _uidset_state {
- struct _CamelIMAPXEngine *ie;
- gint entries, uids;
- gint total, limit;
- guint32 start;
- guint32 last;
+/* Job-specific structs */
+typedef struct _GetMessageData GetMessageData;
+typedef struct _RefreshInfoData RefreshInfoData;
+typedef struct _SyncChangesData SyncChangesData;
+typedef struct _AppendMessageData AppendMessageData;
+typedef struct _CopyMessagesData CopyMessagesData;
+typedef struct _ListData ListData;
+typedef struct _ManageSubscriptionsData ManageSubscriptionsData;
+typedef struct _RenameFolderData RenameFolderData;
+typedef struct _CreateFolderData CreateFolderData;
+typedef struct _DeleteFolderData DeleteFolderData;
+
+struct _GetMessageData {
+ /* in: uid requested */
+ gchar *uid;
+ /* in/out: message content stream output */
+ CamelStream *stream;
+ /* working variables */
+ gsize body_offset;
+ gssize body_len;
+ gsize fetch_offset;
+ gsize size;
+ gboolean use_multi_fetch;
};
-struct _CamelIMAPXJob {
- volatile gint ref_count;
-
- GCond *done_cond;
- GMutex *done_mutex;
- gboolean done_flag;
-
- GCancellable *cancellable;
- GError *error;
- gboolean with_operation_msg;
-
- void (*start)(CamelIMAPXServer *is, struct _CamelIMAPXJob *job);
-
- guint noreply:1; /* dont wait for reply */
- guint32 type; /* operation type */
- gint pri; /* the command priority */
- gshort commands; /* counts how many commands are outstanding */
+struct _RefreshInfoData {
+ /* array of refresh info's */
+ GArray *infos;
+ /* used for building uidset stuff */
+ gint index;
+ gint last_index;
+ gboolean update_unseen;
+ struct _uidset_state uidset;
+ /* changes during refresh */
+ CamelFolderChangeInfo *changes;
+};
+struct _SyncChangesData {
CamelFolder *folder;
-
- union {
- struct {
- /* in: uid requested */
- gchar *uid;
- /* in/out: message content stream output */
- CamelStream *stream;
- /* working variables */
- gsize body_offset;
- gssize body_len;
- gsize fetch_offset;
- gsize size;
- gboolean use_multi_fetch;
- } get_message;
- struct {
- /* array of refresh info's */
- GArray *infos;
- /* used for biulding uidset stuff */
- gint index;
- gint last_index;
- gboolean update_unseen;
- struct _uidset_state uidset;
- /* changes during refresh */
- CamelFolderChangeInfo *changes;
- } refresh_info;
- struct {
- GPtrArray *changed_uids;
- guint32 on_set;
- guint32 off_set;
- GArray *on_user; /* imapx_flag_change */
- GArray *off_user;
- gint unread_change;
- } sync_changes;
- struct {
- gchar *path;
- CamelMessageInfo *info;
- } append_message;
- struct {
- CamelFolder *dest;
- GPtrArray *uids;
- gboolean delete_originals;
- gint index;
- gint last_index;
- struct _uidset_state uidset;
- } copy_messages;
- struct {
- gchar *pattern;
- guint32 flags;
- const gchar *ext;
- GHashTable *folders;
- } list;
-
- struct {
- const gchar *folder_name;
- gboolean subscribe;
- } manage_subscriptions;
-
- struct {
- const gchar *ofolder_name;
- const gchar *nfolder_name;
- } rename_folder;
-
- const gchar *folder_name;
- } u;
+ GPtrArray *changed_uids;
+ guint32 on_set;
+ guint32 off_set;
+ GArray *on_user; /* imapx_flag_change */
+ GArray *off_user;
+ gint unread_change;
};
-typedef enum {
- CAMEL_IMAPX_COMMAND_SIMPLE = 0,
- CAMEL_IMAPX_COMMAND_DATAWRAPPER,
- CAMEL_IMAPX_COMMAND_STREAM,
- CAMEL_IMAPX_COMMAND_AUTH,
- CAMEL_IMAPX_COMMAND_FILE,
- CAMEL_IMAPX_COMMAND_STRING,
- CAMEL_IMAPX_COMMAND_MASK = 0xff,
- CAMEL_IMAPX_COMMAND_LITERAL_PLUS = 0x4000, /* continuation with literal+ */
- CAMEL_IMAPX_COMMAND_CONTINUATION = 0x8000 /* does this command expect continuation? */
-} camel_imapx_command_part_t;
-
-struct _CamelIMAPXCommandPart {
- struct _CamelIMAPXCommandPart *next;
- struct _CamelIMAPXCommandPart *prev;
-
- struct _CamelIMAPXCommand *parent;
-
- gint data_size;
- gchar *data;
-
- camel_imapx_command_part_t type;
-
- gint ob_size;
- gpointer ob;
+struct _AppendMessageData {
+ gchar *path;
+ CamelMessageInfo *info;
};
-typedef void (*CamelIMAPXCommandFunc)(struct _CamelIMAPXServer *engine, struct _CamelIMAPXCommand *);
-
-struct _CamelIMAPXCommand {
- struct _CamelIMAPXCommand *next, *prev;
-
- volatile gint ref_count;
-
- CamelIMAPXServer *is;
- gint pri;
-
- const gchar *name; /* command name/type (e.g. FETCH) */
-
- CamelFolder *select; /* folder to select */
-
- struct _status_info *status; /* status for command, indicates it is complete if != NULL */
+struct _CopyMessagesData {
+ CamelFolder *dest;
+ GPtrArray *uids;
+ gboolean delete_originals;
+ gint index;
+ gint last_index;
+ struct _uidset_state uidset;
+};
- /* If exception is set, it means we were not able to parse above status, it might be
- * because user cancelled the operation or io error */
- GCancellable *cancellable;
- GError *error;
+struct _ListData {
+ gchar *pattern;
+ guint32 flags;
+ gchar *ext;
+ GHashTable *folders;
+};
- guint32 tag;
+struct _ManageSubscriptionsData {
+ gchar *folder_name;
+ gboolean subscribe;
+};
- struct _CamelStreamMem *mem; /* for building the part TOOD: just use a GString? */
- CamelDList parts;
- struct _CamelIMAPXCommandPart *current;
+struct _RenameFolderData {
+ gchar *old_folder_name;
+ gchar *new_folder_name;
+};
- /* used for running some commands syncronously */
- gboolean run_sync_done;
- GCond *run_sync_cond;
- GMutex *run_sync_mutex;
+struct _CreateFolderData {
+ gchar *folder_name;
+};
- /* responsible for free'ing the command */
- CamelIMAPXCommandFunc complete;
- struct _CamelIMAPXJob *job;
+struct _DeleteFolderData {
+ gchar *folder_name;
};
/* states for the connection? */
@@ -224,6 +153,7 @@ enum {
IMAPX_INITIALISED,
IMAPX_SELECTED
};
+
enum {
IMAPX_JOB_GET_MESSAGE = 1 << 0,
IMAPX_JOB_APPEND_MESSAGE = 1 << 1,
@@ -241,7 +171,6 @@ enum {
IMAPX_JOB_RENAME_FOLDER = 1 << 13,
};
-
/*----------------------------------------------------------------------------*/
#endif /* _CAMEL_IMAPX_SERVER_DEFS_H_ */
diff --git a/src/camel/providers/imapx/camel-imapx-server-friend.h b/src/camel/providers/imapx/camel-imapx-server-friend.h
index 7ccfeae..c9a3a0d 100644
--- a/src/camel/providers/imapx/camel-imapx-server-friend.h
+++ b/src/camel/providers/imapx/camel-imapx-server-friend.h
@@ -37,7 +37,7 @@
/*----------------------------------------------------------------------------*/
-struct _CamelIMAPXJob*
+CamelIMAPXJob*
camel_imapx_server_match_active_job (CamelIMAPXServer *self,
guint32 type,
const gchar *uid);
@@ -76,43 +76,30 @@ camel_imapx_server_invalidate_local_cache (CamelIMAPXServer *self,
CamelIMAPXFolder *ifolder,
guint64 new_uidvalidity);
-gint
+gboolean
camel_imapx_server_completion (CamelIMAPXServer *self,
guchar *token,
gint len,
GCancellable *cancellable,
GError **err);
-gint
+gboolean
camel_imapx_server_continuation (CamelIMAPXServer *self,
gboolean litplus,
GCancellable *cancellable,
GError **err);
-void
-camel_imapx_server_command_close (CamelIMAPXServer *self,
- CamelIMAPXCommand *ic);
-
gboolean
camel_imapx_server_command_start (CamelIMAPXServer *self,
- CamelIMAPXCommand *ic);
+ CamelIMAPXCommand *ic,
+ GCancellable *cancellable,
+ GError **err);
gboolean
camel_imapx_server_connect_to_server_process (CamelIMAPXServer *self,
const gchar *cmd,
GError **err);
-struct _CamelIMAPXCommand*
-camel_imapx_server_command_new (CamelIMAPXServer *self,
- const gchar *name,
- CamelFolder *select,
- GCancellable *cancellable,
- const gchar *fmt, ...);
-
-void
-camel_imapx_server_command_unref (CamelIMAPXServer *self,
- struct _CamelIMAPXCommand *ic);
-
gboolean
camel_imapx_server_disconnect (CamelIMAPXServer *self);
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index ed45e01..995d3c8 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -6165,7 +6165,7 @@ camel_imapx_server_invalidate_local_cache (CamelIMAPXServer *self,
invalidate_local_cache (ifolder, new_uidvalidity);
}
-gint
+gboolean
camel_imapx_server_completion (CamelIMAPXServer *self,
guchar *token,
gint len,
@@ -6180,7 +6180,7 @@ camel_imapx_server_completion (CamelIMAPXServer *self,
return imapx_completion (self, token, len, cancellable, err);
}
-gint
+gboolean
camel_imapx_server_continuation (CamelIMAPXServer *self,
gboolean litplus,
GCancellable *cancellable,
@@ -6193,26 +6193,19 @@ camel_imapx_server_continuation (CamelIMAPXServer *self,
return imapx_continuation (self, litplus, cancellable, err);
}
-void
-camel_imapx_server_command_close (CamelIMAPXServer *self,
- CamelIMAPXCommand *ic)
-{
- /* util */
- g_assert (CAMEL_IS_IMAPX_SERVER (self));
- g_assert (ic != NULL);
-
- imapx_command_close (ic);
-}
-
/* Must hold QUEUE_LOCK */
gboolean
camel_imapx_server_command_start (CamelIMAPXServer *self,
- CamelIMAPXCommand *ic)
+ CamelIMAPXCommand *ic,
+ GCancellable *cancellable,
+ GError **err)
{
g_assert (CAMEL_IS_IMAPX_SERVER (self));
g_assert (ic != NULL);
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
- return imapx_command_start (self, ic);
+ return imapx_command_start (self, ic, cancellable, err);
}
gboolean
@@ -6227,39 +6220,6 @@ camel_imapx_server_connect_to_server_process (CamelIMAPXServer *self,
return connect_to_server_process (self, cmd, err);
}
-struct _CamelIMAPXCommand*
-camel_imapx_server_command_new (CamelIMAPXServer *self,
- const gchar *name,
- CamelFolder *select,
- GCancellable *cancellable,
- const gchar *fmt, ...)
-{
- struct _CamelIMAPXCommand *cmd = NULL;
- va_list ap;
-
- g_assert (CAMEL_IS_IMAPX_SERVER (self));
- g_assert (name != NULL);
- g_assert (CAMEL_IS_FOLDER (select));
- /* camcellable may be NULL */
- g_assert (fmt != NULL);
-
- va_start (ap, fmt);
- cmd = imapx_command_new (self, name, select, cancellable, fmt, ap);
- va_end (ap);
-
- return cmd;
-}
-
-void
-camel_imapx_server_command_unref (CamelIMAPXServer *self,
- struct _CamelIMAPXCommand *ic)
-{
- /* util */
- g_assert (CAMEL_IS_IMAPX_SERVER (self));
-
- imapx_command_unref (ic);
-}
-
gboolean
camel_imapx_server_disconnect (CamelIMAPXServer *self)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]