3 * Authors (alphabetical) :
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Public License as published by
8 * the Free Software Foundation; version 2 of the license.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser Public License for more details.
16 #ifndef FRAMEWORKD_GLIB_OUSAGED_H
17 #define FRAMEWORKD_GLIB_OUSAGED_H
20 #include <dbus/dbus-glib.h>
23 #define USAGE_ERROR g_quark_from_static_string(USAGE_INTERFACE)
24 #define IS_USAGE_ERROR(error, code) g_error_matches(error, USAGE_ERROR, code)
25 #define DBUS_USAGE_ERROR_POLICY_UNKNOWN "org.freesmartphone.Usage.PolicyUnknown"
26 #define DBUS_USAGE_ERROR_POLICY_DISABLED "org.freesmartphone.Usage.PolicyDisabled"
27 #define DBUS_USAGE_ERROR_RESOURCE_UNKNOWN "org.freesmartphone.Usage.ResourceUnknown"
28 #define DBUS_USAGE_ERROR_RESOURCE_EXISTS "org.freesmartphone.Usage.ResourceExists"
29 #define DBUS_USAGE_ERROR_RESOURCE_IN_USE "org.freesmartphone.Usage.ResourceInUse"
30 #define DBUS_USAGE_ERROR_USER_EXISTS "org.freesmartphone.Usage.UserExists"
31 #define DBUS_USAGE_ERROR_USER_UNKNOWN "org.freesmartphone.Usage.UserUnknown"
32 #define RESOURCE_ERROR g_quark_from_static_string(RESOURCE_INTERFACE)
33 #define IS_RESOURCE_ERROR(error, code) g_error_matches(error, RESOURCE_ERROR, code)
34 #define DBUS_RESOURCE_ERROR_NOT_ENABLED "org.freesmartphone.Resource.NotEnabled"
36 USAGE_ERROR_POLICY_UNKNOWN
= -1,
37 USAGE_ERROR_POLICY_DISABLED
= -2,
38 USAGE_ERROR_RESOURCE_UNKNOWN
= -3,
39 USAGE_ERROR_RESOURCE_EXISTS
= -4,
40 USAGE_ERROR_RESOURCE_IN_USE
= -5,
41 USAGE_ERROR_USER_EXISTS
= -6,
42 USAGE_ERROR_USER_UNKNOWN
= -7
46 RESOURCE_ERROR_NOT_ENABLED
= -1
50 OUSAGED_RESOURCE_UNKNOWN
= 0,
51 OUSAGED_RESOURCE_GSM
= 1,
52 OUSAGED_RESOURCE_GPS
= 2,
53 OUSAGED_RESOURCE_WIFI
= 3,
54 OUSAGED_RESOURCE_BLUETOOTH
= 4,
55 OUSAGED_RESOURCE_DISPLAY
= 5,
56 OUSAGED_RESOURCE_CPU
= 6
59 #define OUSAGED_RESOURCE_COUNT 7
61 GError
*ousaged_handle_errors(GError
* dbus_error
);
62 GError
*ousaged_handle_resource_errors(GError
* dbus_error
);
63 int ousaged_resource_name_to_int(const char *resource
);
65 void ousaged_list_resources(void (*callback
) (GError
*, char **, gpointer
),
68 void ousaged_get_resource_policy(const char *name
,
69 void (*callback
) (GError
*, char *, gpointer
),
72 void ousaged_set_resource_policy(const char *name
, const char *policy
,
73 void (*callback
) (GError
*, gpointer
),
76 void ousaged_get_resource_state(const char *name
,
77 void (*callback
) (GError
*, gboolean
, gpointer
),
80 void ousaged_get_resource_users(const char *name
,
81 void (*callback
) (GError
*, char **, gpointer
),
84 void ousaged_request_resource(const char *name
,
85 void (*callback
) (GError
*, gpointer
),
88 void ousaged_release_resource(const char *name
,
89 void (*callback
) (GError
*, gpointer
),
92 void ousaged_suspend(void (*callback
) (GError
*, gpointer
), gpointer userdata
);
94 void ousaged_shutdown(void (*callback
) (GError
*, gpointer
), gpointer userdata
);
96 void ousaged_resource_available_handler(DBusGProxy
* proxy
, const char *name
,
97 gboolean availability
,
100 void ousaged_resource_changed_handler(DBusGProxy
* proxy
, const char *name
,
101 gboolean state
, GHashTable
* attributes
,
104 extern DBusGProxy
*ousagedBus
;