private static void HandleWindowCommands(bool present) { IClientWindow window = DBusServiceManager.FindInstance <IClientWindow> ("/ClientWindow"); if (window == null) { return; } foreach (KeyValuePair <string, string> arg in ApplicationContext.CommandLine.Arguments) { switch (arg.Key) { case "show": case "present": present = true; break; case "hide": present = false; window.Hide(); break; } } if (present && !ApplicationContext.CommandLine.Contains("no-present")) { window.Present(); } }
public static void Main() { if (!DBusConnection.ConnectTried) { DBusConnection.Connect(); } if (!DBusConnection.Enabled) { Error("All commands ignored, DBus support is disabled"); return; } else if (!DBusConnection.ApplicationInstanceAlreadyRunning) { Error("Banshee does not seem to be running"); return; } command = DBusServiceManager.FindInstance <DBusCommandService> ("/DBusCommandService"); hide_field = ApplicationContext.CommandLine.Contains("hide-field"); bool present = HandlePlayerCommands() && !ApplicationContext.CommandLine.Contains("indexer"); HandleWindowCommands(present); HandleFiles(); }
private static bool HandleGlobalUIActions() { var global_ui_actions = DBusServiceManager.FindInstance <IGlobalUIActions> ("/GlobalUIActions"); var handled = false; if (ApplicationContext.CommandLine.Contains("show-import-media")) { global_ui_actions.ShowImportDialog(); handled |= true; } if (ApplicationContext.CommandLine.Contains("show-about")) { global_ui_actions.ShowAboutDialog(); handled |= true; } if (ApplicationContext.CommandLine.Contains("show-preferences")) { global_ui_actions.ShowPreferencesDialog(); handled |= true; } if (ApplicationContext.CommandLine.Contains("show-open-location")) { global_ui_actions.ShowOpenLocationDialog(); handled |= true; } return(!handled); }
public static void Main() { Application.InitializePaths(); if (CheckHelpVersion()) { return; } if (DBusConnection.ApplicationInstanceAlreadyRunning) { // DBus Command/Query/File Proxy Client BootClient("Halie"); NotifyStartupComplete(); } else if (DBusConnection.NameHasOwner("CollectionIndexer")) { // Tell the existing indexer to start Banshee when it's done IIndexerClient indexer = DBusServiceManager.FindInstance <IIndexerClient> ("CollectionIndexer", "/IndexerClient"); try { indexer.Hello(); indexer.RebootWhenFinished(Environment.GetCommandLineArgs()); Log.Warning("The Banshee indexer is currently running. Banshee will be started when the indexer finishes."); } catch (Exception e) { Log.Exception("CollectionIndexer found on the Bus, but doesn't say Hello", e); } } else if (ApplicationContext.CommandLine.Contains("indexer")) { // Indexer Client BootClient("Beroe"); } else if (ApplicationContext.CommandLine.Contains("client")) { BootClient(Path.GetFileNameWithoutExtension(ApplicationContext.CommandLine["client"])); } else { if (PlatformDetection.IsMeeGo) { BootClient("MeeGo"); } else { BootClient("Nereid"); } } }
private ObjectPath MakeObjectPath(AbstractPlaylistSource playlist) { StringBuilder object_path_builder = new StringBuilder(); object_path_builder.Append(DBusServiceManager.ObjectRoot); if (playlist.Parent != null) { object_path_builder.AppendFormat("/{0}", DBusServiceManager.MakeDBusSafeString(playlist.Parent.TypeName)); } object_path_builder.Append("/Playlists/"); object_path_builder.Append(DBusServiceManager.MakeDBusSafeString(playlist.UniqueId)); string object_path = object_path_builder.ToString(); playlist_sources[object_path] = playlist; return(new ObjectPath(object_path)); }
private static bool HandlePlayerCommands() { IPlayerEngineService player = DBusServiceManager.FindInstance <IPlayerEngineService> ("/PlayerEngine"); IPlaybackControllerService controller = DBusServiceManager.FindInstance <IPlaybackControllerService> ("/PlaybackController"); IDictionary <string, object> track = null; int handled_count = 0; foreach (KeyValuePair <string, string> arg in ApplicationContext.CommandLine.Arguments) { handled_count++; switch (arg.Key) { // For the player engine case "play": player.Play(); break; case "pause": player.Pause(); break; case "stop": player.Close(); break; case "toggle-playing": player.TogglePlaying(); break; // For the playback controller case "first": controller.First(); break; case "next": controller.Next(ParseBool(arg.Value, "restart")); break; case "previous": controller.Previous(ParseBool(arg.Value, "restart")); break; case "stop-when-finished": controller.StopWhenFinished = !ParseBool(arg.Value); break; case "set-position": player.Position = (uint)Math.Round(Double.Parse(arg.Value) * 1000); break; case "set-volume": player.Volume = UInt16.Parse(arg.Value); break; default: if (arg.Key.StartsWith("query-")) { if (track == null) { try { track = player.CurrentTrack; } catch { } } HandleQuery(player, track, arg.Key.Substring(6)); } else { command.PushArgument(arg.Key, arg.Value ?? String.Empty); handled_count--; } break; } } return(handled_count <= 0); }