예제 #1
0
        [Test] public void UnreadAndReverseLink()
        {
            IResource email = _storage.BeginNewResource("Email");

            email.SetProp(_propUnread, true);
            _folder.AddLink(_propFolder, email);
            email.EndUpdate();

            Assert.AreEqual(1, _unreadManager.GetUnreadCount(_folder));
        }
예제 #2
0
        public void TestComplexLinks()
        {
/*
 *          IResource e1In = _storage.NewResource( "Email" );
 *          e1In.SetProp( "Folder", "Humor" );
 *          IResource e1Out = _storage.NewResource( "Email" );
 *          e1Out.SetProp( "Folder", "Humor" );
 */
            IResource e2 = _storage.NewResource("Email");
//            e2.SetProp( "Folder", "Sergey" );
            IResource e2Reply = _storage.NewResource("Email");
//            e2Reply.SetProp( "Folder", "SentItems" );
            IResource e3 = _storage.NewResource("Email");
//            e3.SetProp( "Folder", "Sergey" );
            IResource e3Reply = _storage.NewResource("Email");
//            e3Reply.SetProp( "Folder", "SentItems" );

            IResource mySelf = _storage.NewResource("Person");
            IResource person = _storage.NewResource("Person");

            e2.AddLink(_propFrom, person);
            e2.AddLink(_propTo, mySelf);
            e2Reply.AddLink(_propFrom, mySelf);
            e2Reply.AddLink(_propTo, person);

            e3.AddLink(_propFrom, person);
            e3.AddLink(_propTo, mySelf);
            e3Reply.AddLink(_propFrom, mySelf);
            e3Reply.AddLink(_propTo, person);

            Console.WriteLine(person.GetLinksOfType(null, _propFrom).Count.ToString());
            Console.WriteLine(person.GetLinksOfType(null, _propTo).Count.ToString());
            Stream stream = ResourceBinarySerialization.Serialize(person);

            person.Delete();
            person = ResourceBinarySerialization.Deserialize(stream);
            Console.WriteLine(person.GetLinksOfType(null, _propFrom).Count.ToString());
            Console.WriteLine(person.GetLinksOfType(null, _propTo).Count.ToString());
            Assert.AreEqual(2, person.GetLinksOfType(null, _propFrom).Count, "There must be 2 links From person to MySelf");
            Assert.AreEqual(2, person.GetLinksOfType(null, _propTo).Count, "There must be 2 links To person From MySelf");
//            Assert( "There must be 2 links From MySelf to person", mySelf.GetLinksOfType( null, _propFrom ).Count == 2 );
//            Assert( "There must be 2 links To MySelf From person", mySelf.GetLinksOfType( null, _propTo ).Count == 2 );

/*
 *          reply.AddLink( _propReply, origin );
 *          origin.AddLink( _propAuthor, person );
 *          Stream stream = ResourceBinarySerialization.Serialize( origin );
 *          origin.Delete();
 *          origin = ResourceBinarySerialization.Deserialize( stream );
 *          Assert( "Reply has no link to deserialized origin", reply.HasLink( _propReply, origin ) );
 *          Assert( "Person has no link to deserialized origin", person.HasLink( _propAuthor, origin ) );
 */
        }
예제 #3
0
        public void DirectedLinkBrokenRestriction()
        {
            int parentLink = _storage.PropTypes.Register("Parent", PropDataType.Link, PropTypeFlags.DirectedLink);

            _storage.RegisterLinkRestriction("Email", parentLink, null, 0, 1);

            IResource email0 = _storage.NewResource("Email");
            IResource email1 = _storage.NewResource("Email");
            IResource email2 = _storage.NewResource("Email");

            email0.AddLink(parentLink, email1);
            email0.AddLink(parentLink, email2);
        }
예제 #4
0
        protected override void Execute()
        {
            IResource res = _store.NewResource("Email");

            res.SetProp("Subject", res.Id.ToString());
            IResource author = _store.NewResource("Person");

            author.SetProp("LastName", "author" + res.Id.ToString());
            res.AddLink("Author", author);
            IResource reply = _store.NewResource("Person");

            reply.SetProp("LastName", "reply" + res.Id.ToString());
            res.AddLink("Reply", reply);
            res.SetProp("Size", res.Id);
        }
