/// /// Copyright © 2003-2008 JetBrains s.r.o. /// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder). /// using System; using JetBrains.Omea.Base; using JetBrains.Omea.OpenAPI; using JetBrains.Omea.ResourceTools; namespace JetBrains.Omea.OutlookPlugin { internal class OutlookAddressBook { private string _name; private bool _imported; private string _entryID; private string _storeID; private bool _exportable = true; public OutlookAddressBook( string name, string entryID, bool exportable ) { _entryID = entryID; _imported = false; _name = name; _exportable = exportable; } public OutlookAddressBook( string name, PairIDs folderIDs, bool exportable ) { _imported = true; _name = name; _entryID = folderIDs.EntryId; _storeID = folderIDs.StoreId; _exportable = exportable; } public string Name { get { return _name; } } public bool Imported { get { return _imported; } } public static void SetName( IResource resAB, string name ) { Guard.NullArgument( resAB, "resAB" ); resAB.SetProp( "DeepName", name ); resAB.SetProp( "Name", name + " (Outlook)" ); } public static void SetName( string entryID, string name ) { IResource resAB = Core.ResourceStore.FindUniqueResource( "AddressBook", PROP.EntryID, entryID ); if ( resAB != null ) { SetName( resAB, name ); } } public static string GetProposedName( string name, string entryID ) { Guard.NullArgument( name, "name" ); Guard.NullArgument( entryID, "entryID" ); if ( name.Length == 0 ) { name = ""; } string proposedName = name; IResource resAB = Core.ResourceStore.FindUniqueResource( "AddressBook", PROP.EntryID, entryID ); if ( resAB != null ) { string existingName = resAB.GetStringProp( "DeepName" ); if ( existingName == proposedName ) { return proposedName; } if ( existingName.StartsWith( name ) ) { string suffixStr = existingName.Substring( name.Length ); bool digitsOnly = true; for( int i=0; i