private void OnDomainChanged(object o, EventArgs args) { QueryDomain domain = (QueryDomain)Enum.Parse(typeof(QueryDomain), ((Gtk.Action)o).Name); if (DomainChanged != null) { DomainChanged(domain, ((ToggleAction)o).Active); } }
// Instantiates and loads a StaticQueryable from an index directory internal static Queryable LoadStaticQueryable(DirectoryInfo index_dir, QueryDomain query_domain) { StaticQueryable static_queryable = null; if (!index_dir.Exists) { return(null); } try { static_queryable = new StaticQueryable(index_dir.Name, index_dir.FullName, true); } catch (InvalidOperationException) { Logger.Log.Warn("Unable to create read-only index (likely due to index version mismatch): {0}", index_dir.FullName); return(null); } catch (Exception e) { Logger.Log.Error(e, "Caught exception while instantiating static queryable: {0}", index_dir.Name); return(null); } if (static_queryable == null) { return(null); } // Load StaticIndex.xml from index_dir.FullName/config string config_file_path = Path.Combine(index_dir.FullName, "StaticIndex.xml"); Config static_index_config; try { static_index_config = Conf.LoadFrom(config_file_path); if (static_index_config == null) { Log.Error("Unable to read config from {0}", config_file_path); return(null); } } catch (Exception e) { Log.Error(e, "Caught exception while reading config from {0}", config_file_path); return(null); } string source = static_index_config.GetOption("Source", null); if (source == null) { Log.Error("Invalid config file: {0}", config_file_path); return(null); } QueryableFlavor flavor = new QueryableFlavor(); flavor.Name = source; flavor.Domain = query_domain; Queryable queryable = new Queryable(flavor, static_queryable); return(queryable); }
private void OnDomainChanged(QueryDomain domain, bool active) { if (active) { this.domain |= domain; } else { this.domain &= ~domain; } // FIXME: Most likely refire the query. }
// Instantiates and loads a StaticQueryable from an index directory internal static Queryable LoadStaticQueryable (DirectoryInfo index_dir, QueryDomain query_domain) { StaticQueryable static_queryable = null; if (!index_dir.Exists) return null; try { static_queryable = new StaticQueryable (index_dir.Name, index_dir.FullName, true); } catch (InvalidOperationException) { Logger.Log.Warn ("Unable to create read-only index (likely due to index version mismatch): {0}", index_dir.FullName); return null; } catch (Exception e) { Logger.Log.Error (e, "Caught exception while instantiating static queryable: {0}", index_dir.Name); return null; } if (static_queryable == null) return null; // Load StaticIndex.xml from index_dir.FullName/config string config_file_path = Path.Combine (index_dir.FullName, "StaticIndex.xml"); Config static_index_config; try { static_index_config = Conf.LoadFrom (config_file_path); if (static_index_config == null) { Log.Error ("Unable to read config from {0}", config_file_path); return null; } } catch (Exception e) { Log.Error (e, "Caught exception while reading config from {0}", config_file_path); return null; } string source = static_index_config.GetOption ("Source", null); if (source == null) { Log.Error ("Invalid config file: {0}", config_file_path); return null; } QueryableFlavor flavor = new QueryableFlavor (); flavor.Name = source; flavor.Domain = query_domain; Queryable queryable = new Queryable (flavor, static_queryable); return queryable; }
public bool AllowsDomain(QueryDomain domain) { return((domain_flags & domain) != 0); }
public void RemoveDomain(QueryDomain domain) { domain_flags &= ~domain; }
/////////////////////////////////////////////////////////////// public void AddDomain(QueryDomain domain) { domain_flags |= domain; }
public bool AllowsDomain (QueryDomain domain) { return (domain_flags & domain) != 0; }
public void RemoveDomain (QueryDomain domain) { domain_flags &= ~domain; }
/////////////////////////////////////////////////////////////// public void AddDomain (QueryDomain domain) { domain_flags |= domain; }
public static void Main(string[] args) { // Initialize GObject type system g_type_init(); main_loop = new MainLoop(); if (args.Length == 0 || Array.IndexOf(args, "--help") > -1 || Array.IndexOf(args, "--usage") > -1) { PrintUsageAndExit(); } if (Array.IndexOf(args, "--version") > -1) { VersionFu.PrintVersion(); Environment.Exit(0); } StringBuilder query_str = new StringBuilder(); query = new Query(); QueryDomain domain = 0; // Parse args int i = 0; while (i < args.Length) { switch (args [i]) { case "--live-query": keep_running = true; break; case "--verbose": verbose = true; break; case "--cache": display_cached_text = true; break; case "--stats-only": verbose = true; display_hits = false; break; case "--max-hits": if (++i >= args.Length) { PrintUsageAndExit(); } query.MaxHits = Int32.Parse(args[i]); break; case "--flood": flood = true; break; case "--listener": listener = true; keep_running = true; break; case "--raw-uri": raw_uri = true; break; case "--keywords": PropertyKeywordFu.ReadKeywordMappings(); Console.WriteLine("Supported query keywords are:"); foreach (string key in PropertyKeywordFu.Keys) { foreach (QueryKeywordMapping mapping in PropertyKeywordFu.Properties(key)) { // Dont print properties without description; they confuse people if (string.IsNullOrEmpty(mapping.Description)) { continue; } Console.WriteLine(" {0,-20} for {1}", key, mapping.Description); } } System.Environment.Exit(0); break; case "--domain": if (++i >= args.Length) { PrintUsageAndExit(); } switch (args [i].ToLower()) { case "local": domain |= QueryDomain.Local; break; case "system": domain |= QueryDomain.System; break; case "network": domain |= QueryDomain.Neighborhood; break; case "global": domain |= QueryDomain.Global; break; case "all": domain |= QueryDomain.All; break; default: PrintUsageAndExit(); break; } break; default: if (args [i].StartsWith("--")) { PrintUsageAndExit(); } if (query_str.Length > 0) { query_str.Append(' '); } query_str.Append(args [i]); break; } ++i; } if (domain != 0) { query.QueryDomain = domain; } if (listener) { query.IsIndexListener = true; } else { if (query_str.Length > 0) { query.AddText(query_str.ToString()); } } query.HitsAddedEvent += OnHitsAdded; query.HitsSubtractedEvent += OnHitsSubtracted; if (!keep_running) { query.FinishedEvent += OnFinished; } else { query.ClosedEvent += OnClosed; } SendQuery(); main_loop.Run(); }
private void OnDomainChanged (QueryDomain domain, bool active) { if (active) this.domain |= domain; else this.domain &= ~domain; // FIXME: Most likely refire the query. }