示例#1
0
        public ApplicationRegisteredEventArgs(RegisteredApplication app, bool existing)

        {
            this.app = app;

            this.existing = existing;
        }
示例#2
0
 public ApplicationRegisteredEventArgs(RegisteredApplication app, bool existing)
 {
     this.app = app;
     this.existing = existing;
 }
示例#3
0
        Growl.Connector.Response gntpListener_RegisterReceived(Growl.Connector.Application application, List<Growl.Connector.NotificationType> notificationTypes, Growl.Connector.RequestInfo requestInfo)
        {
            Growl.Connector.Response response = null;

            // get the icon
            Growl.CoreLibrary.Resource applicationIcon = null;
            if (application.Icon != null && application.Icon.IsSet)
            {
                try
                {
                    applicationIcon = application.Icon;
                }
                catch
                {
                    applicationIcon = null;
                }
            }

            // deal with notification list
            Dictionary<string, RegisteredNotification> rns = new Dictionary<string, RegisteredNotification>(notificationTypes.Count);
            foreach (Growl.Connector.NotificationType nt in notificationTypes)
            {
                Growl.CoreLibrary.Resource icon = null;
                try
                {
                    if (nt.Icon != null && nt.Icon.IsSet)
                    {
                        icon = nt.Icon;
                    }
                }
                catch
                {
                    icon = null;
                }

                RegisteredNotification rn = new RegisteredNotification(nt.DisplayName, nt.Enabled, nt.CustomTextAttributes, nt.CustomBinaryAttributes);
                rn.SetIcon(icon, application.Name);
                rns.Add(nt.Name, rn);
            }

            // update/create the RegisteredApplication
            bool exisiting = false;
            RegisteredApplication ra = null;
            if (IsApplicationRegistered(application.Name))
            {
                exisiting = true;
                ra = GetRegisteredApplication(application.Name);
                ra.SetIcon(applicationIcon);

                // the application is already registered, so we want to use the new notification list, but preserve any exisiting preferences
                foreach (RegisteredNotification raRn in ra.Notifications.Values)
                {
                    foreach (RegisteredNotification rn in rns.Values)
                    {
                        if (raRn.Name == rn.Name)
                        {
                            // use the exisiting preferences
                            rn.Preferences = raRn.Preferences;
                        }
                    }
                }
                ra.Notifications = rns;
            }
            else
            {
                ra = new RegisteredApplication(application.Name, rns, application.CustomTextAttributes, application.CustomBinaryAttributes);
                ra.SetIcon(applicationIcon);
                if (Properties.Settings.Default.ManuallyEnableNewApplications) ra.Preferences.PrefEnabled = false;
                this.applications.Add(ra.Name, ra);

                // fire ApplicationRegistered event
                this.OnApplicationRegistered(ra);
            }

            if (ra.Enabled && !exisiting)
            {
                DisplayStyle.Notification n = new Growl.DisplayStyle.Notification();
                n.UUID = requestInfo.RequestID;
                n.NotificationID = requestInfo.RequestID;
                n.ApplicationName = ra.Name;
                n.Description = String.Format(Properties.Resources.SystemNotification_AppRegistered_Text, ra.Name);
                n.Name = ra.Name;
                n.Priority = (int)Growl.Connector.Priority.Normal;
                n.Sticky = false;   // registration notifications are never sticky
                n.Title = Properties.Resources.SystemNotification_AppRegistered_Title;
                n.Image = ra.GetIcon();
                if (requestInfo.WasForwarded()) n.OriginMachineName = application.MachineName;

                // handle custom attributes
                n.AddCustomTextAttributes(application.CustomTextAttributes);
                n.AddCustomBinaryAttributes(application.CustomBinaryAttributes);

                ShowNotification(n, this.growlDefaultDisplay, null, false, requestInfo);

                response = new Growl.Connector.Response();
            }
            else
            {
                // application is disabled or already registered
                response = new Growl.Connector.Response();
            }

            // handle any forwarding after we have handled it locally
            // (NOTE: as of 03.09.2010 (v2.0.2), notifications are NOT forwarded if
            // they are not enabled (unlike before).
            if (ra.Enabled)
            {
                List<string> limitToTheseComputers = null;
                if (ra.ShouldForward(Properties.Settings.Default.AllowForwarding, out limitToTheseComputers))
                {
                    // update icon urls to binary data for forwarding
                    if (application.Icon != null && application.Icon.IsSet && application.Icon.IsUrl)
                    {
                        System.Drawing.Image icon = (Image)application.Icon;
                        if (icon != null)
                            application.Icon = icon;
                    }
                    foreach (Growl.Connector.NotificationType nt in notificationTypes)
                    {
                        if (nt.Icon != null && nt.Icon.IsSet && nt.Icon.IsUrl)
                        {
                            System.Drawing.Image icon = (Image)nt.Icon;
                            if (icon != null)
                                nt.Icon = icon;
                        }
                    }

                    HandleForwarding(application, notificationTypes, requestInfo, limitToTheseComputers);
                }
            }

            return response;
        }
示例#4
0
 protected void OnApplicationRegistered(RegisteredApplication ra)
 {
     if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
     {
         MethodInvoker invoker = new MethodInvoker(delegate()
         {
             OnApplicationRegistered(ra);
         });
         this.synchronizingObject.Invoke(invoker, null);
     }
     else
     {
         if (this.ApplicationRegistered != null)
         {
             this.ApplicationRegistered(ra);
         }
         SaveApplicationPrefs();
     }
 }
示例#5
0
 protected void OnApplicationRegistered(RegisteredApplication ra, bool existing)
 {
     if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
     {
         MethodInvoker invoker = new MethodInvoker(delegate()
         {
             OnApplicationRegistered(ra, existing);
         });
         this.synchronizingObject.Invoke(invoker, null);
     }
     else
     {
         if (this.ApplicationRegistered != null)
         {
             ApplicationRegisteredEventArgs args = new ApplicationRegisteredEventArgs(ra, existing);
             this.ApplicationRegistered(this, args);
         }
         SaveApplicationPrefs();
     }
 }