oc: synchronize folders ChangeNumber <-> modseq
parent
c4b0ac209b
commit
973ab78761
|
@ -44,6 +44,8 @@
|
|||
|
||||
/* synchronisation & versioning */
|
||||
- (BOOL) synchroniseCache;
|
||||
- (void) synchronizeUpdatedFolder: (NSNumber *) lastModseq
|
||||
withMapping: (NSMutableDictionary *) mapping;
|
||||
- (NSNumber *) modseqFromMessageChangeNumber: (NSString *) changeNum;
|
||||
- (NSString *) messageUIDFromMessageKey: (NSString *) messageKey;
|
||||
- (NSString *) changeNumberForMessageUID: (NSString *) messageUid;
|
||||
|
|
|
@ -70,6 +70,7 @@ static Class SOGoMailFolderK, MAPIStoreMailFolderK, MAPIStoreOutboxFolderK;
|
|||
#undef DEBUG
|
||||
#include <util/attr.h>
|
||||
#include <libmapi/libmapi.h>
|
||||
#include <libmapiproxy.h>
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_errors.h>
|
||||
|
||||
|
@ -663,15 +664,76 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
|
|||
|
||||
if (foundChange)
|
||||
{
|
||||
[self synchronizeUpdatedFolder: lastModseq
|
||||
withMapping: mapping];
|
||||
|
||||
ti = [NSNumber numberWithDouble: [now timeIntervalSince1970]];
|
||||
[currentProperties setObject: ti
|
||||
forKey: @"SyncLastSynchronisationDate"];
|
||||
[versionsMessage save];
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
- (void) synchronizeUpdatedFolder: (NSNumber *) lastModseq
|
||||
withMapping: (NSMutableDictionary *) mapping
|
||||
{
|
||||
/* This method should be called whenever something has changed on the folder.
|
||||
Then we will perform two actions:
|
||||
1 - Update its PidTagChangeNumber property.
|
||||
2 - Store relationship PidTagChangenumber with lastModseq value on the
|
||||
mapping given as parameter */
|
||||
uint64_t *current_cn;
|
||||
struct SRow row;
|
||||
struct SPropValue prop;
|
||||
uint64_t fid;
|
||||
const char *username;
|
||||
struct openchangedb_context *oc_ctx;
|
||||
enum MAPISTATUS retval;
|
||||
TALLOC_CTX *local_mem_ctx = NULL;
|
||||
|
||||
row.cValues = 1;
|
||||
prop.ulPropTag = PidTagChangeNumber;
|
||||
prop.value.d = 0; // It doesn't matter, it will be autogenerated
|
||||
row.lpProps = ∝
|
||||
|
||||
/* We are doing a "touch" operation to update change number of this folder */
|
||||
username = [[self context] connectionInfo]->username;
|
||||
oc_ctx = [[self context] connectionInfo]->oc_ctx;
|
||||
fid = [self objectId];
|
||||
retval = openchangedb_set_folder_properties(oc_ctx, username, fid, &row);
|
||||
if (retval != MAPI_E_SUCCESS)
|
||||
{
|
||||
[self errorWithFormat:@"%s: Error setting change number on %"PRIu64,
|
||||
__PRETTY_FUNCTION__, fid];
|
||||
return;
|
||||
}
|
||||
|
||||
local_mem_ctx = talloc_named(NULL, 0, __PRETTY_FUNCTION__);
|
||||
if (local_mem_ctx == NULL)
|
||||
{
|
||||
[self errorWithFormat:@"%s: Error with talloc_named, out of memory?",
|
||||
__PRETTY_FUNCTION__];
|
||||
return;
|
||||
}
|
||||
retval = openchangedb_get_folder_property(local_mem_ctx, oc_ctx, username,
|
||||
PidTagChangeNumber, fid,
|
||||
(void **) ¤t_cn);
|
||||
if (retval != MAPI_E_SUCCESS)
|
||||
{
|
||||
[self errorWithFormat:@"%s: Error getting change number on %"PRIu64,
|
||||
__PRETTY_FUNCTION__, fid];
|
||||
talloc_free(local_mem_ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
[mapping setObject: lastModseq
|
||||
forKey: [NSString stringWithUnsignedLongLong: *current_cn]];
|
||||
talloc_free(local_mem_ctx);
|
||||
}
|
||||
|
||||
- (NSNumber *) modseqFromMessageChangeNumber: (NSString *) changeNum
|
||||
{
|
||||
NSDictionary *mapping;
|
||||
|
|
Loading…
Reference in New Issue