private void VerifyFromFavoriteSendersFolderEntryId(DefaultFolderContext context) { CultureInfo defaultFoldersCulture = context.Session.SharedDataManager.DefaultFoldersCulture; DefaultFolder defaultFolder = this.DefaultFolders[54]; if (defaultFolder == null || defaultFolder.FolderId == null) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug((long)this.GetHashCode(), "DefaultFolderManager::VerifyFromFavoriteSendersFolderEntryId. MyContacts folder information or the folder id is null. Returning."); return; } DefaultFolder defaultFolder2 = this.DefaultFolders[63]; if (defaultFolder2 == null || defaultFolder2.FolderId == null) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug((long)this.GetHashCode(), "DefaultFolderManager::VerifyFromFavoriteSendersFolderEntryId. FromFavoriteSenders folder or the folder id is null. Returning."); return; } if (!defaultFolder.FolderId.Equals(defaultFolder2.FolderId)) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug((long)this.GetHashCode(), "DefaultFolderManager::VerifyFromFavoriteSendersFolderEntryId. FromFavoriteSenders folder id doesn't match MyContacts folder id. Returning."); return; } string localizableDisplayName = DefaultFolderManager.GetLocalizableDisplayName(DefaultFolderType.MyContacts, defaultFoldersCulture); string localizableDisplayName2 = DefaultFolderManager.GetLocalizableDisplayName(DefaultFolderType.FromFavoriteSenders, defaultFoldersCulture); if (localizableDisplayName.Equals(localizableDisplayName2, StringComparison.OrdinalIgnoreCase)) { ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string, CultureInfo>((long)this.GetHashCode(), "DefaultFolderManager::VerifyFromFavoriteSendersFolderEntryId. FromFavoriteSenders display name matches MyContacts display name '{0}' in culture {1}. Returning.", localizableDisplayName, defaultFoldersCulture); return; } ExTraceGlobals.DefaultFoldersTracer.TraceDebug((long)this.GetHashCode(), "DefaultFolderManager::VerifyFromFavoriteSendersFolderEntryId. Deleting and recreating FromFavoriteSenders and MyContacts folders to fix folder id conflict."); defaultFolder.RemoveForRecover(); defaultFolder2.RemoveForRecover(); DefaultFolderType[] foldersToInit = new DefaultFolderType[] { DefaultFolderType.MyContacts, DefaultFolderType.FromFavoriteSenders }; this.CacheDefaultFolders(context, foldersToInit); }
internal CultureInfo GetBestCulture(CultureInfo stampedCulture, string inboxDisplayName, MailboxSession session) { List <CultureInfo> list = new List <CultureInfo>(); if (stampedCulture != null) { list.Add(stampedCulture); } if (inboxDisplayName != null) { CultureInfo cultureInfo = session.MailboxOwner.PreferredCultures.FirstOrDefault <CultureInfo>(); if (cultureInfo != null) { string localizableDisplayName = DefaultFolderManager.GetLocalizableDisplayName(DefaultFolderType.Inbox, cultureInfo); if (string.Equals(localizableDisplayName, inboxDisplayName, StringComparison.OrdinalIgnoreCase)) { list.Add(cultureInfo); } } } list.Add(session.InternalPreferedCulture); return(Util.CultureSelector.GetPreferedCulture(list.ToArray())); }
internal static DefaultFolderManager Create(MailboxSession session, OpenMailboxSessionFlags openFlags, IList <DefaultFolderType> foldersToInit) { DefaultFolderManager defaultFolderManager = new DefaultFolderManager(session); DefaultFolderContext defaultFolderContext = new DefaultFolderContext(session, defaultFolderManager.defaultFolders); defaultFolderManager.context = defaultFolderContext; if ((openFlags & OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization) == OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization) { defaultFolderContext.DeferFolderIdInit = true; } if ((openFlags & OpenMailboxSessionFlags.IgnoreForcedFolderInit) == OpenMailboxSessionFlags.IgnoreForcedFolderInit) { defaultFolderContext.IgnoreForcedFolderInit = true; } if (defaultFolderContext.Session.SharedDataManager.DefaultFoldersInitialized) { defaultFolderManager.CacheDefaultFoldersFromSharedDataManager(defaultFolderContext); defaultFolderContext.DoneDefaultFolderInitialization(); return(defaultFolderManager); } try { if ((openFlags & OpenMailboxSessionFlags.SuppressFolderIdPrefetch) == OpenMailboxSessionFlags.None) { defaultFolderContext.FolderDataDictionary = defaultFolderManager.ReadFolderData(); } else if (session.Capabilities.CanCreateDefaultFolders) { string inboxDisplayName = null; CultureInfo stampedCulture = session.Capabilities.CanHaveCulture ? session.PreferedCulture : CultureInfo.InvariantCulture; if (session.LogonType != LogonType.Delegated) { object thisObject = null; bool flag = false; byte[] inboxFolderEntryId; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } inboxFolderEntryId = session.Mailbox.MapiStore.GetInboxFolderEntryId(); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } if (IdConverter.IsFolderId(inboxFolderEntryId)) { StoreObjectId inboxId = StoreObjectId.FromProviderSpecificId(inboxFolderEntryId); DefaultFolderManager.TryGetDefaultFolderCulture(session, inboxId, out stampedCulture, out inboxDisplayName); } } defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = defaultFolderManager.GetBestCulture(stampedCulture, inboxDisplayName, session); } else { defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = CultureInfo.InvariantCulture; } defaultFolderManager.CacheDefaultFolders(defaultFolderContext, foldersToInit); defaultFolderManager.ValidateDefaultFolderSet(defaultFolderContext); } finally { defaultFolderContext.DoneDefaultFolderInitialization(); } return(defaultFolderManager); }
internal static DefaultFolderManager Create(MailboxSession session) { return(DefaultFolderManager.Create(session, OpenMailboxSessionFlags.None, MailboxSession.AllDefaultFolders)); }