evolution-data-server r9707 - branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi
- From: jjohnny svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9707 - branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi
- Date: Tue, 28 Oct 2008 13:12:55 +0000 (UTC)
Author: jjohnny
Date: Tue Oct 28 13:12:55 2008
New Revision: 9707
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9707&view=rev
Log:
Use restrictions for fetching summary of new items.
Modified:
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.c
branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.h
Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c Tue Oct 28 13:12:55 2008
@@ -67,6 +67,12 @@
guint32 bits;
} flags_diff_t;
+/*For collecting summary info from server*/
+typedef struct {
+ GSList *items_list;
+ const struct timeval *last_modification_time;
+}fetch_items_data;
+
static CamelMimeMessage *mapi_folder_item_to_msg( CamelFolder *folder, MapiItem *item, CamelException *ex );
static GPtrArray *
@@ -173,11 +179,14 @@
fetch_items_cb (struct mapi_SPropValue_array *array, const mapi_id_t fid, const mapi_id_t mid,
GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
{
- //CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER(data);
- GSList **slist = (GSList **)data;
+ fetch_items_data *fi_data = (fetch_items_data *)data;
+
+ GSList **slist = &(fi_data->items_list);
long *flags;
- struct FILETIME *delivery_date;
+ struct FILETIME *delivery_date = NULL;
+ struct timeval *item_modification_time = NULL;
+
NTTIME ntdate;
MapiItem *item = g_new0(MapiItem , 1);
@@ -205,13 +214,25 @@
item->header.recieved_time = nt_time_to_unix(ntdate);
}
+ delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(array, PR_LAST_MODIFICATION_TIME);
+ if (delivery_date) {
+ ntdate = delivery_date->dwHighDateTime;
+ ntdate = ntdate << 32;
+ ntdate |= delivery_date->dwLowDateTime;
+ item_modification_time = g_new0 (struct timeval, 1);
+ nttime_to_timeval(item_modification_time, ntdate);
+ }
+
+ if (timeval_compare (item_modification_time, fi_data->last_modification_time) == 1)
+ fi_data->last_modification_time = item_modification_time;
+
flags = (long *)find_mapi_SPropValue_data (array, PR_MESSAGE_FLAGS);
if ((*flags & MSGFLAG_READ) != 0)
item->header.flags |= CAMEL_MESSAGE_SEEN;
if ((*flags & MSGFLAG_HASATTACH) != 0)
item->header.flags |= CAMEL_MESSAGE_ATTACHMENTS;
- *slist = g_slist_append (*slist, item);
+ *slist = g_slist_prepend (*slist, item);
return TRUE;
}
@@ -482,11 +503,14 @@
CamelMapiStore *mapi_store = CAMEL_MAPI_STORE (folder->parent_store);
CamelMapiFolder *mapi_folder = CAMEL_MAPI_FOLDER (folder);
-
+ CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (folder->summary);
gboolean is_proxy = folder->parent_store->flags & CAMEL_STORE_PROXY;
gboolean is_locked = TRUE;
gboolean status;
- GSList *item_list = NULL;
+
+ struct mapi_SRestriction *res = NULL;
+ fetch_items_data *fetch_data = g_new0 (fetch_items_data, 1);
+
const gchar *folder_id = NULL;
const guint32 summary_prop_list[] = {
@@ -495,6 +519,7 @@
PR_MESSAGE_DELIVERY_TIME,
PR_MESSAGE_FLAGS,
PR_SENT_REPRESENTING_NAME,
+ PR_LAST_MODIFICATION_TIME,
PR_DISPLAY_TO,
PR_DISPLAY_CC,
PR_DISPLAY_BCC
@@ -532,43 +557,66 @@
guint32 options = 0;
CamelFolderInfo *fi = NULL;
+ fetch_data->last_modification_time = g_new0 (struct timeval, 1); /*First Sync*/
+
+ if (mapi_summary->sync_time_stamp && *mapi_summary->sync_time_stamp &&
+ g_time_val_from_iso8601 (mapi_summary->sync_time_stamp, fetch_data->last_modification_time)) {
+ struct SPropValue sprop;
+ struct timeval t;
+
+ res = g_new0 (struct mapi_SRestriction, 1);
+ res->rt = RES_PROPERTY;
+ /*RELOP_GE acts more like >=. Few extra items are being fetched.*/
+ res->res.resProperty.relop = RELOP_GE;
+ res->res.resProperty.ulPropTag = PR_LAST_MODIFICATION_TIME;
+
+ t.tv_sec = fetch_data->last_modification_time->tv_sec;
+ t.tv_usec = fetch_data->last_modification_time->tv_usec;
+
+ //Creation time ?
+ set_SPropValue_proptag_date_timeval (&sprop, PR_LAST_MODIFICATION_TIME, &t);
+ cast_mapi_SPropValue (&(res->res.resProperty.lpProp), &sprop);
+ }
+
exchange_mapi_util_mapi_id_from_string (folder_id, &temp_folder_id);
if (!camel_mapi_store_connected (mapi_store, ex)) {
+ /*BUG : Fix exception string.*/
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("This message is not available in offline mode."));
goto end2;
}
- if (((CamelMapiFolder *)folder)->type == MAPI_FAVOURITE_FOLDER){
+ if (((CamelMapiFolder *)folder)->type == MAPI_FAVOURITE_FOLDER)
options |= MAPI_OPTIONS_USE_PFSTORE;
- }
- status = exchange_mapi_connection_fetch_items (temp_folder_id, NULL,
+
+ status = exchange_mapi_connection_fetch_items (temp_folder_id, res,
summary_prop_list, G_N_ELEMENTS (summary_prop_list),
NULL, NULL,
- fetch_items_cb, &item_list,
+ fetch_items_cb, fetch_data,
options);
-
if (!status) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Fetch items failed"));
goto end2;
}
+ /*Preserve last_modification_time from this fetch for later use with restrictions.*/
+ mapi_summary->sync_time_stamp = g_time_val_to_iso8601 (fetch_data->last_modification_time);
+
camel_folder_summary_touch (folder->summary);
mapi_sync_summary (folder, ex);
- if (item_list)
- mapi_update_cache (folder, item_list, ex, FALSE);
+ if (fetch_data->items_list)
+ mapi_update_cache (folder, fetch_data->items_list, ex, FALSE);
}
CAMEL_SERVICE_REC_UNLOCK (mapi_store, connect_lock);
is_locked = FALSE;
- g_slist_foreach (item_list, (GFunc) mapi_item_free, NULL);
- g_slist_free (item_list);
- item_list = NULL;
+ g_slist_foreach (fetch_data->items_list, (GFunc) mapi_item_free, NULL);
+ g_slist_free (fetch_data->items_list);
end2:
//TODO:
end1:
Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.c Tue Oct 28 13:12:55 2008
@@ -38,6 +38,8 @@
#include "camel-mapi-folder.h"
#include "camel-mapi-summary.h"
+#define CAMEL_MAPI_SUMMARY_VERSION (1)
+
/* Macros for DB Summary */
#define MS_EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
@@ -165,18 +167,37 @@
static int
mapi_summary_header_from_db (CamelFolderSummary *summary, CamelFIRecord *fir)
{
+ CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY (summary);
+ gchar *part;
+
if (camel_mapi_summary_parent->summary_header_from_db (summary, fir) == -1)
return -1 ;
+ part = fir->bdata;
+
+ if (part)
+ MS_EXTRACT_FIRST_DIGIT(mapi_summary->version);
+
+ if (part && part++) {
+ mapi_summary->sync_time_stamp = g_strdup (part);
+ }
+
return 0;
}
static int
mapi_summary_header_to_db (CamelFolderSummary *summary, CamelException *ex)
{
- if (camel_mapi_summary_parent->summary_header_to_db (summary, ex) == -1)
+ CamelMapiSummary *mapi_summary = CAMEL_MAPI_SUMMARY(summary);
+ struct _CamelFIRecord *fir;
+
+ fir = camel_mapi_summary_parent->summary_header_to_db (summary, ex);
+
+ if(!fir)
return -1;
- return 0;
+ fir->bdata = g_strdup_printf ("%d %s", CAMEL_MAPI_SUMMARY_VERSION, mapi_summary->sync_time_stamp);
+
+ return fir;
}
static CamelMessageInfo*
Modified: branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.h (original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-summary.h Tue Oct 28 13:12:55 2008
@@ -59,7 +59,7 @@
struct _CamelMapiSummary {
CamelFolderSummary parent ;
- char *time_string;
+ gchar *sync_time_stamp;
guint32 version ;
guint32 validity ;
} ;
@@ -74,9 +74,6 @@
CamelFolderSummary *camel_mapi_summary_new (struct _CamelFolder *folder, const char *filename) ;
-/* void camel_gw_summary_add_offline (CamelFolderSummary *summary, const char *uid, CamelMimeMessage *messgae, const CamelMessageInfo *info) ; */
-
-/* void camel_gw_summary_add_offline_uncached (CamelFolderSummary *summary, const char *uid, const CamelMessageInfo *info) ; */
void mapi_summary_clear (CamelFolderSummary *summary, gboolean uncache);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]