示例#1
0
        private void UpdateProxy()
        {
            RequestSettings settings = RequestSettings.getInstance();

            GConf.Client client = new GConf.Client();
            try {
                bool use = (bool)client.Get("/system/http_proxy/use_http_proxy");
                if (!use)
                {
                    return;
                }
                string host = (string)client.Get("/system/http_proxy/host");
                if (host == null)
                {
                    return;
                }
                int port = (int)client.Get("/system/http_proxy/port");
                if (port <= 0)
                {
                    return;
                }
                Console.WriteLine("Proxy " + host + ":" + port);
                settings.Proxy = new WebProxy(host, port);
            }
            catch (Exception e) {}
        }
示例#2
0
		public string Get(string key, string def)
		{
			try
			{
				return (string)c.Get(path + key);
			}
			catch(GConf.NoSuchKeyException)
			{
				c.Set(path + key, def);
				return def;
			}
		}
示例#3
0
 void UpdateFromGConf()
 {
     try {
         // General
         webDirectoryEntry.Text = (string)client.Get(GCONF_APP_PATH + "/web_directory");
         // Apache
         apachectlEntry.Text = (string)client.Get(GCONF_APP_PATH + "/apachectl_path");
     } catch (GConf.NoSuchKeyException e) {
         Console.WriteLine("Error: A key with that name doesn't exist.");
     } catch (System.InvalidCastException e) {
         Console.WriteLine("Error: Cannot typecast.");
     }
 }
示例#4
0
        override protected void PreInstallation(CStatusWindow sw)
        {
            //Herunterladen
            sw.Mainlabel = Catalog.GetString(CConfiguration.txtDownloadTheme);
            GetThemeFile(sw);
            sw.SetProgress("1/" + installationSteps);

            //Entpacken
            sw.Mainlabel = Catalog.GetString(CConfiguration.txtExtracting);
            System.Collections.ArrayList al = new System.Collections.ArrayList();
            al     = CUtility.UncompressFile(LocalThemeFile, Path.GetTempPath(), false, null, al);
            Folder = ((string)(al[0])).Split('/');
            //Console.WriteLine(Folder[0]);
            sw.SetProgress("2/" + installationSteps);

            //Convertieren
            sw.Mainlabel = Catalog.GetString(CConfiguration.txtConvertingIcons);
            sw.SetProgress("3/" + installationSteps);
            CIconThemeManager iconmanager = new CIconThemeManager();

            iconmanager.ThemeName    = Folder[0];
            iconmanager.StatusWindow = sw;
            iconmanager.ImportIcons(Path.GetTempPath() + Folder[0]);
            sw.SetProgress("4/" + installationSteps);
            iconmanager.SaveAllIcons(config.IconInstallPath + "/", true);

            //Sichern
            client        = new GConf.Client();
            sw.Mainlabel  = Catalog.GetString(CConfiguration.txtSavingForRestore);
            prevIconTheme = (string)client.Get(GConfIconThemeKey);
            sw.SetProgress("5/" + installationSteps);
        }
        override protected void PreInstallation(CStatusWindow sw)
        {
            string tarParams = "";

            client = new GConf.Client();

            LocalThemeFile = config.ThemesPath + Path.GetFileName(DownloadUrl);
            string InstallThemeFile = config.ApplicationInstallPath + Path.GetFileName(DownloadUrl);

            tarParams    = CUtility.GetTarParams(Path.GetExtension(DownloadUrl));
            sw.Mainlabel = Catalog.GetString(CConfiguration.txtDownloadTheme);
            //Herunterladen
            if (!File.Exists(InstallThemeFile))
            {
                GetThemeFile(sw);
            }
            sw.SetProgress("1/" + installationSteps);
            //Entpacken
            sw.Mainlabel = Catalog.GetString(CConfiguration.txtExtracting);
            Console.WriteLine("Command: tar" + tarParams + LocalThemeFile + " -C " + config.ApplicationInstallPath);
            ConOutp = CUtility.Execute("tar", tarParams + LocalThemeFile + " -C " + config.ApplicationInstallPath);
            sw.SetProgress("2/" + installationSteps);
            //Sichern
            sw.Mainlabel             = Catalog.GetString(CConfiguration.txtSavingForRestore);
            previousApplicationTheme = (string)client.Get(GConfApplicationKey);
            sw.SetProgress("3/" + installationSteps);
        }
示例#6
0
文件: Config.cs 项目: licnep/smuxi
        protected object Get(string key, object defaultvalue)
        {
            Trace.Call(key, defaultvalue);

#if CONFIG_GCONF
            try {
                return(_GConf.Get(_GConfPrefix + key));
            } catch (GConf.NoSuchKeyException) {
                if (defaultvalue != null)
                {
                    _Set(key, defaultvalue);
                }
                return(defaultvalue);
            }
#elif CONFIG_NINI
            string     inisection = _IniGetSection(key);
            string     inikey     = _IniGetKey(key);
            IniSection section    = m_IniDocument.Sections[inisection];
            if ((section == null) ||
                (!section.Contains(inikey)))
            {
                if (defaultvalue != null)
                {
                    _Set(key, defaultvalue);
                }
                return(defaultvalue);
            }
            else
            {
                // the section and key exist
                return(_Parse(section.GetValue(inikey)));
            }
#endif
        }
