Port from EggDebug to the GLib built-in logging framework

This commit is contained in:
Richard Hughes 2010-11-01 11:28:31 +00:00
parent ed34986e08
commit 59893663fb
35 changed files with 240 additions and 860 deletions

View file

@ -5,5 +5,3 @@ policy/org.freedesktop.upower.policy.in
policy/org.freedesktop.upower.qos.policy.in policy/org.freedesktop.upower.qos.policy.in
src/up-main.c src/up-main.c
tools/up-tool.c tools/up-tool.c
src/egg-debug.c

View file

@ -1,2 +1 @@
tools/egg-debug.c

View file

@ -15,6 +15,7 @@ INCLUDES = \
-DG_UDEV_API_IS_SUBJECT_TO_CHANGE \ -DG_UDEV_API_IS_SUBJECT_TO_CHANGE \
-DUP_COMPILATION \ -DUP_COMPILATION \
-DUP_DISABLE_DEPRECATED \ -DUP_DISABLE_DEPRECATED \
-DG_LOG_DOMAIN=\"UPower\" \
-I$(top_srcdir)/libupower-glib \ -I$(top_srcdir)/libupower-glib \
-I$(top_srcdir) \ -I$(top_srcdir) \
$(GIO_CFLAGS) \ $(GIO_CFLAGS) \
@ -66,8 +67,6 @@ dbusif_DATA = \
org.freedesktop.UPower.Wakeups.xml org.freedesktop.UPower.Wakeups.xml
upowerd_SOURCES = \ upowerd_SOURCES = \
egg-debug.c \
egg-debug.h \
up-polkit.h \ up-polkit.h \
up-polkit.c \ up-polkit.c \
up-daemon.h \ up-daemon.h \
@ -91,7 +90,6 @@ upowerd_SOURCES = \
upowerd_CPPFLAGS = \ upowerd_CPPFLAGS = \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
-DG_LOG_DOMAIN=\"up-daemon\" \
$(AM_CPPFLAGS) $(AM_CPPFLAGS)
upowerd_LDADD = \ upowerd_LDADD = \
@ -130,8 +128,6 @@ check_PROGRAMS = \
up-self-test up-self-test
up_self_test_SOURCES = \ up_self_test_SOURCES = \
egg-debug.c \
egg-debug.h \
up-self-test.c \ up-self-test.c \
up-polkit.h \ up-polkit.h \
up-polkit.c \ up-polkit.c \

View file

@ -3,6 +3,7 @@
INCLUDES = \ INCLUDES = \
-I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(top_builddir)/src -I$(top_srcdir)/src \
-DUP_COMPILATION \ -DUP_COMPILATION \
-DG_LOG_DOMAIN=\"UPower-Dummy\" \
-I$(top_srcdir)/libupower-glib \ -I$(top_srcdir)/libupower-glib \
$(DBUS_GLIB_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \
$(POLKIT_CFLAGS) \ $(POLKIT_CFLAGS) \

View file

@ -27,8 +27,6 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <gio/gio.h> #include <gio/gio.h>
#include "egg-debug.h"
#include "up-backend.h" #include "up-backend.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-marshal.h" #include "up-marshal.h"
@ -93,7 +91,7 @@ up_backend_add_cb (UpBackend *backend)
/* coldplug */ /* coldplug */
ret = up_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native); ret = up_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native);
if (!ret) { if (!ret) {
egg_warning ("failed to coldplug"); g_warning ("failed to coldplug");
goto out; goto out;
} }

View file

@ -1,482 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2007-2009 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* SECTION:egg-debug
* @short_description: Debugging functions
*
* This file contains functions that can be used for debugging.
*/
#include "config.h"
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#include "egg-debug.h"
#define CONSOLE_RESET 0
#define CONSOLE_BLACK 30
#define CONSOLE_RED 31
#define CONSOLE_GREEN 32
#define CONSOLE_YELLOW 33
#define CONSOLE_BLUE 34
#define CONSOLE_MAGENTA 35
#define CONSOLE_CYAN 36
#define CONSOLE_WHITE 37
static gint _fd = -1;
static gboolean _verbose = FALSE;
static gboolean _console = FALSE;
static gchar *_log_filename = NULL;
static gboolean _initialized = FALSE;
static GPtrArray *_modules_array = NULL;
static GPtrArray *_functions_array = NULL;
static gchar **_modules = NULL;
static gchar **_functions = NULL;
/**
* egg_debug_filter_module:
**/
static gboolean
egg_debug_filter_module (const gchar *filename)
{
gchar *module;
const gchar *module_tmp;
guint i;
gboolean ret = FALSE;
/* nothing filtering */
if (_modules_array == NULL)
return FALSE;
/* are we in the filter list */
module = g_strdup (filename);
g_strdelimit (module, ".", '\0');
for (i=0; i<_modules_array->len; i++) {
module_tmp = g_ptr_array_index (_modules_array, i);
if (g_strcmp0 (module_tmp, module) == 0) {
ret = TRUE;
break;
}
}
return ret;
}
/**
* egg_debug_filter_function:
**/
static gboolean
egg_debug_filter_function (const gchar *function)
{
guint i;
const gchar *function_tmp;
gboolean ret = FALSE;
/* nothing filtering */
if (_functions_array == NULL)
return FALSE;
/* are we in the filter list */
for (i=0; i<_functions_array->len; i++) {
function_tmp = g_ptr_array_index (_functions_array, i);
if (g_str_has_prefix (function, function_tmp)) {
ret = TRUE;
break;
}
}
return ret;
}
/**
* egg_debug_set_console_mode:
**/
static void
egg_debug_set_console_mode (guint console_code)
{
gchar command[13];
/* don't put extra commands into logs */
if (!_console)
return;
/* Command is the control command to the terminal */
g_snprintf (command, 13, "%c[%dm", 0x1B, console_code);
printf ("%s", command);
}
/**
* egg_debug_backtrace:
**/
void
egg_debug_backtrace (void)
{
#ifdef HAVE_EXECINFO_H
void *call_stack[512];
int call_stack_size;
char **symbols;
int i = 1;
call_stack_size = backtrace (call_stack, G_N_ELEMENTS (call_stack));
symbols = backtrace_symbols (call_stack, call_stack_size);
if (symbols != NULL) {
egg_debug_set_console_mode (CONSOLE_RED);
g_print ("Traceback:\n");
while (i < call_stack_size) {
g_print ("\t%s\n", symbols[i]);
i++;
}
egg_debug_set_console_mode (CONSOLE_RESET);
free (symbols);
}
#endif
}
/**
* egg_debug_log_line:
**/
static void
egg_debug_log_line (const gchar *buffer)
{
ssize_t count;
/* open a file */
if (_fd == -1) {
/* ITS4: ignore, /var/log/foo is owned by root, and this is just debug text */
_fd = open (_log_filename, O_WRONLY|O_APPEND|O_CREAT, 0777);
if (_fd == -1)
g_error ("could not open log: '%s'", _log_filename);
}
/* ITS4: ignore, debug text always NULL terminated */
count = write (_fd, buffer, strlen (buffer));
if (count == -1)
g_warning ("could not write %s", buffer);
/* newline */
count = write (_fd, "\n", 1);
if (count == -1)
g_warning ("could not write newline");
}
/**
* egg_debug_print_line:
**/
static void
egg_debug_print_line (const gchar *func, const gchar *file, const int line, const gchar *buffer, guint color)
{
gchar *str_time;
gchar *header;
time_t the_time;
time (&the_time);
str_time = g_new0 (gchar, 255);
strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
/* generate header text */
header = g_strdup_printf ("TI:%s\tFI:%s\tFN:%s,%d", str_time, file, func, line);
g_free (str_time);
/* always in light green */
egg_debug_set_console_mode (CONSOLE_GREEN);
printf ("%s\n", header);
/* different colors according to the severity */
egg_debug_set_console_mode (color);
printf (" - %s\n", buffer);
egg_debug_set_console_mode (CONSOLE_RESET);
/* log to a file */
if (_log_filename != NULL) {
egg_debug_log_line (header);
egg_debug_log_line (buffer);
}
/* flush this output, as we need to debug */
fflush (stdout);
g_free (header);
}
/**
* egg_debug_real:
**/
void
egg_debug_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
{
va_list args;
gchar *buffer = NULL;
if (!_verbose && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
return;
va_start (args, format);
g_vasprintf (&buffer, format, args);
va_end (args);
egg_debug_print_line (func, file, line, buffer, CONSOLE_BLUE);
g_free (buffer);
}
/**
* egg_warning_real:
**/
void
egg_warning_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
{
va_list args;
gchar *buffer = NULL;
if (!_verbose && !egg_debug_filter_module (file) && !egg_debug_filter_function (func))
return;
va_start (args, format);
g_vasprintf (&buffer, format, args);
va_end (args);
/* do extra stuff for a warning */
if (!_console)
printf ("*** WARNING ***\n");
egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);
g_free (buffer);
}
/**
* egg_error_real:
**/
void
egg_error_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
{
va_list args;
gchar *buffer = NULL;
va_start (args, format);
g_vasprintf (&buffer, format, args);
va_end (args);
/* do extra stuff for a warning */
if (!_console)
printf ("*** ERROR ***\n");
egg_debug_print_line (func, file, line, buffer, CONSOLE_RED);
g_free (buffer);
/* we want to fix this! */
egg_debug_backtrace ();
exit (1);
}
/**
* egg_debug_is_verbose:
*
* Returns: TRUE if we have debugging enabled
**/
gboolean
egg_debug_is_verbose (void)
{
return _verbose;
}
/**
* egg_debug_set_log_filename:
**/
void
egg_debug_set_log_filename (const gchar *filename)
{
g_free (_log_filename);
_log_filename = g_strdup (filename);
}
/**
* egg_debug_strv_split_to_ptr_array:
**/
static GPtrArray *
egg_debug_strv_split_to_ptr_array (gchar **modules)
{
GPtrArray *array = NULL;
guint i, j;
gchar **split;
/* nothing */
if (modules == NULL)
goto out;
/* create array of strings */
array = g_ptr_array_new_with_free_func (g_free);
/* parse each --debug-foo option */
for (i=0; modules[i] != NULL; i++) {
/* use a comma to delimit multiple entries */
split = g_strsplit (modules[i], ",", -1);
for (j=0; split[j] != NULL; j++)
g_ptr_array_add (array, g_strdup (split[j]));
g_strfreev (split);
}
out:
return array;
}
/**
* egg_debug_pre_parse_hook:
*/
static gboolean
egg_debug_pre_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error)
{
const gchar *env_string;
const GOptionEntry main_entries[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose,
/* TRANSLATORS: turn on all debugging */
N_("Show debugging information for all files"), NULL },
{ NULL}
};
/* global variable */
env_string = g_getenv ("VERBOSE");
if (env_string != NULL)
_verbose = TRUE;
/* add main entry */
g_option_context_add_main_entries (context, main_entries, NULL);
return TRUE;
}
/**
* egg_debug_free:
**/
static void
egg_debug_free (void)
{
if (!_initialized)
return;
/* close file */
if (_fd != -1)
close (_fd);
/* free memory */
g_free (_log_filename);
if (_modules_array != NULL)
g_ptr_array_unref (_modules_array);
if (_functions_array != NULL)
g_ptr_array_unref (_functions_array);
g_strfreev (_modules);
g_strfreev (_functions);
/* can not re-init */
_initialized = FALSE;
}
/**
* egg_debug_post_parse_hook:
*/
static gboolean
egg_debug_post_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error)
{
_initialized = TRUE;
_modules_array = egg_debug_strv_split_to_ptr_array (_modules);
_functions_array = egg_debug_strv_split_to_ptr_array (_functions);
_console = (isatty (fileno (stdout)) == 1);
egg_debug ("Verbose debugging %i (on console %i)", _verbose, _console);
/* run this function on cleanup */
atexit (egg_debug_free);
return TRUE;
}
/**
* egg_debug_get_option_group:
*
* Returns a #GOptionGroup for the commandline arguments recognized
* by debugging. You should add this group to your #GOptionContext
* with g_option_context_add_group(), if you are using
* g_option_context_parse() to parse your commandline arguments.
*
* Returns: a #GOptionGroup for the commandline arguments
*/
GOptionGroup *
egg_debug_get_option_group (void)
{
GOptionGroup *group;
const GOptionEntry debug_entries[] = {
{ "debug-modules", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &_modules,
/* TRANSLATORS: a list of modules to debug */
N_("Debug these specific modules"), NULL },
{ "debug-functions", '\0', 0, G_OPTION_ARG_STRING_ARRAY, &_functions,
/* TRANSLATORS: a list of functions to debug */
N_("Debug these specific functions"), NULL },
{ "debug-log-filename", '\0', 0, G_OPTION_ARG_STRING, &_log_filename,
/* TRANSLATORS: save to a log */
N_("Log debugging data to a file"), NULL },
{ NULL}
};
group = g_option_group_new ("debug", _("Debugging Options"), _("Show debugging options"), NULL, NULL);
g_option_group_set_parse_hooks (group, egg_debug_pre_parse_hook, egg_debug_post_parse_hook);
g_option_group_add_entries (group, debug_entries);
return group;
}
/**
* egg_debug_init:
* @argc: a pointer to the number of command line arguments.
* @argv: a pointer to the array of command line arguments.
*
* Parses command line arguments.
*
* Return value: %TRUE if initialization succeeded, otherwise %FALSE.
**/
gboolean
egg_debug_init (gint *argc, gchar ***argv)
{
GOptionContext *context;
/* already initialized */
if (_initialized)
return TRUE;
context = g_option_context_new (NULL);
g_option_context_set_ignore_unknown_options (context, TRUE);
g_option_context_add_group (context, egg_debug_get_option_group ());
g_option_context_parse (context, argc, argv, NULL);
g_option_context_free (context);
return TRUE;
}

View file

@ -1,83 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2007-2009 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __EGG_DEBUG_H
#define __EGG_DEBUG_H
#include <stdarg.h>
#include <glib.h>
G_BEGIN_DECLS
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/**
* egg_debug:
*
* Non critical debugging
*/
#define egg_debug(...) egg_debug_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
/**
* egg_warning:
*
* Important debugging
*/
#define egg_warning(...) egg_warning_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
/**
* egg_error:
*
* Critical debugging, with exit
*/
#define egg_error(...) egg_error_real (__func__, __FILE__, __LINE__, __VA_ARGS__)
#elif defined(__GNUC__) && __GNUC__ >= 3
#define egg_debug(...) egg_debug_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define egg_warning(...) egg_warning_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define egg_error(...) egg_error_real (__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#else
#define egg_debug(...)
#define egg_warning(...)
#define egg_error(...)
#endif
gboolean egg_debug_init (gint *argc,
gchar ***argv);
GOptionGroup *egg_debug_get_option_group (void);
gboolean egg_debug_is_verbose (void);
void egg_debug_backtrace (void);
void egg_debug_set_log_filename (const gchar *filename);
void egg_debug_real (const gchar *func,
const gchar *file,
gint line,
const gchar *format, ...) __attribute__((format (printf,4,5)));
void egg_warning_real (const gchar *func,
const gchar *file,
gint line,
const gchar *format, ...) __attribute__((format (printf,4,5)));
void egg_error_real (const gchar *func,
const gchar *file,
gint line,
const gchar *format, ...) G_GNUC_NORETURN __attribute__((format (printf,4,5)));
G_END_DECLS
#endif /* __EGG_DEBUG_H */

