public void convert(SerializableConfig config)
 {
     if (config.ServerName != null)
     {
         ServerName = config.ServerName;
     }
     if (config.MaxConnections != null)
     {
         MaxConnections = config.MaxConnections;
     }
     if (config.ipAddress != null)
     {
         ipAddress = config.ipAddress;
     }
     if (config.isAutoListen != null)
     {
         isAutoListen = config.isAutoListen;
     }
     if (config.isStartInTray != null)
     {
         isStartInTray = config.isStartInTray;
     }
     if (config.isHideDonate != null)
     {
         isHideDonate = config.isHideDonate;
     }
     if (config.isUPnPonStart != null)
     {
         isUPnPonStart = config.isUPnPonStart;
     }
     if (config.isShowMessageOnMinimize != null)
     {
         isShowMessageOnMinimize = config.isShowMessageOnMinimize;
     }
     if (config.SERVER_PORT != null)
     {
         SERVER_PORT = config.SERVER_PORT;
     }
     if (config.username != null)
     {
         username = config.username;
     }
     if (config.password != null)
     {
         password = config.password;
     }
     if (config.updateTimeStamps != null)
     {
         updateTimeStamps = config.updateTimeStamps;
     }
     if (config.bannedIPs != null)
     {
         bannedIPs = config.bannedIPs;
     }
     if (config.bannedMACs != null)
     {
         bannedMACs = config.bannedMACs;
     }
 }
Exemplo n.º 2
0
        //add all serializable objects her
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            HttpEngine.PAGE_ROOT = APP_DATA_FOLDER + @"www/";
            EventLog.LOG_FILE    = APP_DATA_FOLDER + "_log.txt";

            if (e.Args.Length > 0)
            {
                addController(e.Args[0]);
            }

            string procname = Process.GetCurrentProcess().ProcessName;
            int    procID   = Process.GetCurrentProcess().Id;

            foreach (Process p in Process.GetProcesses())
            {
                //p.main
                if (p.ProcessName.Equals(procname) && p.Id != procID)
                {
                    Application.Current.Shutdown();
                    return;
                }
            }

            if (File.Exists(App.CONFIG_PATH))
            {
                try
                {
                    App.Config = (SerializableConfig)deserialize(App.CONFIG_PATH);
                }
                catch (InvalidCastException)
                {
                    App.Config = new SerializableConfig();
                }
                if (App.Config == null || App.Config.version == 0 || App.Config.version != SerializableConfig.VERSION)
                {
                    var tmp = new SerializableConfig();
                    if (App.Config.version != SerializableConfig.VERSION)
                    {
                        try
                        {
                            tmp.convert(App.Config);
                        }
                        catch (NullReferenceException) { }
                    }
                    App.Config = tmp;
                }
            }
            if (File.Exists(App.USER_TABLE_PATH))
            {
                try
                {
                    Bouncer.UserTable = (Dictionary <String, String>)deserialize(App.USER_TABLE_PATH);
                }
                catch (InvalidCastException)
                {
                    Bouncer.UserTable = new Dictionary <String, String>();
                }
                if (Bouncer.IsUserTableNull)
                {
                    Bouncer.UserTable = new Dictionary <String, String>();
                }
            }

            Directory.CreateDirectory(CONTROLLER_DIR); // won't erase
            //buildAdministrativeController();
            //buildMediaController();
            //buildFileController();
            //buildAdministrativeControllerfree();
            //buildMediaControllerfree();
            //buildRemoteDesktopController();
            //buildTouchPadControllerFree();
            //buildTouchPadController();
            //buildSlideShowController();

            HttpEngine.addPageMutation("{RSAKEY}", BitConverter.ToString(Bouncer.rcsp.ExportParameters(false).Modulus).Replace("-", ""));
            HttpEngine.addPageMutation("{RSAEX}", BitConverter.ToString(Bouncer.rcsp.ExportParameters(false).Exponent, 0).ToString().Replace("-", ""));

            // for some reason this helps speed up the initial connecting process in some envirnments
            //ClientContainer.REGEX_MOBILE1.IsMatch("blahblah");
            //ClientContainer.REGEX_MOBILE2.IsMatch("blahblah");


            ClientView = new frmClientView(); //needs to be assigned after initialization
            LogView    = new frmLogView();
            frmSettings firstSettings = new frmSettings();

            MainWin          = new frmMain();
            MainWin.settings = firstSettings;

            myTcpServer.Connected    += ClientView.ConnectionInit;
            myTcpServer.Disconnected += ClientView.ConnectionDisconnect;

            if (Config.isUPnPonStart)
            {
                App.MainWin.settings.StartUPnP();
            }

            if (!App.Config.username.Equals(""))
            {
                if (Config.isStartInTray)
                {
                    MainWin.notifyIcon.Visible = true;
                    MainWin.showTrayMessage.Invoke();
                    return;
                }
            }

            MainWin.Show();
        }