Esempio n. 1
0
        private void SendCatalogRequest()
        {
            try
            {
                // Delete all previous content requests
                FoeClientRequest.DeleteOldRequest(_requestInterval);

                // Create Foe Message
                string requestId = FoeClientRequest.GenerateId();

                FoeClientMessage.SendMessage(
                    FoeClientMessage.GetSmtpServer(),
                    FoeClientRegistry.GetEntry("useremail").Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Catalog, requestId, FoeClientRegistry.GetEntry("userid").Value),
                    "");

                // save requestid to DB
                FoeClientRequestItem reqItem = new FoeClientRequestItem();
                reqItem.Id          = requestId;
                reqItem.Type        = "catalog";
                reqItem.DtRequested = DateTime.Now;
                FoeClientRequest.Add(reqItem);

                // remember when the request was sent
                _lastRequestSent = DateTime.Now;
                // Set status
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested catalog.";
            }
            catch (Exception)
            {
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request.";
            }
        }
Esempio n. 2
0
        static bool IsRegistered()
        {
            FoeClientRegistryEntry userIdKey = FoeClientRegistry.GetEntry("userid");

            if (userIdKey == null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        static bool IsFirstRun()
        {
            FoeClientRegistryEntry firstRunKey = FoeClientRegistry.GetEntry("firstrun");

            if ((firstRunKey == null) || (firstRunKey.Value == "T"))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        private void SendSubscriptionRequest()
        {
            try
            {
                // Delete all previous content requests
                FoeClientRequest.DeleteOldRequest(_requestInterval);

                // Create Foe Message
                string catalogs = "";
                List <FoeClientCatalogItem> catalog = FoeClientCatalog.GetAll();
                if (catalog.Count == 0)
                {
                    return;
                }
                foreach (FoeClientCatalogItem item in catalog)
                {
                    if (item.IsSubscribed)
                    {
                        catalogs += item.Code + ",";
                    }
                }
                string requestId = FoeClientRequest.GenerateId();

                FoeClientMessage.SendMessage(
                    FoeClientMessage.GetSmtpServer(),
                    FoeClientRegistry.GetEntry("useremail").Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Content, requestId, FoeClientRegistry.GetEntry("userid").Value),
                    catalogs);

                // save requestid to DB
                FoeClientRequestItem reqItem = new FoeClientRequestItem();
                reqItem.Id          = requestId;
                reqItem.Type        = "content";
                reqItem.DtRequested = DateTime.Now;
                FoeClientRequest.Add(reqItem);

                // remember when the request was sent
                _lastRequestSent = DateTime.Now;
                // Set status
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested update.";
            }
            catch (Exception)
            {
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request.";
            }
        }
Esempio n. 5
0
        private void SaveInfo()
        {
            // Save user email address
            FoeClientRegistry.SetEntry("useremail", tbxEmail.Text.Trim());

            // Save SMTP Info
            FoeClientRegistry.SetEntry("smtpserver", tbxSmtpServer.Text.Trim().ToLower());
            FoeClientRegistry.SetEntry("smtpport", tbxSmtpPort.Text.Trim());
            FoeClientRegistry.SetEntry("smtpauthrequired", (cbxSmtpRequireAuth.Checked ? "T" : "F"));
            FoeClientRegistry.SetEntry("smtpsslenabled", (cbxSmtpRequireSsl.Checked ? "T" : "F"));
            FoeClientRegistry.SetEntry("smtpusername", tbxSmtpUsername.Text.Trim());
            FoeClientRegistry.SetEntry("smtppassword", tbxSmtpPassword.Text);

            // Save POP3 info
            FoeClientRegistry.SetEntry("popserver", tbxPopServer.Text.Trim().ToLower());
            FoeClientRegistry.SetEntry("popport", tbxPopPort.Text.Trim());
            FoeClientRegistry.SetEntry("popsslenabled", (cbxPopRequireSsl.Checked ? "T" : "F"));
            FoeClientRegistry.SetEntry("popusername", tbxPopUsername.Text.Trim());
            FoeClientRegistry.SetEntry("poppassword", tbxPopPassword.Text);
        }
Esempio n. 6
0
        private void timerCheckRegistration_Tick(object sender, EventArgs e)
        {
            try
            {
                // Stop timer
                timerCheckRegistration.Stop();

                // Check messages
                lblStatus.Text = "Checking registration status...";
                FoeClientMessage.DownloadMessages();

                // Check if user ID is now set
                FoeClientRegistryEntry userId = FoeClientRegistry.GetEntry("userid");
                if ((userId == null) || (userId.Value.Trim().Length == 0))
                {
                    lblStatus.Text = "[" + DateTime.Now.ToString("HH:mm:ss") + "] registration still processing. Wait 15 seconds.";
                    timerCheckRegistration.Start();
                    return;
                }

                // Registration is completed
                lblStatus.Text = "Registration completed.";
                _result        = DialogResult.OK;
                Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error checking registration request. Make sure your computer is connected to the Internet and the POP3 servers " +
                                "settings are correct. You can click the Email Settings button to reconfigure SMTP and POP3 settings.",
                                "Foe", MessageBoxButtons.OK, MessageBoxIcon.Error);

                // re-enable buttons
                btnRegister.Enabled      = true;
                btnEmailSettings.Enabled = true;

                // Update status
                lblStatus.Text = "Error checking registration request.";
            }
        }
Esempio n. 7
0
        public EmailInfo()
        {
            InitializeComponent();

            // Try to load existing email address, SMTP and POP3 information
            FoeClientRegistryEntry smtpServer      = FoeClientRegistry.GetEntry("smtpserver");
            FoeClientRegistryEntry smtpPort        = FoeClientRegistry.GetEntry("smtpport");
            FoeClientRegistryEntry smtpRequireAuth = FoeClientRegistry.GetEntry("smtpauthrequired");
            FoeClientRegistryEntry smtpRequireSsl  = FoeClientRegistry.GetEntry("smtpsslenabled");
            FoeClientRegistryEntry smtpUsername    = FoeClientRegistry.GetEntry("smtpusername");
            FoeClientRegistryEntry smtpPassword    = FoeClientRegistry.GetEntry("smtppassword");

            FoeClientRegistryEntry popServer     = FoeClientRegistry.GetEntry("popserver");
            FoeClientRegistryEntry popPort       = FoeClientRegistry.GetEntry("popport");
            FoeClientRegistryEntry popRequireSsl = FoeClientRegistry.GetEntry("popsslenabled");
            FoeClientRegistryEntry popUsername   = FoeClientRegistry.GetEntry("popusername");
            FoeClientRegistryEntry popPassword   = FoeClientRegistry.GetEntry("poppassword");

            FoeClientRegistryEntry userEmail = FoeClientRegistry.GetEntry("useremail");

            // Pre-fill info
            tbxEmail.Text = ((userEmail == null) ? "" : userEmail.Value);

            tbxSmtpServer.Text         = ((smtpServer == null) ? "" : smtpServer.Value);
            tbxSmtpPort.Text           = ((smtpPort == null) ? "" : smtpPort.Value);
            cbxSmtpRequireAuth.Checked = ((smtpRequireAuth == null) || (smtpRequireAuth.Value.ToUpper() == "T"));
            cbxSmtpRequireSsl.Checked  = ((smtpRequireSsl != null) && (smtpRequireSsl.Value.ToUpper() == "T"));
            tbxSmtpUsername.Text       = ((smtpUsername == null) ? "" : smtpUsername.Value);
            tbxSmtpPassword.Text       = ((smtpPassword == null) ? "" : smtpPassword.Value);

            tbxPopServer.Text        = ((popServer == null) ? "" : popServer.Value);
            tbxPopPort.Text          = ((popPort == null) ? "" : popPort.Value);
            cbxPopRequireSsl.Checked = ((popRequireSsl != null) && (popRequireSsl.Value.ToUpper() == "T"));
            tbxPopUsername.Text      = ((popUsername == null) ? "" : popUsername.Value);
            tbxPopPassword.Text      = ((popPassword == null) ? "" : popPassword.Value);
        }
Esempio n. 8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Check if this is the first time setup is run.
            // If so, we'll display the legal notice.
            if (IsFirstRun())
            {
                LegalNotice legalForm = new LegalNotice();
                Application.Run(legalForm);
                if (legalForm.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            // Check if email is configured
            if (!IsEmailConfigured())
            {
                Setup setupForm = new Setup();
                Application.Run(setupForm);

                // Check the DialogResult for setupForm
                if (setupForm.DialogResult == DialogResult.Cancel)
                {
                    MessageBox.Show("Please come back again when you have an email account ready.");
                    return;
                }

                // Open the email information form
                EmailInfo emailInfoForm = new EmailInfo();
                Application.Run(emailInfoForm);
                if (emailInfoForm.DialogResult == DialogResult.Cancel)
                {
                    // User cancelled setup, exit program
                    return;
                }
            }

            // Check if we need to register user
            if (!IsRegistered())
            {
                Registration regForm = new Registration();
                Application.Run(regForm);

                // Check if regForm returns OK
                if (regForm.DialogResult == DialogResult.Cancel)
                {
                    // Exit program
                    return;
                }
            }

            // Setup complete, set FirstRun to "F" (false)
            FoeClientRegistry.SetEntry("firstrun", "F");

            // Start Foe client
            FoeReader foeReader = new FoeReader();

            Application.Run(foeReader);
        }