View file

@ -3,6 +3,7 @@
INCLUDES = \ INCLUDES = \
-I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(top_builddir)/src -I$(top_srcdir)/src \
-DUP_COMPILATION \ -DUP_COMPILATION \
-DG_LOG_DOMAIN=\"UPower-Freebsd\" \
-I$(top_srcdir)/libupower-glib \ -I$(top_srcdir)/libupower-glib \
$(DBUS_GLIB_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \
$(POLKIT_CFLAGS) \ $(POLKIT_CFLAGS) \

View file

@ -38,8 +38,6 @@
#include "up-device-supply.h" #include "up-device-supply.h"
#include "up-util.h" #include "up-util.h"
#include "egg-debug.h"
#include "up-backend.h" #include "up-backend.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-marshal.h" #include "up-marshal.h"
@ -151,7 +149,7 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha
g_object_get (backend->priv->daemon, g_object_get (backend->priv->daemon,
"lid-is-present", &is_present, NULL); "lid-is-present", &is_present, NULL);
if (!is_present) { if (!is_present) {
egg_warning ("received lid event without a configured lid; cold-plugging one"); g_warning ("received lid event without a configured lid; cold-plugging one");
up_backend_lid_coldplug (backend); up_backend_lid_coldplug (backend);
/* FALLTHROUGH */ /* FALLTHROUGH */
} }
@ -165,7 +163,7 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha
goto out; goto out;
if (object == NULL) { if (object == NULL) {
egg_warning ("did not find existing %s device; cold-plugging a new one", subsystem); g_warning ("did not find existing %s device; cold-plugging a new one", subsystem);
up_backend_create_new_device (backend, native); up_backend_create_new_device (backend, native);
goto out; goto out;
} }
@ -266,7 +264,7 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native)); object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object != NULL) { if (object != NULL) {
device = UP_DEVICE (object); device = UP_DEVICE (object);
egg_warning ("treating add event as change event on %s", up_device_get_object_path (device)); g_warning ("treating add event as change event on %s", up_device_get_object_path (device));
up_device_refresh_internal (device); up_device_refresh_internal (device);
} else { } else {
up_backend_create_new_device (backend, native); up_backend_create_new_device (backend, native);
@ -365,7 +363,7 @@ up_backend_get_used_swap (UpBackend *backend)
kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf); kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
if (kd == NULL) { if (kd == NULL) {
egg_warning ("failed to open kvm: '%s'", errbuf); g_warning ("failed to open kvm: '%s'", errbuf);
return 0.0f; return 0.0f;
} }
@ -375,7 +373,7 @@ up_backend_get_used_swap (UpBackend *backend)
goto out; goto out;
} }
if (nswdev < 0) { if (nswdev < 0) {
egg_warning ("failed to get swap info: '%s'", kvm_geterr (kd)); g_warning ("failed to get swap info: '%s'", kvm_geterr (kd));
percent = 0.0f; percent = 0.0f;
goto out; goto out;
} }

View file

@ -30,8 +30,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include "egg-debug.h"
#include "up-backend.h" #include "up-backend.h"
#include "up-backend-acpi.h" #include "up-backend-acpi.h"
#include "up-devd.h" #include "up-devd.h"
@ -148,7 +146,7 @@ up_devd_process_event (const gchar *event, gpointer user_data)
backend = UP_BACKEND(user_data); backend = UP_BACKEND(user_data);
egg_debug("received devd event: '%s'", event); g_debug("received devd event: '%s'", event);
switch (event[0]) { switch (event[0]) {
case UP_DEVD_EVENT_ADD: case UP_DEVD_EVENT_ADD:
@ -180,7 +178,7 @@ up_devd_process_event (const gchar *event, gpointer user_data)
} }
malformed: malformed:
egg_warning("malformed devd event: %s", event); g_warning("malformed devd event: %s", event);
} }
static gboolean static gboolean
@ -221,7 +219,7 @@ up_devd_init (UpBackend *backend)
event_fd = socket(PF_UNIX, SOCK_STREAM, 0); event_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (event_fd < 0) { if (event_fd < 0) {
egg_warning("failed to create event socket: '%s'", g_strerror(errno)); g_warning("failed to create event socket: '%s'", g_strerror(errno));
up_devd_inited = FALSE; up_devd_inited = FALSE;
return; return;
} }
@ -236,7 +234,7 @@ up_devd_init (UpBackend *backend)
g_io_channel_unref (channel); g_io_channel_unref (channel);
up_devd_inited = TRUE; up_devd_inited = TRUE;
} else { } else {
egg_warning ("failed to connect to %s: '%s'", UP_DEVD_SOCK_PATH, g_warning ("failed to connect to %s: '%s'", UP_DEVD_SOCK_PATH,
g_strerror(errno)); g_strerror(errno));
close (event_fd); close (event_fd);
up_devd_inited = FALSE; up_devd_inited = FALSE;

View file

@ -40,8 +40,6 @@
#include "up-acpi-native.h" #include "up-acpi-native.h"
#include "up-util.h" #include "up-util.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-supply.h" #include "up-device-supply.h"
@ -175,22 +173,22 @@ up_device_supply_battery_set_properties (UpDevice *device, UpAcpiNative *native)
up_acpi_native_get_unit (native); up_acpi_native_get_unit (native);
fd = open (UP_ACPIDEV, O_RDONLY); fd = open (UP_ACPIDEV, O_RDONLY);
if (fd < 0) { if (fd < 0) {
egg_warning ("unable to open %s: '%s'", UP_ACPIDEV, g_strerror (errno)); g_warning ("unable to open %s: '%s'", UP_ACPIDEV, g_strerror (errno));
return FALSE; return FALSE;
} }
if (ioctl (fd, ACPIIO_BATT_GET_BIF, &battif) == -1) { if (ioctl (fd, ACPIIO_BATT_GET_BIF, &battif) == -1) {
egg_warning ("ioctl ACPIIO_BATT_GET_BIF failed for battery %d: '%s'", battif.unit, g_strerror (errno)); g_warning ("ioctl ACPIIO_BATT_GET_BIF failed for battery %d: '%s'", battif.unit, g_strerror (errno));
goto end; goto end;
} }
if (ioctl (fd, ACPIIO_BATT_GET_BST, &battst) == -1) { if (ioctl (fd, ACPIIO_BATT_GET_BST, &battst) == -1) {
egg_warning ("ioctl ACPIIO_BATT_GET_BST failed for battery %d: '%s'", battst.unit, g_strerror (errno)); g_warning ("ioctl ACPIIO_BATT_GET_BST failed for battery %d: '%s'", battst.unit, g_strerror (errno));
goto end; goto end;
} }
if (ioctl (fd, ACPIIO_BATT_GET_BATTINFO, &battinfo) == -1) { if (ioctl (fd, ACPIIO_BATT_GET_BATTINFO, &battinfo) == -1) {
egg_warning ("ioctl ACPIIO_BATT_GET_BATTINFO failed for battery %d: '%s'", battinfo.unit, g_strerror (errno)); g_warning ("ioctl ACPIIO_BATT_GET_BATTINFO failed for battery %d: '%s'", battinfo.unit, g_strerror (errno));
goto end; goto end;
} }
@ -356,7 +354,7 @@ up_device_supply_coldplug (UpDevice *device)
native_path = up_acpi_native_get_path (native); native_path = up_acpi_native_get_path (native);
driver = up_acpi_native_get_driver (native); driver = up_acpi_native_get_driver (native);
if (native_path == NULL) { if (native_path == NULL) {
egg_warning ("could not get native path for %p", device); g_warning ("could not get native path for %p", device);
goto out; goto out;
} }
@ -370,7 +368,7 @@ up_device_supply_coldplug (UpDevice *device)
goto out; goto out;
} }
egg_warning ("invalid device %s with driver %s", native_path, driver); g_warning ("invalid device %s with driver %s", native_path, driver);
out: out:
return ret; return ret;

View file

@ -29,8 +29,6 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <glib.h> #include <glib.h>
#include "egg-debug.h"
#include "up-util.h" #include "up-util.h"
gboolean gboolean
@ -133,7 +131,7 @@ up_make_safe_string (const gchar *text)
ret[idx] = ret[i]; ret[idx] = ret[i];
idx++; idx++;
} else { } else {
egg_debug ("invalid char '%c'", ret[i]); g_debug ("invalid char '%c'", ret[i]);
} }
} }

View file

@ -4,6 +4,7 @@ INCLUDES = \
-I$(top_builddir)/src -I$(top_srcdir)/src \ -I$(top_builddir)/src -I$(top_srcdir)/src \
-DUP_COMPILATION \ -DUP_COMPILATION \
-DG_UDEV_API_IS_SUBJECT_TO_CHANGE \ -DG_UDEV_API_IS_SUBJECT_TO_CHANGE \
-DG_LOG_DOMAIN=\"UPower-Linux\" \
-I$(top_srcdir)/libupower-glib \ -I$(top_srcdir)/libupower-glib \
$(USB_CFLAGS) \ $(USB_CFLAGS) \
$(GIO_CFLAGS) \ $(GIO_CFLAGS) \

View file

