Exemplo n.º 1
0
        /// <summary>
        /// Adds a property type to the cache.
        /// </summary>
        internal void AddPropTypeToCache(int ID, string name, PropDataType propType, PropTypeFlags flags)
        {
            if (ID < 0 || ID > 65536)
            {
                throw new BadIndexesException("Invalid property type ID " + ID);
            }

            lock ( _propTypeCache )
            {
                PropTypeItem propTypeItem = new PropTypeItem(ID, name, propType, flags);
                while (_propTypeCache.Count < ID)
                {
                    _propTypeCache.Add(null);
                }

                if (_propTypeCache.Count == ID)
                {
                    _propTypeCache.Add(propTypeItem);
                }
                else
                {
                    _propTypeCache [ID] = propTypeItem;
                }

                _propTypeNameCache [name] = propTypeItem;
            }
        }
Exemplo n.º 2
0
        public int Register(string name, PropDataType dataType, PropTypeFlags flags)
        {
            _propTypes [name] = dataType;
            int id = _propTypes.Count;

            _idToPropType [id]   = name;
            _propTypeToId [name] = id;
            return(id);
        }
Exemplo n.º 3
0
        public int Register(string name, PropDataType dataType, PropTypeFlags flags, IPlugin ownerPlugin)
        {
            bool newPropType = false;
            int  ID          = RegisterPropTypeInternal(name, dataType, flags, false, out newPropType);

            CreateOrUpdatePropTypeResource(name, dataType, flags, ownerPlugin, ID, newPropType);

            return(ID);
        }
Exemplo n.º 4
0
 internal PropTypeItem(int ID, string name, PropDataType type, PropTypeFlags flags)
 {
     _id                 = ID;
     _name               = name;
     _type               = type;
     _flags              = flags;
     _displayName        = null;
     _reverseDisplayName = null;
     _ownerPluginLoaded  = true;
 }
Exemplo n.º 5
0
        internal void   UpdatePropTypeFlags(int propId, PropTypeFlags flags)
        {
            PropTypeItem propType = (PropTypeItem)_propTypeCache [propId];

            propType.SetFlags(flags);

            IResource res = _storage.FindUniqueResource("PropType", "ID", propId);

            if (res != null)
            {
                res.SetProp("Flags", (int)flags);

                UpdatePropTypeRecord(propType.Name, res);
            }
            else
            {
                MyPalStorage.Storage.OnIndexCorruptionDetected("Could not find PropType resource with ID " + propId);
            }
        }