예제 #5
0
        [Test] public void LinkCountAndDeleteLink()
        {
            int       fromLink = _storage.PropTypes.Register("From", PropDataType.Link);
            IResource res      = _storage.NewResource("Person");
            IResource email1   = _storage.NewResource("Email");
            IResource email2   = _storage.NewResource("Email");
            IResource email3   = _storage.NewResource("Email");

            res.AddLink(fromLink, email1);
            res.AddLink(fromLink, email2);
            res.AddLink(fromLink, email3);

            _storage.RegisterLinkRestriction("Person", fromLink, "Email", 0, 1);
            res.DeleteLink(fromLink, email3);
        }
예제 #6
0
 private static void RemoveAttachmentResources()
 {
     //move attachment properties to format file resource
     try
     {
         if (RS.ResourceTypes.Exist(STR.Attachment))
         {
             IResourceList attachments = Core.ResourceStore.GetAllResources(STR.Attachment);
             for (int i = attachments.Count - 1; i >= 0; i--)
             {
                 IResource attachment = attachments[i];
                 IResource formatFile = attachment.GetLinkProp("Source");
                 if (formatFile != null)
                 {
                     formatFile.SetProp(Core.Props.Name, attachment.GetProp(Core.Props.Name));
                     formatFile.SetProp(Core.Props.Date, attachment.GetProp(Core.Props.Date));
                     formatFile.SetProp(PROP.AttachmentIndex, attachment.GetProp(PROP.AttachmentIndex));
                     if (attachment.HasProp(PROP.ResourceTransfer))
                     {
                         formatFile.SetProp(PROP.ResourceTransfer, true);
                     }
                     IResourceList froms = attachment.GetLinksFrom("Contact", PROP.From);
                     foreach (IResource from in froms)
                     {
                         formatFile.AddLink(PROP.From, from);
                     }
                     IResourceList tos = formatFile.GetLinksFrom("Contact", PROP.To);
                     foreach (IResource to in tos)
                     {
                         formatFile.AddLink(PROP.To, to);
                     }
                     attachment.Delete();
                 }
                 else
                 {
                     IResource mail = attachment.GetLinkProp(PROP.InternalAttachment);
                     if (mail != null)
                     {
                         attachment.AddLink(PROP.Attachment, mail);
                     }
                     attachment.ChangeType("UnknownFile");
                 }
             }
             RS.ResourceTypes.Delete(STR.Attachment);
         }
     }
     catch (StorageException) {}
 }
예제 #7
0
        private static void LinkResource(BinaryReader reader, IResource result, int linkId,
                                         BeforeDeserializationDelegate beforeCheck)
        {
            int       linkedResId = reader.ReadInt32();
            IResource linked      = Core.ResourceStore.TryLoadResource(linkedResId);

            if (linked != null)
            {
                linked.BeginUpdate();
                //  Caller may need to perform special actions, e.g. to
                //  keep the consistency of link restrictions
                if (beforeCheck != null)
                {
                    beforeCheck(result, linked, linkId);
                }

                if (Math.Abs(linkId) == Core.ContactManager.Props.LinkBaseContact)
                {
                    Trace.WriteLine("Deserializer -- adding link between " + result.DisplayName + "/" + result.Id + " and " + linked.DisplayName + "/" + linked.Id);
                }
                if (linkId < 0)
                {
                    linked.AddLink(-linkId, result);
                }
                else
                {
                    result.AddLink(linkId, linked);
                }
                linked.EndUpdate();
            }
        }
예제 #8
0
        [Test] public void ImportAIMWithExistingAccount()
        {
            Core.ContactManager.FindOrCreateMySelfContact(null, "test");

            IContact  contact    = Core.ContactManager.FindOrCreateContact(null, "Dmitry Jemerov");
            IResource aimAccount = _storage.NewResource(ResourceTypes.MirandaAIMAccount);

            aimAccount.SetProp(Props.ScreenName, "intelliyole");
            aimAccount.AddLink(Props.MirandaAcct, contact.Resource);

            MockMirandaDB      db           = new MockMirandaDB();
            MockMirandaContact ownerContact = (MockMirandaContact)db.UserContact;

            ownerContact.AddSetting("AIM", "SN", "test");
            ownerContact.AddSetting("AIM", "Nick", "test");

            MockMirandaContact otherContact = db.AddContact();

            otherContact.AddSetting("AIM", "SN", "intelliyole");
            ownerContact.AddSetting("AIM", "Nick", "intelliyole");
            otherContact.AddEvent("AIM", 0, DateTime.Now, 0, "Hello");

            DoImportDB(db);

            IResourceList contacts = Core.ResourceStore.GetAllResources("Contact");

            contacts.Sort(new SortSettings(ResourceProps.DisplayName, true));
            Assert.AreEqual(2, contacts.Count);
            Assert.AreEqual("Dmitry Jemerov", contacts [0].DisplayName);
            Assert.AreEqual("test", contacts [1].DisplayName);
        }
