public static bool IsOwnerEmail(string email) { if (!ContactNames.IsValidString(email)) { return(false); } if (_ownerEmails == null) { IResource myself = Core.ContactManager.MySelf.Resource; _ownerEmails = myself.GetLinksOfTypeLive("EmailAccount", "EmailAcct"); _ownerEmails.ResourceAdded += new ResourceIndexEventHandler(_ownerEmails_ResourceAdded); _ownerEmails.ResourceDeleting += new ResourceIndexEventHandler(_ownerEmails_ResourceDeleting); foreach (IResource emailAcct in _ownerEmails) { AddEmailAcct(emailAcct); } } lock ( _ownerEmailsSet ) { return(_ownerEmailsSet.Contains(email)); } }
public virtual void Update(IActionContext context, ref ActionPresentation presentation) { IResourceList resources = GetResourcesFromContext(context); if (resources == null || resources.Count < 1) { Trace.WriteLine("Resources Counted: NULL or 0"); if (context.Kind == ActionContextKind.Toolbar || context.Kind == ActionContextKind.MainMenu) { presentation.Enabled = false; } else { presentation.Visible = false; } } else { bool checked_ = GetCheckedState(resources); presentation.Checked = checked_; } }
[Test] public void UnlinkResourceFromContactNames2() { IContact main = _contactManager.FindOrCreateContact("account1", "Michael Gerasimov"); IResourceList accounts = main.Resource.GetLinksOfType(null, "EmailAcct"); //--- IResource email1 = _storage.NewResource("email"); email1.SetProp("Subject", "Subject1"); Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkFrom, main.Resource, email1, accounts[0], "A"); IResource email2 = _storage.NewResource("email"); email2.SetProp("Subject", "Subject1"); Core.ContactManager.LinkContactToResource(_contactManager.Props.LinkFrom, main.Resource, email2, accounts[0], "A"); //----------------------------------------------------------------- _contactManager.UnlinkContactInformation(email1); //----------------------------------------------------------------- Assert.AreEqual(1, email1.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkNameFrom).Count); Assert.AreEqual(1, main.Resource.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact).Count); }
private void OpenAction() { IResource selected = null; IResourceList selList = _tasksTree.GetSelectedResources(); if (selList.Count == 1) { selected = selList[0]; } if (selected != null) { if (selected.Type != "Task") { Core.UIManager.DisplayResourceInContext(selected); } else { OpenTaskAction.OpenTask(selected); } } }
protected override void ExecuteAction(IResourceList selectedResources) { try { SaveAllAttachments.SaveAttachments(selectedResources, _path); string[] files = Directory.GetFiles(_path); if (files == null) { return; } for (int i = 0; i < files.Length; ++i) { files[i] = Path.Combine(_path, files[i]); } OutlookFacadeHelper.CreateNewMessage("", "", EmailBodyFormat.PlainText, (IResourceList)null, files, true); } catch (OutlookAttachmentException exception) { Tracer._TraceException(exception); } }
private static void RegisterRestFlagActions() { IResourceList flags = Core.ResourceStore.GetAllResources("Flag").Minus(ResourceFlag.DefaultFlag.Resource.ToResourceList()); flags.Sort(new SortSettings(Core.Props.Name, true)); // Register setters first and then cleaning flag. IResource completeFlag = null; foreach (IResource res in flags) { if (!res.HasProp(-ResourceFlag.PropNextStateFlag)) { RegisterFlagAction(res, "ItemFlagActions"); } else { completeFlag = res; } } RegisterFlagAction(completeFlag, "ItemFlagCompleteActions"); }
[Test] public void TestFilterListEx() { IResource person = _storage.NewResource("Person"); IResource category = CategoryManager.CreateCategory("Test", _categoryManager.RootCategory); IResource email = _storage.NewResource("Email"); IResource email2 = _storage.NewResource("Email"); person.AddLink(_propAuthor, email); _categoryManager.AddResourceCategory(email2, category); IResource workspace = _workspaceManager.CreateWorkspace("Test "); _workspaceManager.AddResourceToWorkspace(workspace, person); _workspaceManager.AddResourceToWorkspace(workspace, category); IResourceList resList = _workspaceManager.GetFilterList(workspace); Assert.AreEqual(4, resList.Count); Assert.IsTrue(resList.IndexOf(email) >= 0); Assert.IsTrue(resList.IndexOf(email2) >= 0); Assert.IsTrue(resList.IndexOf(person) >= 0); Assert.IsTrue(resList.IndexOf(category) >= 0); }
private void ModifyIcon() { for (int index = WatchersOrder.Count - 1; index >= 0; index--) { string ruleName = (string)WatchersOrder[index]; if (isActiveWatcher(ruleName)) { IResourceList list = (IResourceList)WatchedLists[ruleName]; if (list.Count > 0) { FireIconOfWatcher(ruleName); SetTooltipText(); return; } } } // If no watcher currently is active or all watchers do not // satisfy their conditions. NotIcon.Icon = DefaultIcon; NotIcon.Text = DefaultTooltip; }
public override bool AcceptResource(IResource res) { bool accept = base.AcceptResource(res); bool typeConformant = false; if (res.Type == FilterManagerProps.ViewResName) { typeConformant = (_checkType == res.GetStringProp("ContentType")); } else if (res.Type == FilterManagerProps.ViewFolderResName) { typeConformant = true; IResourceList viewsUnder = res.GetLinksTo(FilterManagerProps.ViewResName, Core.Props.Parent); foreach (IResource v in viewsUnder) { typeConformant = typeConformant && (_checkType == v.GetStringProp("ContentType")); } } return(accept && typeConformant); }
internal static IResource FindOrCreateBookmark(IResource parent, string name, string url, bool transient) { url = url.Trim(); if (url.IndexOf("://") < 0) { url = "http://" + url; } IResourceStore store = Core.ResourceStore; IResourceList candidates = SubNodesWithName("Weblink", parent, name).Intersect( store.FindResources(null, FavoritesPlugin._propURL, url), true); if (candidates.Count > 0) { return(candidates[0]); } if (!store.IsOwnerThread()) { return((IResource)Core.ResourceAP.RunUniqueJob( new FindOrCreateBookmarkDelegate(FindOrCreateBookmark), parent, name, url, transient)); } IResource result = (transient) ? store.NewResourceTransient("Weblink") : store.BeginNewResource("Weblink"); try { result.SetProp(_propName, name); result.SetProp(FavoritesPlugin._propURL, url); result.AddLink(FavoritesPlugin._propParent, parent); } finally { if (!transient) { result.EndUpdate(); } } return(result); }
private static void DeleteRulesUnderTheRoot(IResource root, IntHashSet hashDone) { if (!hashDone.Contains(root.Id)) { hashDone.Add(root.Id); IResourceList children = root.GetLinksTo(null, Core.Props.Reply); foreach (IResource res in children) { string ruleName = ConstructRuleName(res); if (Core.FormattingRuleManager.IsRuleRegistered(ruleName)) { Core.FormattingRuleManager.UnregisterRule(ruleName); } } foreach (IResource res in children) { DeleteRulesUnderTheRoot(res, hashDone); } } }
private void ConstructLinkText(IResourceList folders) { string text = string.Empty; foreach (IResource folder in folders) { text += folder.DisplayName + ", "; } if (text.Length > 0) { text = text.Substring(0, text.Length - 2); } resourceTypesLink.Tag = text; AssignResTypesText(text); if (folders.Count > 0) { CurrentResTypeDeep = ExpirationRuleManager.ItemFromContainerType(folders[0].Type); } }
public IResourceList GetChildResources(IResource parent) { if (parent == Core.ResourceTreeManager.ResourceTreeRoot) { IResource ws = Core.WorkspaceManager.ActiveWorkspace; if (ws != null) { IResourceList children = parent.GetLinksToLive(null, Core.Props.Parent); IResourceList otherView = ws.GetLinksOfType("WorkspaceOtherView", "InWorkspace"); Debug.Assert(otherView.Count == 1); children = children.Union(otherView); string nodeSort = Core.ResourceTreeManager.GetResourceNodeSort(parent); if (nodeSort != null) { children.Sort(nodeSort); } return(children); } } return(null); }
public void Drop(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) // Dragging resources over { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); if (targetResource != null && dragResources != null && dragResources.Count > 0) { if (ListOfMailsOrLinkedAttachments(dragResources)) { IResourceList mailsOnly = ResourceTypeHelper.ExtractListForType(dragResources, STR.Email); _moveAction.DoMove(targetResource, mailsOnly); } else if (dragResources.AllResourcesOfType(STR.MAPIFolder)) { _moveFolderAction.DoMove(targetResource, dragResources); } } } }
private static void CollectExportableFolders(IntArrayList listFeedIds) { _exportedFolders.Clear(); // All feeds? if (listFeedIds == null) { IResourceList allFeeds = Core.ResourceStore.GetAllResources(Props.RSSFeedResource); listFeedIds = new IntArrayList(allFeeds.ResourceIds); } foreach (int id in listFeedIds) { IResource feed = Core.ResourceStore.LoadResource(id); IResource parent = feed.GetLinkProp(Core.Props.Parent); while (parent != null) { _exportedFolders[parent.Id] = 1; parent = parent.GetLinkProp(Core.Props.Parent); } } }
[Test] public void TestEmptyOutlineImport2() { StringReader reader = new StringReader("<opml version=\"1.0\"><body><outline text=\"Some Text\"></outline><outline type=\"rss\" text=\".Avery Blog\" title=\".Avery Blog\" xmlUrl=\"http://dotavery.com/blog/Rss.aspx\"/></body></opml>"); OPMLProcessor.Import(reader, _rootGroup, false); IResourceList feedLinks = _rootGroup.GetLinksTo("RSSFeed", "Parent"); IResourceList groupLinks = _rootGroup.GetLinksTo("RSSFeedGroup", "Parent"); Assert.AreEqual(1, feedLinks.Count); Assert.AreEqual(1, groupLinks.Count); IResource feed = feedLinks [0]; Assert.AreEqual(".Avery Blog", feed.GetStringProp("Name")); IResource group = groupLinks [0]; Assert.AreEqual("Some Text", group.GetStringProp("Name")); Assert.AreEqual(0, group.GetLinksTo("RSSFeedGroup", "Parent").Count); }
private void buttonOneToLeaved_Click(object sender, System.EventArgs e) { Debug.Assert(listSplittedContacts.SelectedIndex != -1); if (buttonOneToLeaved.Enabled) { ListBox.SelectedObjectCollection coll = listSplittedContacts.SelectedItems; foreach (IResource res in coll) { listLeavedContacts.Items.Add(res); } IResource[] list = new IResource[coll.Count]; coll.CopyTo(list, 0); foreach (IResource res in list) { listSplittedContacts.Items.Remove(res); AccumulatedContactsToSplit = AccumulatedContactsToSplit.Minus(res.ToResourceList()); } VerifyButtonsAccessibility(); } }
private static ArrayList CollectUniqueContactNames(IResource res, bool showAllNames) { ArrayList uniqueNames = new ArrayList(); IResourceList names = res.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact); int maxNames = names.Count; if (!showAllNames) { maxNames = Math.Min(maxNames, _MaxContactNameList); } for (int i = 0; i < maxNames; i++) { string name = names[i].GetStringProp(Core.Props.Name); if (uniqueNames.IndexOf(name) == -1) { uniqueNames.Add(name); } } return(uniqueNames); }
[Test] public void LoadWorkspaceData() { IResource folder = _storage.NewResource("Folder"); IResource workspace = _workspaceManager.CreateWorkspace("Test"); _workspaceManager.AddResourceToWorkspace(workspace, folder); IResource person = _storage.NewResource("Person"); person.AddLink(_propAuthor, folder); _storage.Close(); _storage = new TestResourceStore(true); _workspaceManager = new WorkspaceManager(_storage, new ResourceTreeManager(_storage), _core.PluginLoader); IResourceList workspaces = _workspaceManager.GetResourceWorkspaces(person); Assert.AreEqual(1, workspaces.Count); Assert.AreEqual("Test", workspaces [0].DisplayName); }
public PostCommentForm(IResource item) { // // Required for Windows Form Designer support // InitializeComponent(); _url = item.GetStringProp(Props.WfwComment); SetToField(item); _txtSubject.Text = "Re: " + item.DisplayName; Text = _txtSubject.Text; IResourceList emailList = Core.ContactManager.MySelf.Resource.GetLinksOfType("EmailAccount", "EmailAcct"); foreach (IResource address in emailList) { _cmbFrom.Items.Add(address); } string name = Settings.SendFrom; if (string.IsNullOrEmpty(name)) { name = Core.ContactManager.MySelf.Resource.DisplayName; } _txtName.Text = name; string sendEmail = Settings.SendEmail; if (string.IsNullOrEmpty(sendEmail)) { sendEmail = Core.ContactManager.MySelf.DefaultEmailAddress; } _cmbFrom.Text = sendEmail; string sendHomePage = Settings.SendHomePage; if (sendHomePage == null) { sendHomePage = Core.ContactManager.MySelf.HomePage; } _txtLink.Text = sendHomePage; RestoreSettings(); }
private static bool AllHaveEnabledDeleters(IResourceList selectedResources) { if (selectedResources.Count == 0) { return(false); } foreach (IResource res in selectedResources.ValidResources) { IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type); if (deleter == null) { return(false); } if (!deleter.CanDeleteResource(res, res.HasProp(Core.Props.IsDeleted))) { return(false); } } return(true); }
public void Attach(IResourceList resList) { if (_resList != null) { Detach(); } Clear(); _resList = resList; if (_resList != null) { _resList.ResourceAdded += new ResourceIndexEventHandler(OnResourceAdded); _resList.ResourceDeleting += new ResourceIndexEventHandler(OnResourceDeleting); _resList.ResourceChanged += new ResourcePropIndexEventHandler(OnResourceChanged); int cnt = _resList.Count; // force instantiation if (_processingLevel > 0) { Monitor.Enter(_resList); } } }
private void ReloadFormattingRules(IResource exceptRule) { lock ( _formattingRules ) { _formattingRules.Clear(); foreach (IResource res in _formattingRuleList) { if (res == exceptRule) { continue; } FormattingRule fmtRule = new FormattingRule(); fmtRule.ItemFormat = GetRuleFormat(res); fmtRule.ResourceType = res.GetStringProp(Core.Props.ContentType); fmtRule.Resource = res; IResourceList conditions = res.GetLinksOfType(FilterManagerProps.ConditionResName, "LinkedCondition"); fmtRule.Conditions = new IResource[conditions.Count]; for (int i = 0; i < conditions.Count; i++) { fmtRule.Conditions[i] = conditions[i]; } conditions = res.GetLinksOfType(FilterManagerProps.ConditionResName, "LinkedNegativeCondition"); fmtRule.NegConditions = new IResource[conditions.Count]; for (int i = 0; i < conditions.Count; i++) { fmtRule.NegConditions[i] = conditions[i]; } _formattingRules.Add(fmtRule); } } if (FormattingRulesChanged != null) { FormattingRulesChanged(this, EventArgs.Empty); } }
private static void ConstructName(IResourceList folders, ref string name, ref string fullName) { fullName = name = "Exp.Rule for "; if (folders.Count < 4) { foreach (IResource res in folders) { name = name + res.DisplayName + ", "; } fullName = name = name.Substring(0, name.Length - 2); } else { name = name + folders[0].DisplayName + ", " + folders[1].DisplayName + " and " + (folders.Count - 2) + " more folders"; foreach (IResource res in folders) { fullName = fullName + res.DisplayName + ", "; } fullName = fullName.Substring(0, fullName.Length - 2); } }
public OutlookOptionsPane_InfoStores() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); _allStores = Core.ResourceStore.GetAllResources(STR.MAPIInfoStore); IResourceList supportedStores = Core.ResourceStore.FindResourcesWithProp(STR.MAPIInfoStore, PROP.StoreSupported); IResourceList unsupportedStores = Core.ResourceStore.GetAllResources(STR.MAPIInfoStore).Minus(supportedStores); if (unsupportedStores.Count > 0) { label1.Text += " Please note that Omea does not support IMAP message stores."; } _checkBoxColumn = _lvInfoStores.AddCheckBoxColumn(); _lvInfoStores.AllowColumnReorder = false; _lvInfoStores.DataProvider = new DProvider(_allStores); _lvInfoStores.Columns.Add(new ResourceIconColumn()); ResourceListView2Column nameCol = _lvInfoStores.AddColumn(Core.Props.Name); nameCol.AutoSize = true; _checkBoxColumn.AfterCheck += HandleAfterCheck; }
/** * Checks if deleting the specified resource will break minimum link count * restrictions on linked resources. */ private bool IsSafeToDeleteResource(IResource res) { foreach (int linkType in res.GetLinkTypeIds()) { IResourceList links = res.GetLinksOfType(null, linkType); for (int i = 0; i < links.Count; i++) { IResource target = MyPalStorage.Storage.TryLoadResource(links.ResourceIds [i]); if (target == null) { continue; } int minCount = MyPalStorage.Storage.GetMinLinkCountRestriction(target.Type, linkType); if (minCount > 0 && target.GetLinkCount(linkType) == minCount) { return(false); } } } return(true); }
//--------------------------------------------------------------------- // Unify flags which define different type of rules. //--------------------------------------------------------------------- private void FixFlagsAndNamingForRules() { IResourceList list = Core.ResourceStore.GetAllResources(FilterManagerProps.RuleResName); foreach (IResource rule in list) { if (!rule.HasProp("IsExpirationFilter")) { rule.SetProp("IsActionFilter", true); } } foreach (IResource rule in list) { if (rule.HasProp("IsExpirationFilter")) { rule.DeleteProp("IsActionFilter"); } } list = Core.ResourceStore.GetAllResources(FilterManagerProps.ViewResName); for (int i = 0; i < list.Count; i++) { IResource rule = list[i]; string deepName = rule.GetStringProp("DeepName"); if ((rule.HasProp("IsFormattingFilter") || rule.HasProp("IsTrayIconFilter")) && rule.GetStringProp("Name").EndsWith("###")) { int existCount = Core.ResourceStore.FindResources(FilterManagerProps.ViewResName, "Name", deepName).Count; if (existCount == 0) { rule.SetProp("Name", deepName); } else { rule.Delete(); } } } }
/** * Saves the category links from the specified tree node collection. */ private void SaveCategoriesFromNodes(IResourceList resList) { IResourceList checkedCats = Core.ResourceStore.EmptyResourceList; GetCheckedCategories(ref checkedCats); foreach (IResource res in resList) { IResourceList currCats = Core.CategoryManager.GetResourceCategories(res); IResourceList minusCats = currCats.Minus(checkedCats); foreach (IResource cat in checkedCats) { Core.CategoryManager.AddResourceCategory(res, cat); } foreach (IResource cat in minusCats) { Core.CategoryManager.RemoveResourceCategory(res, cat); } } }
protected override bool NeedProcess(IResourceList selectedResources) { SelectOutlookFolder dlg = SelectOutlookFolder.GetInstance(IsCopy); using ( dlg ) { if (_lastFolder != null) { dlg.SelectFolder(_lastFolder); } if (dlg.ShowDialog(Core.MainWindow) == DialogResult.OK) { IResource selectedFolder = dlg.SelectedFolderResource; if (selectedFolder != null) { _lastFolder = selectedFolder; return(true); } } } return(false); }
public void ProcessQuery(string query) { //----------------------------------------------------------------- // Avoid perform any UI (and other, generally) work if we are // shutting down - some components (like DefaultViewPane) may // already be disposed. //----------------------------------------------------------------- if (Core.State != CoreState.Running) { return; } IResourceList _resourceListBeforeQuickFind = Core.ResourceBrowser.VisibleResources; const string _captionBeforeQuickFind = "_caption"; IHighlightDataProvider highlightDataProvider; TextIndexManager man = (TextIndexManager)Core.TextIndexManager; IResourceList searchResults = man.ProcessQuery(query, out highlightDataProvider); searchResults = searchResults.Intersect(_resourceListBeforeQuickFind, true); string quickFindCaption = query; if (!quickFindCaption.StartsWith("\"") || !quickFindCaption.EndsWith("\"")) { quickFindCaption = "'" + quickFindCaption + "'"; } ResourceListDisplayOptions options = new ResourceListDisplayOptions(); options.Caption = "Search results for " + quickFindCaption + " in " + _captionBeforeQuickFind; options.HighlightDataProvider = highlightDataProvider; options.SuppressContexts = true; options.ShowNewspaper = Core.ResourceBrowser.NewspaperVisible; IResource ownerView = Core.ResourceBrowser.OwnerResource; Core.ResourceBrowser.DisplayResourceList(ownerView, searchResults, options); Core.ResourceBrowser.FocusResourceList(); }