示例#7
0
        // --------------------------------------------------------------- //

        private string GetStringPref(string key, string def)
        {
            try {
                return((string)config.Get(key));
            } catch {
                return(def);
            }
        }
示例#8
0
 T Get <T> (string key, T fallback)
 {
     try {
         return((T)client.Get(ns + key));
     } catch {
         return(fallback);
     }
 }
示例#9
0
 ///<summary>
 /// _Get returns a string from whichever of the XML files
 ///</summary>
 private object _Get(string key, string defaultvalue)
 {
     try {
         return(Convert.ChangeType((_Conf.Get("/apps/medianet/" + key)), defaultvalue.GetType()));
     } catch (NoSuchKeyException) {
         _Set(key, defaultvalue);
         return(defaultvalue);
     }
 }
示例#10
0
        static void OnOpenPhpmyadminClick(object o, EventArgs a)
        {
            GConf.Client client = new GConf.Client();
            string       args   = (string)client.Get(LampManager.SettingsPanel.GCONF_APP_PATH + "/phpmyadmin_url");

            if (args == "")
            {
                args = "http://localhost/phpmyadmin/";
            }
            string command = (string)client.Get(LampManager.SettingsPanel.GCONF_APP_PATH + "/browser");

            if (command == "")
            {
                command = args;
                args    = "";
            }

            PHPCommands.executeCommand(command, args);
        }
示例#11
0
 private T Get <T> (string @namespace, string key)
 {
     try {
         return((T)gconf_client.Get(@namespace == null
             ? key
             : @namespace + "/" + key));
     } catch {
         return(default(T));
     }
 }
示例#12
0
 public string Get(string path)
 {
     Init();
     try {
         return(gconf.Get(path));
     } catch (GConf.NoSuchKeyException) {
         throw new NoSuchKeyException();
     }
     return(null);
 }
示例#13
0
 private string GetConfValue(string key, string fallback)
 {
     try
     {
         return(_gconf.Get(_sGCONF_KEY + "/" + key) as String);
     }
     catch (GConf.NoSuchKeyException)
     {
         return(fallback);
     }
 }
示例#14
0
        static void OnOpenDirClick(object o, EventArgs a)
        {
            GConf.Client client  = new GConf.Client();
            string       command = "nautilus";
            string       args    = (string)client.Get(LampManager.SettingsPanel.GCONF_APP_PATH + "/web_directory");

            if (args == "")
            {
                args = "/var/www/";
            }
            PHPCommands.executeCommand(command, args);
        }
示例#15
0
        static void SetupAccountUrlToUidMap()
        {
            source_url_to_uid.Clear();

            ICollection accounts = (ICollection)gc.Get("/apps/evolution/mail/accounts");

            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 source_url = xmlDoc.SelectSingleNode("//source/url");
                if (source_url == null || source_url.InnerText == null)
                {
                    continue;
                }

                try {
                    Uri uri = new Uri(source_url.InnerText);
                    source_url_to_uid [uri] = uid;
                } catch (System.UriFormatException) {
                    Logger.Error(
                        "Evolution: Unable to parse account source URI \"{0}\"",
                        source_url.InnerText);
                }
            }
        }
示例#16
0
 static Metacity.Theme GetTheme()
 {
     if (theme == null)
     {
         try {
             GConf.Client client = new GConf.Client();
             // client.AddNotify ("/apps/metacity/general", GConfNotify);
             string themeName = (string)client.Get("/apps/metacity/general/theme");
             theme = Metacity.Theme.Load(themeName);
         } catch {
             // Don't crash if metacity is not available
             return(null);
         }
     }
     return(theme);
 }
示例#17
0
        public bool TryGet <T> (string key, out T val)
        {
            bool success = true;

            val = default(T);
            try {
                val = (T)client.Get(AbsolutePathForKey(key));
            } catch (GConf.NoSuchKeyException) {
                // We don't need to log this, because many keys that do not
                // exist are asked for.
                success = false;
            } catch (Exception e) {
                Log.Error("Encountered error getting GConf key {0}: {1}", key, e.Message);
                Log.Debug(e.StackTrace);
                success = false;
            }
            return(success);
        }
示例#18
0
        static private void GetFontSettings()
        {
            GConf.Client client = new GConf.Client();
            string       font   = null;

            try {
                font = client.Get("/desktop/gnome/interface/font_name") as string;
            } catch (GConf.NoSuchKeyException) { }

            // Sans 10 seems to be the default GNOME fallback
            if (font == null)
            {
                font = "Sans 10";
            }

            Pango.FontDescription font_desc = Pango.FontDescription.FromString(font);

            preferred_font_family = font_desc.Family;
            preferred_font_size   = font_desc.Size / Pango.Scale.PangoScale;
        }
