~peter-pearse/ubuntu/oneiric/upower/prop001

« back to all changes in this revision

Viewing changes to src/up-daemon.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-05 14:31:17 UTC
  • mfrom: (15.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110505143117-9clyzsrw45vt5g6y
Tags: 0.9.10-1
* New upstream release:
  - Fix "unknown" battery status guessing to not be recursive. (LP: #384304)
* debian/control: Drop obsolete devicekit-power-* Conflicts/Replaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <dbus/dbus-glib.h>
33
33
#include <dbus/dbus-glib-lowlevel.h>
34
34
 
 
35
#include "up-config.h"
35
36
#include "up-polkit.h"
36
37
#include "up-device-list.h"
37
38
#include "up-device.h"
73
74
{
74
75
        DBusGConnection         *connection;
75
76
        DBusGProxy              *proxy;
 
77
        UpConfig                *config;
76
78
        UpPolkit                *polkit;
77
79
        UpBackend               *backend;
78
80
        UpDeviceList            *power_devices;
114
116
#define UP_DAEMON_ON_BATTERY_REFRESH_DEVICES_DELAY      1 /* seconds */
115
117
#define UP_DAEMON_POLL_BATTERY_NUMBER_TIMES             5
116
118
 
 
119
/* D-BUS to connect to. Can be set to session bus for testing */
 
120
static DBusBusType daemon_bus_type = DBUS_BUS_SYSTEM;
 
121
 
 
122
DBusBusType
 
123
up_daemon_get_bus_type (void)
 
124
{
 
125
        return daemon_bus_type;
 
126
}
 
127
 
 
128
void
 
129
up_daemon_set_bus_type (DBusBusType type)
 
130
{
 
131
        daemon_bus_type = type;
 
132
}
 
133
 
117
134
/**
118
135
 * up_daemon_get_on_battery_local:
119
136
 *
669
686
        gboolean ret = FALSE;
670
687
        UpDaemonPrivate *priv = daemon->priv;
671
688
 
672
 
        priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
 
689
        priv->connection = dbus_g_bus_get (up_daemon_get_bus_type (), &error);
673
690
        if (priv->connection == NULL) {
674
691
                if (error != NULL) {
675
692
                        g_critical ("error getting system bus: %s", error->message);
759
776
up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed)
760
777
{
761
778
        UpDaemonPrivate *priv = daemon->priv;
 
779
 
 
780
        /* check if we are ignoring the lid */
 
781
        if (up_config_get_boolean (priv->config, "IgnoreLid")) {
 
782
                g_debug ("ignoring lid state");
 
783
                return;
 
784
        }
 
785
 
762
786
        g_debug ("lid_is_closed = %s", lid_is_closed ? "yes" : "no");
763
787
        priv->lid_is_closed = lid_is_closed;
764
788
        g_object_notify (G_OBJECT (daemon), "lid-is-closed");
783
807
up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present)
784
808
{
785
809
        UpDaemonPrivate *priv = daemon->priv;
 
810
 
 
811
        /* check if we are ignoring the lid */
 
812
        if (up_config_get_boolean (priv->config, "IgnoreLid")) {
 
813
                g_debug ("ignoring lid state");
 
814
                return;
 
815
        }
 
816
 
786
817
        g_debug ("lid_is_present = %s", lid_is_present ? "yes" : "no");
787
818
        priv->lid_is_present = lid_is_present;
788
819
        g_object_notify (G_OBJECT (daemon), "lid-is-present");
1028
1059
 
1029
1060
        daemon->priv = UP_DAEMON_GET_PRIVATE (daemon);
1030
1061
        daemon->priv->polkit = up_polkit_new ();
 
1062
        daemon->priv->config = up_config_new ();
1031
1063
        daemon->priv->lid_is_present = FALSE;
1032
1064
        daemon->priv->is_docked = FALSE;
1033
1065
        daemon->priv->lid_is_closed = FALSE;
1345
1377
                dbus_g_connection_unref (priv->connection);
1346
1378
        g_object_unref (priv->power_devices);
1347
1379
        g_object_unref (priv->polkit);
 
1380
        g_object_unref (priv->config);
1348
1381
        g_object_unref (priv->backend);
1349
1382
        g_timer_destroy (priv->about_to_sleep_timer);
1350
1383