Beispiel #1
0
        public static Hashtable GetFirefoxProfiles()
        {
            Hashtable   hashtable  = new Hashtable();
            string      str        = Environment.GetEnvironmentVariable("appdata") + "\\Mozilla\\Firefox\\";
            string      file       = str + "profiles.ini";
            IniReader   iniReader  = new IniReader(file);
            IEnumerator enumerator = iniReader.GetSectionNames().GetEnumerator();

            while (enumerator.MoveNext())
            {
                string text = enumerator.Current.ToString();
                if (text.StartsWith("Profile"))
                {
                    string key   = iniReader.ReadString(text, "Name");
                    string text2 = iniReader.ReadString(text, "Path");
                    text2 = text2.Replace('/', '\\');
                    int num = iniReader.ReadInteger(text, "IsRelative");
                    if (num == 1)
                    {
                        text2 = str + text2;
                    }
                    string prefsfile    = text2 + "\\prefs.js";
                    string scrapbookDir = GetScrapbookDir(text2, prefsfile);
                    hashtable.Add(key, scrapbookDir);
                }
            }
            return(hashtable);
        }
        /// <summary>
        /// Refresh list of marco
        /// </summary>
        public void refreshList()
        {
            listView.Items.Clear();
            IEnumerator e = ini.GetSectionNames().GetEnumerator();

            while (e.MoveNext())
            {
                listView.Items.Add(e.Current);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Loads all settings from the specified reader and replaces all present sections.
        /// </summary>
        /// <param name="reader">The reader to obtain the config from.</param>
        public void Load(IniReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            foreach (var section in reader.GetSectionNames())
            {
                data[section] = new List <string>(reader.ReadSection(section, false));
            }
        }
Beispiel #4
0
        private void FillSections(Dictionary <string, DBHeaderObj> adict, string apath)
        {
            IniReader   ini = new IniReader(apath);
            IEnumerator e   = ini.GetSectionNames().GetEnumerator();
            String      key;

            while (e.MoveNext())
            {
                key = e.Current.ToString() + ':' + Path.GetFileName(ini.ReadString(e.Current.ToString(), "databaseName"));
                if (DBSect(e.Current.ToString()) && !adict.ContainsKey(key))
                {
                    adict.Add(key, new DBHeaderObj(apath, e.Current.ToString(), DefaultDBSect(key)));
                }
            }
        }
        private void LoadIni()
        {
            dataB.birthdays.Clear();

            String dir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                         "//" +
                         SETTINGS_FOLDER;

            String file = dir + SETTINGS_FILE + ".ini";

            // Copy template if file doesn't exist
            if (!File.Exists(file))
            {
                Directory.CreateDirectory(dir);
                File.Copy(dataB.docklet.RelativeFolder + "//" + SETTINGS_FILE + ".bdi", file);
            }

            IniReader ini = new IniReader(file);

            ArrayList sections = ini.GetSectionNames();

            if (sections.Count == 0)
            {
                return;
            }

            foreach (String sec in sections)
            {
                try
                {
                    Birthday birthday = new Birthday();
                    birthday.name = ini.ReadString(sec, KEY_NAME);
                    birthday.date = DateTime.Parse(ini.ReadString(sec, KEY_DATE));

                    dataB.birthdays.Add(birthday);
                }
                catch (Exception) {}
            }
        }
        public void ReadIniMain()
        {
            fFileLog.WriteLog("ReadIniMain Started");
//			if (!File.Exists(sIniFileName))
            if (!File.Exists(LogATM_Server.cIniFileName))
            {
                throw new ServiceExceptions.EIniFileException("Ini file not found - " + LogATM_Server.cIniFileName, 0x01);
            }
            IniReader IniMain;

            try
            {
                IniMain = new IniReader(LogATM_Server.cIniFileName);
            }
            catch (Exception e)
            {
                throw new ServiceExceptions.EIniFileException("Error create IniReader class. \n" + e.Message + "\nSource - " + e.Source, 0x02);
            }
            ArrayList AllSections = new ArrayList();

            AllSections = IniMain.GetSectionNames();
            Boolean IsSectionPresent;

            IsSectionPresent = false;

            if (AllSections.Count > 0)
            {
                foreach (String tmpSectionName in AllSections)
                {
                    fFileLog.WriteLog("IniFileName - " + IniMain.Filename + ". SectionName - " + tmpSectionName);
                    if (tmpSectionName == "Main")
                    {
                        IsSectionPresent = true;
                        break;
                    }
                }
            }
            if (!IsSectionPresent)
            {
                throw new ServiceExceptions.EIniFileException("Section Main does not Exists in IniFile. \n" + LogATM_Server.cIniFileName, 0x03);
            }
            sIniMain.EvtLog = IniMain.ReadString("Main", "IsEvtLog");

            if (sIniMain.EvtLog.Length == 0)
            {
                throw new ServiceExceptions.EIniFileException("Missing or not defined key IsEvtLog.\n" + LogATM_Server.cIniFileName, 0x04);
            }
            if (sIniMain.EvtLog.Remove(1).Contains("Y"))
            {
                sIniMain.isEvtLog = true;
            }
            else
            {
                sIniMain.isEvtLog = false;
            }

            sIniMain.FileLog = IniMain.ReadString("Main", "IsFileLog");
            if (sIniMain.FileLog.Length == 0)
            {
                throw new ServiceExceptions.EIniFileException("Missing or not defined key IsFileLog.\n" + LogATM_Server.cIniFileName, 0x05);
            }
            if (sIniMain.FileLog.Remove(1).Contains("Y"))
            {
                sIniMain.isFileLog = true;
            }
            else
            {
                sIniMain.isFileLog = false;
            }
            sIniMain.sDaysSaveFileLog = IniMain.ReadString("Main", "DaysSaveFileLog");
            if (!Int16.TryParse(sIniMain.sDaysSaveFileLog, out sIniMain.DaysSaveFileLog))
            {
                throw new ServiceExceptions.EIniFileException("Missing or error defined key DaysSaveCopy.\n" + LogATM_Server.cIniFileName, 0x05);
            }
        }
Beispiel #7
0
        public void OnCreate(DOCKLET_STATIC_DATA data, String ini, String iniGroup)
        {
            ODConsole.Initialize();

            docklet = new Docklet(data);

            docklet.Label     = "Featured Skins Docklet";
            docklet.ImageFile = "FeaturedSkins.png";

            #region Global Settings
            // Initialize docklet data
            dockletData = new DockletData();
            dockletData.Applications = new ArrayList();
            dockletData.index        = NO_VALUE;      // No application selected

            // Read global settings from ini file
            IniReader iniReader = new IniReader(docklet.RootFolder + docklet.RelativeFolder + "docklet.ini");

            ArrayList apps = iniReader.GetSectionNames();
            foreach (String app in apps)
            {
                if (app.CompareTo("docklet") == 0)
                {
                    continue;
                }

                Application application = new Application();
                // Name
                application.name = app;
                // Address
                application.address = new Uri(iniReader.ReadString(application.name, "address", ""));
                // Type
                string type = iniReader.ReadString(application.name, "type", "");
                switch (type)
                {
                default:
                    application.type = ApplicationType.INVALID;
                    break;

                case "ini":
                    application.type = ApplicationType.INI;
                    break;

                case "csv":
                    application.type = ApplicationType.CSV;
                    break;
                }
                application.data = new ApplicationData();

                dockletData.Applications.Add(application);
            }
            #endregion

            #region Saved Settings
            if (ini != String.Empty && iniGroup != String.Empty)
            {
                // Reuse the INIReader
                iniReader.Filename = ini;

                // Read saved app index
                dockletData.index    = iniReader.ReadInteger(iniGroup, "AppIndex", NO_VALUE);
                dockletData.cacheDir = iniReader.ReadString(iniGroup, "CacheDir", String.Empty);

                if (dockletData.index > dockletData.Applications.Count)
                {
                    dockletData.index = NO_VALUE;
                }
            }
            #endregion

            #region Context Menu

            ContextMenu menu        = new ContextMenu();
            MenuItem    appsMenu    = new MenuItem("Applications");
            MenuItem    refreshMenu = new MenuItem("Refresh");
            refreshMenu.Enabled = false;

            foreach (Application app in dockletData.Applications)
            {
                appsMenu.MenuItems.Add(new MenuItem(app.name, new EventHandler(onSelectApp)));
                if (app.type == ApplicationType.INVALID)
                {
                    appsMenu.MenuItems[appsMenu.MenuItems.Count - 1].Enabled = false;
                }
            }

            if (dockletData.index != NO_VALUE)
            {
                appsMenu.MenuItems[dockletData.index].Checked = true;
                refreshMenu.Enabled = true;
            }

            menu.MenuItems.Add(appsMenu);
            menu.MenuItems.Add(refreshMenu);

            // Show the menu
            docklet.ContextMenu = menu;

            #endregion

            // Get temporary directory for this session
            if (dockletData.cacheDir == String.Empty || dockletData.cacheDir == null)
            {
                Guid guid = Guid.NewGuid();
                dockletData.cacheDir = guid.ToString();
            }

            // Load Application Data
            if (dockletData.index != NO_VALUE)
            {
                updateThread = new Thread(new ThreadStart(UpdateData));
                updateThread.Start();
            }
        }