Ejemplo n.º 1
0
        public void  Exec(IResource res, IActionParameterStore actionStore)
        {
            ResourceProxy proxy = new ResourceProxy(res);

            proxy.BeginUpdate();
            proxy.SetProp("NoFormat", true);
            proxy.EndUpdate();
        }
Ejemplo n.º 2
0
        public void  Exec(IResource res, IActionParameterStore actionStore)
        {
            ResourceProxy proxy = new ResourceProxy(res);

            proxy.BeginUpdate();
            proxy.SetProp("Importance", 1);
            proxy.EndUpdate();
        }
Ejemplo n.º 3
0
        private void OnDownloadClick()
        {
            _feedAddressPane.SetExistingFeedLink(null);
            if (File.Exists(_feedAddressPane.FeedUrl))
            {
                _feedAddressPane.FeedUrl = "file://" + _feedAddressPane.FeedUrl;
            }
            else
            if (_feedAddressPane.FeedUrl.IndexOf("://") < 0)
            {
                _feedAddressPane.FeedUrl = "http://" + _feedAddressPane.FeedUrl;
            }
            else
            {
                string url = _feedAddressPane.FeedUrl.ToLower();
                if (!HttpReader.IsSupportedProtocol(url))
                {
                    _feedAddressPane.ErrorMessage = "Unknown URL schema. Only http:, https: and file: are supported.";
                    return;
                }
            }

            try
            {
                new Uri(_feedAddressPane.FeedUrl);
            }
            catch (Exception ex)
            {
                _feedAddressPane.ErrorMessage = ex.Message;
                return;
            }

            IResource existingFeed = RSSPlugin.GetExistingFeed(_feedAddressPane.FeedUrl);

            if (existingFeed != null)
            {
                _feedAddressPane.ErrorMessage = "You are already subscribed to that feed.";
                _feedAddressPane.SetExistingFeedLink(existingFeed);
                return;
            }

            _progressLabel.Text = "Downloading...";
            _nextButton.Enabled = false;
            _feedAddressPane.ControlsEnabled = false;

            if (_newFeedProxy != null)
            {
                _newFeedProxy.DeleteAsync();
                _newFeedProxy = null;
            }

            _newFeedProxy = CreateFeedProxy(_feedAddressPane.FeedUrl, null);

            _rssUnitOfWork = new RSSUnitOfWork(_newFeedProxy.Resource, false, true);
            _rssUnitOfWork.DownloadProgress += OnDownloadProgress;
            _rssUnitOfWork.ParseDone        += OnParseDone;
            Core.NetworkAP.QueueJob(JobPriority.Immediate, _rssUnitOfWork);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the messages that's mapped to the specified type.
 /// </summary>
 /// <param name="type">The type to get the message for.</param>
 /// <returns>string</returns>
 public string GetMessage(Type type)
 {
     if (MessageAccessor != null)
     {
         T obj = (T)Activator.CreateInstance(type);
         return(MessageAccessor(obj));
     }
     return(ResourceProxy.GetString(ResourceKey));
 }
Ejemplo n.º 5
0
        public static void RemoveFromSync(IResource contact, string newEntryID)
        {
            ResourceProxy proxy = new ResourceProxy(contact);

            proxy.BeginUpdate();
            proxy.SetProp(PROP.EntryID, newEntryID);
            proxy.SetProp("UserCreated", true);
            proxy.EndUpdateAsync();
        }
Ejemplo n.º 6
0
        public void GetResources_Test()
        {
            ResourceProxy p = busRole.GetResources(ADORole1.ID);

            Assert.IsTrue(p.ChildList.Where(x => x.ID == ADORedource1.ID).Count() > 0);
            Assert.IsTrue(p.ChildList.Where(x => x.ID == ADORedource2.ID).Count() > 0);
            Assert.IsTrue(p.ChildList.Where(x => x.ID == ADORedource1.ID).First().IsAllowed);
            Assert.IsFalse(p.ChildList.Where(x => x.ID == ADORedource2.ID).First().IsAllowed);
        }
Ejemplo n.º 7
0
        public static void Do(DateTime at, IResource feedItem)
        {
            string enclosureUrl = feedItem.GetPropText(Props.EnclosureURL).Trim();

            if (enclosureUrl.Length == 0)
            {
                return;
            }
            IResource feed      = feedItem.GetLinkProp(-Props.RSSItem);
            string    directory = FindDownloadDirectory(feedItem, feed);

            try
            {
                Directory.CreateDirectory(directory);
                string     destFullPath  = null;
                FileStream file          = null;
                int        startPosition = 0;
                if (feedItem.GetIntProp(Props.EnclosureDownloadingState) == DownloadState.InProgress)
                {
                    string enclosureTempFile = feedItem.GetPropText(Props.EnclosureTempFile);
                    if (File.Exists(enclosureTempFile))
                    {
                        try
                        {
                            file          = File.OpenWrite(enclosureTempFile);
                            destFullPath  = enclosureTempFile;
                            startPosition = (int)file.Length;
                            file.Seek(startPosition, SeekOrigin.Begin);
                        }
                        catch (Exception exception)
                        {
                            Tracer._TraceException(exception);
                        }
                    }
                }
                if (destFullPath == null && file == null)
                {
                    destFullPath = FindFreeFileName(enclosureUrl, directory, true);
                    file         = File.Create(destFullPath);
                }

                new ResourceProxy(feedItem).SetProp(Props.EnclosureTempFile, destFullPath);
                Core.NetworkAP.QueueJobAt(at, new DownloadEnclosure(feedItem, file, directory, startPosition));
                _queued = true;
            }
            catch (Exception exception)
            {
                _queued = false;
                ResourceProxy proxy = new ResourceProxy(feedItem);
                proxy.BeginUpdate();
                proxy.SetProp(Props.EnclosureDownloadingState, DownloadState.Failed);
                proxy.SetProp(Props.EnclosureFailureReason, exception.Message);
                proxy.EndUpdate();
                ShowDesktopAlert(DownloadState.Failed, "Downloading Failed", feedItem.DisplayName, exception.Message);
                EnclosureDownloadManager.DownloadNextEnclosure();
            }
        }
Ejemplo n.º 8
0
        public void Initialize()
        {
            _words = new List <string>(
                ResourceProxy.GetDictionary().Split(
                    new string[] { "\n" },
                    StringSplitOptions.RemoveEmptyEntries));

            _random = new Random((int)DateTime.Now.Ticks);
        }
Ejemplo n.º 9
0
        public void   Exec(IResource res, IActionParameterStore actionStore)
        {
            IResourceList flags = actionStore.ParametersAsResList();
            ResourceProxy proxy = new ResourceProxy(res);

            proxy.BeginUpdate();
            proxy.SetProp("Flag", flags[0]);
            proxy.EndUpdate();
        }
Ejemplo n.º 10
0
        public void RemoteSetMozillaBookmarkId(int idres, string rdfid)
        {
            IResource res = Core.ResourceStore.TryLoadResource(idres);

            if (res != null)
            {
                ResourceProxy proxy = new ResourceProxy(res);
                proxy.SetPropAsync(_propBookmarkId, rdfid);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds a shortcut to the specified resource to the shortcut bar.
        /// </summary>
        public void AddShortcutToResource(IResource newShortcut)
        {
            ITabManager tabManager      = Core.TabManager;
            IResource   activeWorkspace = Core.WorkspaceManager.ActiveWorkspace;

            IResourceList shortcutTargets = newShortcut.GetLinksOfType("Shortcut", ShortcutProps.Target);

            if (newShortcut.Type == "SearchView")
            {
                foreach (IResource res in shortcutTargets)
                {
                    if (res.GetStringProp(ShortcutProps.TabID) == tabManager.CurrentTabId &&
                        res.GetLinkProp(ShortcutProps.Workspace) == activeWorkspace)
                    {
                        return;
                    }
                }
            }
            else
            {
                if (shortcutTargets.Count > 0)
                {
                    return;
                }
            }

            ResourceProxy proxy = ResourceProxy.BeginNewResource("Shortcut");

            proxy.SetProp(ShortcutProps.Order, _maxOrder + 1);
            proxy.AddLink(ShortcutProps.Target, newShortcut);

            if (activeWorkspace != null)
            {
                proxy.AddLink(ShortcutProps.Workspace, activeWorkspace);
            }

            if (newShortcut.Type == "SearchView")
            {
                proxy.SetProp(ShortcutProps.TabID, tabManager.CurrentTabId);
                string wsName = "";
                if (activeWorkspace != null)
                {
                    wsName = " in " + activeWorkspace.GetStringProp(Core.Props.Name);
                }

                proxy.SetProp(Core.Props.Name, tabManager.CurrentTab.Name + wsName + ": " +
                              newShortcut.DisplayName);
            }
            else if (newShortcut.DisplayName.Length > 20)
            {
                proxy.SetProp(Core.Props.Name, newShortcut.DisplayName.Substring(0, 20) + "...");
            }
            proxy.EndUpdate();
            RebuildShortcutBar();
        }
Ejemplo n.º 12
0
        private void _btnNewGroup_Click(object sender, System.EventArgs e)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource("RSSFeedGroup");

            proxy.SetProp(Core.Props.Name, "<new folder>");
            proxy.SetProp(Core.Props.Parent, SelectedGroup);
            proxy.EndUpdate();
            _lastNewGroup = proxy.Resource;

            _feedGroupTree.EditResourceLabel(_lastNewGroup);
        }
Ejemplo n.º 13
0
        public override void Execute(IActionContext context)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource("Note");

            proxy.SetProp(Core.Props.Subject, "New note");
            proxy.EndUpdate();

            NoteEditor editor = new NoteEditor();

            Core.UIManager.OpenResourceEditWindow(editor, proxy.Resource, true);
        }
Ejemplo n.º 14
0
        private TResourceObject CreateNewResource(TJira itemJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(_restype);

            proxy.SetProp(Props.JiraId, itemJira.id);
            proxy.AddLink(Core.Props.Parent, _server.Resource);

            proxy.EndUpdate();

            return(CreateResourceObject(proxy.Resource));
        }
Ejemplo n.º 15
0
        public IResource ReregisterRule(IResource baseRes, string name, string[] types,
                                        IResource[] conditions, IResource[] exceptions,
                                        bool isBold, bool isItalic, bool isUnderlined, bool isStrikeout,
                                        string foreColor, string backColor)
        {
            ResourceProxy proxy = new ResourceProxy(baseRes);

            proxy.BeginUpdate();
            FilterRegistry.InitializeView(proxy, name, types, conditions, exceptions);
            AddSpecificParams(baseRes, name, isBold, isItalic, isUnderlined, isStrikeout, foreColor, backColor);
            return(baseRes);
        }
Ejemplo n.º 16
0
        private void OnRenamed(object source, RenamedEventArgs e)
        {
            string oldPath = e.OldFullPath;
            string newPath = e.FullPath;

            Trace.WriteLineIf(TraceWatchers(), "OnRenamed( " + oldPath + " -> " + newPath + " )", "FilePlugin");

            if (Directory.Exists(newPath))
            {
                DirectoryInfo di = IOTools.GetDirectoryInfo(newPath);
                if (di != null)
                {
                    newPath = IOTools.GetFullName(di);
                }
                IResource folder = FindDirectory(oldPath);
                RenameDirectory(folder, e.Name, newPath);
            }
            else
            {
                FileInfo fi = IOTools.GetFileInfo(newPath);
                if (fi != null)
                {
                    newPath = IOTools.GetFullName(fi);
                }
                IResource file = FindFile(oldPath);
                if (file == null)
                {
                    FileInfo fileInfo = IOTools.GetFileInfo(newPath);
                    FindOrCreateFile(fileInfo, false);
                }
                else
                {
                    string        directory = Path.GetDirectoryName(newPath);
                    string        filename  = IOTools.GetFileName(newPath);
                    IResource     folder    = FindDirectory(directory);
                    ResourceProxy proxy     = new ResourceProxy(file);
                    proxy.BeginUpdate();
                    try
                    {
                        proxy.SetProp(FileProxy._propDirectory, directory);
                        proxy.SetProp(Core.Props.Name, filename);
                        if (folder != null)
                        {
                            proxy.SetProp(FileProxy._propParentFolder, folder);
                        }
                    }
                    finally
                    {
                        proxy.EndUpdate();
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void  LinkWithWorkspaces()
        {
            ResourceProxy proxy = new ResourceProxy(BaseResource);

            proxy.BeginUpdate();
            proxy.DeleteLinks("InWorkspace");
            foreach (IResource wsp in linkedWsps)
            {
                proxy.SetProp("InWorkspace", wsp);
            }
            proxy.EndUpdate();
        }
Ejemplo n.º 18
0
        protected override void SetArticleNumbersRange(ref int firstArticle, ref int lastArticle)
        {
            int headersCount2Get   = GetHeadersCount();
            int currentLastArticle = _group.LastArticle;

            // first time last article is not set
            if (currentLastArticle == 0)
            {
                currentLastArticle = lastArticle - headersCount2Get;
                if (currentLastArticle < firstArticle - 1)
                {
                    currentLastArticle = firstArticle - 1;
                }
            }
            else
            {
                if (firstArticle > currentLastArticle)
                {
                    currentLastArticle = firstArticle - 1;
                }
                else if (_group.FirstArticle > lastArticle)
                {
                    ResourceProxy proxy = new ResourceProxy(_group.Resource);
                    proxy.BeginUpdate();
                    try
                    {
                        proxy.DeleteProp(NntpPlugin._propFirstArticle);
                        proxy.DeleteProp(NntpPlugin._propLastArticle);
                    }
                    finally
                    {
                        proxy.EndUpdateAsync();
                    }
                }
            }
            if (headersCount2Get < lastArticle - currentLastArticle)
            {
                lastArticle  = currentLastArticle + headersCount2Get;
                firstArticle = currentLastArticle + 1;
            }
            else
            {
                headersCount2Get = lastArticle - currentLastArticle;
                if (headersCount2Get <= 0)
                {
                    lastArticle = 0;
                }
                else
                {
                    firstArticle = currentLastArticle + 1;
                }
            }
        }
Ejemplo n.º 19
0
        public IResource RegisterRule(string name, string[] types, IResource[] conditions, IResource[] exceptions,
                                      bool isBold, bool isItalic, bool isUnderlined, bool isStrikeout,
                                      string foreColor, string backColor)
        {
            IResource     rule  = FindRule(name);
            ResourceProxy proxy = GetRuleProxy(rule);

            FilterRegistry.InitializeView(proxy, name, types, conditions, exceptions);
            AddSpecificParams(proxy.Resource, name, isBold, isItalic, isUnderlined, isStrikeout, foreColor, backColor);
            CheckRuleInvisiblity(proxy.Resource, conditions);
            return(proxy.Resource);
        }
Ejemplo n.º 20
0
 protected static void SetChangeSetDescription(ResourceProxy proxy, string desc)
 {
     proxy.SetProp(Core.Props.LongBody, desc);
     desc = desc.Replace("\r\n", " ");
     if (desc.Length < 50)
     {
         proxy.SetProp(Core.Props.Subject, desc);
     }
     else
     {
         proxy.SetProp(Core.Props.Subject, desc.Substring(0, 50) + "...");
     }
 }
Ejemplo n.º 21
0
 protected override void WriteImpl(object value)
 {
     if (value != null && value.Equals(string.Empty) && _deletePropIfStringEmpty)
     {
         ResourceProxy proxy = new ResourceProxy(Resource);
         proxy.AsyncPriority = JobPriority.Immediate;
         proxy.DeleteProp(PropId);
     }
     else
     {
         base.WriteImpl(value);
     }
 }
Ejemplo n.º 22
0
        public static void SetCheckNeeded(string protocol, bool check)
        {
            IResource resProtocol = Core.ResourceStore.FindUniqueResource(PROTOCOL_HANDLER, _propProtocol, protocol);

            if (resProtocol != null)
            {
                ResourceProxy proxy = new ResourceProxy(resProtocol);
                proxy.BeginUpdate();
                proxy.AsyncPriority = JobPriority.Immediate;
                proxy.SetProp(_propCheck, check);
                proxy.EndUpdate();
            }
        }
Ejemplo n.º 23
0
        public static void MergeABs(IResource dest, IResource src)
        {
            ResourceProxy prxDest  = new ResourceProxy(dest);
            IResourceList contacts = src.GetLinksOfType("Contact", _propInAddressBook);

            foreach (IResource contact in contacts)
            {
                prxDest.AddLink(_propInAddressBook, contact);
            }
            ResourceProxy prxSrc = new ResourceProxy(src);

            prxSrc.Delete();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// While syncing to JIRA, creates a new Omea resource for the locally-missing project.
        /// </summary>
        /// <returns></returns>
        protected JiraProject CreateProject(RemoteProject projectJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraProject);

            proxy.AsyncPriority = JobPriority.Normal;

            proxy.SetProp(Props.JiraId, projectJira.id);
            proxy.AddLink(Core.Props.Parent, Resource);

            proxy.EndUpdate();

            return(GetProject(proxy.Resource));
        }
Ejemplo n.º 25
0
        public static void RemoveFromSync(IResource contact, bool removeEntryID)
        {
            ResourceProxy proxy = new ResourceProxy(contact);

            proxy.AsyncPriority = JobPriority.Immediate;
            proxy.BeginUpdate();
            if (removeEntryID)
            {
                proxy.DeleteProp(PROP.EntryID);
            }
            proxy.SetProp("UserCreated", true);
            proxy.EndUpdateAsync();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the messages that's mapped to the specified object.
        /// </summary>
        /// <param name="obj">The object to get the message for.</param>
        /// <exception cref="FormatException">Thrown if the number of data items do not match the number of string formaters.</exception>
        /// <returns>string</returns>
        public string GetMessage(object obj)
        {
            string message = MessageAccessor != null?MessageAccessor((T)obj) : ResourceProxy.GetString(ResourceKey);

            // If there are data items (WithValue), then
            // format the resource string with the given values.
            if (DataItems.Count > 0)
            {
                message = string.Format(message, DataItems.Select(accessor => accessor((T)obj)).ToArray <object>());
            }

            return(message);
        }
Ejemplo n.º 27
0
        private JiraComponent CreateComponent(RemoteComponent componentJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraComponent);

            proxy.AsyncPriority = JobPriority.Normal;

            proxy.SetProp(Props.JiraId, componentJira.id);
            proxy.AddLink(Core.Props.Parent, Resource);

            proxy.EndUpdate();

            return(GetComponent(proxy.Resource));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates a new JIRA server resource.
        /// </summary>
        public static JiraServer CreateNew()
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Type);

            proxy.AddLink(Core.Props.Parent, RootResource);
            proxy.EndUpdate();

            JiraServer retval = new JiraServer(proxy.Resource);

            retval.Name = Jiffa.GetRandomName();

            return(retval);
        }
Ejemplo n.º 29
0
 protected override void Execute()
 {
     if (_status == RSSWorkStatus.NotStarted)
     {
         ResourceProxy proxy = new ResourceProxy(_feed);
         // the immediate priority is required to make sure that the resource job to set
         // (updating) status is executed before the parse job, which also has
         // immediate priority
         proxy.AsyncPriority = JobPriority.Immediate;
         proxy.SetPropAsync(Props.UpdateStatus, "(updating)");
         _status = RSSWorkStatus.InProgress;
     }
     RSSLoadDelegate();
 }
Ejemplo n.º 30
0
        private void EnumerateMailsImpl()
        {
            _tracer.Trace("prepare EnumerateMailsImpl");

            try
            {
                if (SyncVersion < 10)
                {
                    UpdateAttachments();
                }
                if (SyncVersion < 9 && Settings.CreateAnnotationFromFollowup)
                {
                    UpdateAnnotation();
                }

                DateTime dtRestriction = Settings.IndexStartDate;
                if (!IsInitialStart())
                {
                    _tracer.Trace("Light enumeration is started");
                    if (Settings.SyncMode == MailSyncMode.None)
                    {
                        PrepareBackgroundWork();
                    }
                    else if (Settings.SyncMode == MailSyncMode.All)
                    {
                        new MailSyncDescriptor(true, dtRestriction, false).NextMethod();
                    }
                    else
                    {
                        new FreshMailEnumerator().NextMethod();
                        PrepareBackgroundWork();
                    }
                }
                else
                {
                    ResourceProxy.BeginNewResource(STR.InitialEmailEnum).EndUpdateAsync();
                    _tracer.Trace("Heavy enumeration is started");
                    new MailSyncDescriptor(true, dtRestriction, false).NextMethod();
                    if (dtRestriction == DateTime.MinValue)
                    {
                        SetSyncComplete();
                    }
                }
            }
            finally
            {
                _tracer.Trace("fire FinishInitialIndexingJob");
                Core.ResourceAP.QueueJob(new MethodInvoker(OutlookPlugin.FinishInitialIndexingJob));
            }
        }