@ -215,19 +215,19 @@ sysfs_resolve_link (const char *dir, const char *attribute)
full_path = g_build_filename (dir, attribute, NULL); full_path = g_build_filename (dir, attribute, NULL);
//egg_warning ("attribute='%s'", attribute); //g_warning ("attribute='%s'", attribute);
//egg_warning ("full_path='%s'", full_path); //g_warning ("full_path='%s'", full_path);
num = readlink (full_path, link_path, sizeof (link_path) - 1); num = readlink (full_path, link_path, sizeof (link_path) - 1);
if (num != -1) { if (num != -1) {
char *absolute_path; char *absolute_path;
link_path[num] = '\0'; link_path[num] = '\0';
//egg_warning ("link_path='%s'", link_path); //g_warning ("link_path='%s'", link_path);
absolute_path = g_build_filename (dir, link_path, NULL); absolute_path = g_build_filename (dir, link_path, NULL);
//egg_warning ("absolute_path='%s'", absolute_path); //g_warning ("absolute_path='%s'", absolute_path);
if (realpath (absolute_path, resolved_path) != NULL) { if (realpath (absolute_path, resolved_path) != NULL) {
//egg_warning ("resolved_path='%s'", resolved_path); //g_warning ("resolved_path='%s'", resolved_path);
found_it = TRUE; found_it = TRUE;
} }
g_free (absolute_path); g_free (absolute_path);

View file

@ -29,8 +29,6 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gudev/gudev.h> #include <gudev/gudev.h>
#include "egg-debug.h"
#include "up-backend.h" #include "up-backend.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-marshal.h" #include "up-marshal.h"
@ -163,7 +161,7 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native)
} else { } else {
native_path = g_udev_device_get_sysfs_path (native); native_path = g_udev_device_get_sysfs_path (native);
egg_warning ("native path %s (%s) ignoring", native_path, subsys); g_warning ("native path %s (%s) ignoring", native_path, subsys);
} }
out: out:
return device; return device;
@ -182,7 +180,7 @@ up_backend_device_changed (UpBackend *backend, GUdevDevice *native)
/* first, check the device and add it if it doesn't exist */ /* first, check the device and add it if it doesn't exist */
object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native)); object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object == NULL) { if (object == NULL) {
egg_warning ("treating change event as add on %s", g_udev_device_get_sysfs_path (native)); g_warning ("treating change event as add on %s", g_udev_device_get_sysfs_path (native));
up_backend_device_add (backend, native); up_backend_device_add (backend, native);
goto out; goto out;
} }
@ -191,7 +189,7 @@ up_backend_device_changed (UpBackend *backend, GUdevDevice *native)
device = UP_DEVICE (object); device = UP_DEVICE (object);
ret = up_device_refresh_internal (device); ret = up_device_refresh_internal (device);
if (!ret) { if (!ret) {
egg_debug ("no changes on %s", up_device_get_object_path (device)); g_debug ("no changes on %s", up_device_get_object_path (device));
goto out; goto out;
} }
out: out:
@ -214,7 +212,7 @@ up_backend_device_add (UpBackend *backend, GUdevDevice *native)
if (object != NULL) { if (object != NULL) {
device = UP_DEVICE (object); device = UP_DEVICE (object);
/* we already have the device; treat as change event */ /* we already have the device; treat as change event */
egg_warning ("treating add event as change event on %s", up_device_get_object_path (device)); g_warning ("treating add event as change event on %s", up_device_get_object_path (device));
up_backend_device_changed (backend, native); up_backend_device_changed (backend, native);
goto out; goto out;
} }
@ -246,13 +244,13 @@ up_backend_device_remove (UpBackend *backend, GUdevDevice *native)
/* does device exist in db? */ /* does device exist in db? */
object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native)); object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object == NULL) { if (object == NULL) {
egg_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (native)); g_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (native));
goto out; goto out;
} }
device = UP_DEVICE (object); device = UP_DEVICE (object);
/* emit */ /* emit */
egg_debug ("emitting device-removed: %s", g_udev_device_get_sysfs_path (native)); g_debug ("emitting device-removed: %s", g_udev_device_get_sysfs_path (native));
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, native, device); g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, native, device);
out: out:
@ -270,16 +268,16 @@ up_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
UpBackend *backend = UP_BACKEND (user_data); UpBackend *backend = UP_BACKEND (user_data);
if (g_strcmp0 (action, "add") == 0) { if (g_strcmp0 (action, "add") == 0) {
egg_debug ("SYSFS add %s", g_udev_device_get_sysfs_path (device)); g_debug ("SYSFS add %s", g_udev_device_get_sysfs_path (device));
up_backend_device_add (backend, device); up_backend_device_add (backend, device);
} else if (g_strcmp0 (action, "remove") == 0) { } else if (g_strcmp0 (action, "remove") == 0) {
egg_debug ("SYSFS remove %s", g_udev_device_get_sysfs_path (device)); g_debug ("SYSFS remove %s", g_udev_device_get_sysfs_path (device));
up_backend_device_remove (backend, device); up_backend_device_remove (backend, device);
} else if (g_strcmp0 (action, "change") == 0) { } else if (g_strcmp0 (action, "change") == 0) {
egg_debug ("SYSFS change %s", g_udev_device_get_sysfs_path (device)); g_debug ("SYSFS change %s", g_udev_device_get_sysfs_path (device));
up_backend_device_changed (backend, device); up_backend_device_changed (backend, device);
} else { } else {
egg_warning ("unhandled action '%s' on %s", action, g_udev_device_get_sysfs_path (device)); g_warning ("unhandled action '%s' on %s", action, g_udev_device_get_sysfs_path (device));
} }
} }
@ -310,7 +308,7 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
/* add all subsystems */ /* add all subsystems */
for (i=0; subsystems[i] != NULL; i++) { for (i=0; subsystems[i] != NULL; i++) {
egg_debug ("registering subsystem : %s", subsystems[i]); g_debug ("registering subsystem : %s", subsystems[i]);
devices = g_udev_client_query_by_subsystem (backend->priv->gudev_client, subsystems[i]); devices = g_udev_client_query_by_subsystem (backend->priv->gudev_client, subsystems[i]);
for (l = devices; l != NULL; l = l->next) { for (l = devices; l != NULL; l = l->next) {
native = l->data; native = l->data;
@ -338,10 +336,10 @@ up_backend_supports_sleep_state (const gchar *state)
/* run script from pm-utils */ /* run script from pm-utils */
command = g_strdup_printf ("/usr/bin/pm-is-supported --%s", state); command = g_strdup_printf ("/usr/bin/pm-is-supported --%s", state);
egg_debug ("excuting command: %s", command); g_debug ("excuting command: %s", command);
ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error); ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to run script: %s", error->message); g_warning ("failed to run script: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -402,7 +400,7 @@ up_backend_has_encrypted_swap (UpBackend *backend)
/* get swaps data */ /* get swaps data */
ret = g_file_get_contents (filename_swaps, &contents_swaps, NULL, &error); ret = g_file_get_contents (filename_swaps, &contents_swaps, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to open %s: %s", filename_swaps, error->message); g_warning ("failed to open %s: %s", filename_swaps, error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -410,7 +408,7 @@ up_backend_has_encrypted_swap (UpBackend *backend)
/* get crypttab data */ /* get crypttab data */
ret = g_file_get_contents (filename_crypttab, &contents_crypttab, NULL, &error); ret = g_file_get_contents (filename_crypttab, &contents_crypttab, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to open %s: %s", filename_crypttab, error->message); g_warning ("failed to open %s: %s", filename_crypttab, error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -432,13 +430,13 @@ up_backend_has_encrypted_swap (UpBackend *backend)
/* add base device to list */ /* add base device to list */
device = g_path_get_basename (lines_swaps[i]); device = g_path_get_basename (lines_swaps[i]);
egg_debug ("adding swap device: %s", device); g_debug ("adding swap device: %s", device);
g_ptr_array_add (devices, device); g_ptr_array_add (devices, device);
} }
/* no swap devices? */ /* no swap devices? */
if (devices->len == 0) { if (devices->len == 0) {
egg_debug ("no swap devices"); g_debug ("no swap devices");
goto out; goto out;
} }
@ -459,11 +457,11 @@ up_backend_has_encrypted_swap (UpBackend *backend)
for (j=0; j<devices->len; j++) { for (j=0; j<devices->len; j++) {
device = g_ptr_array_index (devices, j); device = g_ptr_array_index (devices, j);
if (g_strcmp0 (device, lines_crypttab[i]) == 0) { if (g_strcmp0 (device, lines_crypttab[i]) == 0) {
egg_debug ("swap device %s is encrypted (so cannot hibernate)", device); g_debug ("swap device %s is encrypted (so cannot hibernate)", device);
encrypted_swap = TRUE; encrypted_swap = TRUE;
goto out; goto out;
} }
egg_debug ("swap device %s is not encrypted (allows hibernate)", device); g_debug ("swap device %s is not encrypted (allows hibernate)", device);
} }
} }
@ -502,7 +500,7 @@ up_backend_get_used_swap (UpBackend *backend)
/* get memory data */ /* get memory data */
ret = g_file_get_contents (filename, &contents, NULL, &error); ret = g_file_get_contents (filename, &contents, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to open %s: %s", filename, error->message); g_warning ("failed to open %s: %s", filename, error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -525,7 +523,7 @@ up_backend_get_used_swap (UpBackend *backend)
/* first check if we even have swap, if not consider all swap space used */ /* first check if we even have swap, if not consider all swap space used */
if (swap_total == 0) { if (swap_total == 0) {
egg_debug ("no swap space found"); g_debug ("no swap space found");
percentage = 100.0f; percentage = 100.0f;
goto out; goto out;
} }
@ -533,7 +531,7 @@ up_backend_get_used_swap (UpBackend *backend)
/* work out how close to the line we are */ /* work out how close to the line we are */
if (swap_free > 0 && active > 0) if (swap_free > 0 && active > 0)
percentage = (active * 100) / swap_free; percentage = (active * 100) / swap_free;
egg_debug ("total swap available %i kb, active memory %i kb (%.1f%%)", swap_free, active, percentage); g_debug ("total swap available %i kb, active memory %i kb (%.1f%%)", swap_free, active, percentage);
out: out:
g_free (contents); g_free (contents);
g_strfreev (lines); g_strfreev (lines);

View file

@ -35,8 +35,6 @@
#include <libusb.h> #include <libusb.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-csr.h" #include "up-device-csr.h"
@ -76,7 +74,7 @@ up_device_csr_poll_cb (UpDeviceCsr *csr)
{ {
UpDevice *device = UP_DEVICE (csr); UpDevice *device = UP_DEVICE (csr);
egg_debug ("Polling: %s", up_device_get_object_path (device)); g_debug ("Polling: %s", up_device_get_object_path (device));
up_device_csr_refresh (device); up_device_csr_refresh (device);
/* always continue polling */ /* always continue polling */
@ -96,19 +94,19 @@ up_device_csr_find_device (UpDeviceCsr *csr)
guint i; guint i;
ssize_t cnt; ssize_t cnt;
egg_debug ("Looking for: [%03d][%03d]", csr->priv->bus_num, csr->priv->dev_num); g_debug ("Looking for: [%03d][%03d]", csr->priv->bus_num, csr->priv->dev_num);
/* try to find the right device */ /* try to find the right device */
cnt = libusb_get_device_list (csr->priv->ctx, &devices); cnt = libusb_get_device_list (csr->priv->ctx, &devices);
if (cnt < 0) { if (cnt < 0) {
/* need to depend on > libusb1-1.0.9 for libusb_strerror() /* need to depend on > libusb1-1.0.9 for libusb_strerror()
egg_warning ("failed to get device list: %s", libusb_strerror (cnt)); g_warning ("failed to get device list: %s", libusb_strerror (cnt));
*/ */
egg_warning ("failed to get device list: %d", (int)cnt); g_warning ("failed to get device list: %d", (int)cnt);
goto out; goto out;
} }
if (devices == NULL) { if (devices == NULL) {
egg_warning ("failed to get device list"); g_warning ("failed to get device list");
goto out; goto out;
} }
for (i=0; devices[i] != NULL; i++) { for (i=0; devices[i] != NULL; i++) {
@ -155,7 +153,7 @@ up_device_csr_coldplug (UpDevice *device)
else if (g_strcmp0 (type, "keyboard") == 0) else if (g_strcmp0 (type, "keyboard") == 0)
g_object_set (device, "type", UP_DEVICE_KIND_KEYBOARD, NULL); g_object_set (device, "type", UP_DEVICE_KIND_KEYBOARD, NULL);
else { else {
egg_debug ("not a recognised csr device"); g_debug ("not a recognised csr device");
goto out; goto out;
} }
@ -166,14 +164,14 @@ up_device_csr_coldplug (UpDevice *device)
/* get correct bus numbers? */ /* get correct bus numbers? */
if (csr->priv->bus_num == 0 || csr->priv->dev_num == 0) { if (csr->priv->bus_num == 0 || csr->priv->dev_num == 0) {
egg_warning ("unable to get bus or device numbers"); g_warning ("unable to get bus or device numbers");
goto out; goto out;
} }
/* try to get the usb device */ /* try to get the usb device */
csr->priv->device = up_device_csr_find_device (csr); csr->priv->device = up_device_csr_find_device (csr);
if (csr->priv->device == NULL) { if (csr->priv->device == NULL) {
egg_debug ("failed to get device %p", csr); g_debug ("failed to get device %p", csr);
goto out; goto out;
} }
@ -181,7 +179,7 @@ up_device_csr_coldplug (UpDevice *device)
ret = g_udev_device_has_property (native, "UPOWER_CSR_DUAL"); ret = g_udev_device_has_property (native, "UPOWER_CSR_DUAL");
if (ret) if (ret)
csr->priv->is_dual = g_udev_device_get_property_as_boolean (native, "UPOWER_CSR_DUAL"); csr->priv->is_dual = g_udev_device_get_property_as_boolean (native, "UPOWER_CSR_DUAL");
egg_debug ("is_dual=%i", csr->priv->is_dual); g_debug ("is_dual=%i", csr->priv->is_dual);
/* prefer UPOWER names */ /* prefer UPOWER names */
vendor = g_udev_device_get_property (native, "UPOWER_VENDOR"); vendor = g_udev_device_get_property (native, "UPOWER_VENDOR");
@ -237,14 +235,14 @@ up_device_csr_refresh (UpDevice *device)
/* ensure we still have a device */ /* ensure we still have a device */
if (csr->priv->device == NULL) { if (csr->priv->device == NULL) {
egg_warning ("no device!"); g_warning ("no device!");
goto out; goto out;
} }
/* open USB device */ /* open USB device */
retval = libusb_open (csr->priv->device, &handle); retval = libusb_open (csr->priv->device, &handle);
if (retval < 0) { if (retval < 0) {
egg_warning ("could not open device: %i", retval); g_warning ("could not open device: %i", retval);
goto out; goto out;
} }
@ -257,29 +255,29 @@ up_device_csr_refresh (UpDevice *device)
retval = libusb_control_transfer (handle, 0xc0, 0x09, 0x03|addr, 0x00|addr, retval = libusb_control_transfer (handle, 0xc0, 0x09, 0x03|addr, 0x00|addr,
buf, 8, UP_DEVICE_CSR_REFRESH_TIMEOUT); buf, 8, UP_DEVICE_CSR_REFRESH_TIMEOUT);
if (retval < 0) { if (retval < 0) {
egg_warning ("failed to write to device: %i", retval); g_warning ("failed to write to device: %i", retval);
goto out; goto out;
} }
/* ensure we wrote 8 bytes */ /* ensure we wrote 8 bytes */
if (retval != 8) { if (retval != 8) {
egg_warning ("failed to write to device, wrote %i bytes", retval); g_warning ("failed to write to device, wrote %i bytes", retval);
goto out; goto out;
} }
/* is a C504 receiver busy? */ /* is a C504 receiver busy? */
if (buf[CSR_P0] == 0x3b && buf[CSR_P4] == 0) { if (buf[CSR_P0] == 0x3b && buf[CSR_P4] == 0) {
egg_warning ("receiver busy"); g_warning ("receiver busy");
goto out; goto out;
} }
/* get battery status */ /* get battery status */
csr->priv->raw_value = buf[CSR_P5] & 0x07; csr->priv->raw_value = buf[CSR_P5] & 0x07;
egg_debug ("charge level: %d", csr->priv->raw_value); g_debug ("charge level: %d", csr->priv->raw_value);
if (csr->priv->raw_value != 0) { if (csr->priv->raw_value != 0) {
percentage = (100.0 / 7.0) * csr->priv->raw_value; percentage = (100.0 / 7.0) * csr->priv->raw_value;
g_object_set (device, "percentage", percentage, NULL); g_object_set (device, "percentage", percentage, NULL);
egg_debug ("percentage=%f", percentage); g_debug ("percentage=%f", percentage);
} }
/* reset time */ /* reset time */
@ -308,7 +306,7 @@ up_device_csr_init (UpDeviceCsr *csr)
csr->priv->poll_timer_id = 0; csr->priv->poll_timer_id = 0;
retval = libusb_init (&csr->priv->ctx); retval = libusb_init (&csr->priv->ctx);
if (retval < 0) if (retval < 0)
egg_warning ("could not initialize libusb: %i", retval); g_warning ("could not initialize libusb: %i", retval);
} }
/** /**

View file

@ -48,8 +48,6 @@
#include <unistd.h> #include <unistd.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-hid.h" #include "up-device-hid.h"
@ -110,7 +108,7 @@ up_device_hid_is_ups (UpDeviceHid *hid)
/* get device info */ /* get device info */
retval = ioctl (hid->priv->fd, HIDIOCGDEVINFO, &device_info); retval = ioctl (hid->priv->fd, HIDIOCGDEVINFO, &device_info);
if (retval < 0) { if (retval < 0) {
egg_debug ("HIDIOCGDEVINFO failed: %s", strerror (errno)); g_debug ("HIDIOCGDEVINFO failed: %s", strerror (errno));
goto out; goto out;
} }
@ -134,7 +132,7 @@ up_device_hid_poll (UpDeviceHid *hid)
{ {
UpDevice *device = UP_DEVICE (hid); UpDevice *device = UP_DEVICE (hid);
egg_debug ("Polling: %s", up_device_get_object_path (device)); g_debug ("Polling: %s", up_device_get_object_path (device));
up_device_hid_refresh (device); up_device_hid_refresh (device);
/* always continue polling */ /* always continue polling */
@ -159,7 +157,7 @@ up_device_hid_get_string (UpDeviceHid *hid, int sindex)
if (ioctl (hid->priv->fd, HIDIOCGSTRING, &sdesc) < 0) if (ioctl (hid->priv->fd, HIDIOCGSTRING, &sdesc) < 0)
return ""; return "";
egg_debug ("value: '%s'", sdesc.value); g_debug ("value: '%s'", sdesc.value);
return sdesc.value; return sdesc.value;
} }
@ -321,22 +319,22 @@ up_device_hid_coldplug (UpDevice *device)
/* get the device file */ /* get the device file */
device_file = g_udev_device_get_device_file (native); device_file = g_udev_device_get_device_file (native);
if (device_file == NULL) { if (device_file == NULL) {
egg_debug ("could not get device file for HID device"); g_debug ("could not get device file for HID device");
goto out; goto out;
} }
/* connect to the device */ /* connect to the device */
egg_debug ("using device: %s", device_file); g_debug ("using device: %s", device_file);
hid->priv->fd = open (device_file, O_RDONLY | O_NONBLOCK); hid->priv->fd = open (device_file, O_RDONLY | O_NONBLOCK);
if (hid->priv->fd < 0) { if (hid->priv->fd < 0) {
egg_debug ("cannot open device file %s", device_file); g_debug ("cannot open device file %s", device_file);
goto out; goto out;
} }
/* first check that we are an UPS */ /* first check that we are an UPS */
ret = up_device_hid_is_ups (hid); ret = up_device_hid_is_ups (hid);
if (!ret) { if (!ret) {
egg_debug ("not a HID device: %s", device_file); g_debug ("not a HID device: %s", device_file);
goto out; goto out;
} }
@ -359,7 +357,7 @@ up_device_hid_coldplug (UpDevice *device)
/* coldplug everything */ /* coldplug everything */
ret = up_device_hid_get_all_data (hid); ret = up_device_hid_get_all_data (hid);
if (!ret) { if (!ret) {
egg_debug ("failed to coldplug: %s", device_file); g_debug ("failed to coldplug: %s", device_file);
goto out; goto out;
} }
@ -390,14 +388,14 @@ up_device_hid_refresh (UpDevice *device)
/* it's okay if there's nothing as we are non-blocking */ /* it's okay if there's nothing as we are non-blocking */
if (rd == -1) { if (rd == -1) {
egg_debug ("no data"); g_debug ("no data");
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
/* did we read enough data? */ /* did we read enough data? */
if (rd < (int) sizeof (ev[0])) { if (rd < (int) sizeof (ev[0])) {
egg_warning ("incomplete read (%i<%i)", rd, (int) sizeof (ev[0])); g_warning ("incomplete read (%i<%i)", rd, (int) sizeof (ev[0]));
goto out; goto out;
} }

View file

@ -38,8 +38,6 @@
#include <plist/plist.h> #include <plist/plist.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-idevice.h" #include "up-device-idevice.h"
@ -65,7 +63,7 @@ up_device_idevice_poll_cb (UpDeviceIdevice *idevice)
{ {
UpDevice *device = UP_DEVICE (idevice); UpDevice *device = UP_DEVICE (idevice);
egg_debug ("Polling: %s", up_device_get_object_path (device)); g_debug ("Polling: %s", up_device_get_object_path (device));
up_device_idevice_refresh (device); up_device_idevice_refresh (device);
/* always continue polling */ /* always continue polling */
@ -201,7 +199,7 @@ up_device_idevice_refresh (UpDevice *device)
plist_get_uint_val (node, &percentage); plist_get_uint_val (node, &percentage);
g_object_set (device, "percentage", (double) percentage, NULL); g_object_set (device, "percentage", (double) percentage, NULL);
egg_debug ("percentage=%"G_GUINT64_FORMAT, percentage); g_debug ("percentage=%"G_GUINT64_FORMAT, percentage);
/* get charging status */ /* get charging status */
node = plist_dict_get_item (dict, "BatteryIsCharging"); node = plist_dict_get_item (dict, "BatteryIsCharging");
@ -219,7 +217,7 @@ up_device_idevice_refresh (UpDevice *device)
g_object_set (device, g_object_set (device,
"state", state, "state", state,
NULL); NULL);
egg_debug ("state=%s", up_device_state_to_string (state)); g_debug ("state=%s", up_device_state_to_string (state));
plist_free (dict); plist_free (dict);

View file

@ -34,8 +34,6 @@
#include <gudev/gudev.h> #include <gudev/gudev.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-supply.h" #include "up-device-supply.h"
@ -314,33 +312,33 @@ up_device_supply_get_design_voltage (const gchar *native_path)
/* design maximum */ /* design maximum */
voltage = sysfs_get_double (native_path, "voltage_max_design") / 1000000.0; voltage = sysfs_get_double (native_path, "voltage_max_design") / 1000000.0;
if (voltage > 1.00f) { if (voltage > 1.00f) {
egg_debug ("using max design voltage"); g_debug ("using max design voltage");
goto out; goto out;
} }
/* design minimum */ /* design minimum */
voltage = sysfs_get_double (native_path, "voltage_min_design") / 1000000.0; voltage = sysfs_get_double (native_path, "voltage_min_design") / 1000000.0;
if (voltage > 1.00f) { if (voltage > 1.00f) {
egg_debug ("using min design voltage"); g_debug ("using min design voltage");
goto out; goto out;
} }
/* current voltage */ /* current voltage */
voltage = sysfs_get_double (native_path, "voltage_present") / 1000000.0; voltage = sysfs_get_double (native_path, "voltage_present") / 1000000.0;
if (voltage > 1.00f) { if (voltage > 1.00f) {
egg_debug ("using present voltage"); g_debug ("using present voltage");
goto out; goto out;
} }
/* current voltage, alternate form */ /* current voltage, alternate form */
voltage = sysfs_get_double (native_path, "voltage_now") / 1000000.0; voltage = sysfs_get_double (native_path, "voltage_now") / 1000000.0;
if (voltage > 1.00f) { if (voltage > 1.00f) {
egg_debug ("using present voltage (alternate)"); g_debug ("using present voltage (alternate)");
goto out; goto out;
} }
/* completely guess, to avoid getting zero values */ /* completely guess, to avoid getting zero values */
egg_warning ("no voltage values, using 10V as approximation"); g_warning ("no voltage values, using 10V as approximation");
voltage = 10.0f; voltage = 10.0f;
out: out:
return voltage; return voltage;
@ -367,7 +365,7 @@ up_device_supply_make_safe_string (gchar *text)
text[idx] = text[i]; text[idx] = text[i];
idx++; idx++;
} else { } else {
egg_debug ("invalid char '%c'", text[i]); g_debug ("invalid char '%c'", text[i]);
} }
} }
@ -500,12 +498,12 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
/* the last full should not be bigger than the design */ /* the last full should not be bigger than the design */
if (energy_full > energy_full_design) if (energy_full > energy_full_design)
egg_warning ("energy_full (%f) is greater than energy_full_design (%f)", g_warning ("energy_full (%f) is greater than energy_full_design (%f)",
energy_full, energy_full_design); energy_full, energy_full_design);
/* some systems don't have this */ /* some systems don't have this */
if (energy_full < 0.01 && energy_full_design > 0.01) { if (energy_full < 0.01 && energy_full_design > 0.01) {
egg_warning ("correcting energy_full (%f) using energy_full_design (%f)", g_warning ("correcting energy_full (%f) using energy_full_design (%f)",
energy_full, energy_full_design); energy_full, energy_full_design);
energy_full = energy_full_design; energy_full = energy_full_design;
} }
@ -542,7 +540,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
else if (g_ascii_strcasecmp (status, "unknown") == 0) else if (g_ascii_strcasecmp (status, "unknown") == 0)
state = UP_DEVICE_STATE_UNKNOWN; state = UP_DEVICE_STATE_UNKNOWN;
else { else {
egg_warning ("unknown status string: %s", status); g_warning ("unknown status string: %s", status);
state = UP_DEVICE_STATE_UNKNOWN; state = UP_DEVICE_STATE_UNKNOWN;
} }
@ -552,7 +550,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
/* reset unknown counter */ /* reset unknown counter */
if (state != UP_DEVICE_STATE_UNKNOWN) { if (state != UP_DEVICE_STATE_UNKNOWN) {
egg_debug ("resetting unknown timeout after %i retries", supply->priv->unknown_retries); g_debug ("resetting unknown timeout after %i retries", supply->priv->unknown_retries);
supply->priv->unknown_retries = 0; supply->priv->unknown_retries = 0;
} }
@ -570,7 +568,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
/* some batteries don't update last_full attribute */ /* some batteries don't update last_full attribute */
if (energy > energy_full) { if (energy > energy_full) {
egg_warning ("energy %f bigger than full %f", energy, energy_full); g_warning ("energy %f bigger than full %f", energy, energy_full);
energy_full = energy; energy_full = energy;
} }
@ -638,7 +636,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
} }
/* print what we did */ /* print what we did */
egg_debug ("guessing battery state '%s' using global on-battery:%i", g_debug ("guessing battery state '%s' using global on-battery:%i",
up_device_state_to_string (state), on_battery); up_device_state_to_string (state), on_battery);
g_object_unref (daemon); g_object_unref (daemon);
@ -646,7 +644,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
/* if empty, and BIOS does not know what to do */ /* if empty, and BIOS does not know what to do */
if (state == UP_DEVICE_STATE_UNKNOWN && energy < 0.01) { if (state == UP_DEVICE_STATE_UNKNOWN && energy < 0.01) {
egg_warning ("Setting %s state empty as unknown and very low", native_path); g_warning ("Setting %s state empty as unknown and very low", native_path);
state = UP_DEVICE_STATE_EMPTY; state = UP_DEVICE_STATE_EMPTY;
} }
@ -710,7 +708,7 @@ up_device_supply_poll_battery (UpDeviceSupply *supply)
{ {
UpDevice *device = UP_DEVICE (supply); UpDevice *device = UP_DEVICE (supply);
egg_debug ("No updates on supply %s for %i seconds; forcing update", up_device_get_object_path (device), UP_DEVICE_SUPPLY_REFRESH_TIMEOUT); g_debug ("No updates on supply %s for %i seconds; forcing update", up_device_get_object_path (device), UP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
supply->priv->poll_timer_id = 0; supply->priv->poll_timer_id = 0;
up_device_supply_refresh (device); up_device_supply_refresh (device);
@ -739,7 +737,7 @@ up_device_supply_coldplug (UpDevice *device)
native = G_UDEV_DEVICE (up_device_get_native (device)); native = G_UDEV_DEVICE (up_device_get_native (device));
native_path = g_udev_device_get_sysfs_path (native); native_path = g_udev_device_get_sysfs_path (native);
if (native_path == NULL) { if (native_path == NULL) {
egg_warning ("could not get native path for %p", device); g_warning ("could not get native path for %p", device);
goto out; goto out;
} }
@ -751,7 +749,7 @@ up_device_supply_coldplug (UpDevice *device)
} else if (g_ascii_strcasecmp (device_type, "battery") == 0) { } else if (g_ascii_strcasecmp (device_type, "battery") == 0) {
type = UP_DEVICE_KIND_BATTERY; type = UP_DEVICE_KIND_BATTERY;
} else { } else {
egg_warning ("did not recognise type %s, please report", device_type); g_warning ("did not recognise type %s, please report", device_type);
} }
} }

View file

@ -42,8 +42,6 @@
#include <errno.h> #include <errno.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-device-wup.h" #include "up-device-wup.h"
@ -87,7 +85,7 @@ up_device_wup_poll_cb (UpDeviceWup *wup)
{ {
UpDevice *device = UP_DEVICE (wup); UpDevice *device = UP_DEVICE (wup);
egg_debug ("Polling: %s", up_device_get_object_path (device)); g_debug ("Polling: %s", up_device_get_object_path (device));
up_device_wup_refresh (device); up_device_wup_refresh (device);
/* always continue polling */ /* always continue polling */
@ -105,7 +103,7 @@ up_device_wup_set_speed (UpDeviceWup *wup)
retval = tcgetattr (wup->priv->fd, &t); retval = tcgetattr (wup->priv->fd, &t);
if (retval != 0) { if (retval != 0) {
egg_debug ("failed to get speed"); g_debug ("failed to get speed");
return FALSE; return FALSE;
} }
@ -118,7 +116,7 @@ up_device_wup_set_speed (UpDeviceWup *wup)
t.c_cflag &= ~CSTOPB; t.c_cflag &= ~CSTOPB;
retval = tcsetattr (wup->priv->fd, TCSANOW, &t); retval = tcsetattr (wup->priv->fd, TCSANOW, &t);
if (retval != 0) { if (retval != 0) {
egg_debug ("failed to set speed"); g_debug ("failed to set speed");
return FALSE; return FALSE;
} }
@ -138,10 +136,10 @@ up_device_wup_write_command (UpDeviceWup *wup, const gchar *data)
gint length; gint length;
length = strlen (data); length = strlen (data);
egg_debug ("writing [%s]", data); g_debug ("writing [%s]", data);
retval = write (wup->priv->fd, data, length); retval = write (wup->priv->fd, data, length);
if (retval != length) { if (retval != length) {
egg_debug ("Writing [%s] to device failed", data); g_debug ("Writing [%s] to device failed", data);
ret = FALSE; ret = FALSE;
} }
return ret; return ret;
@ -159,7 +157,7 @@ up_device_wup_read_command (UpDeviceWup *wup)
gchar buffer[UP_DEVICE_WUP_COMMAND_LEN]; gchar buffer[UP_DEVICE_WUP_COMMAND_LEN];
retval = read (wup->priv->fd, &buffer, UP_DEVICE_WUP_COMMAND_LEN); retval = read (wup->priv->fd, &buffer, UP_DEVICE_WUP_COMMAND_LEN);
if (retval < 0) { if (retval < 0) {
egg_debug ("failed to read from fd: %s", strerror (errno)); g_debug ("failed to read from fd: %s", strerror (errno));
return NULL; return NULL;
} }
return g_strdup (buffer); return g_strdup (buffer);
@ -197,7 +195,7 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
/* ensure we have a long enough response */ /* ensure we have a long enough response */
length = strlen (data); length = strlen (data);
if (length < 3) { if (length < 3) {
egg_debug ("not enough data '%s'", data); g_debug ("not enough data '%s'", data);
goto out; goto out;
} }
@ -208,7 +206,7 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
/* does packet exist? */ /* does packet exist? */
if (packet == NULL) { if (packet == NULL) {
egg_debug ("no start char in %s", data); g_debug ("no start char in %s", data);
goto out; goto out;
} }
@ -227,7 +225,7 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
tokens = g_strsplit (packet, ",", -1); tokens = g_strsplit (packet, ",", -1);
number_tokens = g_strv_length (tokens); number_tokens = g_strv_length (tokens);
if (number_tokens < 3) { if (number_tokens < 3) {
egg_debug ("not enough tokens '%s'", packet); g_debug ("not enough tokens '%s'", packet);
goto out; goto out;
} }
@ -238,11 +236,11 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
/* check the first token */ /* check the first token */
length = strlen (tokens[0]); length = strlen (tokens[0]);
if (length != 2) { if (length != 2) {
egg_debug ("expected command '#?' but got '%s'", tokens[0]); g_debug ("expected command '#?' but got '%s'", tokens[0]);
goto out; goto out;
} }
if (tokens[0][0] != '#') { if (tokens[0][0] != '#') {
egg_debug ("expected command '#?' but got '%s'", tokens[0]); g_debug ("expected command '#?' but got '%s'", tokens[0]);
goto out; goto out;
} }
command = tokens[0][1]; command = tokens[0][1];
@ -250,7 +248,7 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
/* check the second token */ /* check the second token */
length = strlen (tokens[1]); length = strlen (tokens[1]);
if (length != 1) { if (length != 1) {
egg_debug ("expected command '?' but got '%s'", tokens[1]); g_debug ("expected command '?' but got '%s'", tokens[1]);
goto out; goto out;
} }
subcommand = tokens[1][0]; /* expect to be '-' */ subcommand = tokens[1][0]; /* expect to be '-' */
@ -258,14 +256,14 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
/* check the length is present */ /* check the length is present */
length = strlen (tokens[2]); length = strlen (tokens[2]);
if (length == 0) { if (length == 0) {
egg_debug ("length value not present"); g_debug ("length value not present");
goto out; goto out;
} }
/* check the length matches what data we've got*/ /* check the length matches what data we've got*/
size = atoi (tokens[2]); size = atoi (tokens[2]);
if (size != number_tokens - offset) { if (size != number_tokens - offset) {
egg_debug ("size expected to be '%i' but got '%i'", number_tokens - offset, size); g_debug ("size expected to be '%i' but got '%i'", number_tokens - offset, size);
goto out; goto out;
} }
@ -277,7 +275,7 @@ up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
NULL); NULL);
ret = TRUE; ret = TRUE;
} else { } else {
egg_debug ("ignoring command '%c'", command); g_debug ("ignoring command '%c'", command);
} }
out: out:
@ -313,40 +311,40 @@ up_device_wup_coldplug (UpDevice *device)
/* get the device file */ /* get the device file */
device_file = g_udev_device_get_device_file (native); device_file = g_udev_device_get_device_file (native);
if (device_file == NULL) { if (device_file == NULL) {
egg_debug ("could not get device file for WUP device"); g_debug ("could not get device file for WUP device");
goto out; goto out;
} }
/* connect to the device */ /* connect to the device */
wup->priv->fd = open (device_file, O_RDWR | O_NONBLOCK); wup->priv->fd = open (device_file, O_RDWR | O_NONBLOCK);
if (wup->priv->fd < 0) { if (wup->priv->fd < 0) {
egg_debug ("cannot open device file %s", device_file); g_debug ("cannot open device file %s", device_file);
goto out; goto out;
} }
egg_debug ("opened %s", device_file); g_debug ("opened %s", device_file);
/* set speed */ /* set speed */
ret = up_device_wup_set_speed (wup); ret = up_device_wup_set_speed (wup);
if (!ret) { if (!ret) {
egg_debug ("not a WUP device (cannot set speed): %s", device_file); g_debug ("not a WUP device (cannot set speed): %s", device_file);
goto out; goto out;
} }
/* attempt to clear */ /* attempt to clear */
ret = up_device_wup_write_command (wup, "#R,W,0;"); ret = up_device_wup_write_command (wup, "#R,W,0;");
if (!ret) if (!ret)
egg_debug ("failed to clear, nonfatal"); g_debug ("failed to clear, nonfatal");
/* setup logging interval */ /* setup logging interval */
data = g_strdup_printf ("#L,W,3,E,1,%i;", UP_DEVICE_WUP_REFRESH_TIMEOUT); data = g_strdup_printf ("#L,W,3,E,1,%i;", UP_DEVICE_WUP_REFRESH_TIMEOUT);
ret = up_device_wup_write_command (wup, data); ret = up_device_wup_write_command (wup, data);
if (!ret) if (!ret)
egg_debug ("failed to setup logging interval, nonfatal"); g_debug ("failed to setup logging interval, nonfatal");
g_free (data); g_free (data);
/* dummy read */ /* dummy read */
data = up_device_wup_read_command (wup); data = up_device_wup_read_command (wup);
egg_debug ("data after clear %s", data); g_debug ("data after clear %s", data);
/* shouldn't do anything */ /* shouldn't do anything */
up_device_wup_parse_command (wup, data); up_device_wup_parse_command (wup, data);
@ -375,7 +373,7 @@ up_device_wup_coldplug (UpDevice *device)
NULL); NULL);
/* coldplug */ /* coldplug */
egg_debug ("coldplug"); g_debug ("coldplug");
ret = up_device_wup_refresh (device); ret = up_device_wup_refresh (device);
out: out:
return ret; return ret;
@ -397,14 +395,14 @@ up_device_wup_refresh (UpDevice *device)
/* get data */ /* get data */
data = up_device_wup_read_command (wup); data = up_device_wup_read_command (wup);
if (data == NULL) { if (data == NULL) {
egg_debug ("no data"); g_debug ("no data");
goto out; goto out;
} }
/* parse */ /* parse */
ret = up_device_wup_parse_command (wup, data); ret = up_device_wup_parse_command (wup, data);
if (!ret) { if (!ret) {
egg_debug ("failed to parse %s", data); g_debug ("failed to parse %s", data);
goto out; goto out;
} }

