Ejemplo n.º 1
0
		private void LoadConfiguration (Config config)
		{
			if (config == null)
				config = Conf.Get (Conf.Names.NetworkingConfig);

			if (String.IsNullOrEmpty (name))
				// Whats a good default value ?
				name = config.GetOption (Conf.Names.ServiceName, String.Empty);

			// Check to see if our enabled status hasn't changed
                        if (enabled != config.GetOption (Conf.Names.ServiceEnabled, enabled)) {
                                enabled = config.GetOption (Conf.Names.ServiceEnabled, enabled);
                                
                                if (enabled) {
					try {
						Publish ();
					} catch (ClientException) {
						Log.Error ("Could not start avahi");
						return;
					}
				} else
					Unpublish ();
                                
                                Logger.Log.Info ("Zeroconf: Index sharing is {0}", enabled ? "enabled" : "disabled");
                        }

                        // Handle index name changes
                        if (String.Compare (name, config.GetOption (Conf.Names.ServiceName, name)) != 0)
				Update ();
                }
Ejemplo n.º 2
0
		private void ReadConf (Config config)
		{
			if (config == null || config.Name != "GoogleBackends")
				return;

			username = config.GetOption ("GMailUsername", null);
			search_folder = config.GetOption ("GMailSearchFolder", null);

			string password_source = config.GetOption ("GMailPasswordSource", "conf-data");
			password_source = password_source.ToLower ();
			switch (password_source) {
			case "conf-file":
				password = config.GetOption ("GMailPassword", null);
				break;

			case "gnome-keyring":
				Log.Error ("GMailPasswordSource: gnome-keyring is not supported yet");
				break;

			case "kdewallet":
				try {
					password = KdeUtils.ReadPasswordKDEWallet ("beagle", username);
				} catch (Exception e) {
					Log.Error (e, "Error in reading password in KDE wallet");
				}
				break;

			default:
				Log.Error ("GMailPasswordSource should be one of 'kdewallet,gnome-keyring,conf-file");
				break;

			}

			valid_account = (
				! String.IsNullOrEmpty (username) &&
				! String.IsNullOrEmpty (password) &&
				! String.IsNullOrEmpty (search_folder));

			if (! valid_account)
				Log.Warn ("GMail account information not set. Search is disabled.");
			else
				Log.Debug ("GMail account information successfully read.");

			domain = config.GetOption ("GoogleAppDomainName", null);
			if (String.IsNullOrEmpty (domain))
				domain = GMAIL_DOMAIN;
			else
				// Google Apps domain is of form
				// a/mydomain.name
				domain = ("a/" + domain);
		}
Ejemplo n.º 3
0
		private void SetKeyBindings (Config config)
		{
			string tip_text = Catalog.GetString ("Desktop Search");
			string binding = config.GetOption ("KeyBinding", null);
			Console.WriteLine ("new binding {0}", binding);

			if (String.IsNullOrEmpty (binding)) {
				// Move old preference value to new
				bool binding_ctrl = config.GetOption (Conf.Names.KeyBinding_Ctrl, false);
				bool binding_alt = config.GetOption (Conf.Names.KeyBinding_Alt, false);
				string binding_key = config.GetOption (Conf.Names.KeyBinding_Key, "F12");
				KeyBinding show_binding = new KeyBinding (binding_key, binding_ctrl, binding_alt);

				binding = show_binding.ToString ();
			}

			if (!String.IsNullOrEmpty (binding)) {
				tip_text += String.Format (" ({0})", binding);
				keybinder.UnbindAll ();
				keybinder.Bind (binding, OnTrayActivated);
			}

			tray.TooltipText = tip_text;
		}
Ejemplo n.º 4
0
	private static void ShowOption (Config config, Option option)
	{
		if (option.Type == OptionType.Bool) {
			Console.WriteLine ("  - {0}={2} ({1})",
					    option.Name,
					    option.Description,
					    config.GetOption (option.Name, true));

		} else if (option.Type == OptionType.String) {
			Console.WriteLine ("  - {0}={2} ({1})",
					    option.Name,
					    option.Description,
					    config.GetOption (option.Name, String.Empty));

		} else if (option.Type == OptionType.List) {
			Console.WriteLine ("  - {0} : ({1})", option.Name, option.Description);

			Console.Write ("    Parameters:");
			string[] param_names = config.GetListOptionParams (option.Name);

			for (int j = 0; j < param_names.Length; ++j)
				Console.Write (" [{0}] ", param_names [j]);
			Console.WriteLine ();

			List<string[]> items = config.GetListOptionValues (option.Name);
			if (items == null)
				return;

			Console.WriteLine ("    Values:");
			foreach (string[] item in items) {
				DisplayListItem (param_names, item);
			}
		}
	}
Ejemplo n.º 5
0
		private void ConfigUpdateHandler (Config config)
		{
			if (config == null || config.Name != Conf.Names.NetworkingConfig)
				return;

			bool to_webinterface = config.GetOption ("WebInterface", false);
			Log.Debug ("WebInterface option changed to {0}", to_webinterface);
			if (to_webinterface)
				StartWebserver ();
			else
				StopWebserver ();
		}
Ejemplo n.º 6
0
		private void OnConfigurationChanged (Config config)
		{
			if (config == null || config.Name != Conf.Names.FilesQueryableConfig)
				return;

			List<string[]> values = config.GetListOptionValues (Conf.Names.Roots);
			if (values == null)
				values = new List<string[]> (0);

			ArrayList roots_wanted = new ArrayList (values.Count);
			foreach (string[] root in values)
				roots_wanted.Add (root [0]);
			
			if (config.GetOption (Conf.Names.IndexHomeDir, true))
				roots_wanted.Add (PathFinder.HomeDir);

			IList roots_to_add, roots_to_remove;
			ArrayFu.IntersectListChanges (roots_wanted, Roots, out roots_to_add, out roots_to_remove);

			foreach (string root in roots_to_remove)
				RemoveRoot (root);

			foreach (string root in roots_to_add)
				AddRoot (root);
		}