예제 #1
0
 /// <summary>
 /// Save Dcc Settings
 /// </summary>
 /// <param name="ini"></param>
 /// <param name="dcc"></param>
 public static void SaveDCCSettings(string ini, DCC dcc)
 {
     try {
         int i = 0;
         IniFileHelper.WriteINI(ini, "Settings", "PopupDownloadManager", dcc.PopupDownloadManager.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "DownloadDirectory", dcc.DownloadDirectory);
         IniFileHelper.WriteINI(ini, "Settings", "FileExistsAction", dcc.FileExistsAction.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "IgnoreCount", dcc.Ignorelist.Count.ToString());
         for (i = 1; i <= dcc.Ignorelist.Count; i++)
         {
             IniFileHelper.WriteINI(ini, i.ToString().Trim(), "Data", dcc.Ignorelist.Item[i].Data.ToString());
             IniFileHelper.WriteINI(ini, i.ToString().Trim(), "Type", dcc.Ignorelist.Item[i].Type.ToString());
         }
         if (dcc.ChatPrompt == DccPrompt.Prompt)
         {
             IniFileHelper.WriteINI(ini, "Settings", "ChatPrompt", "1");
         }
         else if (dcc.ChatPrompt == DccPrompt.AcceptAll)
         {
             IniFileHelper.WriteINI(ini, "Settings", "ChatPrompt", "2");
         }
         else if (dcc.ChatPrompt == DccPrompt.Ignore)
         {
             IniFileHelper.WriteINI(ini, "Settings", "ChatPrompt", "3");
         }
         if (dcc.SendPrompt == DccPrompt.Prompt)
         {
             IniFileHelper.WriteINI(ini, "Settings", "SendPrompt", "1");
         }
         else if (dcc.SendPrompt == DccPrompt.AcceptAll)
         {
             IniFileHelper.WriteINI(ini, "Settings", "SendPrompt", "2");
         }
         else if (dcc.SendPrompt == DccPrompt.Ignore)
         {
             IniFileHelper.WriteINI(ini, "Settings", "SendPrompt", "3");
         }
         IniFileHelper.WriteINI(ini, "Settings", "UseIpAddress", dcc.UseIpAddress.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "CustomIpAddress", dcc.CustomIpAddress);
         IniFileHelper.WriteINI(ini, "Settings", "IgnoreCount", dcc.Ignorelist.Count.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "SendPort", dcc.SendPort.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "RandomizePort", dcc.RandomizePort.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "BufferSize", dcc.BufferSize.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "AutoIgnore", dcc.AutoIgnore.ToString());
         IniFileHelper.WriteINI(ini, "Settings", "AutoCloseDialogs", dcc.AutoCloseDialogs.ToString());
     } catch (Exception ex) {
         throw ex;
     }
 }
예제 #2
0
        /// <summary>
        /// Load Dcc Settings
        /// </summary>
        /// <param name="ini"></param>
        /// <param name="startupPath"></param>
        /// <returns></returns>
        public static DCC Read(string startupPath)
        {
            var ini = startupPath + @"\data\config\dcc.ini";
            var dcc = new DCC();
            var i   = 0;
            var n   = 0;

            dcc.FileExistsAction = (DccFileExistsAction)Convert.ToInt32(IniFileHelper.ReadINI(ini, "Settings", "FileExistsAction", "1"));
            n = Convert.ToInt32(IniFileHelper.ReadINI(ini, "Settings", "ChatPrompt", "1"));
            if (n == 1)
            {
                dcc.ChatPrompt = DccPrompt.Prompt;
            }
            else if (n == 2)
            {
                dcc.ChatPrompt = DccPrompt.AcceptAll;
            }
            else if (n == 3)
            {
                dcc.ChatPrompt = DccPrompt.Ignore;
            }
            n = Convert.ToInt32(IniFileHelper.ReadINI(ini, "Settings", "SendPrompt", "1"));
            if (n == 1)
            {
                dcc.SendPrompt = DccPrompt.Prompt;
            }
            else if (n == 2)
            {
                dcc.SendPrompt = DccPrompt.AcceptAll;
            }
            else if (n == 3)
            {
                dcc.SendPrompt = DccPrompt.Ignore;
            }
            dcc.PopupDownloadManager = Convert.ToBoolean(IniFileHelper.ReadINI(ini, "Settings", "PopupDownloadManager", "False"));
            dcc.DownloadDirectory    = IniFileHelper.ReadINI(ini, "Settings", "DownloadDirectory", "");
            if (string.IsNullOrEmpty(dcc.DownloadDirectory) == true)
            {
                dcc.DownloadDirectory = startupPath + "\\";
            }
            dcc.DownloadDirectory = dcc.DownloadDirectory.Replace("\\\\", "");
            dcc.BufferSize        = Convert.ToInt64(IniFileHelper.ReadINI(ini, "Settings", "BufferSize", "1024"));
            dcc.UseIpAddress      = Convert.ToBoolean(IniFileHelper.ReadINI(ini, "Settings", "UseIpAddress", "False"));
            dcc.CustomIpAddress   = IniFileHelper.ReadINI(ini, "Settings", "CustomIpAddress", "");
            if (dcc.CustomIpAddress.Length == 0)
            {
                dcc.CustomIpAddress = DccSettings.IpAddress();
            }
            dcc.Ignorelist.Count = Convert.ToInt32(IniFileHelper.ReadINI(ini, "Settings", "IgnoreCount", "0"));
            dcc.SendPort         = IniFileHelper.ReadINI(ini, "Settings", "SendPort", "1024");
            dcc.RandomizePort    = Convert.ToBoolean(IniFileHelper.ReadINI(ini, "Settings", "RandomizePort", "True"));
            dcc.Ignorelist.Count = Convert.ToInt32(IniFileHelper.ReadINI(ini, "Settings", "IgnoreCount", dcc.Ignorelist.Count.ToString()));
            dcc.AutoIgnore       = Convert.ToBoolean(IniFileHelper.ReadINI(ini, "Settings", "AutoIgnore", "True"));
            dcc.AutoCloseDialogs = Convert.ToBoolean(IniFileHelper.ReadINI(ini, "Settings", "AutoCloseDialogs", "False"));
            for (i = 1; i <= dcc.Ignorelist.Count; i++)
            {
                //var _with2 = dcc.dIgnorelist.dItem[i];
                dcc.Ignorelist.Item[i].Data = IniFileHelper.ReadINI(ini, i.ToString(), "Data", "");
                dcc.Type = (DCCIgnoreType)Convert.ToInt32(IniFileHelper.ReadINI(ini, i.ToString(), "Type", "0"));
                switch (dcc.Type)
                {
                case DCCIgnoreType.Nicknames:
                    dcc.Type = DCCIgnoreType.Nicknames;
                    break;

                case DCCIgnoreType.Hostnames:
                    dcc.Type = DCCIgnoreType.Hostnames;
                    break;

                case DCCIgnoreType.FileTypes:
                    dcc.Type = DCCIgnoreType.FileTypes;
                    break;
                }
            }
            return(dcc);
        }