2008-08-01 13:15:40 +01:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
|
|
|
*
|
2008-11-11 10:13:24 -05:00
|
|
|
* Copyright (C) 2007 David Zeuthen <davidz@redhat.com>
|
2008-08-01 16:48:33 +01:00
|
|
|
* Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
|
2008-08-01 13:15:40 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <signal.h>
|
2010-02-05 10:37:32 +00:00
|
|
|
#include <sys/time.h>
|
2008-08-01 13:15:40 +01:00
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
|
2010-01-18 12:26:55 +00:00
|
|
|
#include "up-client.h"
|
|
|
|
|
#include "up-device.h"
|
|
|
|
|
#include "up-wakeups.h"
|
2009-01-23 17:14:02 +00:00
|
|
|
|
|
|
|
|
#include "egg-debug.h"
|
2008-08-05 17:26:35 +01:00
|
|
|
|
2008-08-01 13:15:40 +01:00
|
|
|
static GMainLoop *loop;
|
|
|
|
|
static gboolean opt_monitor_detail = FALSE;
|
|
|
|
|
|
2009-10-22 10:30:53 +01:00
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_get_timestamp:
|
2009-10-22 10:30:53 +01:00
|
|
|
**/
|
|
|
|
|
static gchar *
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_get_timestamp (void)
|
2009-10-22 10:30:53 +01:00
|
|
|
{
|
|
|
|
|
gchar *str_time;
|
|
|
|
|
gchar *timestamp;
|
|
|
|
|
time_t the_time;
|
|
|
|
|
struct timeval time_val;
|
|
|
|
|
|
|
|
|
|
time (&the_time);
|
|
|
|
|
gettimeofday (&time_val, NULL);
|
|
|
|
|
str_time = g_new0 (gchar, 255);
|
|
|
|
|
strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
|
|
|
|
|
|
|
|
|
|
/* generate header text */
|
|
|
|
|
timestamp = g_strdup_printf ("%s.%03i", str_time, (gint) time_val.tv_usec / 1000);
|
|
|
|
|
g_free (str_time);
|
|
|
|
|
return timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-01 13:15:40 +01:00
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_device_added_cb:
|
2008-08-01 13:15:40 +01:00
|
|
|
**/
|
|
|
|
|
static void
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_device_added_cb (UpClient *client, UpDevice *device, gpointer user_data)
|
2008-08-01 13:15:40 +01:00
|
|
|
{
|
2009-10-22 10:30:53 +01:00
|
|
|
gchar *timestamp;
|
2010-02-05 09:26:10 +00:00
|
|
|
gchar *text = NULL;
|
|
|
|
|
timestamp = up_tool_get_timestamp ();
|
|
|
|
|
g_print ("[%s]\tdevice added: %s\n", timestamp, up_device_get_object_path (device));
|
2008-08-01 13:15:40 +01:00
|
|
|
if (opt_monitor_detail) {
|
2010-02-05 09:26:10 +00:00
|
|
|
text = up_device_to_text (device);
|
|
|
|
|
g_print ("%s\n", text);
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
2009-10-22 10:30:53 +01:00
|
|
|
g_free (timestamp);
|
2010-02-05 09:26:10 +00:00
|
|
|
g_free (text);
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_device_changed_cb:
|
2008-08-01 13:15:40 +01:00
|
|
|
**/
|
|
|
|
|
static void
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_device_changed_cb (UpClient *client, UpDevice *device, gpointer user_data)
|
2008-08-01 13:15:40 +01:00
|
|
|
{
|
2009-10-22 10:30:53 +01:00
|
|
|
gchar *timestamp;
|
2010-02-05 09:26:10 +00:00
|
|
|
gchar *text = NULL;
|
|
|
|
|
timestamp = up_tool_get_timestamp ();
|
|
|
|
|
g_print ("[%s]\tdevice changed: %s\n", timestamp, up_device_get_object_path (device));
|
2008-08-01 13:15:40 +01:00
|
|
|
if (opt_monitor_detail) {
|
|
|
|
|
/* TODO: would be nice to just show the diff */
|
2010-02-05 09:26:10 +00:00
|
|
|
text = up_device_to_text (device);
|
|
|
|
|
g_print ("%s\n", text);
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
2009-10-22 10:30:53 +01:00
|
|
|
g_free (timestamp);
|
2010-02-05 09:26:10 +00:00
|
|
|
g_free (text);
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_device_removed_cb:
|
2008-08-01 13:15:40 +01:00
|
|
|
**/
|
|
|
|
|
static void
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_device_removed_cb (UpClient *client, UpDevice *device, gpointer user_data)
|
2008-08-01 13:15:40 +01:00
|
|
|
{
|
2009-10-22 10:30:53 +01:00
|
|
|
gchar *timestamp;
|
2010-02-05 09:26:10 +00:00
|
|
|
timestamp = up_tool_get_timestamp ();
|
|
|
|
|
g_print ("[%s]\tdevice removed: %s\n", timestamp, up_device_get_object_path (device));
|
2008-11-11 13:58:26 -05:00
|
|
|
if (opt_monitor_detail)
|
|
|
|
|
g_print ("\n");
|
2009-10-22 10:30:53 +01:00
|
|
|
g_free (timestamp);
|
2008-11-11 13:58:26 -05:00
|
|
|
}
|
|
|
|
|
|
2009-07-03 10:52:24 +01:00
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_client_print:
|
2009-07-03 10:52:24 +01:00
|
|
|
**/
|
2008-11-11 13:58:26 -05:00
|
|
|
static void
|
2010-02-05 09:26:10 +00:00
|
|
|
up_client_print (UpClient *client)
|
2008-11-11 13:58:26 -05:00
|
|
|
{
|
2009-07-03 10:52:24 +01:00
|
|
|
gchar *daemon_version;
|
|
|
|
|
gboolean can_suspend;
|
|
|
|
|
gboolean can_hibernate;
|
|
|
|
|
gboolean on_battery;
|
|
|
|
|
gboolean on_low_battery;
|
|
|
|
|
gboolean lid_is_closed;
|
|
|
|
|
gboolean lid_is_present;
|
|
|
|
|
|
|
|
|
|
g_object_get (client,
|
|
|
|
|
"daemon-version", &daemon_version,
|
|
|
|
|
"can-suspend", &can_suspend,
|
|
|
|
|
"can-hibernate", &can_hibernate,
|
|
|
|
|
"on-battery", &on_battery,
|
|
|
|
|
"on-low_battery", &on_low_battery,
|
|
|
|
|
"lid-is-closed", &lid_is_closed,
|
|
|
|
|
"lid-is-present", &lid_is_present,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
g_print (" daemon-version: %s\n", daemon_version);
|
|
|
|
|
g_print (" can-suspend: %s\n", can_suspend ? "yes" : "no");
|
|
|
|
|
g_print (" can-hibernate %s\n", can_hibernate ? "yes" : "no");
|
|
|
|
|
g_print (" on-battery: %s\n", on_battery ? "yes" : "no");
|
|
|
|
|
g_print (" on-low-battery: %s\n", on_low_battery ? "yes" : "no");
|
|
|
|
|
g_print (" lid-is-closed: %s\n", lid_is_closed ? "yes" : "no");
|
|
|
|
|
g_print (" lid-is-present: %s\n", lid_is_present ? "yes" : "no");
|
|
|
|
|
|
|
|
|
|
g_free (daemon_version);
|
2008-11-11 13:58:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_changed_cb:
|
2008-11-11 13:58:26 -05:00
|
|
|
**/
|
|
|
|
|
static void
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_changed_cb (UpClient *client, gpointer user_data)
|
2008-11-11 13:58:26 -05:00
|
|
|
{
|
2009-10-22 10:30:53 +01:00
|
|
|
gchar *timestamp;
|
2010-02-05 09:26:10 +00:00
|
|
|
timestamp = up_tool_get_timestamp ();
|
2009-10-22 10:30:53 +01:00
|
|
|
g_print ("[%s]\tdaemon changed:\n", timestamp);
|
2008-11-11 13:58:26 -05:00
|
|
|
if (opt_monitor_detail) {
|
2010-02-05 09:26:10 +00:00
|
|
|
up_client_print (client);
|
2008-11-11 13:58:26 -05:00
|
|
|
g_print ("\n");
|
|
|
|
|
}
|
2009-10-22 10:30:53 +01:00
|
|
|
g_free (timestamp);
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_do_monitor:
|
2008-08-01 13:15:40 +01:00
|
|
|
**/
|
|
|
|
|
static gboolean
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_do_monitor (UpClient *client)
|
2008-08-01 13:15:40 +01:00
|
|
|
{
|
|
|
|
|
g_print ("Monitoring activity from the power daemon. Press Ctrl+C to cancel.\n");
|
|
|
|
|
|
2010-02-05 09:26:10 +00:00
|
|
|
g_signal_connect (client, "device-added", G_CALLBACK (up_tool_device_added_cb), NULL);
|
|
|
|
|
g_signal_connect (client, "device-removed", G_CALLBACK (up_tool_device_removed_cb), NULL);
|
|
|
|
|
g_signal_connect (client, "device-changed", G_CALLBACK (up_tool_device_changed_cb), NULL);
|
|
|
|
|
g_signal_connect (client, "changed", G_CALLBACK (up_tool_changed_cb), NULL);
|
2008-08-05 17:26:35 +01:00
|
|
|
|
2008-08-01 13:15:40 +01:00
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-22 16:55:24 +01:00
|
|
|
/**
|
2010-02-05 09:26:10 +00:00
|
|
|
* up_tool_print_wakeup_item:
|
|
|
|
|
**/
|
|
|
|
|
static void
|
|
|
|
|
up_tool_print_wakeup_item (UpWakeupItem *item)
|
|
|
|
|
{
|
|
|
|
|
g_print ("userspace:%i id:%i, interrupts:%.1f, cmdline:%s, details:%s\n",
|
|
|
|
|
up_wakeup_item_get_is_userspace (item),
|
|
|
|
|
up_wakeup_item_get_id (item),
|
|
|
|
|
up_wakeup_item_get_value (item),
|
|
|
|
|
up_wakeup_item_get_cmdline (item),
|
|
|
|
|
up_wakeup_item_get_details (item));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* up_tool_show_wakeups:
|
2009-04-22 16:55:24 +01:00
|
|
|
**/
|
|
|
|
|
static gboolean
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_show_wakeups (void)
|
2009-04-22 16:55:24 +01:00
|
|
|
{
|
|
|
|
|
guint i;
|
|
|
|
|
gboolean ret;
|
2010-02-05 09:26:10 +00:00
|
|
|
UpWakeups *wakeups;
|
|
|
|
|
UpWakeupItem *item;
|
2009-04-22 16:55:24 +01:00
|
|
|
guint total;
|
|
|
|
|
GPtrArray *array;
|
|
|
|
|
|
|
|
|
|
/* create new object */
|
2010-02-05 09:26:10 +00:00
|
|
|
wakeups = up_wakeups_new ();
|
2009-04-22 16:55:24 +01:00
|
|
|
|
|
|
|
|
/* do we have support? */
|
2010-02-05 09:41:06 +00:00
|
|
|
ret = up_wakeups_get_has_capability (wakeups);
|
2009-04-22 16:55:24 +01:00
|
|
|
if (!ret) {
|
|
|
|
|
g_print ("No wakeup capability\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get total */
|
2010-02-05 09:41:06 +00:00
|
|
|
total = up_wakeups_get_total_sync (wakeups, NULL, NULL);
|
2009-04-22 16:55:24 +01:00
|
|
|
g_print ("Total wakeups per minute: %i\n", total);
|
|
|
|
|
|
|
|
|
|
/* get data */
|
2010-02-05 09:41:06 +00:00
|
|
|
array = up_wakeups_get_data_sync (wakeups, NULL, NULL);
|
2009-04-22 16:55:24 +01:00
|
|
|
if (array == NULL)
|
|
|
|
|
goto out;
|
|
|
|
|
g_print ("Wakeup sources:\n");
|
|
|
|
|
for (i=0; i<array->len; i++) {
|
2010-02-05 09:26:10 +00:00
|
|
|
item = g_ptr_array_index (array, i);
|
|
|
|
|
up_tool_print_wakeup_item (item);
|
2009-04-22 16:55:24 +01:00
|
|
|
}
|
2010-02-05 09:26:10 +00:00
|
|
|
g_ptr_array_unref (array);
|
2009-04-22 16:55:24 +01:00
|
|
|
out:
|
|
|
|
|
g_object_unref (wakeups);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-01 13:15:40 +01:00
|
|
|
/**
|
|
|
|
|
* main:
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
2009-09-11 14:37:51 +01:00
|
|
|
gint retval = EXIT_FAILURE;
|
2009-01-30 13:55:42 +00:00
|
|
|
guint i;
|
2008-08-01 13:15:40 +01:00
|
|
|
GOptionContext *context;
|
2008-08-04 11:54:15 +01:00
|
|
|
gboolean opt_dump = FALSE;
|
2009-01-30 13:55:42 +00:00
|
|
|
gboolean opt_wakeups = FALSE;
|
2008-08-06 06:58:45 +01:00
|
|
|
gboolean opt_enumerate = FALSE;
|
|
|
|
|
gboolean opt_monitor = FALSE;
|
|
|
|
|
gchar *opt_show_info = FALSE;
|
2008-11-11 13:58:26 -05:00
|
|
|
gboolean opt_version = FALSE;
|
2009-02-27 13:18:57 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
GError *error = NULL;
|
2010-02-05 09:26:10 +00:00
|
|
|
gchar *text = NULL;
|
2008-08-01 13:15:40 +01:00
|
|
|
|
2010-02-05 09:26:10 +00:00
|
|
|
UpClient *client;
|
|
|
|
|
UpDevice *device;
|
2008-08-05 17:26:35 +01:00
|
|
|
|
2008-08-01 13:15:40 +01:00
|
|
|
const GOptionEntry entries[] = {
|
2008-08-05 15:39:05 +01:00
|
|
|
{ "enumerate", 'e', 0, G_OPTION_ARG_NONE, &opt_enumerate, _("Enumerate objects paths for devices"), NULL },
|
2008-08-05 17:26:35 +01:00
|
|
|
{ "dump", 'd', 0, G_OPTION_ARG_NONE, &opt_dump, _("Dump all parameters for all objects"), NULL },
|
2009-01-30 13:55:42 +00:00
|
|
|
{ "wakeups", 'w', 0, G_OPTION_ARG_NONE, &opt_wakeups, _("Get the wakeup data"), NULL },
|
2008-08-05 17:26:35 +01:00
|
|
|
{ "monitor", 'm', 0, G_OPTION_ARG_NONE, &opt_monitor, _("Monitor activity from the power daemon"), NULL },
|
2008-08-01 13:15:40 +01:00
|
|
|
{ "monitor-detail", 0, 0, G_OPTION_ARG_NONE, &opt_monitor_detail, _("Monitor with detail"), NULL },
|
2008-08-05 17:26:35 +01:00
|
|
|
{ "show-info", 'i', 0, G_OPTION_ARG_STRING, &opt_show_info, _("Show information about object path"), NULL },
|
2008-11-12 09:58:36 +00:00
|
|
|
{ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, "Print version of client and daemon", NULL },
|
2008-08-01 13:15:40 +01:00
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
g_type_init ();
|
|
|
|
|
|
2010-02-05 05:26:32 +01:00
|
|
|
context = g_option_context_new ("UPower tool");
|
2008-08-01 13:15:40 +01:00
|
|
|
g_option_context_add_main_entries (context, entries, NULL);
|
2009-11-23 14:24:00 +00:00
|
|
|
g_option_context_add_group (context, egg_debug_get_option_group ());
|
2008-08-01 13:15:40 +01:00
|
|
|
g_option_context_parse (context, &argc, &argv, NULL);
|
|
|
|
|
g_option_context_free (context);
|
|
|
|
|
|
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
2010-02-05 09:26:10 +00:00
|
|
|
client = up_client_new ();
|
2008-08-01 13:15:40 +01:00
|
|
|
|
2008-11-11 13:58:26 -05:00
|
|
|
if (opt_version) {
|
2009-07-03 10:52:24 +01:00
|
|
|
gchar *daemon_version;
|
|
|
|
|
g_object_get (client,
|
|
|
|
|
"daemon-version", &daemon_version,
|
|
|
|
|
NULL);
|
2010-02-05 05:26:32 +01:00
|
|
|
g_print ("UPower client version %s\n"
|
|
|
|
|
"UPower daemon version %s\n",
|
2009-07-03 10:52:24 +01:00
|
|
|
PACKAGE_VERSION, daemon_version);
|
|
|
|
|
g_free (daemon_version);
|
2009-02-27 13:18:57 +00:00
|
|
|
retval = 0;
|
2008-11-11 13:58:26 -05:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-11 14:37:51 +01:00
|
|
|
/* wakeups */
|
2009-01-30 13:55:42 +00:00
|
|
|
if (opt_wakeups) {
|
2010-02-05 09:26:10 +00:00
|
|
|
up_tool_show_wakeups ();
|
2009-09-11 14:37:51 +01:00
|
|
|
retval = EXIT_SUCCESS;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opt_enumerate || opt_dump) {
|
2008-08-01 13:15:40 +01:00
|
|
|
GPtrArray *devices;
|
2010-02-05 09:41:06 +00:00
|
|
|
ret = up_client_enumerate_devices_sync (client, NULL, &error);
|
2010-02-05 09:26:10 +00:00
|
|
|
if (!ret) {
|
2009-04-01 09:15:04 +01:00
|
|
|
egg_warning ("failed to enumerate: %s", error->message);
|
2008-08-01 13:15:40 +01:00
|
|
|
goto out;
|
2009-04-01 09:15:04 +01:00
|
|
|
}
|
2010-02-05 09:26:10 +00:00
|
|
|
devices = up_client_get_devices (client);
|
2009-01-30 13:55:42 +00:00
|
|
|
for (i=0; i < devices->len; i++) {
|
2010-02-05 09:26:10 +00:00
|
|
|
device = (UpDevice*) g_ptr_array_index (devices, i);
|
2008-11-11 13:58:26 -05:00
|
|
|
if (opt_enumerate) {
|
2010-02-05 09:26:10 +00:00
|
|
|
g_print ("%s\n", up_device_get_object_path (device));
|
2008-11-11 13:58:26 -05:00
|
|
|
} else {
|
2010-02-05 09:26:10 +00:00
|
|
|
g_print ("Device: %s\n", up_device_get_object_path (device));
|
|
|
|
|
text = up_device_to_text (device);
|
|
|
|
|
g_print ("%s\n", text);
|
|
|
|
|
g_free (text);
|
2008-08-04 16:41:58 +01:00
|
|
|
}
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
2010-02-05 09:26:10 +00:00
|
|
|
g_ptr_array_unref (devices);
|
2008-11-11 13:58:26 -05:00
|
|
|
if (opt_dump) {
|
|
|
|
|
g_print ("Daemon:\n");
|
2010-02-05 09:26:10 +00:00
|
|
|
up_client_print (client);
|
2008-11-11 13:58:26 -05:00
|
|
|
}
|
2009-09-11 14:37:51 +01:00
|
|
|
retval = EXIT_SUCCESS;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opt_monitor || opt_monitor_detail) {
|
2010-03-26 11:15:45 +00:00
|
|
|
ret = up_client_enumerate_devices_sync (client, NULL, &error);
|
|
|
|
|
if (!ret) {
|
|
|
|
|
egg_warning ("failed to enumerate: %s", error->message);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2010-02-05 09:26:10 +00:00
|
|
|
if (!up_tool_do_monitor (client))
|
2008-08-01 13:15:40 +01:00
|
|
|
goto out;
|
2009-09-11 14:37:51 +01:00
|
|
|
retval = EXIT_SUCCESS;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opt_show_info != NULL) {
|
2010-02-05 09:26:10 +00:00
|
|
|
device = up_device_new ();
|
2010-02-05 09:41:06 +00:00
|
|
|
ret = up_device_set_object_path_sync (device, opt_show_info, NULL, &error);
|
2009-02-27 13:18:57 +00:00
|
|
|
if (!ret) {
|
|
|
|
|
g_print ("failed to set path: %s\n", error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
} else {
|
2010-02-05 09:26:10 +00:00
|
|
|
text = up_device_to_text (device);
|
|
|
|
|
g_print ("%s\n", text);
|
|
|
|
|
g_free (text);
|
2009-02-27 13:18:57 +00:00
|
|
|
}
|
2008-08-05 17:26:35 +01:00
|
|
|
g_object_unref (device);
|
2009-09-11 14:37:51 +01:00
|
|
|
retval = EXIT_SUCCESS;
|
|
|
|
|
goto out;
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|
|
|
|
|
out:
|
2008-08-05 17:26:35 +01:00
|
|
|
g_object_unref (client);
|
2009-02-27 13:18:57 +00:00
|
|
|
return retval;
|
2008-08-01 13:15:40 +01:00
|
|
|
}
|