Beispiel #1
0
 static void Main()
 {
     Application.ThreadException += Application_ThreadException;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Forms.Main = new Main();
     UserInterfaceFactory.GetUiSystem().DisplayMainForm(Forms.Main);
 }
        internal void BuildObjectGraph(Action shutdown)
        {
            const int FIVE_SECONDS   = 5000;
            const int THIRTY_SECONDS = 30000;

            var args          = Environment.GetCommandLineArgs();
            var nativeMethods = new NativeMethods();

            logger     = new Logger();
            systemInfo = new SystemInfo();

            InitializeConfiguration();
            InitializeLogging();
            InitializeText();

            var messageBox     = new MessageBox(text);
            var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
            var explorerShell  = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var proxyFactory   = new ProxyFactory(new ProxyObjectFactory(), logger);
            var runtimeHost    = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
            var serviceProxy   = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)));
            var sessionContext = new SessionContext();
            var uiFactory      = new UserInterfaceFactory(text);

            var bootstrapOperations = new Queue <IOperation>();
            var sessionOperations   = new Queue <IRepeatableOperation>();

            bootstrapOperations.Enqueue(new I18nOperation(logger, text, textResource));
            bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger));

            sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
            sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext));
            sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new KioskModeTerminationOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));

            var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
            var sessionSequence   = new RepeatableOperationSequence(logger, sessionOperations);

            RuntimeController = new RuntimeController(
                appConfig,
                logger,
                messageBox,
                bootstrapSequence,
                sessionSequence,
                runtimeHost,
                serviceProxy,
                sessionContext,
                shutdown,
                text,
                uiFactory);
        }
Beispiel #3
0
        public void ShowSiteProperties()
        {
            DialogSitePropertiesViewModel vm = new DialogSitePropertiesViewModel();

            UserInterfaceFactory.GetUiSystem().DisplayForm(AvailableForms.SiteProperties, vm);
            if (vm.IsCallsignAndGridSquareValid() == false)
            {
                UserInterfaceFactory.GetUiSystem().DisplayModalError(
                    "Paclink must have a valid configuration to continue...", "Error");
                Environment.Exit(-1);
            }
        }
