2
* \file xvidcap-dbus-client.c
4
* This file contains a command line application for remote controlling
5
* xvidcap itself through dbus remote function calls.
10
* Copyright (C) 2004-07 Karl, Frankfurt
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
#ifndef DOXYGEN_SHOULD_SKIP_THIS
30
#endif // HAVE_CONFIG_H
31
#endif // DOXYGEN_SHOULD_SKIP_THIS
37
#include <dbus/dbus-glib-bindings.h>
39
#include "xvidcap-client-bindings.h"
40
#include "xvidcap-intl.h"
43
* \brief enumeration of types of actions supported to be used in a switch
53
* \brief displays command line usage
55
* @param prog a string containing the name of the program
60
printf (_("Usage: %s, ver %s, khb (c) 2003-07\n"), prog, VERSION);
63
("[--action #] action to perform (\"start\"|\"stop\"|\"pause\")\n"));
69
* \brief main function of the application to do the remote function invocation
71
* @return completion status
75
main (int argc, char *argv[])
77
// there's one one argument supported
78
struct option options[] = {
79
{"action", required_argument, NULL, 0}
85
DBusGConnection *connection;
88
while ((c = getopt_long (argc, argv, "v", options, &opt_index)) != -1) {
90
case 0: // it's a long option
93
if (strcasecmp (optarg, "start") == 0) {
94
action = ACTION_START;
95
} else if (strcasecmp (optarg, "stop") == 0) {
97
} else if (strcasecmp (optarg, "pause") == 0) {
98
action = ACTION_PAUSE;
110
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
111
if (connection == NULL) {
112
g_warning ("Unable to connect to dbus: %sn", error->message);
113
g_error_free (error);
114
// Basically here, there is a problem, since there is no dbus :)
116
// This won't trigger activation!
117
proxy = dbus_g_proxy_new_for_name (connection,
118
"net.jarre_de_the.Xvidcap",
119
"/net/jarre_de_the/Xvidcap",
120
"net.jarre_de_the.Xvidcap");
125
if (!net_jarre_de_the_Xvidcap_start (proxy, &error)) {
126
g_warning (_("Could not send start command to xvidcap: %s"),
128
g_error_free (error);
133
if (!net_jarre_de_the_Xvidcap_stop (proxy, &error)) {
134
g_warning (_("Could not send stop command to xvidcap: %s"),
136
g_error_free (error);
141
if (!net_jarre_de_the_Xvidcap_pause (proxy, &error)) {
142
g_warning (_("Could not pause/unpause xvidcap: %s"),
144
g_error_free (error);
150
g_object_unref (proxy);
152
// The DBusGConnection should never be unreffed, it lives once and is
153
// shared amongst the process