public ApplicationMain.Signal Process(string uri, ref List <InternalNotification> queuedNotifications, ref int signalValue) { // general format: growl:action*data1&data2&data3...etc // example: growl:display*http://www.somesite.org/display.xml // 09.22.2009 - changed protocol scheme from growl:// to just growl: because of a bug in Google Chrome: http://code.google.com/p/chromium/issues/detail?id=160 // the old syntax (with //) is still supported as well ApplicationMain.Signal result = 0; Regex regex = new Regex(@"growl:(//)?(?<Action>[^\*]*)\*(?<Data>[\s\S]*)"); Match match = regex.Match(uri); if (match.Success) { string action = match.Groups["Action"].Value.ToLower(); string data = match.Groups["Data"].Value; switch (action) { case "display": InstallDisplay id = new InstallDisplay(); using (id) { bool newDisplayLoaded = id.LaunchInstaller(data, this.appIsAlreadyRunning, ref queuedNotifications); if (newDisplayLoaded) { result = ApplicationMain.Signal.ReloadDisplays; } } id = null; break; case "extension": // this isnt a real use case yet break; case "language": InstallLanguage il = new InstallLanguage(); using (il) { bool languageInstalled = il.LaunchInstaller(data, this.appIsAlreadyRunning, ref queuedNotifications, ref signalValue); if (languageInstalled) { result = ApplicationMain.Signal.UpdateLanguage; } } il = null; break; case "languageelevatedinstall": InstallLanguage eil = new InstallLanguage(); using (eil) { bool languageInstalled = eil.FinishElevatedInstall(data, ref queuedNotifications, ref signalValue); if (languageInstalled) { result = ApplicationMain.Signal.UpdateLanguage; } } eil = null; break; case "forwarder": InstallForwarder ifwd = new InstallForwarder(); using (ifwd) { bool installed = ifwd.LaunchInstaller(data, this.appIsAlreadyRunning, ref queuedNotifications, ref signalValue); if (installed) { result = ApplicationMain.Signal.ReloadForwarders; } } ifwd = null; break; case "subscriber": InstallSubscriber isub = new InstallSubscriber(); using (isub) { bool installed = isub.LaunchInstaller(data, this.appIsAlreadyRunning, ref queuedNotifications, ref signalValue); if (installed) { result = ApplicationMain.Signal.ReloadSubscribers; } } isub = null; break; } } // go silent to suppress the 'Growl is running' notification if another event has occurred if (result > 0) { result = result | ApplicationMain.Signal.Silent; } return(result); }
internal void AlreadyRunning(int signalFlag, int signalValue) { ApplicationMain.Signal signal = (ApplicationMain.Signal)signalFlag; bool silent = ((signal & ApplicationMain.Signal.Silent) == ApplicationMain.Signal.Silent); bool reloadDisplays = ((signal & ApplicationMain.Signal.ReloadDisplays) == ApplicationMain.Signal.ReloadDisplays); bool updateLanguage = ((signal & ApplicationMain.Signal.UpdateLanguage) == ApplicationMain.Signal.UpdateLanguage); bool handleListenUrl = ((signal & ApplicationMain.Signal.HandleListenUrl) == ApplicationMain.Signal.HandleListenUrl); bool reloadForwarders = ((signal & ApplicationMain.Signal.ReloadForwarders) == ApplicationMain.Signal.ReloadForwarders); bool reloadSubscribers = ((signal & ApplicationMain.Signal.ReloadSubscribers) == ApplicationMain.Signal.ReloadSubscribers); bool showSettings = ((signal & ApplicationMain.Signal.ShowSettings) == ApplicationMain.Signal.ShowSettings); if (!silent && this.controller != null) { this.controller.SendSystemNotification(Properties.Resources.SystemNotification_Running_Title, Properties.Resources.SystemNotification_Running_Text, null); } if (reloadDisplays) { DisplayStyleManager.DiscoverNewDisplayPlugins(); //if(this.mainForm != null) this.mainForm.BindDisplayList(); } if (updateLanguage) { if (signalValue == 0) { Properties.Settings.Default.CultureCode = ""; } else { // read each subfolder in the app folder and find the one with the matching hash System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath); foreach (System.IO.DirectoryInfo directory in di.GetDirectories()) { if (directory.Name.GetHashCode() == signalValue) { Properties.Settings.Default.CultureCode = directory.Name; break; } } } } if (handleListenUrl) { HandleListenUrls(); } if (reloadForwarders) { ForwardDestinationManager.DiscoverNewPlugins(); /* NOTE: the signalValue should be the hash of the plugin folder that was loaded, * so we could loop through the folders looking for a matching has (similar to how * the updateLanguage section works above), but the DiscoverNewPlugins already * loops through the folders anyway, so we can just let it do its thing. */ } if (reloadSubscribers) { SubscriptionManager.DiscoverNewPlugins(); /* NOTE: the signalValue should be the hash of the plugin folder that was loaded, * so we could loop through the folders looking for a matching has (similar to how * the updateLanguage section works above), but the DiscoverNewPlugins already * loops through the folders anyway, so we can just let it do its thing. */ } if (showSettings) { this.ShowForm(); } }