Updates
[gmpc.git] / remote / main.c
blobf56687359cb5730dd978d4efbd22c0e246ab1cef
1 /*
2 * Copyright (C) 2004-2007 Qball Cow <qball@sarine.nl>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <gtk/gtk.h>
25 #include "bacon-message-connection.h"
28 int main ( int argc, char **argv )
30 BaconMessageConnection *bacon_connection = NULL;
32 gtk_init(&argc, &argv);
37 bacon_connection = bacon_message_connection_new("gmpc");
38 if(bacon_connection != NULL)
40 if (!bacon_message_connection_get_is_server (bacon_connection))
42 GError *error = NULL;
43 GOptionContext *context;
44 /* version */
45 gboolean version;
46 /* quit gmpc */
47 gboolean quit=FALSE;
48 /* play */
49 gboolean play=FALSE;
50 gboolean pause=FALSE;
51 gboolean prev=FALSE;
52 gboolean next=FALSE;
53 gboolean stop=FALSE;
55 GOptionEntry entries[] = {
57 "version", 0, 0, G_OPTION_ARG_NONE, &version,
58 "Print the version number and exit", NULL
61 "quit", 'q', 0, G_OPTION_ARG_NONE, &quit,
62 "Quit the running gmpc", NULL
65 "play", 'c', 0, G_OPTION_ARG_NONE, &play,
66 "Give the running gmpc the play command", NULL
69 "pause", 'v', 0, G_OPTION_ARG_NONE, &pause,
70 "Give the running gmpc the pause command", NULL
73 "next", 'b', 0, G_OPTION_ARG_NONE, &next,
74 "Give the running gmpc the next command", NULL
77 "prev", 'z', 0, G_OPTION_ARG_NONE, &prev,
78 "Give the running gmpc the prev command", NULL
81 "stop", 'x', 0, G_OPTION_ARG_NONE, &stop,
82 "Give the running gmpc the stop command", NULL
88 {NULL}
91 /*Create the commandline option parser */
92 context = g_option_context_new("GMPC remote program");
93 g_option_context_add_main_entries(context, entries, NULL);
95 /*Time to parse the options */
96 g_option_context_parse(context, &argc, &argv, &error);
97 g_option_context_free(context);
99 if(quit)
101 printf("send quit\n");
102 bacon_message_connection_send(bacon_connection, "QUIT");
104 if(play || pause)
106 printf("send play\n");
107 bacon_message_connection_send(bacon_connection, "PLAY");
109 if(prev)
111 printf("send prev\n");
112 bacon_message_connection_send(bacon_connection, "PREV");
114 if(next)
116 printf("send next\n");
117 bacon_message_connection_send(bacon_connection, "NEXT");
119 if(stop)
121 printf("send stop\n");
122 bacon_message_connection_send(bacon_connection, "STOP");
127 else {
128 printf("GMPC is not running\n");
129 bacon_message_connection_free (bacon_connection);
130 return EXIT_FAILURE;
133 return EXIT_SUCCESS;
135 return EXIT_FAILURE;