예제 #9
0
        [Test] public void ResourceRecursive()
        {
            IResource folder    = _storage.NewResource("Folder");
            IResource workspace = _workspaceManager.CreateWorkspace("Test");

            _workspaceManager.AddResourceToWorkspaceRecursive(workspace, folder);

            IResourceList wsResources = _workspaceManager.GetFilterList(workspace);

            Assert.AreEqual(1, wsResources.Count);

            IResource childFolder = _storage.NewResource("Folder");

            childFolder.AddLink("Parent", folder);

            wsResources = _workspaceManager.GetFilterList(workspace);
            Assert.AreEqual(2, wsResources.Count);

            IResource person = _storage.NewResource("Person");

            person.AddLink(_propAuthor, childFolder);
            Assert.AreEqual(3, _workspaceManager.GetFilterList(workspace).Count);

            _workspaceManager.RemoveResourceFromWorkspace(workspace, childFolder);
            Assert.AreEqual(1, _workspaceManager.GetFilterList(workspace).Count);

            _workspaceManager.AddResourceToWorkspace(workspace, childFolder);
            Assert.AreEqual(3, _workspaceManager.GetFilterList(workspace).Count);
        }
예제 #10
0
 private void ReceiveResoources()
 {
     foreach (TreeNode treeNode in _resourceTreeView.Nodes)
     {
         NodeCheckState currState = _resourceTreeView.GetNodeCheckState(treeNode);
         if (currState == NodeCheckState.Checked)
         {
             ResourceUnpack resourceUnpack = (ResourceUnpack)treeNode.Tag;
             resourceUnpack.AcceptReceiving();
             _mail.AddLink("ResourceAttachment", resourceUnpack.Resource);
             foreach (TreeNode linkTreeNode in treeNode.Nodes)
             {
                 foreach (TreeNode linkedResourceNode in linkTreeNode.Nodes)
                 {
                     currState = _resourceTreeView.GetNodeCheckState(linkedResourceNode);
                     if (currState == NodeCheckState.Checked)
                     {
                         resourceUnpack = (ResourceUnpack)linkedResourceNode.Tag;
                         resourceUnpack.AcceptReceiving();
                     }
                 }
             }
         }
     }
 }
예제 #11
0
        private IResource NewFolder(IResource parent)
        {
            IResource result = _core.ResourceStore.NewResource("Folder");

            result.AddLink(_propParent, parent);
            return(result);
        }
예제 #12
0
        public static void PlaceResourceToFolder(IResource res, IResource folder)
        {
            IResourceStore store = Core.ResourceStore;

            if (!store.IsOwnerThread())
            {
                Core.ResourceAP.QueueJob(JobPriority.Immediate,
                                         new PlaceResourceToFolderDelegate(PlaceResourceToFolder), res, folder);
            }
            else
            {
                if (!res.IsDeleted)
                {
                    IResourceList folders = res.GetLinksFrom(NntpPlugin._newsFolder, NntpPlugin._propTo);
                    foreach (IResource oldfolder in folders)
                    {
                        res.DeleteLink(NntpPlugin._propTo, oldfolder);
                    }
                    res.AddLink(NntpPlugin._propTo, folder);
                    if (folder == SentItems)
                    {
                        res.DeleteProp(NntpPlugin._propNntpText);
                    }
                }
            }
        }
