Merge pull request #127 from Zentyal/jkerihuel/asynchronous-notifications
[oxcnotif] Delete deprecated notification codepull/79/head^2
commit
b7907d654d
|
@ -185,12 +185,6 @@
|
||||||
/* subclass helpers */
|
/* subclass helpers */
|
||||||
- (void) setupVersionsMessage;
|
- (void) setupVersionsMessage;
|
||||||
- (void) ensureIDsForChildKeys: (NSArray *) keys;
|
- (void) ensureIDsForChildKeys: (NSArray *) keys;
|
||||||
- (void) postNotificationsForMoveCopyMessagesWithMIDs: (uint64_t *) srcMids
|
|
||||||
andMessageURLs: (NSArray *) oldMessageURLs
|
|
||||||
andCount: (uint32_t) midCount
|
|
||||||
fromFolder: (MAPIStoreFolder *) sourceFolder
|
|
||||||
withMIDs: (uint64_t *) targetMids
|
|
||||||
wantCopy: (uint8_t) wantCopy;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -587,8 +587,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||||
NSUInteger count, max;
|
NSUInteger count, max;
|
||||||
id msgObject;
|
id msgObject;
|
||||||
SOGoUser *ownerUser;
|
SOGoUser *ownerUser;
|
||||||
struct mapistore_connection_info *connInfo;
|
|
||||||
struct mapistore_object_notification_parameters *notif_parameters;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* flags that control the behaviour of the operation
|
/* flags that control the behaviour of the operation
|
||||||
|
@ -627,49 +625,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (![message isNew])
|
|
||||||
{
|
|
||||||
/* folder notification */
|
|
||||||
notif_parameters
|
|
||||||
= talloc_zero(NULL,
|
|
||||||
struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = [self objectId];
|
|
||||||
notif_parameters->tag_count = 5;
|
|
||||||
notif_parameters->tags = talloc_array (notif_parameters,
|
|
||||||
enum MAPITAGS, 5);
|
|
||||||
notif_parameters->tags[0] = PR_CONTENT_COUNT;
|
|
||||||
notif_parameters->tags[1] = PR_DELETED_COUNT_TOTAL;
|
|
||||||
notif_parameters->tags[2] = PR_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[3] = PR_NORMAL_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[4] = PR_DELETED_MSG_COUNT;
|
|
||||||
notif_parameters->new_message_count = true;
|
|
||||||
notif_parameters->message_count = [[self messageKeys]
|
|
||||||
count] - 1;
|
|
||||||
connInfo = [[self context] connectionInfo];
|
|
||||||
mapistore_push_notification (connInfo->mstore_ctx,
|
|
||||||
MAPISTORE_FOLDER,
|
|
||||||
MAPISTORE_OBJECT_MODIFIED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free(notif_parameters);
|
|
||||||
|
|
||||||
/* message notification */
|
|
||||||
notif_parameters
|
|
||||||
= talloc_zero(NULL,
|
|
||||||
struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = mid;
|
|
||||||
notif_parameters->folder_id = [self objectId];
|
|
||||||
/* Exchange sends a fnevObjectCreated!! */
|
|
||||||
mapistore_push_notification (connInfo->mstore_ctx,
|
|
||||||
MAPISTORE_MESSAGE,
|
|
||||||
MAPISTORE_OBJECT_CREATED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free(notif_parameters);
|
|
||||||
|
|
||||||
/* table notification */
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
[[activeTables objectAtIndex: count]
|
|
||||||
notifyChangesForChild: message];
|
|
||||||
}
|
|
||||||
[self logWithFormat: @"successfully deleted object at URL: %@", childURL];
|
[self logWithFormat: @"successfully deleted object at URL: %@", childURL];
|
||||||
/* Ensure we are respecting flags parameter */
|
/* Ensure we are respecting flags parameter */
|
||||||
[mapping unregisterURLWithID: mid andFlags: flags];
|
[mapping unregisterURLWithID: mid andFlags: flags];
|
||||||
|
@ -796,13 +751,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||||
/* Notifications */
|
/* Notifications */
|
||||||
if (rc == MAPISTORE_SUCCESS)
|
if (rc == MAPISTORE_SUCCESS)
|
||||||
{
|
{
|
||||||
[self postNotificationsForMoveCopyMessagesWithMIDs: srcMids
|
|
||||||
andMessageURLs: oldMessageURLs
|
|
||||||
andCount: midCount
|
|
||||||
fromFolder: sourceFolder
|
|
||||||
withMIDs: targetMids
|
|
||||||
wantCopy: wantCopy];
|
|
||||||
|
|
||||||
// We cleanup cache of our source and destination folders
|
// We cleanup cache of our source and destination folders
|
||||||
[self cleanupCaches];
|
[self cleanupCaches];
|
||||||
[sourceFolder cleanupCaches];
|
[sourceFolder cleanupCaches];
|
||||||
|
@ -1004,113 +952,6 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
||||||
withIDs: newIDs];
|
withIDs: newIDs];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) postNotificationsForMoveCopyMessagesWithMIDs: (uint64_t *) srcMids
|
|
||||||
andMessageURLs: (NSArray *) oldMessageURLs
|
|
||||||
andCount: (uint32_t) midCount
|
|
||||||
fromFolder: (MAPIStoreFolder *) sourceFolder
|
|
||||||
withMIDs: (uint64_t *) targetMids
|
|
||||||
wantCopy: (uint8_t) wantCopy
|
|
||||||
{
|
|
||||||
NSArray *activeTables;
|
|
||||||
NSUInteger count, tableCount, max;
|
|
||||||
MAPIStoreMessage *message;
|
|
||||||
NSString *messageURL;
|
|
||||||
MAPIStoreMapping *mapping;
|
|
||||||
struct mapistore_object_notification_parameters *notif_parameters;
|
|
||||||
struct mapistore_connection_info *connInfo;
|
|
||||||
|
|
||||||
connInfo = [[self context] connectionInfo];
|
|
||||||
|
|
||||||
// For the "source folder, we ensure the table caches are loaded so
|
|
||||||
// that old and new state can be compared
|
|
||||||
activeTables = [sourceFolder activeMessageTables];
|
|
||||||
max = [activeTables count];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
[[activeTables objectAtIndex: count] restrictedChildKeys];
|
|
||||||
|
|
||||||
if (!wantCopy)
|
|
||||||
{
|
|
||||||
// We notify the client. We start with the source folder.
|
|
||||||
notif_parameters = talloc_zero(NULL, struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = [sourceFolder objectId];
|
|
||||||
notif_parameters->tag_count = 5;
|
|
||||||
notif_parameters->tags = talloc_array (notif_parameters, enum MAPITAGS, 5);
|
|
||||||
notif_parameters->tags[0] = PR_CONTENT_COUNT;
|
|
||||||
notif_parameters->tags[1] = PR_DELETED_COUNT_TOTAL;
|
|
||||||
notif_parameters->tags[2] = PR_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[3] = PR_NORMAL_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[4] = PR_RECIPIENT_ON_NORMAL_MSG_COUNT;
|
|
||||||
notif_parameters->new_message_count = true;
|
|
||||||
notif_parameters->message_count = [[sourceFolder messageKeys] count] - midCount;
|
|
||||||
mapistore_push_notification (connInfo->mstore_ctx,
|
|
||||||
MAPISTORE_FOLDER,
|
|
||||||
MAPISTORE_OBJECT_MODIFIED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free(notif_parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// move/copy notification of the copied/moved message
|
|
||||||
for (count = 0; count < midCount; count++)
|
|
||||||
{
|
|
||||||
notif_parameters = talloc_zero (NULL, struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->tag_count = 0;
|
|
||||||
notif_parameters->new_message_count = true;
|
|
||||||
notif_parameters->message_count = 0;
|
|
||||||
notif_parameters->object_id = targetMids[count];
|
|
||||||
notif_parameters->folder_id = [self objectId];
|
|
||||||
notif_parameters->old_object_id = srcMids[count];
|
|
||||||
notif_parameters->old_folder_id = [sourceFolder objectId];
|
|
||||||
|
|
||||||
mapistore_push_notification (connInfo->mstore_ctx,
|
|
||||||
MAPISTORE_MESSAGE,
|
|
||||||
(wantCopy ? MAPISTORE_OBJECT_COPIED : MAPISTORE_OBJECT_MOVED),
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free (notif_parameters);
|
|
||||||
|
|
||||||
message = [sourceFolder lookupMessageByURL: [oldMessageURLs objectAtIndex: count]];
|
|
||||||
// table notification
|
|
||||||
for (tableCount = 0; tableCount < max; tableCount++)
|
|
||||||
[[activeTables objectAtIndex: tableCount]
|
|
||||||
notifyChangesForChild: message];
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the "destination folder, we ensure the table caches are loaded so
|
|
||||||
// that old and new state can be compared
|
|
||||||
activeTables = [self activeMessageTables];
|
|
||||||
max = [activeTables count];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
[[activeTables objectAtIndex: count] restrictedChildKeys];
|
|
||||||
|
|
||||||
notif_parameters = talloc_zero(NULL, struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = [self objectId];
|
|
||||||
notif_parameters->tag_count = 5;
|
|
||||||
notif_parameters->tags = talloc_array (notif_parameters, enum MAPITAGS, 5);
|
|
||||||
notif_parameters->tags[0] = PR_CONTENT_COUNT;
|
|
||||||
notif_parameters->tags[1] = PR_DELETED_COUNT_TOTAL;
|
|
||||||
notif_parameters->tags[2] = PR_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[3] = PR_NORMAL_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[4] = PR_RECIPIENT_ON_NORMAL_MSG_COUNT;
|
|
||||||
notif_parameters->new_message_count = true;
|
|
||||||
notif_parameters->message_count = [[self messageKeys] count] + midCount;
|
|
||||||
connInfo = [[self context] connectionInfo];
|
|
||||||
mapistore_push_notification (connInfo->mstore_ctx,
|
|
||||||
MAPISTORE_FOLDER,
|
|
||||||
MAPISTORE_OBJECT_MODIFIED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free(notif_parameters);
|
|
||||||
|
|
||||||
// table notification
|
|
||||||
mapping = [self mapping];
|
|
||||||
for (count = 0; count < midCount; count++)
|
|
||||||
{
|
|
||||||
messageURL = [mapping urlFromID: targetMids[count]];
|
|
||||||
message = [self lookupMessageByURL: messageURL];
|
|
||||||
for (tableCount = 0; tableCount < max; tableCount++)
|
|
||||||
[[activeTables objectAtIndex: tableCount]
|
|
||||||
notifyChangesForChild: message];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int) getDeletedFMIDs: (struct UI8Array_r **) fmidsPtr
|
- (int) getDeletedFMIDs: (struct UI8Array_r **) fmidsPtr
|
||||||
andCN: (uint64_t *) cnPtr
|
andCN: (uint64_t *) cnPtr
|
||||||
fromChangeNumber: (uint64_t) changeNum
|
fromChangeNumber: (uint64_t) changeNum
|
||||||
|
|
|
@ -1295,13 +1295,6 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self postNotificationsForMoveCopyMessagesWithMIDs: srcMids
|
|
||||||
andMessageURLs: oldMessageURLs
|
|
||||||
andCount: midCount
|
|
||||||
fromFolder: sourceFolder
|
|
||||||
withMIDs: targetMids
|
|
||||||
wantCopy: wantCopy];
|
|
||||||
|
|
||||||
// We cleanup cache of our source and destination folders
|
// We cleanup cache of our source and destination folders
|
||||||
[self cleanupCaches];
|
[self cleanupCaches];
|
||||||
[sourceFolder cleanupCaches];
|
[sourceFolder cleanupCaches];
|
||||||
|
|
|
@ -465,9 +465,6 @@ rtf2html (NSData *compressedRTF)
|
||||||
enum mapistore_error rc;
|
enum mapistore_error rc;
|
||||||
NSArray *containerTables;
|
NSArray *containerTables;
|
||||||
NSUInteger count, max;
|
NSUInteger count, max;
|
||||||
struct mapistore_object_notification_parameters *notif_parameters;
|
|
||||||
uint64_t folderId;
|
|
||||||
struct mapistore_context *mstoreCtx;
|
|
||||||
MAPIStoreContext *context;
|
MAPIStoreContext *context;
|
||||||
SOGoUser *ownerUser;
|
SOGoUser *ownerUser;
|
||||||
BOOL userIsOwner;
|
BOOL userIsOwner;
|
||||||
|
@ -498,47 +495,6 @@ rtf2html (NSData *compressedRTF)
|
||||||
/* notifications */
|
/* notifications */
|
||||||
if ([container isKindOfClass: MAPIStoreFolderK])
|
if ([container isKindOfClass: MAPIStoreFolderK])
|
||||||
{
|
{
|
||||||
folderId = [(MAPIStoreFolder *) container objectId];
|
|
||||||
mstoreCtx = [[self context] connectionInfo]->mstore_ctx;
|
|
||||||
|
|
||||||
/* folder modified */
|
|
||||||
notif_parameters
|
|
||||||
= talloc_zero(memCtx, struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = folderId;
|
|
||||||
if (isNew)
|
|
||||||
{
|
|
||||||
notif_parameters->tag_count = 3;
|
|
||||||
notif_parameters->tags = talloc_array (notif_parameters,
|
|
||||||
enum MAPITAGS, 3);
|
|
||||||
notif_parameters->tags[0] = PR_CONTENT_COUNT;
|
|
||||||
notif_parameters->tags[1] = PR_MESSAGE_SIZE;
|
|
||||||
notif_parameters->tags[2] = PR_NORMAL_MESSAGE_SIZE;
|
|
||||||
notif_parameters->new_message_count = true;
|
|
||||||
notif_parameters->message_count
|
|
||||||
= [[(MAPIStoreFolder *) container messageKeys] count] + 1;
|
|
||||||
}
|
|
||||||
mapistore_push_notification (mstoreCtx,
|
|
||||||
MAPISTORE_FOLDER,
|
|
||||||
MAPISTORE_OBJECT_MODIFIED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free (notif_parameters);
|
|
||||||
|
|
||||||
/* message created */
|
|
||||||
if (isNew)
|
|
||||||
{
|
|
||||||
notif_parameters
|
|
||||||
= talloc_zero(memCtx,
|
|
||||||
struct mapistore_object_notification_parameters);
|
|
||||||
notif_parameters->object_id = [self objectId];
|
|
||||||
notif_parameters->folder_id = folderId;
|
|
||||||
|
|
||||||
notif_parameters->tag_count = 0xffff;
|
|
||||||
mapistore_push_notification (mstoreCtx,
|
|
||||||
MAPISTORE_MESSAGE, MAPISTORE_OBJECT_CREATED,
|
|
||||||
notif_parameters);
|
|
||||||
talloc_free (notif_parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we ensure the table caches are loaded so that old and new state
|
/* we ensure the table caches are loaded so that old and new state
|
||||||
can be compared */
|
can be compared */
|
||||||
containerTables = [self activeContainerMessageTables];
|
containerTables = [self activeContainerMessageTables];
|
||||||
|
|
|
@ -87,58 +87,7 @@
|
||||||
|
|
||||||
- (void) notifyChangesForChild: (MAPIStoreMessage *) child
|
- (void) notifyChangesForChild: (MAPIStoreMessage *) child
|
||||||
{
|
{
|
||||||
NSUInteger currentChildRow, newChildRow;
|
|
||||||
NSArray *list;
|
|
||||||
NSString *childName;
|
|
||||||
struct mapistore_table_notification_parameters notif_parameters;
|
|
||||||
struct mapistore_context *mstoreCtx;
|
|
||||||
|
|
||||||
mstoreCtx = [[(MAPIStoreFolder *) container context]
|
|
||||||
connectionInfo]->mstore_ctx;
|
|
||||||
|
|
||||||
notif_parameters.table_type = tableType;
|
|
||||||
notif_parameters.handle = handleId;
|
|
||||||
notif_parameters.folder_id = [(MAPIStoreFolder *) container objectId];
|
|
||||||
notif_parameters.object_id = [child objectId];
|
|
||||||
notif_parameters.instance_id = 0; /* TODO: always 0 ? */
|
|
||||||
|
|
||||||
childName = [child nameInContainer];
|
|
||||||
list = [self restrictedChildKeys];
|
|
||||||
currentChildRow = [list indexOfObject: childName];
|
|
||||||
notif_parameters.row_id = currentChildRow;
|
|
||||||
|
|
||||||
[self cleanupCaches];
|
|
||||||
list = [self restrictedChildKeys];
|
|
||||||
newChildRow = [list indexOfObject: childName];
|
|
||||||
|
|
||||||
if (currentChildRow == NSNotFound)
|
|
||||||
{
|
|
||||||
if (newChildRow != NSNotFound)
|
|
||||||
{
|
|
||||||
notif_parameters.row_id = newChildRow;
|
|
||||||
mapistore_push_notification (mstoreCtx,
|
|
||||||
MAPISTORE_TABLE,
|
|
||||||
MAPISTORE_OBJECT_CREATED,
|
|
||||||
¬if_parameters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (newChildRow == NSNotFound)
|
|
||||||
mapistore_push_notification (mstoreCtx,
|
|
||||||
MAPISTORE_TABLE,
|
|
||||||
MAPISTORE_OBJECT_DELETED,
|
|
||||||
¬if_parameters);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* the fact that the row order has changed has no impact here */
|
|
||||||
notif_parameters.row_id = newChildRow;
|
|
||||||
mapistore_push_notification (mstoreCtx,
|
|
||||||
MAPISTORE_TABLE,
|
|
||||||
MAPISTORE_OBJECT_MODIFIED,
|
|
||||||
¬if_parameters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue