internal static StoreObjectType ReadStoreObjectTypeFromPropertyBag(ICorePropertyBag propertyBag) { object propertyValue = propertyBag.TryGetProperty(CoreItemSchema.ItemClass); string text; if (PropertyError.IsPropertyValueTooBig(propertyValue) || PropertyError.IsPropertyNotFound(propertyValue)) { text = string.Empty; } else { text = PropertyBag.CheckPropertyValue <string>(CoreItemSchema.ItemClass, propertyValue); } StoreObjectType objectType = ObjectClass.GetObjectType(text); for (int i = 0; i < ItemBuilder.storeObjectTypeDetectionChain.Length; i++) { StoreObjectType?storeObjectType = ItemBuilder.storeObjectTypeDetectionChain[i](propertyBag, text, objectType); if (storeObjectType != null) { return(storeObjectType.Value); } } return(objectType); }
internal static StoreObjectType GetFolderType(PropertyBag.BasicPropertyStore propertyBag) { int? num = propertyBag.GetValue(InternalSchema.MapiFolderType) as int?; FolderType? folderType = (num != null) ? new FolderType?((FolderType)num.GetValueOrDefault()) : null; StoreObjectType storeObjectType = ObjectClass.GetObjectType(propertyBag.GetValue(InternalSchema.ContainerClass) as string); bool? flag = propertyBag.GetValue(InternalSchema.IsOutlookSearchFolder) as bool?; if (storeObjectType == StoreObjectType.TasksFolder && folderType == FolderType.Search) { storeObjectType = StoreObjectType.SearchFolder; } else if (!Folder.IsFolderType(storeObjectType) || storeObjectType == StoreObjectType.Folder) { if (folderType == FolderType.Search) { if (flag == true) { storeObjectType = StoreObjectType.OutlookSearchFolder; } else { storeObjectType = StoreObjectType.SearchFolder; } } else { storeObjectType = StoreObjectType.Folder; } } return(storeObjectType); }
internal FolderInformation(CoreFolder coreFolder) { this.propertyBag = CoreObject.GetPersistablePropertyBag(coreFolder); this.propertyBag.Load(MapiAclTableRestriction.FolderInformation.PropertyDefinitions); string valueOrDefault = this.propertyBag.GetValueOrDefault <string>(StoreObjectSchema.ContainerClass); this.storeObjectType = ObjectClass.GetObjectType(valueOrDefault); }
public static Schema GetSchema(string className) { if (ObjectClass.IsOfClass(className, "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}") || ObjectClass.IsOfClass(className, "IPM.Appointment.Occurrence")) { return(CalendarItemOccurrenceSchema.Instance); } StoreObjectType objectType = ObjectClass.GetObjectType(className); return(ObjectClass.GetSchema(objectType)); }
internal static StoreObjectId GetStoreObjectId(MapiEvent mapiEvent, out string className) { className = string.Empty; switch (mapiEvent.ItemType) { case Microsoft.Mapi.ObjectType.MAPI_FOLDER: case Microsoft.Mapi.ObjectType.MAPI_MESSAGE: className = mapiEvent.ObjectClass; break; } StoreObjectType storeObjectType = ObjectClass.GetObjectType(className); StoreObjectId result = null; if (mapiEvent.ItemEntryId != null) { result = StoreObjectId.FromProviderSpecificId(mapiEvent.ItemEntryId, storeObjectType); } return(result); }
protected override StoreObjectType GetStoreObjectType(PropertyBag.BasicPropertyStore propertyBag) { return(ObjectClass.GetObjectType(propertyBag.GetValue(InternalSchema.ItemClass) as string)); }
private static Notification CreateNotification(MapiNotification notification) { Notification result; if (notification.NotificationType == AdviseFlags.NewMail) { MapiNewMailNotification mapiNewMailNotification = notification as MapiNewMailNotification; result = new NewMailNotification(StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.EntryId, ObjectClass.GetObjectType(mapiNewMailNotification.MessageClass)), StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.ParentId, StoreObjectType.Folder), mapiNewMailNotification.MessageClass, (MessageFlags)mapiNewMailNotification.MessageFlags); } else if (notification.NotificationType == AdviseFlags.SearchComplete) { result = new ObjectNotification(null, null, null, null, (NotificationObjectType)0, null, NotificationType.SearchComplete); } else if (notification.NotificationType == AdviseFlags.ConnectionDropped) { MapiConnectionDroppedNotification mapiConnectionDroppedNotification = notification as MapiConnectionDroppedNotification; result = new ConnectionDroppedNotification(mapiConnectionDroppedNotification.ServerDN, mapiConnectionDroppedNotification.UserDN, mapiConnectionDroppedNotification.TickDeath); } else { MapiObjectNotification mapiObjectNotification = notification as MapiObjectNotification; if (mapiObjectNotification == null) { throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType)); } AdviseFlags notificationType = notification.NotificationType; NotificationType type; if (notificationType <= AdviseFlags.ObjectDeleted) { if (notificationType == AdviseFlags.ObjectCreated) { type = NotificationType.Created; goto IL_10A; } if (notificationType == AdviseFlags.ObjectDeleted) { type = NotificationType.Deleted; goto IL_10A; } } else { if (notificationType == AdviseFlags.ObjectModified) { type = NotificationType.Modified; goto IL_10A; } if (notificationType == AdviseFlags.ObjectMoved) { type = NotificationType.Moved; goto IL_10A; } if (notificationType == AdviseFlags.ObjectCopied) { type = NotificationType.Copied; goto IL_10A; } } throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType)); IL_10A: UnresolvedPropertyDefinition[] propertyDefinitions; if (mapiObjectNotification.Tags != null) { propertyDefinitions = PropertyTagCache.UnresolvedPropertyDefinitionsFromPropTags(mapiObjectNotification.Tags); } else { propertyDefinitions = Array <UnresolvedPropertyDefinition> .Empty; } result = new ObjectNotification((mapiObjectNotification.EntryId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.EntryId, StoreObjectType.Unknown), (mapiObjectNotification.ParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.ParentId, StoreObjectType.Folder), (mapiObjectNotification.OldId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldId, StoreObjectType.Unknown), (mapiObjectNotification.OldParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldParentId, StoreObjectType.Folder), (NotificationObjectType)mapiObjectNotification.ObjectType, propertyDefinitions, type); } return(result); }
private void ReadFromMessageProperties(MessageItem messageItem) { SharingFlavor?valueAsNullable = messageItem.GetValueAsNullable <SharingFlavor>(InternalSchema.SharingFlavor); if (valueAsNullable == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingFlavor is missing", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingFlavor"); } this.context.SharingFlavor = valueAsNullable.Value; SharingCapabilities?valueAsNullable2 = messageItem.GetValueAsNullable <SharingCapabilities>(InternalSchema.SharingCapabilities); if (valueAsNullable2 == null) { ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: SharingCapabilities is missing, use default value", messageItem.Session.UserLegacyDN); this.context.SetDefaultCapabilities(); } else { this.context.SharingCapabilities = valueAsNullable2.Value; } string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorName, null); if (valueOrDefault == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorName is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingInitiatorName"); } this.context.InitiatorName = valueOrDefault; string valueOrDefault2 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorSmtp, null); if (valueOrDefault2 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingInitiatorSmtp"); } if (!SmtpAddress.IsValidSmtpAddress(valueOrDefault2)) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault2); throw new InvalidSharingMessageException("SharingInitiatorSmtp"); } this.context.InitiatorSmtpAddress = valueOrDefault2; byte[] valueOrDefault3 = messageItem.GetValueOrDefault <byte[]>(InternalSchema.SharingInitiatorEntryId, null); if (valueOrDefault3 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingInitiatorEntryId"); } if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault3)) { ExTraceGlobals.SharingTracer.TraceError <string, byte[]>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault3); throw new InvalidSharingMessageException("SharingInitiatorEntryId"); } this.context.InitiatorEntryId = valueOrDefault3; string valueOrDefault4 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteType, null); if (valueOrDefault4 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteType is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingRemoteType"); } if (SharingDataType.FromContainerClass(valueOrDefault4) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault4); throw new InvalidSharingMessageException("SharingRemoteType"); } this.context.FolderClass = valueOrDefault4; string valueOrDefault5 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteName, null); if (valueOrDefault5 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteName is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingRemoteName"); } this.context.FolderName = valueOrDefault5; string valueOrDefault6 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteUid, null); if (valueOrDefault6 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingRemoteUid"); } try { this.context.FolderId = StoreObjectId.FromHexEntryId(valueOrDefault6, ObjectClass.GetObjectType(valueOrDefault4)); } catch (CorruptDataException) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault6); throw new InvalidSharingMessageException("SharingRemoteUid"); } string valueOrDefault7 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteStoreUid, null); if (valueOrDefault7 == null) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is missing.", messageItem.Session.UserLegacyDN); throw new InvalidSharingMessageException("SharingRemoteStoreUid"); } byte[] array = null; try { array = HexConverter.HexStringToByteArray(valueOrDefault7); } catch (FormatException) { } if (array == null || StoreEntryId.TryParseStoreEntryIdMailboxDN(array) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault7); throw new InvalidSharingMessageException("SharingRemoteStoreUid"); } this.context.MailboxId = array; SharingContextPermissions?valueAsNullable3 = messageItem.GetValueAsNullable <SharingContextPermissions>(InternalSchema.SharingPermissions); if (valueAsNullable3 != null) { this.context.SharingPermissions = valueAsNullable3.Value; } SharingContextDetailLevel?valueAsNullable4 = messageItem.GetValueAsNullable <SharingContextDetailLevel>(InternalSchema.SharingDetail); if (valueAsNullable4 != null) { this.context.SharingDetail = valueAsNullable4.Value; return; } if (this.context.DataType == SharingDataType.Calendar) { this.context.SharingDetail = SharingContextDetailLevel.FullDetails; } }
public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties) { EnumValidator.ThrowIfInvalid <ManifestChangeType>(changeType, "changeType"); if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace)) { this.TraceChangeChangeCallbackProps(entryId, sourceKey, changeKey, changeList, lastModifiedTime, changeType, associated, properties); } int? num = null; string text = null; bool read = false; ConversationId conversationId = null; bool firstMessageInConversation = false; ExDateTime? filterDate = null; foreach (PropValue propValue in properties) { if (!propValue.IsError()) { PropTag propTag = propValue.PropTag; if (propTag <= PropTag.MessageDeliveryTime) { if (propTag != PropTag.MessageClass) { ConversationIndex index; if (propTag != PropTag.ConversationIndex) { if (propTag == PropTag.MessageDeliveryTime) { if (propValue.PropType == PropType.SysTime) { filterDate = new ExDateTime?((ExDateTime)propValue.GetDateTime()); } } } else if (propValue.PropType == PropType.Binary && ConversationIndex.TryCreate(propValue.GetBytes(), out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1) { firstMessageInConversation = true; } } else if (propValue.PropType == PropType.String) { text = propValue.GetString(); } } else if (propTag != PropTag.MessageFlags) { if (propTag != PropTag.InternetArticleNumber) { if (propTag == PropTag.ConversationId) { if (propValue.PropType == PropType.Binary) { conversationId = ConversationId.Create(propValue.GetBytes()); } } } else { if (propValue.PropType != PropType.Int) { return(ManifestCallbackStatus.Continue); } num = new int?(propValue.GetInt()); } } else if (propValue.PropType == PropType.Int) { MessageFlags @int = (MessageFlags)propValue.GetInt(); read = ((@int & MessageFlags.IsRead) == MessageFlags.IsRead); } } } if (changeType == ManifestChangeType.Add || changeType == ManifestChangeType.Change) { if (num == null) { return(ManifestCallbackStatus.Continue); } StoreObjectId id = StoreObjectId.FromProviderSpecificId(entryId, (text == null) ? StoreObjectType.Unknown : ObjectClass.GetObjectType(text)); MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(id); MailboxSyncWatermark mailboxSyncWatermark = MailboxSyncWatermark.CreateForSingleItem(); mailboxSyncWatermark.UpdateWithChangeNumber(num.Value, read); ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateItemChangeManifestEntry(mailboxSyncItemId, mailboxSyncWatermark); serverManifestEntry.IsNew = (changeType == ManifestChangeType.Add); serverManifestEntry.MessageClass = text; serverManifestEntry.ConversationId = conversationId; serverManifestEntry.FirstMessageInConversation = firstMessageInConversation; serverManifestEntry.FilterDate = filterDate; mailboxSyncItemId.ChangeKey = changeKey; this.lastServerManifestEntry = serverManifestEntry; } else { StoreObjectId id2 = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown); MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id2); if (mailboxSyncItemId2 == null) { return(ManifestCallbackStatus.Continue); } this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId2); this.lastServerManifestEntry.ConversationId = conversationId; } return(this.CheckYieldOrStop()); }
internal override void ParseSharingMessageProvider(SharingContext context, SharingMessageProvider sharingMessageProvider) { if (!AddressBookEntryId.IsAddressBookEntryId(context.InitiatorEntryId)) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: InitiatorEntryId is invalid.", context.UserLegacyDN); throw new InvalidSharingDataException("InitiatorEntryId", HexConverter.ByteArrayToHexString(context.InitiatorEntryId)); } if (!string.IsNullOrEmpty(sharingMessageProvider.FolderId)) { try { context.FolderId = StoreObjectId.FromHexEntryId(sharingMessageProvider.FolderId, ObjectClass.GetObjectType(context.FolderClass)); } catch (CorruptDataException) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: FolderId is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.FolderId); throw new InvalidSharingDataException("FolderId", sharingMessageProvider.FolderId); } } if (!string.IsNullOrEmpty(sharingMessageProvider.MailboxId)) { byte[] array = HexConverter.HexStringToByteArray(sharingMessageProvider.MailboxId); if (StoreEntryId.TryParseStoreEntryIdMailboxDN(array) == null) { ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: MailboxId is invalid: {1}", context.UserLegacyDN, sharingMessageProvider.MailboxId); throw new InvalidSharingDataException("MailboxId", sharingMessageProvider.MailboxId); } context.MailboxId = array; } }