예제 #13
0
        private static void ImportFeed(XmlReader reader, IResource group, bool addToWorkspace)
        {
            if (reader.MoveToAttribute("xmlUrl") || reader.MoveToAttribute("xmlurl"))
            {
                IResource existingFeed = Core.ResourceStore.FindUniqueResource("RSSFeed", "URL", reader.Value);
                if (existingFeed != null)
                {
                    return;
                }
            }
            else
            {
                return;
            }

            IResource feed = Core.ResourceStore.BeginNewResource("RSSFeed");

            feed.SetProp(Props.URL, reader.Value);
            reader.MoveToElement();

            SetFeedProp(feed, reader, Core.Props.Name, "title", "text");
            SetFeedProp(feed, reader, Props.HomePage, "htmlUrl", "htmlurl");
            SetFeedProp(feed, reader, Props.Description, "description");
            SetFeedProp(feed, reader, Props.Language, "language");

            feed.AddLink("Parent", group);

            feed.EndUpdate();
            if (addToWorkspace)
            {
                Core.WorkspaceManager.AddToActiveWorkspace(feed);
            }
        }
예제 #14
0
        [Test] public void NonUniqueResources()
        {
            _treeView.UniqueResources = false;
            IResource folder1 = CreateResource("Folder", "Name", "A", _root);
            IResource folder2 = CreateResource("Folder", "Name", "B", _root);
            IResource folder3 = CreateResource("Folder", "Name", "X", folder1);

            folder3.AddLink("Parent", folder2);

            _treeView.RootResource = _root;
            _treeView.Nodes [0].Expand();
            _treeView.Nodes [1].Expand();

            Assert.AreEqual(1, _treeView.Nodes [0].Nodes.Count);
            Assert.AreEqual(1, _treeView.Nodes [1].Nodes.Count);

            folder3.SetProp("Name", "Y");
            _treeView.ProcessPendingUpdates();

            Assert.AreEqual("Y", _treeView.Nodes [0].Nodes [0].Text);
            Assert.AreEqual("Y", _treeView.Nodes [1].Nodes [0].Text);

            folder1.SetProp("Name", "C");
            _treeView.ProcessPendingUpdates();
            Assert.AreEqual("C", _treeView.Nodes [0].Text);
            Assert.AreEqual(2, _treeView.Nodes.Count);

            folder1.Delete();
            _treeView.ProcessPendingUpdates();
            Assert.AreEqual(1, _treeView.Nodes.Count);
        }
예제 #15
0
        private void SaveNotifyRule()
        {
            IResource rule = _targetResource.GetLinkProp(_propNotifyMeRule);

            if (rule != null)
            {
                Core.FilterRegistry.DeleteRule(rule);
            }

            string ruleName;

            IResource[] ruleConditions = BuildRuleConditions(out ruleName);
            IResource[] ruleActions    = BuildRuleActions();

            if (ruleActions.Length > 0)
            {
                string ruleResType = Core.NotificationManager.GetRuleResourceType(_targetResource.Type);
                rule = Core.FilterRegistry.RegisterRule(StandardEvents.ResourceReceived, ruleName,
                                                        (ruleResType == null)? null : new string[1] {
                    ruleResType
                },
                                                        ruleConditions, null, ruleActions);

                _targetResource.AddLink(_propNotifyMeRule, rule);
            }
        }
예제 #16
0
        [Test] public void UnreadAndLink()
        {
            IResource email = _storage.BeginNewResource("Email");

            email.SetProp(_propUnread, true);
            email.AddLink(_propFolder, _folder);
            email.EndUpdate();

            Assert.AreEqual(1, _unreadManager.GetUnreadCount(_folder));

            IResource email2 = _storage.BeginNewResource("Email");

            email2.AddLink(_propFolder, _folder);
            email2.SetProp(_propUnread, true);
            email2.EndUpdate();

            Assert.AreEqual(2, _unreadManager.GetUnreadCount(_folder));

            email.BeginUpdate();
            email.SetProp(_propUnread, false);
            email.DeleteLink(_propFolder, _folder);
            email.EndUpdate();
            Assert.AreEqual(1, _unreadManager.GetUnreadCount(_folder));

            email2.Delete();
            Assert.AreEqual(0, _unreadManager.GetUnreadCount(_folder));
        }
