[evolution-mapi/push-notify: 5/6] Splitting summary fetch functions.
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-mapi/push-notify: 5/6] Splitting summary fetch functions.
- Date: Fri, 11 Dec 2009 05:35:37 +0000 (UTC)
commit 4d9b8f70835fad754d0436147b09415117e6b0fd
Author: Johnny Jacob <jjohnny novell com>
Date: Fri Dec 11 10:04:14 2009 +0530
Splitting summary fetch functions.
src/camel/camel-mapi-folder.c | 80 ++++++++++++++++++++--------------
src/camel/camel-mapi-folder.h | 8 +++
src/camel/camel-mapi-notifications.c | 61 +++++++++++++++++++++++---
3 files changed, 110 insertions(+), 39 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index cd6b8b4..9030bfa 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -79,12 +79,6 @@ typedef struct {
} flags_diff_t;
/*For collecting summary info from server*/
-typedef struct {
- GSList *items_list;
- GTimeVal last_modification_time;
- CamelFolder *folder;
- CamelFolderChangeInfo *changes;
-}fetch_items_data;
static CamelMimeMessage *mapi_folder_item_to_msg( CamelFolder *folder, MapiItem *item, CamelException *ex );
static void mapi_update_cache (CamelFolder *folder, GSList *list, CamelFolderChangeInfo **changeinfo,
@@ -300,7 +294,7 @@ read_item_common (MapiItem *item, uint32_t ulPropTag, gconstpointer prop_data)
}
static gboolean
-fetch_items_cb (FetchItemsCallbackData *item_data, gpointer data)
+fetch_items_summary_cb (FetchItemsCallbackData *item_data, gpointer data)
{
fetch_items_data *fi_data = (fetch_items_data *)data;
@@ -966,26 +960,12 @@ mapi_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
}
-
-void
-mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
+gboolean
+camel_mapi_folder_fetch_summary (CamelStore *store, const mapi_id_t fid, struct mapi_SRestriction *res,
+ struct SSortOrderSet *sort, fetch_items_data *fetch_data, guint32 options)
{
-
- CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (folder->parent_store);
- CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (folder);
- CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (folder->summary);
- CamelSession *session = ((CamelService *)folder->parent_store)->session;
-
- gboolean is_proxy = folder->parent_store->flags & CAMEL_STORE_PROXY;
- gboolean is_locked = FALSE;
gboolean status;
-
- struct mapi_SRestriction *res = NULL;
- struct SSortOrderSet *sort = NULL;
- struct mapi_update_deleted_msg *deleted_items_op_msg;
- fetch_items_data *fetch_data = g_new0 (fetch_items_data, 1);
-
- const gchar *folder_id = NULL;
+ const gchar *folder_name;
const guint32 summary_prop_list[] = {
PR_INTERNET_CPID,
@@ -1008,6 +988,43 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
PR_TRANSPORT_MESSAGE_HEADERS_UNICODE
};
+ /*TODO : Check for online state*/
+
+ camel_operation_start (NULL, _("Fetching summary information for new messages in")); /* %s"), folder->name); */
+
+ status = exchange_mapi_connection_fetch_items (fid, res, sort, summary_prop_list,
+ G_N_ELEMENTS (summary_prop_list),
+ NULL, NULL, fetch_items_summary_cb,
+ fetch_data, options);
+
+ if (!status)
+ camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Fetching items failed"));
+
+ camel_operation_end (NULL);
+
+ return status;
+}
+
+void
+mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
+{
+
+ CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (folder->parent_store);
+ CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (folder);
+ CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (folder->summary);
+ CamelSession *session = ((CamelService *)folder->parent_store)->session;
+
+ gboolean is_proxy = folder->parent_store->flags & CAMEL_STORE_PROXY;
+ gboolean is_locked = FALSE;
+ gboolean status;
+
+ struct mapi_SRestriction *res = NULL;
+ struct SSortOrderSet *sort = NULL;
+ struct mapi_update_deleted_msg *deleted_items_op_msg;
+ fetch_items_data *fetch_data = g_new0 (fetch_items_data, 1);
+
+ const gchar *folder_id = NULL;
+
if (((CamelOfflineStore *) mapi_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
goto end1;
@@ -1083,14 +1100,8 @@ mapi_refresh_folder(CamelFolder *folder, CamelException *ex)
if (((CamelMapiFolder *)folder)->type & CAMEL_MAPI_FOLDER_PUBLIC)
options |= MAPI_OPTIONS_USE_PFSTORE;
- camel_operation_start (NULL, _("Fetching summary information for new messages in %s"), folder->name);
-
- status = exchange_mapi_connection_fetch_items (temp_folder_id, res, sort,
- summary_prop_list, G_N_ELEMENTS (summary_prop_list),
- NULL, NULL,
- fetch_items_cb, fetch_data,
- options);
- camel_operation_end (NULL);
+ status = camel_mapi_folder_fetch_summary (mapi_store, temp_folder_id, res, sort,
+ fetch_data, options);
if (!status) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Fetching items failed"));
@@ -1134,6 +1145,7 @@ static const uint32_t camel_GetPropsList[] = {
PR_MID,
PR_INTERNET_CPID,
+
PR_TRANSPORT_MESSAGE_HEADERS,
PR_TRANSPORT_MESSAGE_HEADERS_UNICODE,
PR_MESSAGE_CLASS,
@@ -1809,6 +1821,8 @@ mapi_get_message_info(CamelFolder *folder, const char *uid)
mi = (CamelMessageInfoBase *)msg_info ;
return (msg_info);
}
+ /* Go online and fetch message summary. */
+
msg_info = camel_message_info_new(folder->summary);
mi = (CamelMessageInfoBase *)msg_info ;
diff --git a/src/camel/camel-mapi-folder.h b/src/camel/camel-mapi-folder.h
index 90accc6..ca4d0be 100644
--- a/src/camel/camel-mapi-folder.h
+++ b/src/camel/camel-mapi-folder.h
@@ -128,6 +128,12 @@ struct _CamelMapiFolderClass {
} ;
+typedef struct {
+ GSList *items_list;
+ GTimeVal last_modification_time;
+ CamelFolder *folder;
+ CamelFolderChangeInfo *changes;
+}fetch_items_data;
/* Standard Camel function */
CamelType camel_mapi_folder_get_type (void);
@@ -138,6 +144,8 @@ camel_mapi_folder_new(CamelStore *store, const char *folder_name, const char *fo
void mapi_update_summary ( CamelFolder *folder, GList *item_list,CamelException *ex) ;
void mapi_refresh_folder(CamelFolder *folder, CamelException *ex);
+gboolean camel_mapi_folder_fetch_summary (CamelStore *store, const mapi_id_t fid, struct mapi_SRestriction *res,
+ struct SSortOrderSet *sort, fetch_items_data *fetch_data, guint32 options);
G_END_DECLS
diff --git a/src/camel/camel-mapi-notifications.c b/src/camel/camel-mapi-notifications.c
index 0643e5b..2868d7c 100644
--- a/src/camel/camel-mapi-notifications.c
+++ b/src/camel/camel-mapi-notifications.c
@@ -49,10 +49,9 @@
#define d_notifications(x) x
-static void
-mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg);
-static void
-mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg);
+static void mapi_push_notification_listener (CamelSession *session, CamelSessionThreadMsg *msg);
+static void mapi_push_notification_listener_close (CamelSession *session, CamelSessionThreadMsg *msg);
+static void mapi_new_mail_handler (struct NewMailNotification *event, gpointer *data);
struct mapi_push_notification_msg {
CamelSessionThreadMsg msg;
@@ -63,6 +62,56 @@ struct mapi_push_notification_msg {
gpointer event_data;
};
+static void
+mapi_new_mail_handler (struct NewMailNotification *event, gpointer *data)
+{
+ struct mapi_SRestriction *res = NULL;
+ struct SPropValue sprop;
+ guint32 options = 0;
+ CamelMapiStore *store = (CamelMapiStore *)data;
+ fetch_items_data *fetch_data = g_new0 (fetch_items_data, 1);
+ CamelFolder *folder = NULL;
+ const gchar *folder_id = exchange_mapi_util_mapi_id_to_string (event->FID);
+ const gchar *folder_name = NULL;
+
+ /* d_notifications(mapidump_newmail (event, "\t")); */
+ /* FIXME : Continue only if we are handling a mail object.*/
+ if (0) return;
+
+ /*Use restriction to fetch the message summary based on MID*/
+ res = g_new0 (struct mapi_SRestriction, 1);
+
+ res->rt = RES_PROPERTY;
+ res->res.resProperty.relop = RES_PROPERTY;
+ res->res.resProperty.ulPropTag = PR_MID;
+ res->res.resProperty.lpProp.ulPropTag = PR_MID;
+ res->res.resProperty.lpProp.value.dbl = event->MID;
+
+ /* set_SPropValue_proptag (&sprop, PR_MID, &event->MID); */
+ /* cast_mapi_SPropValue (&(res->res.resProperty.lpProp), &sprop); */
+
+ /* Get the folder object */
+ folder_name = camel_mapi_store_folder_lookup (store,folder_id);
+ folder = camel_store_get_folder (store, folder_name, 0, NULL);
+ if (!folder) g_print("%s %s : WARNING - FOLDER OBJECTI S INVLAUDes \n", G_STRLOC, G_STRFUNC);
+ /* FIXME : Abort on failure*/
+ fetch_data->changes = camel_folder_change_info_new ();
+ fetch_data->folder = folder;
+
+ camel_mapi_folder_fetch_summary (store, event->FID, res, NULL, fetch_data, options);
+
+ camel_folder_summary_touch (folder->summary);
+ /* mapi_sync_summary */
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ camel_store_summary_touch ((CamelStoreSummary *)((CamelMapiStore *)folder->parent_store)->summary);
+ camel_store_summary_save ((CamelStoreSummary *)((CamelMapiStore *)folder->parent_store)->summary);
+
+ camel_object_trigger_event (folder, "folder_changed", fetch_data->changes);
+ camel_folder_change_info_free (fetch_data->changes);
+ g_free (res);
+ g_free (folder_id);
+}
+
static gint
mapi_notifications_filter (guint16 type, void *event, void *private_data)
{
@@ -88,7 +137,7 @@ mapi_notifications_filter (guint16 type, void *event, void *private_data)
case fnevNewMail:
case fnevNewMail|fnevMbit:
d_notifications(printf ("Event : New mail\n"));
- new_mail_handler (event);
+ mapi_new_mail_handler (event, private_data);
break;
case fnevMbit|fnevObjectCreated:
d_notifications(printf ("Event : Message created\n"));
@@ -154,7 +203,7 @@ camel_mapi_notfication_listener_start (CamelMapiStore *store, guint16 mask,
mapi_push_notification_msg_op->event_options = options;
mapi_push_notification_msg_op->event_mask = mask;
- mapi_push_notification_msg_op->event_data = NULL;
+ mapi_push_notification_msg_op->event_data = store;
camel_session_thread_queue (session, &mapi_push_notification_msg_op->msg, 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]