Exemplo n.º 6
0
 public PropId <T> Register <T>(string name, PropDataTypeGeneric <T> dataType, PropTypeFlags flags)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public int Register(string name, PropDataType dataType, PropTypeFlags flags, IPlugin ownerPlugin)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        private static void RegisterMailTypes(OutlookPlugin ownerPlugin, IContactManager contactManager)
        {
            if (RS.ResourceTypes.Exist("MAPIFolderRoot"))
            {
                IResourceList resourcesToDelete = RS.GetAllResources("MAPIFolderRoot");
                foreach (IResource resource in resourcesToDelete)
                {
                    resource.Delete();
                }
            }
            RegisterResources(ownerPlugin);
            PROP.SyncVersion =
                RS.PropTypes.Register(STR.SyncVersion, PropDataType.Int, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);

            PROP.EntryID = ResourceTypeHelper.UpdatePropTypeRegistration(STR.EntryID, PropDataType.String,
                                                                         PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.StoreID   = RS.PropTypes.Register(STR.StoreID, PropDataType.String, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.RecordKey = ResourceTypeHelper.UpdatePropTypeRegistration(STR.RecordKey, PropDataType.String,
                                                                           PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.InternetMsgID = ResourceTypeHelper.UpdatePropTypeRegistration(STR.InternetMsgID,
                                                                               PropDataType.String, PropTypeFlags.Internal);
            PROP.ReplyTo                  = ResourceTypeHelper.UpdatePropTypeRegistration(STR.ReplyTo, PropDataType.String, PropTypeFlags.Internal);
            PROP.ConversationIndex        = RS.PropTypes.Register("ConversationIndex", PropDataType.String, PropTypeFlags.Internal);
            PROP.ReplyToConversationIndex = RS.PropTypes.Register("ReplyToConversationIndex", PropDataType.String, PropTypeFlags.Internal);

            PROP.SentOn          = RS.PropTypes.Register(STR.SentOn, PropDataType.Date);
            PROP.LastReceiveDate = RS.PropTypes.Register(STR.LastReceiveDate, PropDataType.Date);

            PROP.Extension       = RS.PropTypes.Register(STR.Extension, PropDataType.String);
            PROP.ResType         = RS.PropTypes.Register("ResType", PropDataType.String, PropTypeFlags.Internal);
            PROP.AttachmentIndex = RS.PropTypes.Register(STR.AttachmentIndex, PropDataType.Int, PropTypeFlags.Internal);
            PROP.AttachMethod    = RS.PropTypes.Register(STR.AttachMethod, PropDataType.Int, PropTypeFlags.Internal);

            PROP.ResourceTransfer = RS.PropTypes.Register("ResorceTransfer", PropDataType.Bool, PropTypeFlags.Internal);

            CorrectDeletedItemsProperty();

            PROP.DeletedInIMAP         = RS.PropTypes.Register("DeletedInIMAP", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.IgnoredFolder         = RS.PropTypes.Register("IgnoredFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.DefaultFolderEntryIDs = RS.PropTypes.Register(STR.DefaultFolderEntryIDs, PropDataType.StringList, PropTypeFlags.Internal);
            PROP.MySelf           = Core.ContactManager.Props.Myself;
            PROP.Imported         = RS.PropTypes.Register(STR.Imported, PropDataType.Int, PropTypeFlags.Internal);
            PROP.OpenIgnoreFolder = RS.PropTypes.Register("OpenIgnoreFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.OpenSelectFolder = RS.PropTypes.Register("OpenSelectFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.MessageFlag      = RS.PropTypes.Register(STR.MessageFlag, PropDataType.String, PropTypeFlags.Internal);
            PROP.LastModifiedTime = ResourceTypeHelper.UpdatePropTypeRegistration("LastModifiedTime",
                                                                                  PropDataType.Date, PropTypeFlags.Internal);
            PROP.Priority        = RS.PropTypes.Register(STR.Priority, PropDataType.Int);
            PROP.EmbeddedMessage = RS.PropTypes.Register(STR.EmbeddedMessage, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.Importance      = RS.PropTypes.Register(STR.Importance, PropDataType.Int);
            PROP.SeeAll          = RS.PropTypes.Register("SeeAll", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.ContainerClass  = RS.PropTypes.Register(STR.ContainerClass, PropDataType.String, PropTypeFlags.Internal);
            PROP.BodyFormat      = RS.PropTypes.Register(STR.BodyFormat, PropDataType.String, PropTypeFlags.Internal);
            PROP.DefaultFolder   = RS.PropTypes.Register(STR.DefaultFolder, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.MAPIVisible     = RS.PropTypes.Register(STR.MAPIVisible, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.ShowPictures    = RS.PropTypes.Register(STR.ShowPictures, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.NoFormat        = RS.PropTypes.Register(STR.NoFormat, PropDataType.Bool, PropTypeFlags.Internal);

            PROP.SyncComplete          = RS.PropTypes.Register("SyncComplete", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.Target                = ResourceTypeHelper.UpdatePropTypeRegistration("Target", PropDataType.Link, PropTypeFlags.DirectedLink);
            PROP.IgnoreContactImport   = RS.PropTypes.Register(STR.IgnoreContactImport, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DeletedItemsFolder    = RS.PropTypes.Register(STR.DeletedItemsFolder, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DefaultDeletedItems   = RS.PropTypes.Register(STR.DefaultDeletedItems, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DeletedItemsEntryID   = RS.PropTypes.Register(STR.DeletedItemsEntryID, PropDataType.String, PropTypeFlags.Internal);
            PROP.JunkEmailEntryID      = RS.PropTypes.Register(STR.JunkEmailEntryID, PropDataType.String, PropTypeFlags.Internal);
            PROP.PR_STORE_SUPPORT_MASK = RS.PropTypes.Register(STR.PR_STORE_SUPPORT_MASK, PropDataType.Int, PropTypeFlags.Internal);
            PROP.StoreSupported        = RS.PropTypes.Register(STR.StoreSupported, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.StoreTypeChecked      = RS.PropTypes.Register(STR.StoreTypeChecked, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.PR_CONTENT_COUNT      = RS.PropTypes.Register(STR.PR_CONTENT_COUNT, PropDataType.Int, PropTypeFlags.Internal);
            PROP.PR_ICON_INDEX         = RS.PropTypes.Register(STR.PR_ICON_INDEX, PropDataType.Int, PropTypeFlags.Internal);
            CommonProps.Register();

            if (RS.PropTypes.Exist(STR.PR_ATTACH_CONTENT_ID))
            {
                IResourceList list = RS.FindResourcesWithProp(STR.Email, STR.PR_ATTACH_CONTENT_ID);
                foreach (IResource mail in list)
                {
                    mail.SetProp(CommonProps.ContentId, mail.GetStringProp(STR.PR_ATTACH_CONTENT_ID));
                    mail.DeleteProp(STR.PR_ATTACH_CONTENT_ID);
                }
                IPropType propType = RS.PropTypes[STR.PR_ATTACH_CONTENT_ID];
                RS.PropTypes.Delete(propType.Id);
            }
            PROP.PR_ATTACH_NUM = RS.PropTypes.Register(STR.PR_ATTACH_NUM, PropDataType.Int, PropTypeFlags.Internal);
            PROP.LastMailDate  = RS.PropTypes.Register(STR.LastMailDate, PropDataType.Date, PropTypeFlags.Internal);
            PROP.OMTaskId      = RS.PropTypes.Register(STR.OMTaskId, PropDataType.String, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);

            PROP.AttachmentPicWidth  = RS.PropTypes.Register(STR.Width, PropDataType.Int, PropTypeFlags.Internal);
            PROP.AttachmentPicHeight = RS.PropTypes.Register(STR.Height, PropDataType.Int, PropTypeFlags.Internal);

            PROP.From = contactManager.Props.LinkFrom;
            PROP.To   = contactManager.Props.LinkTo;
            PROP.CC   = contactManager.Props.LinkCC;

            PROP.EmailAccountFrom = Core.ContactManager.Props.LinkEmailAcctFrom;
            PROP.EmailAccountTo   = Core.ContactManager.Props.LinkEmailAcctTo;
            PROP.EmailAccountCC   = Core.ContactManager.Props.LinkEmailAcctCC;
            RS.RegisterLinkRestriction(STR.Email, PROP.From, "Contact", 0, 1);

            PROP.SelectedInFolder = RS.PropTypes.Register("SelectedInFolder", PropDataType.Link, PropTypeFlags.Internal);

            PROP.Attachment = Core.ResourceStore.PropTypes.Register(STR.Attachment, PropDataType.Link,
                                                                    PropTypeFlags.SourceLink | PropTypeFlags.DirectedLink, ownerPlugin);
            RS.PropTypes.RegisterDisplayName(PROP.Attachment, "Outlook Message", "Attachment");

            PROP.AttType            = RS.PropTypes.Register(STR.AttachmentType, PropDataType.Link, PropTypeFlags.Internal);
            PROP.OwnerStore         = RS.PropTypes.Register("OwnerStore", PropDataType.Link, PropTypeFlags.Internal);
            PROP.TopLevelCategory   = RS.PropTypes.Register("TopLevelCategory", PropDataType.Link, PropTypeFlags.Internal);
            PROP.InternalAttachment = RS.PropTypes.Register("InternalAttachment", PropDataType.Link, PropTypeFlags.Internal);

            IResource     propMAPIFolderLink = RS.FindUniqueResource("PropType", "Name", STR.MAPIFolder);
            PropTypeFlags flags = PropTypeFlags.Normal | PropTypeFlags.CountUnread;

            if (propMAPIFolderLink != null)
            {
                propMAPIFolderLink.SetProp("Flags", (int)flags);
                PROP.MAPIFolder = propMAPIFolderLink.GetIntProp("ID");
            }
            else
            {
                PROP.MAPIFolder = RS.PropTypes.Register(STR.MAPIFolder, PropDataType.Link, flags);
            }
            RS.PropTypes.RegisterDisplayName(PROP.MAPIFolder, "Outlook Folder");

            RS.ResourceTypes.Register(STR.Task, "Subject");

            RS.RegisterUniqueRestriction(STR.Email, PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.OutlookABDescriptor, PROP.EntryID);
            RS.RegisterUniqueRestriction("AddressBook", PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.DeletedItemsEntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.JunkEmailEntryID);
            RS.RegisterUniqueRestriction("Contact", PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIStore, PROP.StoreID);

            RS.RegisterLinkRestriction(STR.Email, PROP.MAPIFolder, STR.MAPIFolder, 0, 1);
            RS.RegisterUniqueRestriction(STR.MAPIFolder, PROP.EntryID);
            RS.RegisterLinkRestriction(STR.MAPIFolder, Core.Props.Parent, null, 1, 1);
            RS.RegisterLinkRestriction(STR.MAPIFolder, PROP.OwnerStore, STR.MAPIStore, 1, 1);
            RS.RegisterLinkRestriction(STR.Email, PROP.OwnerStore, STR.MAPIStore, 0, 1);
            RS.DeleteUniqueRestriction(STR.Task, PROP.OMTaskId);
            RS.RegisterUniqueRestriction(STR.Task, PROP.EntryID);

            RemoveInvalidAttachmentResources();
            RemoveAttachmentResources();
            UpdateOutlookAttachments( );
            ChangeDatePropForMAPIStore();

            PROP.Status      = RS.PropTypes.Register("Status", PropDataType.Int);
            PROP.RemindDate  = RS.PropTypes.Register("RemindDate", PropDataType.Date);
            PROP.StartDate   = RS.PropTypes.Register("StartDate", PropDataType.Date);
            PROP.Description = RS.PropTypes.Register("Description", PropDataType.String);
            //  NB: this prop format must coinside with that in TasksPlugin.
            PROP.SuperTaskLink = RS.PropTypes.Register(STR.SuperTaskLink, PropDataType.Link, PropTypeFlags.DirectedLink | PropTypeFlags.Internal);
            RS.ResourceTypes.Register("SentItemsEnumSign", "", ResourceTypeFlags.NoIndex | ResourceTypeFlags.Internal);
            UpdateLastMailDateForFolders();
            RemoveWrongGlobalBooks();
            RemoveOMTaskIDs();
            UpdateDeletedItemsFolders();
            DeleteInvalidMAPIFolders();
            UpdateMapiInfoStores();
            _registered = true;
        }
Exemplo n.º 9
0
        public static int UpdatePropTypeRegistration(string name, PropDataType dataType, PropTypeFlags flags)
        {
            int       propID;
            IResource propres = Core.ResourceStore.FindUniqueResource("PropType", "Name", name);

            if (propres != null)
            {
                propID = propres.GetIntProp("ID");
                propres.SetProp("Flags", (int)flags);
            }
            else
            {
                propID = Core.ResourceStore.PropTypes.Register(name, dataType, flags);
            }
            return(propID);
        }
Exemplo n.º 10
0
 public bool HasFlag(PropTypeFlags flag)
 {
     return((_flags & flag) != 0);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a resource describing the property type.
        /// </summary>
        private IResource CreatePropTypeResource(int ID, string name, PropDataType propType, PropTypeFlags flags)
        {
            IResource res = _storage.BeginNewResource("PropType");

            res.SetProp(_storage.Props.Name, name);
            res.SetProp(_storage.Props.TypeId, ID);
            res.SetProp(_storage.Props.DataType, (int)propType);
            res.SetProp(_storage.Props.Flags, (int)flags);
            res.EndUpdate();
            return(res);
        }
Exemplo n.º 12
0
        /**
         * Adds a record for the specified prop type to the DB.
         */

        internal int RegisterPropTypeInternal(string name, PropDataType propType, PropTypeFlags flags,
                                              bool forceType, out bool newPropType)
        {
            _storage.CheckOwnerThread();
            IRecord rec = _propTypeTable.GetRecordByEqual(1, name);

            if (rec != null)
            {
                if (!_propTypeNameCache.ContainsKey(name))
                {
                    throw new BadIndexesException("Property type " + name + " found in PropTypes table but missing in name cache");
                }

                bool recordChanged = false;
                if (rec.GetIntValue(2) != (int)propType)
                {
                    if (forceType)
                    {
                        rec.SetValue(2, IntInternalizer.Intern((int)propType));
                        ((PropTypeItem)this[name]).SetDataType(propType);
                        recordChanged = true;
                    }
                    else
                    {
                        throw new StorageException("Inconsistent registration for property type " + name +
                                                   ": old type " + (PropDataType)rec.GetIntValue(2) + ", new type " + propType);
                    }
                }
                int           propId   = rec.GetIntValue(0);
                PropTypeFlags newFlags = flags | this [propId].Flags;
                if (rec.GetIntValue(3) != (int)newFlags)
                {
                    rec.SetValue(3, (int)newFlags);
                    recordChanged = true;
                }
                if (recordChanged)
                {
                    rec.Commit();
                }

                newPropType = false;
                PropTypeItem propTypeItem = (PropTypeItem)_propTypeCache [propId];
                propTypeItem.SetFlags(newFlags);
                return(propId);
            }

            if ((flags & (PropTypeFlags.DirectedLink | PropTypeFlags.CountUnread)) != 0 &&
                propType != PropDataType.Link)
            {
                throw new StorageException("DirectedLink and CountUnread flags can be used only on Link properties");
            }

            int ID;

            lock ( _propTypeTable )
            {
                IRecord propertyType = _propTypeTable.NewRecord();
                propertyType.SetValue(1, name);
                propertyType.SetValue(2, IntInternalizer.Intern((int)propType));
                propertyType.SetValue(3, (int)flags);
                _storage.SafeCommitRecord(propertyType, "PropTypeCollection.RegisterPropTypeInternal");
                ID = propertyType.GetID();
                if (ID > 65536)
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("Invalid next ID in property type table");
                }
            }

            AddPropTypeToCache(ID, name, propType, flags);

            newPropType = true;
            return(ID);
        }
Exemplo n.º 13
0
        internal void CreateOrUpdatePropTypeResource(string name, PropDataType dataType, PropTypeFlags flags, IPlugin ownerPlugin, int ID, bool newPropType)
        {
            if (newPropType)
            {
                IResource res;
                try
                {
                    res = CreatePropTypeResource(ID, name, dataType, flags);
                }
                catch (ResourceRestrictionException ex)   // OM-9471
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("ResourceRestrictionException when creating PropType resource: " +
                                                                   ex.Message);
                    return;
                }
                _storage.SetOwnerPlugin(res, ownerPlugin);
            }
            else
            {
                IResource res = _storage.FindUniqueResource("PropType", "Name", name);

                if (res != null)
                {
                    res.SetProp("Flags", (int)this [name].Flags);      // ensure OR'ed flags are applied correctly
                    _storage.SetOwnerPlugin(res, ownerPlugin);
                }
                else
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("Could not find PropType resource for property type " + name);
                }
            }
        }
Exemplo n.º 14
0
        public PropId <T> Register <T>(string name, PropDataTypeGeneric <T> dataType, PropTypeFlags flags,
                                       IPlugin ownerPlugin)
        {
            int id = Register(name, dataType.Type, flags, ownerPlugin);

            return(InternPropId(new PropId <T>(id)));
        }
Exemplo n.º 15
0
 public int Register(string name, PropDataType propType, PropTypeFlags flags)
 {
     return(Register(name, propType, flags, null));
 }
Exemplo n.º 16
0
 internal void SetFlags(PropTypeFlags flags)
 {
     _flags = flags;
 }