예제 #17
0
파일: BookEditPane.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// Runs in the resource thread and saves the data entered by the user
        /// to the resource store.
        /// </summary>
        private void DoSave()
        {
            _book.SetProp("Name", _edtName.Text);
            _book.DeleteLinks(PropTypes.BookAuthor);

            // Parse the list of author names separated with
            string[] authors = _edtAuthors.Text.Split(',', ';');
            foreach (string author in authors)
            {
                if (author.Trim().Length == 0)
                {
                    continue;
                }
                IContact contact = Core.ContactManager.FindOrCreateContact(null, author.Trim());
                if (contact != null)
                {
                    _book.AddLink(PropTypes.BookAuthor, contact.Resource);
                }
            }

            _book.SetProp(PropTypes.PubYear, (int)_udYear.Value);

            if (_edtIsbn.Text.Length > 0)
            {
                _book.SetProp(PropTypes.Isbn, _edtIsbn.Text);
            }
            else
            {
                _book.DeleteProp(PropTypes.Isbn);
            }
        }
예제 #18
0
        [Test] public void RepairUniqueRestrictionWithLinkRestrictions()
        {
            int       testLink = _storage.PropTypes.Register("TestLink", PropDataType.Link); testLink = testLink;
            IResource email1   = _storage.NewResource("Email");
            IResource email2   = _storage.NewResource("Email");
            IResource from1    = _storage.NewResource("Person");
            IResource from2    = _storage.NewResource("Person");

            email1.AddLink(_propAuthor, from1);
            email2.AddLink(_propAuthor, from2);

            from1.SetProp("Name", "Dmitry");
            from2.SetProp("Name", "Dmitry");

            _storage.RegisterLinkRestriction("Email", _propAuthor, null, 1, Int32.MaxValue);
            _storage.RegisterUniqueRestriction("Person", _storage.PropTypes ["Name"].Id);

            ResourceStoreRepair repair = new ResourceStoreRepair(null);

            repair.FixErrors = true;
            repair.RepairRestrictions();

            Assert.IsTrue(!from1.IsDeleted);
            Assert.IsTrue(!from2.IsDeleted);
        }
예제 #19
0
        private IResource NewItem(IResource parent)
        {
            IResource result = _core.ResourceStore.NewResource("Item");

            result.AddLink(_propParent, parent);
            return(result);
        }
예제 #20
0
파일: Contact.cs 프로젝트: mo5h/omeo
        public void SetPhoneNumber(string phoneName, string phoneNumber)
        {
            #region Preconditions
            if (String.IsNullOrEmpty(phoneName))
            {
                throw new ArgumentNullException("phoneName", "IContact -- Invalid phone name - null or empty");
            }
            if (String.IsNullOrEmpty(phoneNumber))
            {
                throw new ArgumentNullException("phoneNumber", "IContact -- Invalid phone number - null or empty");
            }
            #endregion Preconditions

            IResource phone = GetPhoneByName(phoneName);
            if (phone != null)
            {
                phone.SetProp(ContactManager._propPhoneNumber, phoneNumber);
            }
            else
            {
                phone = Core.ResourceStore.BeginNewResource("Phone");
                try
                {
                    phone.SetProp(ContactManager._propPhoneName, phoneName);
                    phone.SetProp(ContactManager._propPhoneNumber, phoneNumber);
                    _resource.AddLink(ContactManager._propPhone, phone);
                }
                finally
                {
                    phone.EndUpdate();
                }
            }
        }
예제 #21
0
        private static void CheckMyselfLinkageWithAccounts()
        {
            IResource     res           = Core.ContactManager.MySelf.Resource;
            IResourceList accounts      = res.GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct);
            IResourceList cNames        = res.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact);
            IResourceList namesAccounts = Core.ResourceStore.EmptyResourceList;

            foreach (IResource cName in cNames)
            {
                namesAccounts = namesAccounts.Union(cName.GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct), true);
            }

            Trace.WriteLine("ContactsUpgrade - " + accounts.Count + " normal accounts found: ");
            foreach (IResource acc in accounts)
            {
                Trace.WriteLine("              " + acc.DisplayName);
            }

            Trace.WriteLine("ContactsUpgrade - " + namesAccounts.Count + " ContactName accounts found: ");
            foreach (IResource acc in namesAccounts)
            {
                Trace.WriteLine("              " + acc.DisplayName);
            }

            accounts = namesAccounts.Minus(accounts);

            Trace.WriteLine("ContactsUpgrade - found " + accounts.Count + " hanged accounts.");
            foreach (IResource acc in accounts)
            {
                Trace.WriteLine("          " + acc.DisplayName);
                res.AddLink(Core.ContactManager.Props.LinkEmailAcct, acc);
            }
        }
