コード例 #1
0
ファイル: NetworkSettings.cs プロジェクト: guideX/nexirc3
 /// <summary>
 /// Get
 /// </summary>
 /// <returns></returns>
 public List <NetworkData> Get()
 {
     try {
         if (!_useCache)
         {
             var n      = Convert.ToInt32(IniFileHelper.ReadINI(_iniFile, "Settings", "Count", "0"));
             var result = new List <NetworkData>();
             for (var i = 1; i <= n; i++)
             {
                 var d = new NetworkData();
                 d.Description = IniFileHelper.ReadINI(_iniFile, i.ToString(), "Description", "");
                 d.Id          = i;
                 if (!string.IsNullOrEmpty(d.Description))
                 {
                     result.Add(d);
                 }
             }
             _cache    = result;
             _useCache = true;
             return(result);
         }
         else
         {
             return(_cache);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #2
0
ファイル: NetworkSettings.cs プロジェクト: guideX/nexirc3
 /// <summary>
 /// Get Default
 /// </summary>
 /// <returns></returns>
 public NetworkData GetDefault()
 {
     try {
         var network = new NetworkData();
         var msg     = IniFileHelper.ReadINI(_iniFile, "Settings", "Index", "0");
         int n       = 0;
         if (int.TryParse(msg, out n))
         {
             if (n != 0)
             {
                 network.Description = IniFileHelper.ReadINI(_iniFile, n.ToString(), "Description", "");
                 network.Id          = n;
                 return(network);
             }
             else
             {
                 return(new NetworkData());
             }
         }
         else
         {
             return(new NetworkData());
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #3
0
        /// <summary>
        /// Get Channel Folders
        /// </summary>
        /// <returns></returns>
        public List <ChannelFolderModel> Get(string network = "")
        {
            var channelFolders = new List <ChannelFolderModel>();

            try {
                if (!_useCache)
                {
                    var n = Convert.ToInt32(IniFileHelper.ReadINI(_iniFile, "Settings", "Count", "0"));
                    for (var i = 1; i <= n; i++)
                    {
                        var c = new ChannelFolderModel();
                        var b = false;
                        c.Network = IniFileHelper.ReadINI(_iniFile, i.ToString(), "Network", "");
                        if (!string.IsNullOrEmpty(network))
                        {
                            if (!string.IsNullOrEmpty(c.Network))
                            {
                                if (c.Network == network)
                                {
                                    b = true;
                                }
                            }
                            else
                            {
                                b = false;
                            }
                        }
                        else
                        {
                            b = true;
                        }
                        if (b)
                        {
                            c.Channel = IniFileHelper.ReadINI(_iniFile, i.ToString(), "Channel", "");
                            var msg = IniFileHelper.ReadINI(_iniFile, i.ToString(), "Order", "0");
                            var t   = 0;
                            if (int.TryParse(msg, out t))
                            {
                                c.Order = t;
                            }
                            channelFolders.Add(c);
                        }
                    }
                    _cached   = channelFolders;
                    _useCache = true;
                    return(channelFolders);
                }
                else
                {
                    return(_cached.Where(c => c.Network == network).ToList());
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
コード例 #4
0
ファイル: NetworkSettings.cs プロジェクト: guideX/nexirc3
 /// <summary>
 /// Get By Id
 /// </summary>
 /// <param name="networkId"></param>
 /// <returns></returns>
 public NetworkData GetById(int networkId)
 {
     try {
         var network = new NetworkData();
         network.Id          = networkId;
         network.Description = IniFileHelper.ReadINI(_iniFile, networkId.ToString(), "Description", "");
         return(network);
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #5
0
ファイル: QuerySettings.cs プロジェクト: guideX/nexirc3
 /// <summary>
 /// Get
 /// </summary>
 /// <returns></returns>
 public QuerySettingsData Get()
 {
     try {
         if (_useCached)
         {
             return(_cached);
         }
         else
         {
             var data = new QuerySettingsData();
             data.SpamPhrases   = new List <string>();
             data.AutoAllowList = new List <string>();
             data.AutoDenyList  = new List <string>();
             int n = 0;
             if (int.TryParse(IniFileHelper.ReadINI(_iniFile, "Settings", "AutoAllow", "1"), out n))
             {
                 data.AutoAllow = (QueryPermission)n;
             }
             if (int.TryParse(IniFileHelper.ReadINI(_iniFile, "Settings", "AutoDeny", "1"), out n))
             {
                 data.AutoDeny = (QueryPermission)n;
             }
             data.StandByMessage   = IniFileHelper.ReadINI(_iniFile, "Settings", "StandByMessage", "");
             data.DeclineMessage   = IniFileHelper.ReadINI(_iniFile, "Settings", "DeclineMessage", "");
             data.EnableSpamFilter = Convert.ToBoolean(IniFileHelper.ReadINI(_iniFile, "Settings", "EnableSpamFilter ", "True"));
             data.PromptUser       = Convert.ToBoolean(IniFileHelper.ReadINI(_iniFile, "Settings", "PromptUser", "False"));
             var autoAllowCount  = Convert.ToInt32(IniFileHelper.ReadINI(_iniFile, "Settings", "AutoAllowCount", "0"));
             var autoDenyCount   = Convert.ToInt32(IniFileHelper.ReadINI(_iniFile, "Settings", "AutoDenyCount", "0"));
             var spamPhraseCount = Convert.ToInt32(IniFileHelper.ReadINI(_iniFile, "Settings", "SpamPhraseCount", "0"));
             data.AutoShowWindow = Convert.ToBoolean(IniFileHelper.ReadINI(_iniFile, "Settings", "AutoShowWindow", "True"));
             data.AutoAllowList  = new List <string>();
             for (var i = 1; i <= autoAllowCount; i++)
             {
                 data.AutoAllowList.Add(IniFileHelper.ReadINI(_iniFile, "AutoAllowList", i.ToString(), ""));
             }
             for (var i = 1; i <= autoDenyCount; i++)
             {
                 data.AutoDenyList.Add(IniFileHelper.ReadINI(_iniFile, "AutoDenyList", i.ToString(), ""));
             }
             for (var i = 1; i <= spamPhraseCount; i++)
             {
                 data.SpamPhrases.Add(IniFileHelper.ReadINI(_iniFile, "SpamPhrases", i.ToString(), ""));
             }
             _useCached = true;
             _cached    = data;
             return(data);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #6
0
ファイル: NetworkSettings.cs プロジェクト: guideX/nexirc3
        public int Count()
        {
            var msg = IniFileHelper.ReadINI(_iniFile, "Settings", "Count", "0");
            var n   = 0;

            if (int.TryParse(msg, out n))
            {
                return(n);
            }
            else
            {
                return(0);
            }
        }
コード例 #7
0
ファイル: NetworkSettings.cs プロジェクト: guideX/nexirc3
 /// <summary>
 /// Add
 /// </summary>
 /// <param name="network"></param>
 /// <returns></returns>
 public int Add(NetworkData network)
 {
     try {
         var msg = IniFileHelper.ReadINI(_iniFile, "Settings", "Count", "0");
         var n   = 0;
         if (int.TryParse(msg, out (n)))
         {
             n = n + 1;
             IniFileHelper.WriteINI(_iniFile, "Settings", "Count", n.ToString());
             IniFileHelper.WriteINI(_iniFile, n.ToString(), "Description", network.Description);
         }
         _useCache = false;
         return(n);
     } catch (Exception ex) {
         throw ex;
     }
 }
コード例 #8
0
ファイル: NetworkBusiness.cs プロジェクト: guideX/nexirc3
        /// <summary>
        /// Read All
        /// </summary>
        /// <returns></returns>
        public List <NetworkModel> ReadAll()
        {
            var result = new List <NetworkModel> {
                new NetworkModel()
            };
            var c = IniFileHelper.ReadIniInt(_ini, "Settings", "Count");

            for (var i = 1; i <= c; i++)
            {
                var item = new NetworkModel()
                {
                    Description = IniFileHelper.ReadINI(_ini, i.ToString(), "Description", ""),
                    NetworkID   = i
                };
                if (!string.IsNullOrEmpty(item.Description))
                {
                    result.Add(item);
                }
            }
            return(result);
        }
コード例 #9
0
ファイル: DccSettings.cs プロジェクト: guideX/nexirc3
        /// <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);
        }