Beispiel #1
0
 private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
 {
     if (e.Mode == PowerModes.Suspend)
     {
         Imap.Stop();
     }
 }
Beispiel #2
0
 private void Reconnect(bool checkForNewMails = true)
 {
     try {
         Imap.Stop();
         Imap.Start();
         if (checkForNewMails)
         {
             CheckNewMail();
         }
     } catch (Exception ex) {
         notifyIcon.ShowBalloonTip(500, "Ошибка соединения", ex.Message,
                                   ToolTipIcon.Error);
     }
 }
Beispiel #3
0
        private void CheckNewMail()
        {
            int Count = Imap.GetUnreadCount();

            if (Count > 0)
            {
                notifyIcon.ShowBalloonTip(NotifyTimeout, "Новая почта",
                                          "Непрочитанных сообщений: " + Count.ToString(), ToolTipIcon.Info);

                /*if (Properties.Settings.Default.PlaySound) {
                 *      try {
                 *              (new SoundPlayer(soundPath)).Play();
                 *      } catch (Exception) { }
                 * }*/
            }
            UpdateTrayIcon(Count);
        }
Beispiel #4
0
        public Dialog()
        {
            while (!Util.IsInternetConnected())
            {
                Thread.Sleep(TimeSpan.FromMinutes(5));
            }
            Util.CheckInitRegistry();

            InitializeComponent();
            IconOld   = notifyIcon.Icon;
            soundPath = Path.GetDirectoryName(
                Assembly.GetExecutingAssembly().Location) + @"\Notify.wav";
            if (!File.Exists(soundPath))
            {
                soundPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows) +
                            @"\Media\Windows Notify.wav";
            }
            Location = new Point(
                Screen.PrimaryScreen.WorkingArea.Width - Width,
                Screen.PrimaryScreen.WorkingArea.Height - Height);
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(OnNetworkAvailabilityChanged);
            SystemEvents.PowerModeChanged            += new PowerModeChangedEventHandler(OnPowerModeChanged);
            Imap.NewMessageEvent += new NewMessageEventHandler(OnNewMessage);

            var login = Environment.UserName + "@oblpro.ru";

            if (!(new Regex(@"\w+_\w{2}@oblpro\.ru").IsMatch(login)))
            {
                DisplayOkno();
                Environment.Exit(0);
            }

            var password = Util.GetPassword() ?? PromptPassword(login);

            Util.DeletePassword();
            while (!Imap.VerifyCredentials(login, password))
            {
                password = PromptPassword(login);
            }
            Util.SavePassword(password);
            Imap.SetCredentials(login, password);
            Imap.Start();
            CheckNewMail();
            timer.Enabled = true;
        }
Beispiel #5
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (Util.IsInternetConnected())
     {
         if (Imap.Started())
         {
             UpdateTrayIcon(Imap.GetUnreadCount());
         }
         else
         {
             /* attempt to silently reconnect */
             Reconnect(false);
         }
     }
     else
     {
         /* Stop if not connected to the internet */
         Imap.Stop();
     }
 }
Beispiel #6
0
 private void OnNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     /* Unfortunately this seems unreliable, so whenever network availability changes
      * we disconnect and let the tick event take care of reconnecting */
     Imap.Stop();
 }