예제 #22
0
        [Test] public void ResourcesOutsideContainersTest()
        {
            IResource person   = _storage.NewResource("Person");
            IResource category = CategoryManager.CreateCategory("Test", _categoryManager.RootCategory);
            IResource email    = _storage.NewResource("Email");
            IResource email2   = _storage.NewResource("Email");
            IResource email3   = _storage.NewResource("Email");

            email.AddLink(_propAuthor, person);
            email2.AddLink(_propAuthor, person);
            _categoryManager.AddResourceCategory(email2, category);
            _categoryManager.AddResourceCategory(email3, category);

            IResource workspace = _workspaceManager.CreateWorkspace("Test ");

            _workspaceManager.AddResourceToWorkspace(workspace, person);

            Assert.IsFalse(_workspaceManager.HasResourcesOutsideContainers(workspace));

            _workspaceManager.AddResourceToWorkspace(workspace, category);

            Assert.IsTrue(_workspaceManager.HasResourcesOutsideContainers(workspace));
            IResourceList outsideList = _workspaceManager.GetResourcesOutsideContainers(workspace);

            Assert.IsFalse(outsideList.Contains(email));
            Assert.IsFalse(outsideList.Contains(email2));
            Assert.IsTrue(outsideList.Contains(email3));
        }
예제 #23
0
        [Test] public void UnreadResourceEntersWorkspace()
        {
            Core.ResourceStore.ResourceTypes.Register("Folder", "Name");
            int propInFolder = Core.ResourceStore.PropTypes.Register("InFolder", PropDataType.Link,
                                                                     PropTypeFlags.CountUnread);

            _wsManager.RegisterWorkspaceType("Folder", new int[] { propInFolder },
                                             WorkspaceResourceType.Container);

            IResource ws     = _wsManager.CreateWorkspace("Test");
            IResource folder = _storage.NewResource("Folder");

            _wsManager.AddResourceToWorkspace(ws, folder);

            UnreadState theState = _unreadManager.SetUnreadState("", ws);

            Assert.AreEqual(0, theState.GetUnreadCount(folder));

            IResource email = _storage.NewResource("Email");

            email.SetProp(_propUnread, true);

            Assert.AreEqual(0, theState.GetUnreadCount(folder));
            email.AddLink("InFolder", folder);
            Assert.AreEqual(1, theState.GetUnreadCount(folder));

            email.DeleteLink("InFolder", folder);
            Assert.AreEqual(0, theState.GetUnreadCount(folder));
        }
예제 #24
0
        [Test] public void ImportICQWithExistingAccount()
        {
            IContact  contact    = Core.ContactManager.FindOrCreateContact(null, "Dmitry Jemerov");
            IResource icqAccount = _storage.NewResource(ResourceTypes.MirandaICQAccount);

            icqAccount.SetProp(Props.UIN, 84614327);
            icqAccount.AddLink(Props.MirandaAcct, contact.Resource);

            MockMirandaDB      db           = new MockMirandaDB();
            MockMirandaContact ownerContact = (MockMirandaContact)db.UserContact;

            ownerContact.AddSetting("ICQ", "UIN", 84614327);
            ownerContact.AddSetting("ICQ", "FirstName", "yole@work");

            MockMirandaContact otherContact = db.AddContact();

            otherContact.AddSetting("ICQ", "UIN", 1000);
            otherContact.AddSetting("ICQ", "FirstName", "Test");
            otherContact.AddEvent("ICQ", 0, DateTime.Now, 0, "Hello");

            DoImportDB(db);

            IResourceList conversations = _storage.GetAllResources(ResourceTypes.MirandaConversation);

            Assert.AreEqual(1, conversations.Count);
            IResource conv = conversations [0];

            Assert.AreEqual(contact.Resource, conv.GetLinkProp("To"));
        }