示例#19
0
		static private void GetFontSettings ()
		{
			GConf.Client client = new GConf.Client ();
			string font = null;

			try {
				font = client.Get ("/desktop/gnome/interface/font_name") as string;
			} catch (GConf.NoSuchKeyException) { }

			// Sans 10 seems to be the default GNOME fallback
			if (font == null)
				font = "Sans 10";

			Pango.FontDescription font_desc = Pango.FontDescription.FromString (font);

			preferred_font_family = font_desc.Family;
			preferred_font_size = font_desc.Size / Pango.Scale.PangoScale;
		}
示例#20
0
 static Metacity.Theme GetTheme()
 {
     if (theme == null) {
         try {
             GConf.Client client = new GConf.Client ();
             // client.AddNotify ("/apps/metacity/general", GConfNotify);
             string themeName = (string)client.Get ("/apps/metacity/general/theme");
             theme = Metacity.Theme.Load (themeName);
         } catch {
             // Don't crash if metacity is not available
             return null;
         }
     }
     return theme;
 }
示例#21
0
        //Load all initial program settings (width, height, refresh interval, download folder...)
        public bool LoadProgramSettings()
        {
            try {
                ProxyKind = CConfiguration.ProxyType.None;
                //WindowAttributes
                Window.X      = (int)GConfClient.Get(gangGconfPath + "xPosition");
                Window.Y      = (int)GConfClient.Get(gangGconfPath + "yPosition");
                Window.Width  = (int)GConfClient.Get(gangGconfPath + "width");
                Window.Height = (int)GConfClient.Get(gangGconfPath + "height");
                //Program paths
                themesDownloadPath = (string)GConfClient.Get(gangGconfPath + "themesDownloadPath");
                XmlRefreshInterval = (int)GConfClient.Get(gangGconfPath + "xmlRefreshInterval");
                //ProxySettings
                ProxyKind      = (CConfiguration.ProxyType)GConfClient.Get(gangGconfPath + "proxyKind");
                gangProxy.Ip   = (string)GConfClient.Get(gangGconfPath + "proxyIp");
                gangProxy.Port = (int)GConfClient.Get(gangGconfPath + "proxyPort");
                readSystemProxySettings();

                //UpdateSettings
                DontBotherForUpdates = (bool)GConfClient.Get(gangGconfPath + "dontBotherMeForUpdates");
                return(true);
            } catch {
                Console.Out.WriteLine("Old gconf settings detected...writing new settings!");
                SaveProgramSettings();
                return(false);
            }
        }
        protected override void PreInstallation(CStatusWindow sw)
        {
            //Herunterladen
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtDownloadTheme);
            GetThemeFile(sw);
            sw.SetProgress("1/"+installationSteps);

            //Entpacken
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtExtracting);
            System.Collections.ArrayList al = new System.Collections.ArrayList();
            al = CUtility.UncompressFile(LocalThemeFile,Path.GetTempPath(),false, null,al);
            Folder = ((string)(al[0])).Split('/');
            //Console.WriteLine(Folder[0]);
            sw.SetProgress("2/"+installationSteps);

            //Convertieren
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtConvertingIcons);
            sw.SetProgress("3/"+installationSteps);
            CIconThemeManager iconmanager = new CIconThemeManager();
            iconmanager.ThemeName = Folder[0];
            iconmanager.StatusWindow = sw;
            iconmanager.ImportIcons(Path.GetTempPath()+Folder[0]);
            sw.SetProgress("4/"+installationSteps);
            iconmanager.SaveAllIcons(config.IconInstallPath+"/",true);

            //Sichern
            client = new GConf.Client();
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtSavingForRestore);
            prevIconTheme=(string)client.Get(GConfIconThemeKey);
            sw.SetProgress("5/"+installationSteps);
        }
        protected override void PreInstallation(CStatusWindow sw)
        {
            string tarParams="";
            client = new GConf.Client();

            tarParams=CUtility.GetTarParams(Path.GetExtension(DownloadUrl));
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtDownloadTheme);

            if (!File.Exists(LocalThemeFile))
                GetThemeFile(sw);
            sw.SetProgress("1/"+installationSteps);
            //Entpacken
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtExtracting);
            Console.WriteLine("Command: tar"+tarParams+LocalThemeFile+" -C "+config.DecorationInstallPath);
            ConOutp = CUtility.Execute("tar",tarParams+LocalThemeFile+" -C "+config.DecorationInstallPath);
            sw.SetProgress("2/"+installationSteps);
            //Sichern
            sw.Mainlabel=Catalog.GetString(CConfiguration.txtSavingForRestore);
            previousDecorationTheme = (string)client.Get(GConfDecorationKey);
            sw.SetProgress("3/"+installationSteps);
        }
示例#24
0
 // Methods :: Public :: Get
 /// <summary>
 ///	Get the value of a key in GConf.
 /// </summary>
 /// <param name="key">
 ///	The key.
 /// </param>
 /// <returns>
 ///	The value located at <paramref name="key" /> (boxed).
 /// </returns>
 public static object Get(string key)
 {
     return(gconf_client.Get(key));
 }