public MainWindow() { InitializeComponent(); appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Tlhan Ghun\\Paw\\"; appProgramPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); try { if (Properties.Settings.Default.useAutomaticUpdate) { Winkle.VersionCheck myUpdateChecker = new Winkle.VersionCheck("Paw", "http://tlhan-ghun.de/files/pawWinkle.xml"); Winkle.UpdateInfo myUpdateResponse = myUpdateChecker.checkForUpdate(System.Reflection.Assembly.GetExecutingAssembly(), true); Console.WriteLine("Update check done"); } } catch { } passwordManager = new PasswordManager(); registeredApps = new Dictionary <string, GrowlApplication>(); pawIconPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Paw.ico"; if (!System.IO.Directory.Exists(appDataPath)) { System.IO.Directory.CreateDirectory(appDataPath); } Growl.Connector.Application pawApp = new Growl.Connector.Application("Paw"); List <NotificationType> pawClasses = new List <NotificationType>(); pawClasses.Add(new NotificationType("General notifications")); pawClasses.Add(new NotificationType("Growl server messages")); pawClasses.Add(new NotificationType("Error messages")); pawApp.Icon = Growl.CoreLibrary.ImageConverter.ImageFromUrl(appProgramPath + "\\Paw.ico"); GrowlApplication comWindow = new GrowlApplication(pawApp, pawClasses); registeredApps.Add("Paw", comWindow); m_notifyIcon = new System.Windows.Forms.NotifyIcon(); m_notifyIcon.Text = "Paw - a GNTP to Snarl bridge"; m_notifyIcon.Icon = new System.Drawing.Icon(pawIconPath); m_notifyIcon.Click += new EventHandler(trayClick); m_notifyMenu = new System.Windows.Forms.ContextMenu(); m_notifyMenu.MenuItems.Add("Paw"); m_notifyMenu.MenuItems.Add("-"); m_notifyMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Start / stop", new System.EventHandler(trayStartStop))); m_notifyMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Preferences", new System.EventHandler(trayClick))); m_notifyMenu.MenuItems.Add("-"); m_notifyMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("Quit", new System.EventHandler(trayClose))); m_notifyIcon.ContextMenu = m_notifyMenu; }
private Response registerReceived(Growl.Connector.Application application, List <NotificationType> notificationTypes, RequestInfo requestInfo) { Response returnCode = new Response(); if (registeredApps.ContainsKey(application.Name.ToUpper())) { returnCode = new Response(ErrorCode.ALREADY_PROCESSED, "Already registered"); } else { GrowlApplication comWindow = new GrowlApplication(application, notificationTypes); registeredApps.Add(application.Name.ToUpper(), comWindow); } return(returnCode); }
private Response notificationReceived(Notification notification, CallbackInfo callbackInfo, RequestInfo requestInfo) { Response returnCode = new Response(); if (!registeredApps.ContainsKey(notification.ApplicationName.ToUpper())) { returnCode = new Response(ErrorCode.UNKNOWN_APPLICATION, "Application not registered"); SnarlConnector.ShowMessageEx("Error messages", "Growl notification from unregistered app", "The application " + notification.ApplicationName + " tried to send a notification without being registered", 10, pawIconPath, registeredApps["Paw"].windowHandle, Snarl.WindowsMessage.WM_USER + 24, ""); } else { bool deleteIcon = false; string iconPath = ""; iconPath = IconFetcher.getPathToIcon(notification); if (iconPath == "") { GrowlApplication thisApp = registeredApps[notification.ApplicationName.ToUpper()]; if (notification.Name != null) { if (thisApp.alertClassIcons.ContainsKey(notification.Name)) { iconPath = thisApp.alertClassIcons[notification.Name]; } } if (iconPath == "") { iconPath = registeredApps[notification.ApplicationName.ToUpper()].pathToIcon; } } else { deleteIcon = true; } SnarlConnector.ShowMessageEx(notification.Name, notification.Title, notification.Text, 10, iconPath, registeredApps[notification.ApplicationName.ToUpper()].windowHandle, Snarl.WindowsMessage.WM_USER + 24, ""); if (deleteIcon) { try { System.IO.File.Delete(iconPath); } catch { } } } return(returnCode); }