View file

@ -40,8 +40,6 @@
#include <gudev/gudev.h> #include <gudev/gudev.h>
#include "sysfs-utils.h" #include "sysfs-utils.h"
#include "egg-debug.h"
#include "up-types.h" #include "up-types.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-input.h" #include "up-input.h"
@ -120,33 +118,33 @@ up_input_event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
/* not enough data */ /* not enough data */
if (input->priv->offset + read_bytes < sizeof (struct input_event)) { if (input->priv->offset + read_bytes < sizeof (struct input_event)) {
input->priv->offset = input->priv->offset + read_bytes; input->priv->offset = input->priv->offset + read_bytes;
egg_debug ("incomplete read"); g_debug ("incomplete read");
goto out; goto out;
} }
/* we have all the data */ /* we have all the data */
input->priv->offset = 0; input->priv->offset = 0;
egg_debug ("event.value=%d ; event.code=%d (0x%02x)", g_debug ("event.value=%d ; event.code=%d (0x%02x)",
input->priv->event.value, input->priv->event.value,
input->priv->event.code, input->priv->event.code,
input->priv->event.code); input->priv->event.code);
/* switch? */ /* switch? */
if (input->priv->event.type != EV_SW) { if (input->priv->event.type != EV_SW) {
egg_debug ("not a switch event"); g_debug ("not a switch event");
continue; continue;
} }
/* is not lid */ /* is not lid */
if (input->priv->event.code != SW_LID) { if (input->priv->event.code != SW_LID) {
egg_debug ("not a lid"); g_debug ("not a lid");
continue; continue;
} }
/* check switch state */ /* check switch state */
if (ioctl (g_io_channel_unix_get_fd(channel), EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { if (ioctl (g_io_channel_unix_get_fd(channel), EVIOCGSW(sizeof (bitmask)), bitmask) < 0) {
egg_debug ("ioctl EVIOCGSW failed"); g_debug ("ioctl EVIOCGSW failed");
continue; continue;
} }
@ -180,11 +178,11 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
/* is a switch */ /* is a switch */
path = g_build_filename (native_path, "../capabilities/sw", NULL); path = g_build_filename (native_path, "../capabilities/sw", NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS)) { if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
egg_debug ("not a switch [%s]", path); g_debug ("not a switch [%s]", path);
g_free (path); g_free (path);
path = g_build_filename (native_path, "capabilities/sw", NULL); path = g_build_filename (native_path, "capabilities/sw", NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS)) { if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
egg_debug ("not a switch [%s]", path); g_debug ("not a switch [%s]", path);
goto out; goto out;
} }
} }
@ -192,7 +190,7 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
/* get caps */ /* get caps */
ret = g_file_get_contents (path, &contents, NULL, &error); ret = g_file_get_contents (path, &contents, NULL, &error);
if (!ret) { if (!ret) {
egg_debug ("failed to get contents for [%s]: %s", path, error->message); g_debug ("failed to get contents for [%s]: %s", path, error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -200,14 +198,14 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
/* convert to a bitmask */ /* convert to a bitmask */
num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask)); num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask));
if (num_bits != 1) { if (num_bits != 1) {
egg_debug ("not one bitmask entry for %s", native_path); g_debug ("not one bitmask entry for %s", native_path);
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
/* is this a lid? */ /* is this a lid? */
if (!test_bit (SW_LID, bitmask)) { if (!test_bit (SW_LID, bitmask)) {
egg_debug ("not a lid: %s", native_path); g_debug ("not a lid: %s", native_path);
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -215,7 +213,7 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
/* get device file */ /* get device file */
device_file = g_udev_device_get_device_file (d); device_file = g_udev_device_get_device_file (d);
if (device_file == NULL || device_file[0] == '\0') { if (device_file == NULL || device_file[0] == '\0') {
egg_warning ("no device file"); g_warning ("no device file");
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -223,26 +221,26 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
/* open device file */ /* open device file */
input->priv->eventfp = open (device_file, O_RDONLY | O_NONBLOCK); input->priv->eventfp = open (device_file, O_RDONLY | O_NONBLOCK);
if (input->priv->eventfp <= 0) { if (input->priv->eventfp <= 0) {
egg_warning ("cannot open '%s': %s", device_file, strerror (errno)); g_warning ("cannot open '%s': %s", device_file, strerror (errno));
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
/* get initial state */ /* get initial state */
if (ioctl (input->priv->eventfp, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { if (ioctl (input->priv->eventfp, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) {
egg_warning ("ioctl EVIOCGSW on %s failed", native_path); g_warning ("ioctl EVIOCGSW on %s failed", native_path);
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
/* create channel */ /* create channel */
egg_debug ("watching %s (%i)", device_file, input->priv->eventfp); g_debug ("watching %s (%i)", device_file, input->priv->eventfp);
input->priv->channel = g_io_channel_unix_new (input->priv->eventfp); input->priv->channel = g_io_channel_unix_new (input->priv->eventfp);
/* set binary encoding */ /* set binary encoding */
status = g_io_channel_set_encoding (input->priv->channel, NULL, &error); status = g_io_channel_set_encoding (input->priv->channel, NULL, &error);
if (status != G_IO_STATUS_NORMAL) { if (status != G_IO_STATUS_NORMAL) {
egg_warning ("failed to set encoding: %s", error->message); g_warning ("failed to set encoding: %s", error->message);
g_error_free (error); g_error_free (error);
ret = FALSE; ret = FALSE;
goto out; goto out;
@ -255,7 +253,7 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
g_io_add_watch (input->priv->channel, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, up_input_event_io, input); g_io_add_watch (input->priv->channel, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, up_input_event_io, input);
/* set if we are closed */ /* set if we are closed */
egg_debug ("using %s for lid event", native_path); g_debug ("using %s for lid event", native_path);
up_daemon_set_lid_is_closed (input->priv->daemon, test_bit (SW_LID, bitmask)); up_daemon_set_lid_is_closed (input->priv->daemon, test_bit (SW_LID, bitmask));
out: out:
g_free (path); g_free (path);

View file

@ -32,8 +32,6 @@
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib-lowlevel.h>
#include "egg-debug.h"
#include "up-polkit.h" #include "up-polkit.h"
#include "up-device-list.h" #include "up-device-list.h"
#include "up-device.h" #include "up-device.h"
@ -238,13 +236,13 @@ up_daemon_set_powersave (UpDaemon *daemon, gboolean powersave)
/* run script */ /* run script */
command = up_backend_get_powersave_command (daemon->priv->backend, powersave); command = up_backend_get_powersave_command (daemon->priv->backend, powersave);
if (command == NULL) { if (command == NULL) {
egg_warning ("no powersave command set"); g_warning ("no powersave command set");
goto out; goto out;
} }
egg_debug ("excuting command: %s", command); g_debug ("excuting command: %s", command);
ret = g_spawn_command_line_async (command, &error); ret = g_spawn_command_line_async (command, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to run script: %s", error->message); g_warning ("failed to run script: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -336,7 +334,7 @@ up_daemon_about_to_sleep (UpDaemon *daemon, DBusGMethodInvocation *context)
goto out; goto out;
/* we've told the clients we're going down */ /* we've told the clients we're going down */
egg_debug ("emitting sleeping"); g_debug ("emitting sleeping");
g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0); g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0);
g_timer_start (priv->about_to_sleep_timer); g_timer_start (priv->about_to_sleep_timer);
daemon->priv->sent_sleeping_signal = TRUE; daemon->priv->sent_sleeping_signal = TRUE;
@ -382,7 +380,7 @@ up_daemon_deferred_sleep_cb (UpDaemonDeferredSleep *sleep)
} }
/* emit signal for session components */ /* emit signal for session components */
egg_debug ("emitting resuming"); g_debug ("emitting resuming");
g_signal_emit (daemon, signals[SIGNAL_RESUMING], 0); g_signal_emit (daemon, signals[SIGNAL_RESUMING], 0);
/* reset the about-to-sleep logic */ /* reset the about-to-sleep logic */
@ -426,7 +424,7 @@ up_daemon_deferred_sleep (UpDaemon *daemon, const gchar *command, DBusGMethodInv
/* we didn't use AboutToSleep() so send the signal for clients now */ /* we didn't use AboutToSleep() so send the signal for clients now */
if (!priv->sent_sleeping_signal) { if (!priv->sent_sleeping_signal) {
egg_debug ("no AboutToSleep(), so emitting ::Sleeping()"); g_debug ("no AboutToSleep(), so emitting ::Sleeping()");
g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0); g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0);
priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout, priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout,
(GSourceFunc) up_daemon_deferred_sleep_cb, sleep); (GSourceFunc) up_daemon_deferred_sleep_cb, sleep);
@ -438,7 +436,7 @@ up_daemon_deferred_sleep (UpDaemon *daemon, const gchar *command, DBusGMethodInv
/* about to sleep */ /* about to sleep */
elapsed = 1000.0f * g_timer_elapsed (priv->about_to_sleep_timer, NULL); elapsed = 1000.0f * g_timer_elapsed (priv->about_to_sleep_timer, NULL);
egg_debug ("between AboutToSleep() and %s was %fms", sleep->command, elapsed); g_debug ("between AboutToSleep() and %s was %fms", sleep->command, elapsed);
if (elapsed < priv->conf_sleep_timeout) { if (elapsed < priv->conf_sleep_timeout) {
/* we have to wait for the difference in time */ /* we have to wait for the difference in time */
priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout - elapsed, priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout - elapsed,
@ -547,10 +545,10 @@ up_daemon_check_hibernate_swap (UpDaemon *daemon)
if (daemon->priv->kernel_can_hibernate) { if (daemon->priv->kernel_can_hibernate) {
waterline = up_backend_get_used_swap (daemon->priv->backend); waterline = up_backend_get_used_swap (daemon->priv->backend);
if (waterline < UP_DAEMON_SWAP_WATERLINE) { if (waterline < UP_DAEMON_SWAP_WATERLINE) {
egg_debug ("enough swap to for hibernate"); g_debug ("enough swap to for hibernate");
return TRUE; return TRUE;
} else { } else {
egg_debug ("not enough swap to hibernate"); g_debug ("not enough swap to hibernate");
return FALSE; return FALSE;
} }
} }
@ -707,19 +705,19 @@ up_daemon_startup (UpDaemon *daemon)
/* register on bus */ /* register on bus */
ret = up_daemon_register_power_daemon (daemon); ret = up_daemon_register_power_daemon (daemon);
if (!ret) { if (!ret) {
egg_warning ("failed to register"); g_warning ("failed to register");
goto out; goto out;
} }
/* stop signals and callbacks */ /* stop signals and callbacks */
egg_debug ("daemon now coldplug"); g_debug ("daemon now coldplug");
g_object_freeze_notify (G_OBJECT(daemon)); g_object_freeze_notify (G_OBJECT(daemon));
priv->during_coldplug = TRUE; priv->during_coldplug = TRUE;
/* coldplug backend backend */ /* coldplug backend backend */
ret = up_backend_coldplug (priv->backend, daemon); ret = up_backend_coldplug (priv->backend, daemon);
if (!ret) { if (!ret) {
egg_warning ("failed to coldplug backend"); g_warning ("failed to coldplug backend");
goto out; goto out;
} }
@ -733,7 +731,7 @@ up_daemon_startup (UpDaemon *daemon)
/* start signals and callbacks */ /* start signals and callbacks */
g_object_thaw_notify (G_OBJECT(daemon)); g_object_thaw_notify (G_OBJECT(daemon));
priv->during_coldplug = FALSE; priv->during_coldplug = FALSE;
egg_debug ("daemon now not coldplug"); g_debug ("daemon now not coldplug");
/* set power policy */ /* set power policy */
up_daemon_set_powersave (daemon, priv->on_battery); up_daemon_set_powersave (daemon, priv->on_battery);
@ -757,7 +755,7 @@ void
up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed) up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed)
{ {
UpDaemonPrivate *priv = daemon->priv; UpDaemonPrivate *priv = daemon->priv;
egg_debug ("lid_is_closed = %s", lid_is_closed ? "yes" : "no"); g_debug ("lid_is_closed = %s", lid_is_closed ? "yes" : "no");
priv->lid_is_closed = lid_is_closed; priv->lid_is_closed = lid_is_closed;
g_object_notify (G_OBJECT (daemon), "lid-is-closed"); g_object_notify (G_OBJECT (daemon), "lid-is-closed");
} }
@ -769,7 +767,7 @@ void
up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present) up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present)
{ {
UpDaemonPrivate *priv = daemon->priv; UpDaemonPrivate *priv = daemon->priv;
egg_debug ("lid_is_present = %s", lid_is_present ? "yes" : "no"); g_debug ("lid_is_present = %s", lid_is_present ? "yes" : "no");
priv->lid_is_present = lid_is_present; priv->lid_is_present = lid_is_present;
g_object_notify (G_OBJECT (daemon), "lid-is-present"); g_object_notify (G_OBJECT (daemon), "lid-is-present");
} }
@ -781,7 +779,7 @@ void
up_daemon_set_on_battery (UpDaemon *daemon, gboolean on_battery) up_daemon_set_on_battery (UpDaemon *daemon, gboolean on_battery)
{ {
UpDaemonPrivate *priv = daemon->priv; UpDaemonPrivate *priv = daemon->priv;
egg_debug ("on_battery = %s", on_battery ? "yes" : "no"); g_debug ("on_battery = %s", on_battery ? "yes" : "no");
priv->on_battery = on_battery; priv->on_battery = on_battery;
g_object_notify (G_OBJECT (daemon), "on-battery"); g_object_notify (G_OBJECT (daemon), "on-battery");
} }
@ -793,7 +791,7 @@ void
up_daemon_set_on_low_battery (UpDaemon *daemon, gboolean on_low_battery) up_daemon_set_on_low_battery (UpDaemon *daemon, gboolean on_low_battery)
{ {
UpDaemonPrivate *priv = daemon->priv; UpDaemonPrivate *priv = daemon->priv;
egg_debug ("on_low_battery = %s", on_low_battery ? "yes" : "no"); g_debug ("on_low_battery = %s", on_low_battery ? "yes" : "no");
priv->on_low_battery = on_low_battery; priv->on_low_battery = on_low_battery;
g_object_notify (G_OBJECT (daemon), "on-low-battery"); g_object_notify (G_OBJECT (daemon), "on-low-battery");
} }
@ -812,7 +810,7 @@ up_daemon_refresh_battery_devices_cb (UpDaemon *daemon)
return FALSE; return FALSE;
} }
egg_debug ("doing the delayed refresh (%i)", priv->battery_poll_count); g_debug ("doing the delayed refresh (%i)", priv->battery_poll_count);
up_daemon_refresh_battery_devices (daemon); up_daemon_refresh_battery_devices (daemon);
/* keep going until none left to do */ /* keep going until none left to do */
@ -879,11 +877,11 @@ up_daemon_device_changed_cb (UpDevice *device, UpDaemon *daemon)
/* emit */ /* emit */
if (!priv->during_coldplug) { if (!priv->during_coldplug) {
object_path = up_device_get_object_path (device); object_path = up_device_get_object_path (device);
egg_debug ("emitting device-changed: %s", object_path); g_debug ("emitting device-changed: %s", object_path);
/* don't crash the session */ /* don't crash the session */
if (object_path == NULL) { if (object_path == NULL) {
egg_warning ("INTERNAL STATE CORRUPT: not sending NULL, device:%p", device); g_warning ("INTERNAL STATE CORRUPT: not sending NULL, device:%p", device);
return; return;
} }
g_signal_emit (daemon, signals[SIGNAL_DEVICE_CHANGED], 0, object_path); g_signal_emit (daemon, signals[SIGNAL_DEVICE_CHANGED], 0, object_path);
@ -921,11 +919,11 @@ up_daemon_device_added_cb (UpBackend *backend, GObject *native, UpDevice *device
/* emit */ /* emit */
if (!priv->during_coldplug) { if (!priv->during_coldplug) {
object_path = up_device_get_object_path (device); object_path = up_device_get_object_path (device);
egg_debug ("emitting added: %s (during coldplug %i)", object_path, priv->during_coldplug); g_debug ("emitting added: %s (during coldplug %i)", object_path, priv->during_coldplug);
/* don't crash the session */ /* don't crash the session */
if (object_path == NULL) { if (object_path == NULL) {
egg_warning ("INTERNAL STATE CORRUPT: not sending NULL, native:%p, device:%p", native, device); g_warning ("INTERNAL STATE CORRUPT: not sending NULL, native:%p, device:%p", native, device);
return; return;
} }
g_signal_emit (daemon, signals[SIGNAL_DEVICE_ADDED], 0, object_path); g_signal_emit (daemon, signals[SIGNAL_DEVICE_ADDED], 0, object_path);
@ -959,11 +957,11 @@ up_daemon_device_removed_cb (UpBackend *backend, GObject *native, UpDevice *devi
/* emit */ /* emit */
if (!priv->during_coldplug) { if (!priv->during_coldplug) {
object_path = up_device_get_object_path (device); object_path = up_device_get_object_path (device);
egg_debug ("emitting device-removed: %s", object_path); g_debug ("emitting device-removed: %s", object_path);
/* don't crash the session */ /* don't crash the session */
if (object_path == NULL) { if (object_path == NULL) {
egg_warning ("INTERNAL STATE CORRUPT: not sending NULL, native:%p, device:%p", native, device); g_warning ("INTERNAL STATE CORRUPT: not sending NULL, native:%p, device:%p", native, device);
return; return;
} }
g_signal_emit (daemon, signals[SIGNAL_DEVICE_REMOVED], 0, object_path); g_signal_emit (daemon, signals[SIGNAL_DEVICE_REMOVED], 0, object_path);
@ -983,7 +981,7 @@ up_daemon_properties_changed_cb (GObject *object, GParamSpec *pspec, UpDaemon *d
/* emit */ /* emit */
if (!daemon->priv->during_coldplug) { if (!daemon->priv->during_coldplug) {
egg_debug ("emitting changed"); g_debug ("emitting changed");
g_signal_emit (daemon, signals[SIGNAL_CHANGED], 0); g_signal_emit (daemon, signals[SIGNAL_CHANGED], 0);
} }
} }
@ -1025,7 +1023,7 @@ up_daemon_init (UpDaemon *daemon)
daemon->priv->conf_allow_hibernate_encrypted_swap = daemon->priv->conf_allow_hibernate_encrypted_swap =
g_key_file_get_boolean (file, "UPower", "AllowHibernateEncryptedSwap", NULL); g_key_file_get_boolean (file, "UPower", "AllowHibernateEncryptedSwap", NULL);
} else { } else {
egg_warning ("failed to load config file: %s", error->message); g_warning ("failed to load config file: %s", error->message);
g_error_free (error); g_error_free (error);
} }
g_key_file_free (file); g_key_file_free (file);

View file

@ -25,8 +25,6 @@
#include <stdio.h> #include <stdio.h>
#include <glib.h> #include <glib.h>
#include "egg-debug.h"
#include "up-native.h" #include "up-native.h"
#include "up-device-list.h" #include "up-device-list.h"
@ -85,13 +83,13 @@ up_device_list_insert (UpDeviceList *list, GObject *native, GObject *device)
native_path = up_native_get_native_path (native); native_path = up_native_get_native_path (native);
if (native_path == NULL) { if (native_path == NULL) {
egg_warning ("failed to get native path"); g_warning ("failed to get native path");
return FALSE; return FALSE;
} }
g_hash_table_insert (list->priv->map_native_path_to_device, g_hash_table_insert (list->priv->map_native_path_to_device,
g_strdup (native_path), g_object_ref (device)); g_strdup (native_path), g_object_ref (device));
g_ptr_array_add (list->priv->array, g_object_ref (device)); g_ptr_array_add (list->priv->array, g_object_ref (device));
egg_debug ("added %s", native_path); g_debug ("added %s", native_path);
return TRUE; return TRUE;
} }
@ -102,7 +100,7 @@ static gboolean
up_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data) up_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data)
{ {
if (value == user_data) { if (value == user_data) {
egg_debug ("removed %s", (char *) key); g_debug ("removed %s", (char *) key);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -124,7 +122,7 @@ up_device_list_remove (UpDeviceList *list, GObject *device)
/* we're removed the last instance? */ /* we're removed the last instance? */
if (!G_IS_OBJECT (device)) { if (!G_IS_OBJECT (device)) {
egg_warning ("INTERNAL STATE CORRUPT: we've removed the last instance of %p", device); g_warning ("INTERNAL STATE CORRUPT: we've removed the last instance of %p", device);
return FALSE; return FALSE;
} }

View file

@ -32,8 +32,6 @@
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib-lowlevel.h>
#include "egg-debug.h"
#include "up-native.h" #include "up-native.h"
#include "up-device.h" #include "up-device.h"
#include "up-history.h" #include "up-history.h"
@ -549,7 +547,7 @@ up_device_coldplug (UpDevice *device, UpDaemon *daemon, GObject *native)
if (klass->coldplug != NULL) { if (klass->coldplug != NULL) {
ret = klass->coldplug (device); ret = klass->coldplug (device);
if (!ret) { if (!ret) {
egg_debug ("failed to coldplug %s", device->priv->native_path); g_debug ("failed to coldplug %s", device->priv->native_path);
goto out; goto out;
} }
} }
@ -557,14 +555,14 @@ up_device_coldplug (UpDevice *device, UpDaemon *daemon, GObject *native)
/* only put on the bus if we succeeded */ /* only put on the bus if we succeeded */
ret = up_device_register_device (device); ret = up_device_register_device (device);
if (!ret) { if (!ret) {
egg_warning ("failed to register device %s", device->priv->native_path); g_warning ("failed to register device %s", device->priv->native_path);
goto out; goto out;
} }
/* force a refresh, although failure isn't fatal */ /* force a refresh, although failure isn't fatal */
ret = up_device_refresh_internal (device); ret = up_device_refresh_internal (device);
if (!ret) { if (!ret) {
egg_debug ("failed to refresh %s", device->priv->native_path); g_debug ("failed to refresh %s", device->priv->native_path);
/* TODO: refresh should really have seporate /* TODO: refresh should really have seporate
* success _and_ changed parameters */ * success _and_ changed parameters */
@ -736,13 +734,13 @@ up_device_refresh_internal (UpDevice *device)
/* do the refresh */ /* do the refresh */
ret = klass->refresh (device); ret = klass->refresh (device);
if (!ret) { if (!ret) {
egg_debug ("no changes"); g_debug ("no changes");
goto out; goto out;
} }
/* the first time, print all properties */ /* the first time, print all properties */
if (!device->priv->has_ever_refresh) { if (!device->priv->has_ever_refresh) {
egg_debug ("added native-path: %s\n", device->priv->native_path); g_debug ("added native-path: %s\n", device->priv->native_path);
device->priv->has_ever_refresh = TRUE; device->priv->has_ever_refresh = TRUE;
goto out; goto out;
} }
@ -828,13 +826,13 @@ up_device_register_device (UpDevice *device)
gboolean ret = TRUE; gboolean ret = TRUE;
device->priv->object_path = up_device_compute_object_path (device); device->priv->object_path = up_device_compute_object_path (device);
egg_debug ("object path = %s", device->priv->object_path); g_debug ("object path = %s", device->priv->object_path);
dbus_g_connection_register_g_object (device->priv->system_bus_connection, dbus_g_connection_register_g_object (device->priv->system_bus_connection,
device->priv->object_path, G_OBJECT (device)); device->priv->object_path, G_OBJECT (device));
device->priv->system_bus_proxy = dbus_g_proxy_new_for_name (device->priv->system_bus_connection, device->priv->system_bus_proxy = dbus_g_proxy_new_for_name (device->priv->system_bus_connection,
DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (device->priv->system_bus_proxy == NULL) { if (device->priv->system_bus_proxy == NULL) {
egg_warning ("proxy invalid"); g_warning ("proxy invalid");
ret = FALSE; ret = FALSE;
} }
return ret; return ret;
@ -861,7 +859,7 @@ up_device_perhaps_changed_cb (GObject *object, GParamSpec *pspec, UpDevice *devi
/* The order here matters; we want Device::Changed() before /* The order here matters; we want Device::Changed() before
* the DeviceChanged() signal on the main object */ * the DeviceChanged() signal on the main object */
egg_debug ("emitting changed on %s", device->priv->native_path); g_debug ("emitting changed on %s", device->priv->native_path);
g_signal_emit (device, signals[SIGNAL_CHANGED], 0); g_signal_emit (device, signals[SIGNAL_CHANGED], 0);
} }
@ -885,7 +883,7 @@ up_device_init (UpDevice *device)
device->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); device->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (device->priv->system_bus_connection == NULL) { if (device->priv->system_bus_connection == NULL) {
egg_error ("error getting system bus: %s", error->message); g_error ("error getting system bus: %s", error->message);
g_error_free (error); g_error_free (error);
} }
g_signal_connect (device, "notify::update-time", G_CALLBACK (up_device_perhaps_changed_cb), device); g_signal_connect (device, "notify::update-time", G_CALLBACK (up_device_perhaps_changed_cb), device);

View file

@ -27,7 +27,6 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <gio/gio.h> #include <gio/gio.h>
#include "egg-debug.h"
#include "up-history.h" #include "up-history.h"
#include "up-stats-item.h" #include "up-stats-item.h"
#include "up-history-item.h" #include "up-history-item.h"
@ -133,7 +132,7 @@ up_history_array_limit_resolution (GPtrArray *array, guint max_num)
gfloat preset; gfloat preset;
new = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); new = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
egg_debug ("length of array (before) %i", array->len); g_debug ("length of array (before) %i", array->len);
/* check length */ /* check length */
length = array->len; length = array->len;
@ -152,7 +151,7 @@ up_history_array_limit_resolution (GPtrArray *array, guint max_num)
first = up_history_item_get_time (item); first = up_history_item_get_time (item);
division = (first - last) / (gfloat) max_num; division = (first - last) / (gfloat) max_num;
egg_debug ("Using a x division of %f (first=%i,last=%i)", division, first, last); g_debug ("Using a x division of %f (first=%i,last=%i)", division, first, last);
/* Reduces the number of points to a pre-set level using a time /* Reduces the number of points to a pre-set level using a time
* division algorithm so we don't keep diluting the previous * division algorithm so we don't keep diluting the previous
@ -193,7 +192,7 @@ up_history_array_limit_resolution (GPtrArray *array, guint max_num)
} }
/* check length */ /* check length */
egg_debug ("length of array (after) %i", new->len); g_debug ("length of array (after) %i", new->len);
out: out:
return new; return new;
} }
@ -216,7 +215,7 @@ up_history_copy_array_timespan (const GPtrArray *array, guint timespan)
/* new data */ /* new data */
array_new = g_ptr_array_new (); array_new = g_ptr_array_new ();
g_get_current_time (&timeval); g_get_current_time (&timeval);
egg_debug ("limiting data to last %i seconds", timespan); g_debug ("limiting data to last %i seconds", timespan);
/* treat the timespan like a range, and search backwards */ /* treat the timespan like a range, and search backwards */
timespan *= 0.95f; timespan *= 0.95f;
@ -364,7 +363,7 @@ cont:
/* average */ /* average */
if (non_zero_accuracy != 0) if (non_zero_accuracy != 0)
average = total_value / non_zero_accuracy; average = total_value / non_zero_accuracy;
egg_debug ("average is %f", average); g_debug ("average is %f", average);
/* make the values a factor of 0, so that 1.0 is twice the /* make the values a factor of 0, so that 1.0 is twice the
* average, and -1.0 is half the average */ * average, and -1.0 is half the average */
@ -445,22 +444,22 @@ up_history_array_to_file (UpHistory *history, GPtrArray *list, const gchar *file
part = g_string_free (string, FALSE); part = g_string_free (string, FALSE);
/* how many did we kill? */ /* how many did we kill? */
egg_debug ("culled %i of %i", cull_count, list->len); g_debug ("culled %i of %i", cull_count, list->len);
/* we failed to convert to string */ /* we failed to convert to string */
if (!ret) { if (!ret) {
egg_warning ("failed to convert"); g_warning ("failed to convert");
goto out; goto out;
} }
/* save to disk */ /* save to disk */
ret = g_file_set_contents (filename, part, -1, &error); ret = g_file_set_contents (filename, part, -1, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to set data: %s", error->message); g_warning ("failed to set data: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
egg_debug ("saved %s", filename); g_debug ("saved %s", filename);
out: out:
g_free (part); g_free (part);
@ -488,14 +487,14 @@ up_history_array_from_file (GPtrArray *list, const gchar *filename)
/* do we exist */ /* do we exist */
ret = g_file_test (filename, G_FILE_TEST_EXISTS); ret = g_file_test (filename, G_FILE_TEST_EXISTS);
if (!ret) { if (!ret) {
egg_debug ("failed to get data from %s as file does not exist", filename); g_debug ("failed to get data from %s as file does not exist", filename);
goto out; goto out;
} }
/* get contents */ /* get contents */
ret = g_file_get_contents (filename, &data, NULL, &error); ret = g_file_get_contents (filename, &data, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get data: %s", error->message); g_warning ("failed to get data: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -504,12 +503,12 @@ up_history_array_from_file (GPtrArray *list, const gchar *filename)
parts = g_strsplit (data, "\n", 0); parts = g_strsplit (data, "\n", 0);
length = g_strv_length (parts); length = g_strv_length (parts);
if (length == 0) { if (length == 0) {
egg_debug ("no data in %s", filename); g_debug ("no data in %s", filename);
goto out; goto out;
} }
/* add valid entries */ /* add valid entries */
egg_debug ("loading %i items of data from %s", length, filename); g_debug ("loading %i items of data from %s", length, filename);
for (i=0; i<length-1; i++) { for (i=0; i<length-1; i++) {
item = up_history_item_new (); item = up_history_item_new ();
ret = up_history_item_set_from_string (item, parts[i]); ret = up_history_item_set_from_string (item, parts[i]);
@ -537,7 +536,7 @@ up_history_save_data (UpHistory *history)
/* we have an ID? */ /* we have an ID? */
if (history->priv->id == NULL) { if (history->priv->id == NULL) {
egg_warning ("no ID, cannot save"); g_warning ("no ID, cannot save");
goto out; goto out;
} }
@ -621,19 +620,19 @@ up_history_schedule_save (UpHistory *history)
/* if low power, then don't batch up save requests */ /* if low power, then don't batch up save requests */
ret = up_history_is_low_power (history); ret = up_history_is_low_power (history);
if (ret) { if (ret) {
egg_warning ("saving directly to disk as low power"); g_warning ("saving directly to disk as low power");
up_history_save_data (history); up_history_save_data (history);
return TRUE; return TRUE;
} }
/* we already have one saved */ /* we already have one saved */
if (history->priv->save_id != 0) { if (history->priv->save_id != 0) {
egg_debug ("deferring as others queued"); g_debug ("deferring as others queued");
return TRUE; return TRUE;
} }
/* nothing scheduled, do new */ /* nothing scheduled, do new */
egg_debug ("saving in %i seconds", UP_HISTORY_SAVE_INTERVAL); g_debug ("saving in %i seconds", UP_HISTORY_SAVE_INTERVAL);
history->priv->save_id = g_timeout_add_seconds (UP_HISTORY_SAVE_INTERVAL, history->priv->save_id = g_timeout_add_seconds (UP_HISTORY_SAVE_INTERVAL,
(GSourceFunc) up_history_schedule_save_cb, history); (GSourceFunc) up_history_schedule_save_cb, history);
#if GLIB_CHECK_VERSION(2,25,8) #if GLIB_CHECK_VERSION(2,25,8)
@ -699,7 +698,7 @@ up_history_set_id (UpHistory *history, const gchar *id)
if (id == NULL) if (id == NULL)
return FALSE; return FALSE;
egg_debug ("using id: %s", id); g_debug ("using id: %s", id);
history->priv->id = g_strdup (id); history->priv->id = g_strdup (id);
/* load all previous data */ /* load all previous data */
ret = up_history_load_data (history); ret = up_history_load_data (history);

View file

@ -34,8 +34,6 @@
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include "egg-debug.h"
#include "up-kbd-backlight.h" #include "up-kbd-backlight.h"
#include "up-marshal.h" #include "up-marshal.h"
#include "up-daemon.h" #include "up-daemon.h"
@ -76,7 +74,7 @@ up_kbd_backlight_brightness_write (UpKbdBacklight *kbd_backlight, gint value)
/* write new values to backlight */ /* write new values to backlight */
if (kbd_backlight->priv->fd < 0) { if (kbd_backlight->priv->fd < 0) {
egg_warning ("cannot write to kbd_backlight as file not open"); g_warning ("cannot write to kbd_backlight as file not open");
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -92,7 +90,7 @@ up_kbd_backlight_brightness_write (UpKbdBacklight *kbd_backlight, gint value)
lseek (kbd_backlight->priv->fd, 0, SEEK_SET); lseek (kbd_backlight->priv->fd, 0, SEEK_SET);
retval = write (kbd_backlight->priv->fd, text, length); retval = write (kbd_backlight->priv->fd, text, length);
if (retval != length) { if (retval != length) {
egg_warning ("writing '%s' to device failed", text); g_warning ("writing '%s' to device failed", text);
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -141,7 +139,7 @@ up_kbd_backlight_set_brightness (UpKbdBacklight *kbd_backlight, gint value, GErr
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
egg_debug ("setting brightness to %i", value); g_debug ("setting brightness to %i", value);
ret = up_kbd_backlight_brightness_write(kbd_backlight, value); ret = up_kbd_backlight_brightness_write(kbd_backlight, value);
if (!ret) { if (!ret) {
@ -195,7 +193,7 @@ up_kbd_backlight_find (UpKbdBacklight *kbd_backlight)
/* open directory */ /* open directory */
dir = g_dir_open ("/sys/class/leds", 0, &error); dir = g_dir_open ("/sys/class/leds", 0, &error);
if (dir == NULL) { if (dir == NULL) {
egg_warning ("failed to get directory: %s", error->message); g_warning ("failed to get directory: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -217,13 +215,13 @@ up_kbd_backlight_find (UpKbdBacklight *kbd_backlight)
path_max = g_build_filename (dir_path, "max_brightness", NULL); path_max = g_build_filename (dir_path, "max_brightness", NULL);
ret = g_file_get_contents (path_max, &buf_max, NULL, &error); ret = g_file_get_contents (path_max, &buf_max, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get max brightness: %s", error->message); g_warning ("failed to get max brightness: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
kbd_backlight->priv->max_brightness = g_ascii_strtoull (buf_max, &end, 10); kbd_backlight->priv->max_brightness = g_ascii_strtoull (buf_max, &end, 10);
if (kbd_backlight->priv->max_brightness == 0 && end == buf_max) { if (kbd_backlight->priv->max_brightness == 0 && end == buf_max) {
egg_warning ("failed to convert max brightness: %s", buf_max); g_warning ("failed to convert max brightness: %s", buf_max);
goto out; goto out;
} }
@ -231,13 +229,13 @@ up_kbd_backlight_find (UpKbdBacklight *kbd_backlight)
path_now = g_build_filename (dir_path, "brightness", NULL); path_now = g_build_filename (dir_path, "brightness", NULL);
ret = g_file_get_contents (path_now, &buf_now, NULL, &error); ret = g_file_get_contents (path_now, &buf_now, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get brightness: %s", error->message); g_warning ("failed to get brightness: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
kbd_backlight->priv->brightness = g_ascii_strtoull (buf_now, &end, 10); kbd_backlight->priv->brightness = g_ascii_strtoull (buf_now, &end, 10);
if (kbd_backlight->priv->brightness == 0 && end == buf_now) { if (kbd_backlight->priv->brightness == 0 && end == buf_now) {
egg_warning ("failed to convert brightness: %s", buf_now); g_warning ("failed to convert brightness: %s", buf_now);
goto out; goto out;
} }
@ -271,13 +269,13 @@ up_kbd_backlight_init (UpKbdBacklight *kbd_backlight)
/* find a kbd backlight in sysfs */ /* find a kbd backlight in sysfs */
if (!up_kbd_backlight_find (kbd_backlight)) { if (!up_kbd_backlight_find (kbd_backlight)) {
egg_debug ("cannot find a keyboard backlight"); g_debug ("cannot find a keyboard backlight");
return; return;
} }
kbd_backlight->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); kbd_backlight->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error != NULL) { if (error != NULL) {
egg_warning ("Cannot connect to bus: %s", error->message); g_warning ("Cannot connect to bus: %s", error->message);
g_error_free (error); g_error_free (error);
return; return;
} }

View file

@ -36,8 +36,6 @@
#include <dbus/dbus-glib.h> #include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib-lowlevel.h>
#include "egg-debug.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-qos.h" #include "up-qos.h"
#include "up-kbd-backlight.h" #include "up-kbd-backlight.h"
@ -67,10 +65,10 @@ up_main_acquire_name_on_proxy (DBusGProxy *bus_proxy, const gchar *name)
G_TYPE_INVALID); G_TYPE_INVALID);
if (!ret) { if (!ret) {
if (error != NULL) { if (error != NULL) {
egg_warning ("Failed to acquire %s: %s", name, error->message); g_warning ("Failed to acquire %s: %s", name, error->message);
g_error_free (error); g_error_free (error);
} else { } else {
egg_warning ("Failed to acquire %s", name); g_warning ("Failed to acquire %s", name);
} }
goto out; goto out;
} }
@ -78,10 +76,10 @@ up_main_acquire_name_on_proxy (DBusGProxy *bus_proxy, const gchar *name)
/* already taken */ /* already taken */
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
if (error != NULL) { if (error != NULL) {
egg_warning ("Failed to acquire %s: %s", name, error->message); g_warning ("Failed to acquire %s: %s", name, error->message);
g_error_free (error); g_error_free (error);
} else { } else {
egg_warning ("Failed to acquire %s", name); g_warning ("Failed to acquire %s", name);
} }
ret = FALSE; ret = FALSE;
goto out; goto out;
@ -96,7 +94,7 @@ out:
static void static void
up_main_sigint_handler (gint sig) up_main_sigint_handler (gint sig)
{ {
egg_debug ("Handling SIGINT"); g_debug ("Handling SIGINT");
/* restore default */ /* restore default */
signal (SIGINT, SIG_DFL); signal (SIGINT, SIG_DFL);
@ -151,14 +149,13 @@ main (gint argc, gchar **argv)
context = g_option_context_new ("upower daemon"); context = g_option_context_new ("upower daemon");
g_option_context_add_main_entries (context, options, NULL); g_option_context_add_main_entries (context, options, NULL);
g_option_context_add_group (context, egg_debug_get_option_group ());
g_option_context_parse (context, &argc, &argv, NULL); g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context); g_option_context_free (context);
/* get bus connection */ /* get bus connection */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (bus == NULL) { if (bus == NULL) {
egg_warning ("Couldn't connect to system bus: %s", error->message); g_warning ("Couldn't connect to system bus: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -167,21 +164,21 @@ main (gint argc, gchar **argv)
bus_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS, bus_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (bus_proxy == NULL) { if (bus_proxy == NULL) {
egg_warning ("Could not construct bus_proxy object; bailing out"); g_warning ("Could not construct bus_proxy object; bailing out");
goto out; goto out;
} }
/* aquire name */ /* aquire name */
ret = up_main_acquire_name_on_proxy (bus_proxy, DEVKIT_POWER_SERVICE_NAME); ret = up_main_acquire_name_on_proxy (bus_proxy, DEVKIT_POWER_SERVICE_NAME);
if (!ret) { if (!ret) {
egg_warning ("Could not acquire name; bailing out"); g_warning ("Could not acquire name; bailing out");
goto out; goto out;
} }
/* do stuff on ctrl-c */ /* do stuff on ctrl-c */
signal (SIGINT, up_main_sigint_handler); signal (SIGINT, up_main_sigint_handler);
egg_debug ("Starting upowerd version %s", PACKAGE_VERSION); g_debug ("Starting upowerd version %s", PACKAGE_VERSION);
qos = up_qos_new (); qos = up_qos_new ();
kbd_backlight = up_kbd_backlight_new (); kbd_backlight = up_kbd_backlight_new ();
@ -190,7 +187,7 @@ main (gint argc, gchar **argv)
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
ret = up_daemon_startup (daemon); ret = up_daemon_startup (daemon);
if (!ret) { if (!ret) {
egg_warning ("Could not startup; bailing out"); g_warning ("Could not startup; bailing out");
goto out; goto out;
} }

View file

@ -30,8 +30,6 @@
#include <polkit/polkit.h> #include <polkit/polkit.h>
#include "egg-debug.h"
#include "up-polkit.h" #include "up-polkit.h"
#include "up-daemon.h" #include "up-daemon.h"
@ -145,7 +143,7 @@ up_polkit_get_uid (UpPolkit *polkit, PolkitSubject *subject, uid_t *uid)
const gchar *name; const gchar *name;
if (!POLKIT_IS_SYSTEM_BUS_NAME (subject)) { if (!POLKIT_IS_SYSTEM_BUS_NAME (subject)) {
egg_debug ("not system bus name"); g_debug ("not system bus name");
return FALSE; return FALSE;
} }
@ -168,7 +166,7 @@ up_polkit_get_pid (UpPolkit *polkit, PolkitSubject *subject, pid_t *pid)
/* bus name? */ /* bus name? */
if (!POLKIT_IS_SYSTEM_BUS_NAME (subject)) { if (!POLKIT_IS_SYSTEM_BUS_NAME (subject)) {
egg_debug ("not system bus name"); g_debug ("not system bus name");
goto out; goto out;
} }
@ -178,7 +176,7 @@ up_polkit_get_pid (UpPolkit *polkit, PolkitSubject *subject, pid_t *pid)
"/org/freedesktop/DBus/Bus", "/org/freedesktop/DBus/Bus",
"org.freedesktop.DBus", &error); "org.freedesktop.DBus", &error);
if (proxy == NULL) { if (proxy == NULL) {
egg_warning ("DBUS error: %s", error->message); g_warning ("DBUS error: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -190,7 +188,7 @@ up_polkit_get_pid (UpPolkit *polkit, PolkitSubject *subject, pid_t *pid)
G_TYPE_UINT, pid, G_TYPE_UINT, pid,
G_TYPE_INVALID); G_TYPE_INVALID);
if (!ret) { if (!ret) {
egg_warning ("failed to get pid: %s", error->message); g_warning ("failed to get pid: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }

View file

@ -32,8 +32,6 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include "egg-debug.h"
#include "up-qos.h" #include "up-qos.h"
#include "up-marshal.h" #include "up-marshal.h"
#include "up-daemon.h" #include "up-daemon.h"
@ -141,7 +139,7 @@ up_qos_get_lowest (UpQos *qos, UpQosKind type)
/* over-ride */ /* over-ride */
if (lowest < qos->priv->minimum[type]) { if (lowest < qos->priv->minimum[type]) {
egg_debug ("minium override from %i to %i", lowest, qos->priv->minimum[type]); g_debug ("minium override from %i to %i", lowest, qos->priv->minimum[type]);
lowest = qos->priv->minimum[type]; lowest = qos->priv->minimum[type];
} }
@ -165,7 +163,7 @@ up_qos_latency_write (UpQos *qos, UpQosKind type, gint value)
/* write new values to pm-qos */ /* write new values to pm-qos */
if (qos->priv->fd[type] < 0) { if (qos->priv->fd[type] < 0) {
egg_warning ("cannot write to pm-qos as file not open"); g_warning ("cannot write to pm-qos as file not open");
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -177,7 +175,7 @@ up_qos_latency_write (UpQos *qos, UpQosKind type, gint value)
/* write to device file */ /* write to device file */
retval = write (qos->priv->fd[type], text, length); retval = write (qos->priv->fd[type], text, length);
if (retval != length) { if (retval != length) {
egg_warning ("writing '%s' to device failed", text); g_warning ("writing '%s' to device failed", text);
ret = FALSE; ret = FALSE;
goto out; goto out;
} }
@ -229,7 +227,7 @@ up_qos_get_cmdline (gint pid)
filename = g_strdup_printf ("/proc/%i/cmdline", pid); filename = g_strdup_printf ("/proc/%i/cmdline", pid);
ret = g_file_get_contents (filename, &cmdline, NULL, &error); ret = g_file_get_contents (filename, &cmdline, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get cmdline: %s", error->message); g_warning ("failed to get cmdline: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -327,7 +325,7 @@ up_qos_request_latency (UpQos *qos, const gchar *type_text, gint value, gboolean
up_qos_item_set_kind (item, type); up_qos_item_set_kind (item, type);
g_ptr_array_add (qos->priv->data, item); g_ptr_array_add (qos->priv->data, item);
egg_debug ("Recieved Qos from '%s' (%i:%i)' saving as #%i", g_debug ("Recieved Qos from '%s' (%i:%i)' saving as #%i",
up_qos_item_get_sender (item), up_qos_item_get_sender (item),
up_qos_item_get_value (item), up_qos_item_get_value (item),
up_qos_item_get_persistent (item), up_qos_item_get_persistent (item),
@ -386,7 +384,7 @@ up_qos_cancel_request (UpQos *qos, guint cookie, DBusGMethodInvocation *context)
goto out; goto out;
} }
egg_debug ("Clear #%i", cookie); g_debug ("Clear #%i", cookie);
/* remove object from list */ /* remove object from list */
g_ptr_array_remove (qos->priv->data, item); g_ptr_array_remove (qos->priv->data, item);
@ -443,7 +441,7 @@ up_qos_set_minimum_latency (UpQos *qos, const gchar *type_text, gint value, DBus
return; return;
} }
egg_debug ("setting %s minimum to %i", type_text, value); g_debug ("setting %s minimum to %i", type_text, value);
qos->priv->minimum[type] = value; qos->priv->minimum[type] = value;
/* may have changed */ /* may have changed */
@ -505,7 +503,7 @@ up_qos_remove_dbus (UpQos *qos, const gchar *sender)
for (i=0; i<data->len; i++) { for (i=0; i<data->len; i++) {
item = g_ptr_array_index (data, i); item = g_ptr_array_index (data, i);
if (strcmp (up_qos_item_get_sender (item), sender) == 0) { if (strcmp (up_qos_item_get_sender (item), sender) == 0) {
egg_debug ("Auto-revoked idle qos on %s", sender); g_debug ("Auto-revoked idle qos on %s", sender);
g_ptr_array_remove (qos->priv->data, item); g_ptr_array_remove (qos->priv->data, item);
up_qos_latency_perhaps_changed (qos, up_qos_item_get_kind (item)); up_qos_latency_perhaps_changed (qos, up_qos_item_get_kind (item));
} }
@ -574,14 +572,14 @@ up_qos_init (UpQos *qos)
qos->priv->fd[UP_QOS_KIND_CPU_DMA] = open ("/dev/cpu_dma_latency", O_WRONLY); qos->priv->fd[UP_QOS_KIND_CPU_DMA] = open ("/dev/cpu_dma_latency", O_WRONLY);
if (qos->priv->fd[UP_QOS_KIND_CPU_DMA] < 0) if (qos->priv->fd[UP_QOS_KIND_CPU_DMA] < 0)
egg_warning ("cannot open cpu_dma device file"); g_debug ("cannot open cpu_dma device file");
qos->priv->fd[UP_QOS_KIND_NETWORK] = open ("/dev/network_latency", O_WRONLY); qos->priv->fd[UP_QOS_KIND_NETWORK] = open ("/dev/network_latency", O_WRONLY);
if (qos->priv->fd[UP_QOS_KIND_NETWORK] < 0) if (qos->priv->fd[UP_QOS_KIND_NETWORK] < 0)
egg_warning ("cannot open network device file"); g_debug ("cannot open network device file");
qos->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); qos->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error != NULL) { if (error != NULL) {
egg_warning ("Cannot connect to bus: %s", error->message); g_warning ("Cannot connect to bus: %s", error->message);
g_error_free (error); g_error_free (error);
return; return;
} }

View file

@ -24,8 +24,6 @@
#include <glib-object.h> #include <glib-object.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <up-history-item.h> #include <up-history-item.h>
#include "egg-debug.h"
#include "up-backend.h" #include "up-backend.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-device.h" #include "up-device.h"
@ -273,7 +271,6 @@ main (int argc, char **argv)
{ {
g_type_init (); g_type_init ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
egg_debug_init (&argc, &argv);
/* tests go here */ /* tests go here */
g_test_add_func ("/power/backend", up_test_backend_func); g_test_add_func ("/power/backend", up_test_backend_func);

View file

@ -27,8 +27,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "egg-debug.h"
#include "up-wakeups.h" #include "up-wakeups.h"
#include "up-daemon.h" #include "up-daemon.h"
#include "up-marshal.h" #include "up-marshal.h"
@ -99,7 +97,7 @@ up_wakeups_get_cmdline (guint pid)
filename = g_strdup_printf ("/proc/%i/cmdline", pid); filename = g_strdup_printf ("/proc/%i/cmdline", pid);
ret = g_file_get_contents (filename, &cmdline, NULL, &error); ret = g_file_get_contents (filename, &cmdline, NULL, &error);
if (!ret) { if (!ret) {
egg_debug ("failed to get cmdline: %s", error->message); g_debug ("failed to get cmdline: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -347,7 +345,7 @@ up_wakeups_poll_kernel_cb (UpWakeups *wakeups)
GPtrArray *sections; GPtrArray *sections;
UpWakeupItem *item; UpWakeupItem *item;
egg_debug ("event"); g_debug ("event");
/* set all kernel data objs to zero */ /* set all kernel data objs to zero */
for (i=0; i<wakeups->priv->data->len; i++) { for (i=0; i<wakeups->priv->data->len; i++) {
@ -359,7 +357,7 @@ up_wakeups_poll_kernel_cb (UpWakeups *wakeups)
/* get the data */ /* get the data */
ret = g_file_get_contents (UP_WAKEUPS_SOURCE_KERNEL, &data, NULL, &error); ret = g_file_get_contents (UP_WAKEUPS_SOURCE_KERNEL, &data, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get data: %s", error->message); g_warning ("failed to get data: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -472,7 +470,7 @@ up_wakeups_poll_userspace_cb (UpWakeups *wakeups)
guint interrupts; guint interrupts;
gfloat interval = 5.0f; gfloat interval = 5.0f;
egg_debug ("event"); g_debug ("event");
/* set all userspace data objs to zero */ /* set all userspace data objs to zero */
for (i=0; i<wakeups->priv->data->len; i++) { for (i=0; i<wakeups->priv->data->len; i++) {
@ -484,7 +482,7 @@ up_wakeups_poll_userspace_cb (UpWakeups *wakeups)
/* get the data */ /* get the data */
ret = g_file_get_contents (UP_WAKEUPS_SOURCE_USERSPACE, &data, NULL, &error); ret = g_file_get_contents (UP_WAKEUPS_SOURCE_USERSPACE, &data, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to get data: %s", error->message); g_warning ("failed to get data: %s", error->message);
g_error_free (error); g_error_free (error);
goto out; goto out;
} }
@ -507,7 +505,7 @@ up_wakeups_poll_userspace_cb (UpWakeups *wakeups)
if (strstr (lines[i], "Sample period:") != NULL) { if (strstr (lines[i], "Sample period:") != NULL) {
string = g_ptr_array_index (sections, 2); string = g_ptr_array_index (sections, 2);
interval = atof (string); interval = atof (string);
egg_debug ("interval=%f", interval); g_debug ("interval=%f", interval);
goto skip; goto skip;
} }
@ -584,7 +582,7 @@ up_wakeups_timerstats_disable (UpWakeups *wakeups)
if (!wakeups->priv->polling_enabled) if (!wakeups->priv->polling_enabled)
return TRUE; return TRUE;
egg_debug ("disabling timer stats"); g_debug ("disabling timer stats");
/* clear polling */ /* clear polling */
if (wakeups->priv->poll_kernel_id != 0) { if (wakeups->priv->poll_kernel_id != 0) {
@ -615,7 +613,7 @@ up_wakeups_timerstats_disable (UpWakeups *wakeups)
static gboolean static gboolean
up_wakeups_disable_cb (UpWakeups *wakeups) up_wakeups_disable_cb (UpWakeups *wakeups)
{ {
egg_debug ("disabling timer stats as we are idle"); g_debug ("disabling timer stats as we are idle");
up_wakeups_timerstats_disable (wakeups); up_wakeups_timerstats_disable (wakeups);
/* never repeat */ /* never repeat */
@ -644,7 +642,7 @@ up_wakeups_timerstats_enable (UpWakeups *wakeups)
if (wakeups->priv->polling_enabled) if (wakeups->priv->polling_enabled)
return TRUE; return TRUE;
egg_debug ("enabling timer stats"); g_debug ("enabling timer stats");
/* setup polls */ /* setup polls */
wakeups->priv->poll_kernel_id = wakeups->priv->poll_kernel_id =
@ -747,7 +745,7 @@ up_wakeups_init (UpWakeups *wakeups)
wakeups->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); wakeups->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error != NULL) { if (error != NULL) {
egg_warning ("Cannot connect to bus: %s", error->message); g_warning ("Cannot connect to bus: %s", error->message);
g_error_free (error); g_error_free (error);
return; return;
} }

View file

@ -2,6 +2,7 @@
INCLUDES = \ INCLUDES = \
-DUP_COMPILATION \ -DUP_COMPILATION \
-DG_LOG_DOMAIN=\"UPower\" \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/libupower-glib \ -I$(top_srcdir)/libupower-glib \
$(DBUS_GLIB_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \
@ -13,8 +14,6 @@ UPOWER_LIBS = $(top_builddir)/libupower-glib/libupower-glib.la
bin_PROGRAMS = upower bin_PROGRAMS = upower
upower_SOURCES = \ upower_SOURCES = \
egg-debug.c \
egg-debug.h \
up-tool.c \ up-tool.c \
$(BUILT_SOURCES) $(BUILT_SOURCES)

View file

@ -1 +0,0 @@
../src/egg-debug.c

View file

@ -1 +0,0 @@
../src/egg-debug.h

View file

@ -35,8 +35,6 @@
#include "up-device.h" #include "up-device.h"
#include "up-wakeups.h" #include "up-wakeups.h"
#include "egg-debug.h"
static GMainLoop *loop; static GMainLoop *loop;
static gboolean opt_monitor_detail = FALSE; static gboolean opt_monitor_detail = FALSE;
@ -275,7 +273,6 @@ main (int argc, char **argv)
context = g_option_context_new ("UPower tool"); context = g_option_context_new ("UPower tool");
g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_main_entries (context, entries, NULL);
g_option_context_add_group (context, egg_debug_get_option_group ());
g_option_context_parse (context, &argc, &argv, NULL); g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context); g_option_context_free (context);
@ -306,7 +303,7 @@ main (int argc, char **argv)
GPtrArray *devices; GPtrArray *devices;
ret = up_client_enumerate_devices_sync (client, NULL, &error); ret = up_client_enumerate_devices_sync (client, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to enumerate: %s", error->message); g_warning ("failed to enumerate: %s", error->message);
goto out; goto out;
} }
devices = up_client_get_devices (client); devices = up_client_get_devices (client);
@ -333,7 +330,7 @@ main (int argc, char **argv)
if (opt_monitor || opt_monitor_detail) { if (opt_monitor || opt_monitor_detail) {
ret = up_client_enumerate_devices_sync (client, NULL, &error); ret = up_client_enumerate_devices_sync (client, NULL, &error);
if (!ret) { if (!ret) {
egg_warning ("failed to enumerate: %s", error->message); g_warning ("failed to enumerate: %s", error->message);
goto out; goto out;
} }
if (!up_tool_do_monitor (client)) if (!up_tool_do_monitor (client))