예제 #1
0
        internal void Initialize(string appPath, System.ComponentModel.ISynchronizeInvoke synchronizingObject)
        {
            this.appPath = appPath;
            this.synchronizingObject = synchronizingObject;

            this.historyFolder = Growl.CoreLibrary.PathUtility.Combine(Utility.UserSettingFolder, @"History\");
            PastNotificationManager.HistoryFolder = this.historyFolder;

            string imageCacheFolder = Growl.CoreLibrary.PathUtility.Combine(Utility.UserSettingFolder, @"ImageCache\");
            ImageCache.CacheFolder = imageCacheFolder;

            // handle any upgrade logic
            bool upgrade = (Growl.Properties.Settings.Default.SettingsVersion < 2);
            if (upgrade)
            {
                Utility.WriteDebugInfo("UPGRADE INITIATED");

                SettingSaver raSettingSaver = new SettingSaver(REGISTERED_APPLICATIONS_SETTINGS_FILENAME, LegacyDeserializers.LegacyDeserializationHelper.OldApplicationsHelper);
                raSettingSaver.Save(raSettingSaver.Load());

                SettingSaver fcSettingSaver = new SettingSaver(FORWARD_COMPUTERS_SETTINGS_FILENAME, LegacyDeserializers.LegacyDeserializationHelper.OldForwardDestinationHelper);
                fcSettingSaver.Save(fcSettingSaver.Load());

                SettingSaver sbSettingSaver = new SettingSaver(SUBSCRIPTIONS_SETTINGS_FILENAME, LegacyDeserializers.LegacyDeserializationHelper.OldSubscriptionHelper);
                sbSettingSaver.Save(sbSettingSaver.Load());

                PastNotificationManager.DeleteHistory();

                Growl.Properties.Settings.Default.SettingsVersion = 2;

                Utility.WriteDebugInfo(String.Format("UPGRADE COMPLETED - NOW AT VERSION: {0}", Growl.Properties.Settings.Default.SettingsVersion));
            }

            DisplayStyleManager.DisplayLoaded += new DisplayStyleManager.DisplayLoadedEventHandler(DisplayStyleManager_DisplayLoaded);

            LoadPasswords();
            LoadMiscPrefs();
            LoadDisplays();     // this could take a long time as well, but other things depend on it so we have to do it synchronously and just wait
            LoadApplications();
            LoadForwardedComputers();
            LoadSubscriptions();

            // this must come *after* LoadForwardedComputers has ran
            StartBonjour();

            this.activityMonitor = new ActivityMonitor();
            this.activityMonitor.WentIdle += new ActivityMonitor.ActivityMonitorEventHandler(activityMonitor_WentIdle);
            this.activityMonitor.ResumedActivity += new ActivityMonitor.ActivityMonitorEventHandler(activityMonitor_ResumedActivity);
            this.activityMonitor.StillActive += new EventHandler(activityMonitor_StillActive);
            this.activityMonitor.CheckForIdle = Properties.Settings.Default.CheckForIdle;
            this.activityMonitor.IdleAfterSeconds = Properties.Settings.Default.IdleAfterSeconds;
        }
예제 #2
0
 void activityMonitor_WentIdle(ActivityMonitor.ActivityMonitorEventArgs args)
 {
     if (args.Reason == ActivityMonitor.ActivityMonitorEventReason.ApplicationPaused)
         this.paused = true;
     else if (args.Reason == ActivityMonitor.ActivityMonitorEventReason.UserInactivity)
         this.idle = true;
     else if (args.Reason == ActivityMonitor.ActivityMonitorEventReason.DesktopLocked)
         this.idle = true;
 }
예제 #3
0
        private void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (this.mutex != null)
                    {
                        try
                        {
                            this.mutex.ReleaseMutex();
                            this.mutex.Close();
                            this.mutex = null;
                        }
                        catch
                        {
                        }
                    }

                    DisplayStyleManager.DisplayLoaded -= new DisplayStyleManager.DisplayLoadedEventHandler(DisplayStyleManager_DisplayLoaded);

                    if (this.bonjour != null)
                    {
                        this.bonjour.ServiceFound -= new Bonjour.NetServiceFoundEventHandler(bonjour_ServiceFound);
                        this.bonjour.ServiceRemoved -= new Bonjour.NetServiceRemovedEventHandler(bonjour_ServiceRemoved);
                        this.bonjour.Stop();
                        this.bonjour.Dispose();
                        this.bonjour = null;
                    }

                    if (this.activityMonitor != null)
                    {
                        this.activityMonitor.WentIdle -= new ActivityMonitor.ActivityMonitorEventHandler(activityMonitor_WentIdle);
                        this.activityMonitor.ResumedActivity -= new ActivityMonitor.ActivityMonitorEventHandler(activityMonitor_ResumedActivity);
                        this.activityMonitor.StillActive -= new EventHandler(activityMonitor_StillActive);
                        this.activityMonitor.Dispose();
                        this.activityMonitor = null;
                    }

                    if (this.gntpListener != null)
                    {
                        this.gntpListener.RegisterReceived -= new Growl.Daemon.GrowlServer.RegisterReceivedEventHandler(gntpListener_RegisterReceived);
                        this.gntpListener.NotifyReceived -= new Growl.Daemon.GrowlServer.NotifyReceivedEventHandler(gntpListener_NotifyReceived);
                        this.gntpListener.SubscribeReceived -= new Growl.Daemon.GrowlServer.SubscribeReceivedEventHandler(gntpListener_SubscribeReceived);
                        this.gntpListener.Dispose();
                        this.gntpListener = null;
                    }

                    if (this.udpListener != null)
                    {
                        this.udpListener.RegistrationReceived -= new Growl.UDPLegacy.MessageReceiver.RegistrationHandler(udpListener_RegistrationReceived);
                        this.udpListener.NotificationReceived -= new Growl.UDPLegacy.MessageReceiver.NotificationHandler(udpListener_NotificationReceived);
                        this.udpListener.Dispose();
                        this.udpListener = null;
                    }

                    if (this.udpListenerLocal != null)
                    {
                        this.udpListenerLocal.RegistrationReceived -= new Growl.UDPLegacy.MessageReceiver.RegistrationHandler(udpListener_RegistrationReceived);
                        this.udpListenerLocal.NotificationReceived -= new Growl.UDPLegacy.MessageReceiver.NotificationHandler(udpListener_NotificationReceived);
                        this.udpListenerLocal.Dispose();
                        this.udpListenerLocal = null;
                    }

                    if (this.subscriptions != null)
                    {
                        foreach (Subscription subscription in this.subscriptions.Values)
                        {
                            subscription.StatusChanged -= new Subscription.SubscriptionStatusChangedEventHandler(subscription_StatusChanged);
                        }
                    }

                    if (this.forwards != null)
                    {
                        foreach (ForwardDestination fd in this.forwards.Values)
                        {
                            SubscribedForwardDestination sfd = fd as SubscribedForwardDestination;
                            if(sfd != null)
                                sfd.Unsubscribed -= new SubscribedForwardDestination.SubscribingComputerUnscubscribedEventHandler(sfc_Unsubscribed);
                        }
                    }

                    if (DisplayStyleManager.AvailableDisplayStyles != null)
                    {
                        foreach (Display display in DisplayStyleManager.AvailableDisplayStyles.Values)
                        {
                            display.NotificationCallback -= new Display.NotificationCallbackEventHandler(display_NotificationCallback);
                        }
                    }
                }
                this.disposed = true;
            }
        }
예제 #4
0
        void activityMonitor_ResumedActivity(ActivityMonitor.ActivityMonitorEventArgs args)
        {
            // refresh all displays (this handles the case where sticky notifications were received while the
            // screen was locked and thus drawn with just a black space)
            RefreshActiveNotifications();

            lock (this.missedNotifications)
            {
                if (this.missedNotifications.Count > 0)
                {
                    // show missed notification summary
                    List<PastNotification> mn = new List<PastNotification>(this.missedNotifications);
                    ShowMissedNotifications(mn);

                    Utility.WriteDebugInfo("RESUMED ACTIVITY - You missed {0} notifications while you were away", mn.Count);

                    this.missedNotifications.Clear();
                }
            }

            this.idle = false;
            this.paused = false;
        }