예제 #25
0
        private IResource NewUnreadResource(string type, IResource folder)
        {
            IResource res = _storage.NewResource(type);

            res.SetProp(_propUnread, true);
            res.AddLink(_propFolder, folder);
            return(res);
        }
예제 #26
0
        private IResource CreateResource(string resType, string propName, string propValue, IResource parent)
        {
            IResource res = _storage.NewResource(resType);

            res.SetProp(propName, propValue);
            res.AddLink("Parent", parent);
            return(res);
        }
예제 #27
0
        private void NewWeblink()
        {
            bool newWeblink = false;

            if (_favorite == null)
            {
                _favorite  = Core.ResourceStore.BeginNewResource("Weblink");
                newWeblink = true;
            }
            else
            {
                _favorite.BeginUpdate();
            }
            try
            {
                string url = _URLBox.Text;
                _favorite.SetProp(Core.Props.Name, _nameBox.Text);
                _favorite.SetProp(FavoritesPlugin._propURL, url);
                int updateFreq = 0;
                if (_updateCheckBox.Checked)
                {
                    updateFreq = (int)_hoursBox.Value * 60 * 60;
                    int unitIndex = _unitBox.SelectedIndex;
                    if (unitIndex > 0)  // days or weeks
                    {
                        updateFreq *= 24;
                        if (unitIndex > 1)  // weeks
                        {
                            updateFreq *= 7;
                        }
                    }
                }
                _favorite.SetProp(FavoritesPlugin._propUpdateFreq, updateFreq);
                if (_parent != null)
                {
                    _favorite.AddLink(FavoritesPlugin._propParent, _parent);
                }
                Core.WorkspaceManager.AddToActiveWorkspace(_favorite);
            }
            finally
            {
                _favorite.EndUpdate();
            }
            if (newWeblink)
            {
                IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(_favorite);
                string           error   = null;
                if (profile != null && profile.CanCreate(_favorite, out error))
                {
                    profile.Create(_favorite);
                }
                else
                {
                    Core.UserInterfaceAP.QueueJob(new LineDelegate(DisplayError), error);
                }
                BookmarkService.ImmediateQueueWeblink(_favorite, _URLBox.Text);
            }
        }
예제 #28
0
 private static void ParseNewsgroups(IResource article, IResource groupRes, ServerResource serverRes, string newsgroups)
 {
     string[] groups = newsgroups.Split(',');
     foreach (string group in groups)
     {
         bool groupFound = false;
         foreach (IResource res in serverRes.Groups)
         {
             if (groupRes != res &&
                 String.Compare(group, res.GetPropText(Core.Props.Name), true) == 0 &&
                 new NewsgroupResource(res).IsSubscribed)
             {
                 article.AddLink(NntpPlugin._propTo, res);
                 groupFound = true;
                 break;
             }
         }
         if (!groupFound)
         {
             IResource     fakeGroup  = null;
             IResourceList fakeGroups = Core.ResourceStore.FindResources(
                 NntpPlugin._newsGroup, Core.Props.Name, group);
             if (fakeGroups.Count == 0)
             {
                 fakeGroup = Core.ResourceStore.NewResource(NntpPlugin._newsGroup);
                 fakeGroup.SetProp(Core.Props.Name, group);
             }
             else
             {
                 foreach (IResource res in fakeGroups)
                 {
                     if (fakeGroup == null || res.HasProp(Core.Props.Parent))
                     {
                         fakeGroup = res;
                         if (res.HasProp(Core.Props.Parent))
                         {
                             break;
                         }
                     }
                 }
             }
             article.AddLink(NntpPlugin._propTo, fakeGroup);
         }
     }
 }
예제 #29
0
        private static void SetLinks(IResource target, IResource task, int link)
        {
            IResourceList linked = task.GetLinksOfType(null, link);

            foreach (IResource res in linked)
            {
                target.AddLink(link, res);
            }
        }
예제 #30
0
        /**
         * Creates the resource for the current address book and links it to the
         * address book root.
         */

        private void CreateAddressBook()
        {
            _abResource = Core.ResourceStore.BeginNewResource("AddressBook");
            _abResource.SetProp("Name", _name);
            _abResource.SetProp("DeepName", _name);
            _abResource.SetProp("ContentType", _ownerType);
            _abResource.AddLink("Parent", _addressBookRoot);
            _abResource.EndUpdate();
        }