public static IEnumerable<Item> GetItems(string query)
        {
            Items.Clear ();
            if (string.IsNullOrEmpty (prefs.URLs)) {
                RequestTrackerItem defitem = new RequestTrackerItem (
                         "No Trackers Configured",
                         "Please use the GNOME Do Preferences to add some RT sites",
                         "FAIL{0}");
                Items.Add (defitem);
            } else {
                string[] urlbits = prefs.URLs.Split('|');
                for (int i = 0; i < urlbits.Length; i++) {
                    string name = urlbits[i];
                    string uri = urlbits[++i];
                    Uri url;
                    try {
                        url = new System.Uri(uri);
                    } catch (System.UriFormatException) {
                        continue;
                    }

                    string description = string.Format (url.ToString (), query);

                    Items.Add (new RequestTrackerItem (name, description, url.ToString ()));
                }
            }
            return Items.OfType<Item> ();
        }
Beispiel #2
0
        public static IEnumerable <Item> GetItems(string query)
        {
            Items.Clear();
            if (string.IsNullOrEmpty(prefs.URLs))
            {
                RequestTrackerItem defitem = new RequestTrackerItem(
                    "No Trackers Configured",
                    "Please use the GNOME Do Preferences to add some RT sites",
                    "FAIL{0}");
                Items.Add(defitem);
            }
            else
            {
                string[] urlbits = prefs.URLs.Split('|');
                for (int i = 0; i < urlbits.Length; i++)
                {
                    string name = urlbits[i];
                    string uri  = urlbits[++i];
                    Uri    url;
                    try {
                        url = new System.Uri(uri);
                    } catch (System.UriFormatException) {
                        continue;
                    }

                    string description = string.Format(url.ToString(), query);

                    Items.Add(new RequestTrackerItem(name, description, url.ToString()));
                }
            }
            return(Items.OfType <Item> ());
        }
Beispiel #3
0
        private string GetUrl(RequestTrackerItem tracker, ITextItem ticket)
        {
            if (tracker.URL.Substring(0, 4) == "FAIL")
            {
                Do.Platform.Services.Notifications.Notify("Request Tracker", "No trackers are configured. Please use the GNOME Do preferences ");
                throw new UriFormatException();
            }
            string newtext = Regex.Replace(ticket.Text, @"[^0-9]", "");

            if (string.IsNullOrEmpty(newtext))
            {
                Do.Platform.Services.Notifications.Notify("Request Tracker", "No ticket number provided");
                throw new ArgumentNullException();
            }

            string query = HttpUtility.UrlEncode(newtext);

            return(FormatUrl(tracker.URL, query));
        }