public static object Get (string path) { lock (lock_obj) { GConfThreadHelper helper = new GConfThreadHelper (path); GLib.Idle.Add (new GLib.IdleHandler (helper.GConfReady)); while (! helper.finished && ! Shutdown.ShutdownRequested) Monitor.Wait (lock_obj, one_second); if (helper.ex != null) throw helper.ex; return helper.data; } }
public static object Get(string path) { lock (lock_obj) { GConfThreadHelper helper = new GConfThreadHelper(path); GLib.Idle.Add(new GLib.IdleHandler(helper.GConfReady)); while (!helper.finished && !Shutdown.ShutdownRequested) { Monitor.Wait(lock_obj, one_second); } if (helper.ex != null) { throw helper.ex; } return(helper.data); } }
protected override bool Setup() { string dir_name = summary_info.DirectoryName; int imap_start_idx; int idx = dir_name.IndexOf(".evolution/mail/imap4/"); if (idx >= 0) { this.backend_type = ImapBackendType.Imap4; imap_start_idx = idx + 22; } else { this.backend_type = ImapBackendType.Imap; imap_start_idx = dir_name.IndexOf(".evolution/mail/imap/") + 21; } string imap_start = dir_name.Substring(imap_start_idx); this.imap_name = imap_start.Substring(0, imap_start.IndexOf('/')); ICollection accounts = null; try { accounts = (ICollection)GConfThreadHelper.Get("/apps/evolution/mail/accounts"); } catch (Exception ex) { Logger.Log.Warn("Caught exception in Setup(): " + ex.Message); Logger.Log.Warn("There are no configured evolution accounts, ignoring {0}", this.imap_name); return(false); } // This should only happen if we shut down while waiting for the GConf results to come back. if (accounts == null) { return(false); } foreach (string xml in accounts) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode account = xmlDoc.SelectSingleNode("//account"); if (account == null) { continue; } string uid = null; foreach (XmlAttribute attr in account.Attributes) { if (attr.Name == "uid") { uid = attr.InnerText; break; } } if (uid == null) { continue; } XmlNode imap_url_node = xmlDoc.SelectSingleNode("//source/url"); if (imap_url_node == null) { continue; } string imap_url = imap_url_node.InnerText; // If there is a semicolon in the username part of the URL, it // indicates that there's an auth scheme there. We don't care // about that, so remove it. int user_end = imap_url.IndexOf('@'); int semicolon = imap_url.IndexOf(';', 0, user_end + 1); if (semicolon != -1) { imap_url = imap_url.Substring(0, semicolon) + imap_url.Substring(user_end); } // Escape backslashes, which frequently appear when using IMAP against Exchange servers this.imap_name = this.imap_name.Replace("\\", "%5c"); // Escape out additional @s in the name. I hate the class libs so much. int lastIdx = this.imap_name.LastIndexOf('@'); if (this.imap_name.IndexOf('@') != lastIdx) { string toEscape = this.imap_name.Substring(0, lastIdx); this.imap_name = toEscape.Replace("@", "%40") + this.imap_name.Substring(lastIdx); } string backend_url_prefix; if (this.backend_type == ImapBackendType.Imap) { backend_url_prefix = "imap"; } else { backend_url_prefix = "imap4"; } if (imap_url.StartsWith(backend_url_prefix + "://" + this.imap_name + "/")) { this.account_name = uid; break; } } if (this.account_name == null) { Logger.Log.Info("Unable to determine account name for {0}", this.imap_name); return(false); } // Need to check the directory on disk to see if it's a junk/spam folder, // since the folder name will be "foo/spam" and not match the check below. DirectoryInfo dir_info = new DirectoryInfo(dir_name); if (this.IsSpamFolder(dir_info.Name)) { return(false); } // Check if the folder is listed in the configuration as to be excluded from indexing if (this.IgnoreFolder(dir_info.FullName)) { return(false); } this.folder_name = GetFolderName(new DirectoryInfo(dir_name)); return(true); }