Beispiel #4
0
        public void FormLoading()
        {
            Globals.strProductName       = typeof(Main).Assembly.GetName().Name; // TBD: might need to use different property to retrieve this
            Globals.strProductVersion    = typeof(Main).Assembly.GetName().Version.ToString();
            Globals.blnRunningInTestMode = false;

            var startupPath = typeof(Main).Assembly.Location;

            if (startupPath.IndexOf("Source") == -1)
            {
                Globals.SiteBinDirectory = startupPath + @"\";
                int intDirPtr = Globals.SiteBinDirectory.ToLower().IndexOf(@"bin\");
                if (intDirPtr != -1)
                {
                    Globals.SiteRootDirectory = Globals.SiteBinDirectory.Substring(0, intDirPtr);
                }
            }
            else
            {
                Globals.blnRunningInTestMode = true;
                string strProgramFiles = Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
                Globals.SiteRootDirectory = Path.Combine(strProgramFiles, @"Paclink\");
                Globals.SiteBinDirectory  = Globals.SiteRootDirectory + @"Bin\";
            }

            Globals.SiteDataDirectory = Globals.SiteRootDirectory + @"Data\";
            if (Globals.SiteBinDirectory.ToLower().IndexOf("bin") == -1)
            {
                UserInterfaceFactory.GetUiSystem().DisplayModalError(
                    "Illegal Paclink directory structure...Paclink.exe " + @"Must be in the \Bin subdirectory as installed!",
                    "Directory Error");
                Environment.Exit(0);
            }

            Globals.Settings.Save("Main", "Program Version", Globals.strProductVersion);
            Globals.blnUseRMSRelay        = Globals.Settings.Get("Properties", "Use RMS Relay", false);
            Globals.strRMSRelayIPPath     = Globals.Settings.Get("Properties", "Local IP Path", "");
            Globals.intRMSRelayPort       = Globals.Settings.Get("Properties", "RMS Relay Port", 8772);
            Globals.blnUseExternalDNS     = Globals.Settings.Get("Properties", "Use External DNS", false);
            Globals.blnForceHFRouting     = Globals.Settings.Get("Properties", "Force radio-only", false);
            Globals.blnEnablAutoforward   = Globals.Settings.Get("Properties", "Enable Autoforward", false);
            Globals.blnPactorDialogResume = Globals.Settings.Get("Properties", "Pactor Dialog Resume", true);

            Globals.InitializeLocalIPAddresses();
        }
Beispiel #5
0
        public void OpenPOP3AndSMTPPorts()
        {
            try
            {
                // Open SMTP/POP3 ports...
                if (Globals.objSMTPPort != null)
                {
                    Globals.objSMTPPort.LocalPort = Globals.intSMTPPortNumber;
                    Globals.objSMTPPort.Listen(true);
                }

                if (Globals.objPOP3Port != null)
                {
                    Globals.objPOP3Port.LocalPort = Globals.intPOP3PortNumber;
                    Globals.objPOP3Port.Listen(true);
                }
            }
            catch (Exception ex)
            {
                UserInterfaceFactory.GetUiSystem().DisplayModalError("Error restarting POP3 and SMTP Ports: " + ex.Message, "Error");
            }
        }
Beispiel #6
0
 public void ShowPollingInterval()
 {
     UserInterfaceFactory.GetUiSystem().DisplayForm(AvailableForms.Polling, Globals.PollingData);
 }
Beispiel #7
0
 public void ShowAGWEngine()
 {
     UserInterfaceFactory.GetUiSystem().DisplayForm(AvailableForms.AgwEngine, new DialogAgwEngineViewModel());
 }
        public PrimaryThread()
        {
            //
            // Initializes the program on startup...
            //
            int intIndex = Globals.Settings.Get("Properties", "Default Local IP Address Index", 0);

            if (intIndex < 0)
            {
                intIndex = 0;
            }
            if (Globals.strLocalIPAddresses.Length - 1 >= intIndex)
            {
                Globals.strLocalIPAddress = Globals.strLocalIPAddresses[intIndex];
            }

            Globals.SiteCallsign      = Globals.Settings.Get("Properties", "Site Callsign", "");
            Globals.SiteGridSquare    = Globals.Settings.Get("Properties", "Grid Square", "");
            Globals.intSMTPPortNumber = Globals.Settings.Get("Properties", "SMTP Port Number", 25);
            Globals.intPOP3PortNumber = Globals.Settings.Get("Properties", "POP3 Port Number", 110);
            Globals.blnLAN            = Globals.Settings.Get("Properties", "LAN Connection", true);
            Globals.blnEnableRadar    = Globals.Settings.Get("Properties", "Enable Radar", false);
            Globals.strServiceCodes   = Globals.Settings.Get("Properties", "ServiceCodes", "");
            if (string.IsNullOrEmpty(Globals.strServiceCodes))
            {
                if (Globals.IsMARSCallsign(Globals.SiteCallsign))
                {
                    Globals.strServiceCodes = Globals.strMARSServiceCode;
                }
                else
                {
                    Globals.strServiceCodes = Globals.strHamServiceCode;
                }

                Globals.Settings.Save("Properties", "ServiceCodes", Globals.strServiceCodes);
            }
            string strSitePassword = Globals.Settings.Get("Properties", "Site Password", "");

            Globals.POP3Password = Globals.Settings.Get("Properties", "EMail Password", strSitePassword);
            Globals.Settings.Save("Properties", "EMail Password", Globals.POP3Password);
            Globals.Settings.Save("Properties", "Site Password", "");
            Globals.SecureLoginPassword = Globals.Settings.Get("Properties", "Secure Login Password", "");
            Channels.FillChannelCollection();
            try
            {
                Globals.PollingData.LoadParameters();
            }
            catch (Exception ex)
            {
                _log.Error("[Main.Startup C] " + ex.Message);
            }

            try
            {
                // Open the properties dialog box if no initial configuration has been set...
                DialogSitePropertiesViewModel vm = new DialogSitePropertiesViewModel();
                if (vm.IsCallsignAndGridSquareValid() == false)
                {
                    UserInterfaceFactory.GetUiSystem().DisplayForm(AvailableForms.SiteProperties, vm);
                    if (vm.IsCallsignAndGridSquareValid() == false)
                    {
                        MessageBox.Show("Paclink must have a valid initial configuration to continue...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyApplication.Forms.Main.CloseWindow();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error("[Main.Startup F] " + ex.Message);
            }

            try
            {
                Accounts.RefreshAccountsList();
            }
            catch (Exception ex)
            {
                _log.Error("[Main.Startup G] " + ex.Message);
            }

            try
            {
                MyApplication.Forms.Main.UpdateChannelList();
            }
            catch (Exception ex)
            {
                _log.Error("[Main.Startup G] " + ex.Message);
            }

            MyApplication.Forms.Main.UpdateSiteCallsign(Globals.SiteCallsign);
            if (Globals.UseRMSRelay())
            {
                Globals.queChannelDisplay.Enqueue("G*** Paclink is set to connect to RMS Relay.");
            }

            if (Globals.blnForceHFRouting)
            {
                Globals.queChannelDisplay.Enqueue("G*** Paclink is set to send messages via radio-only forwarding.");
            }

            Globals.queChannelDisplay.Enqueue("G*** Paclink " + Application.ProductVersion + " ready...");
            MyApplication.Forms.Main.EnableMainWindowInterface();
            if (thrSMTP != null)
            {
                _abortSMTPThread = true;
                thrSMTP.Join();
                thrSMTP = null;
            }

            thrSMTP      = new Thread(SMTPThread);
            thrSMTP.Name = "SMTP";
            thrSMTP.Start();
            if (thrChannel != null)
            {
                _abortChannelThread = true;
                thrChannel.Join();
                thrChannel = null;
            }

            thrChannel      = new Thread(ChannelThread);
            thrChannel.Name = "Channel";
            thrChannel.Start();
        }
        internal void BuildObjectGraph(Action shutdown)
        {
            const int FIVE_SECONDS   = 5000;
            const int THIRTY_SECONDS = 30000;

            logger     = new Logger();
            systemInfo = new SystemInfo();

            InitializeConfiguration();
            InitializeLogging();
            InitializeText();

            var args                  = Environment.GetCommandLineArgs();
            var messageBox            = new MessageBoxFactory(text);
            var nativeMethods         = new NativeMethods();
            var uiFactory             = new UserInterfaceFactory(text);
            var desktopFactory        = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
            var explorerShell         = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var fileSystem            = new FileSystem();
            var processFactory        = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var proxyFactory          = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory)));
            var remoteSessionDetector = new RemoteSessionDetector(ModuleLogger(nameof(RemoteSessionDetector)));
            var runtimeHost           = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
            var runtimeWindow         = uiFactory.CreateRuntimeWindow(appConfig);
            var server                = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy)));
            var serviceProxy          = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime);
            var sessionContext        = new SessionContext();
            var splashScreen          = uiFactory.CreateSplashScreen(appConfig);
            var userInfo              = new UserInfo(ModuleLogger(nameof(UserInfo)));
            var vmDetector            = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo);

            var bootstrapOperations = new Queue <IOperation>();
            var sessionOperations   = new Queue <IRepeatableOperation>();

            bootstrapOperations.Enqueue(new I18nOperation(logger, text));
            bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger));

            sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext));
            sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext));
            sessionOperations.Enqueue(new DisclaimerOperation(logger, sessionContext));
            sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server));
            sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext));
            sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
            sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
            sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new ProctoringWorkaroundOperation(logger, sessionContext));
            sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));

            var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
            var sessionSequence   = new RepeatableOperationSequence(logger, sessionOperations);

            RuntimeController = new RuntimeController(
                appConfig,
                logger,
                messageBox,
                bootstrapSequence,
                sessionSequence,
                runtimeHost,
                runtimeWindow,
                serviceProxy,
                sessionContext,
                shutdown,
                splashScreen,
                text,
                uiFactory);
        }