diff options
| author | Martin Jansa <Martin.Jansa@gmail.com> | 2014-02-23 01:24:52 +0100 |
|---|---|---|
| committer | Martin Jansa <Martin.Jansa@gmail.com> | 2014-04-20 10:43:30 +0200 |
| commit | d30f99e6bb59131837dd4fef0c12cc8783f039c4 (patch) | |
| tree | 1836c5b7546c8554c9d5609e499ee3b135276d76 /meta-efl/recipes-efl/e17 | |
| parent | 6c9ef2d6fec8a5bee6b17e6ab824e953fd016acc (diff) | |
| download | meta-openembedded-d30f99e6bb59131837dd4fef0c12cc8783f039c4.tar.gz | |
e-tasks: Migrate to eldbus
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-efl/recipes-efl/e17')
| -rw-r--r-- | meta-efl/recipes-efl/e17/e-tasks/0001-dbus-stuff-Convert-to-eldbus.patch | 204 | ||||
| -rw-r--r-- | meta-efl/recipes-efl/e17/e-tasks_git.bb | 4 |
2 files changed, 207 insertions, 1 deletions
diff --git a/meta-efl/recipes-efl/e17/e-tasks/0001-dbus-stuff-Convert-to-eldbus.patch b/meta-efl/recipes-efl/e17/e-tasks/0001-dbus-stuff-Convert-to-eldbus.patch new file mode 100644 index 0000000000..f92a772fe1 --- /dev/null +++ b/meta-efl/recipes-efl/e17/e-tasks/0001-dbus-stuff-Convert-to-eldbus.patch | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | From 37223289b3d85ea8876e7ba7c9ff97ec428073ba Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 3 | Date: Sat, 22 Feb 2014 14:36:38 +0100 | ||
| 4 | Subject: [PATCH] dbus-stuff: Convert to eldbus | ||
| 5 | |||
| 6 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
| 7 | --- | ||
| 8 | configure.ac | 2 +- | ||
| 9 | src/Makefile.am | 2 +- | ||
| 10 | src/dbus-stuff.c | 95 ++++++++++++++++++++++++++++++++------------------------ | ||
| 11 | src/dbus-stuff.h | 13 ++------ | ||
| 12 | src/main.c | 2 +- | ||
| 13 | 5 files changed, 61 insertions(+), 53 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/configure.ac b/configure.ac | ||
| 16 | index b3e4d12..4ace32a 100644 | ||
| 17 | --- a/configure.ac | ||
| 18 | +++ b/configure.ac | ||
| 19 | @@ -15,7 +15,7 @@ AC_HEADER_STDC | ||
| 20 | |||
| 21 | AM_PROG_LIBTOOL | ||
| 22 | |||
| 23 | -PKG_CHECK_MODULES(TASKS, [elementary eina dbus-1 edbus sqlite3]) | ||
| 24 | +PKG_CHECK_MODULES(TASKS, [elementary eina dbus-1 eldbus sqlite3]) | ||
| 25 | |||
| 26 | AC_OUTPUT([ | ||
| 27 | Makefile | ||
| 28 | diff --git a/src/Makefile.am b/src/Makefile.am | ||
| 29 | index 2143dc9..31d5253 100644 | ||
| 30 | --- a/src/Makefile.am | ||
| 31 | +++ b/src/Makefile.am | ||
| 32 | @@ -8,7 +8,7 @@ AM_CPPFLAGS = \ | ||
| 33 | $(TASKS_CFLAGS) | ||
| 34 | |||
| 35 | AM_CFLAGS =\ | ||
| 36 | - $(EDBUS_CFLAGS) \ | ||
| 37 | + $(ELDBUS_CFLAGS) \ | ||
| 38 | -Wall\ | ||
| 39 | -g | ||
| 40 | |||
| 41 | diff --git a/src/dbus-stuff.c b/src/dbus-stuff.c | ||
| 42 | index 50809bc..9f02ef3 100644 | ||
| 43 | --- a/src/dbus-stuff.c | ||
| 44 | +++ b/src/dbus-stuff.c | ||
| 45 | @@ -1,8 +1,7 @@ | ||
| 46 | /*************************************************************************** | ||
| 47 | * dbus-stuff.c | ||
| 48 | * | ||
| 49 | - * Copyright 2009 cchandel | ||
| 50 | - * <cchandel@yahoo.com> | ||
| 51 | + * Copyright 2009 cchandel <cchandel@yahoo.com> | ||
| 52 | ****************************************************************************/ | ||
| 53 | |||
| 54 | /* | ||
| 55 | @@ -21,51 +20,67 @@ | ||
| 56 | * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA | ||
| 57 | */ | ||
| 58 | #include "dbus-stuff.h" | ||
| 59 | -#include <string.h> | ||
| 60 | -#include <E_DBus.h> | ||
| 61 | -#include <Elementary.h> | ||
| 62 | +#include "Eldbus.h" | ||
| 63 | |||
| 64 | -void occupy_cpu(void) | ||
| 65 | +void on_usage_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) | ||
| 66 | +{ | ||
| 67 | + const char *errname, *errmsg; | ||
| 68 | + if (eldbus_message_error_get(msg, &errname, &errmsg)) | ||
| 69 | + fprintf(stderr, "Error: %s %s\n", errname, errmsg); | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +int ousaged_resource(const char *resource, int used) | ||
| 73 | { | ||
| 74 | - e_dbus_init(); | ||
| 75 | - conn = e_dbus_bus_get(DBUS_BUS_SYSTEM); | ||
| 76 | - | ||
| 77 | - DBusMessage *msg; | ||
| 78 | - msg = dbus_message_new_method_call( | ||
| 79 | - "org.freesmartphone.ousaged", | ||
| 80 | - "/org/freesmartphone/Usage", | ||
| 81 | - "org.freesmartphone.Usage", | ||
| 82 | - "RequestResource" | ||
| 83 | - ); | ||
| 84 | - | ||
| 85 | - const char *resource = "CPU"; | ||
| 86 | - dbus_message_append_args (msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID); | ||
| 87 | + eldbus_init(); | ||
| 88 | + const char *REQUEST = "RequestResource"; | ||
| 89 | + const char *RELEASE = "ReleaseResource"; | ||
| 90 | + const int PREQUEST = 1; | ||
| 91 | |||
| 92 | - e_dbus_message_send(conn, msg, dbus_reply_cb, -1, NULL); | ||
| 93 | - dbus_message_unref(msg); | ||
| 94 | -} | ||
| 95 | + Eldbus_Connection *conn; | ||
| 96 | + Eldbus_Object *obj; | ||
| 97 | + Eldbus_Proxy *usage; | ||
| 98 | + Eldbus_Pending *pending; | ||
| 99 | + conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); | ||
| 100 | + if (!conn) | ||
| 101 | + { | ||
| 102 | + fprintf(stderr, "Error: could not get system bus\n"); | ||
| 103 | + return EXIT_FAILURE; | ||
| 104 | + } | ||
| 105 | |||
| 106 | -void release_cpu(void) | ||
| 107 | -{ | ||
| 108 | - DBusMessage *msg; | ||
| 109 | - msg = dbus_message_new_method_call( | ||
| 110 | - "org.freesmartphone.ousaged", | ||
| 111 | - "/org/freesmartphone/Usage", | ||
| 112 | - "org.freesmartphone.Usage", | ||
| 113 | - "ReleaseResource" | ||
| 114 | - ); | ||
| 115 | - | ||
| 116 | - const char *resource = "CPU"; | ||
| 117 | - dbus_message_append_args (msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID); | ||
| 118 | + obj = eldbus_object_get(conn, "org.freesmartphone.ousaged", "/org/freesmartphone/Usage"); | ||
| 119 | + if (!obj) | ||
| 120 | + { | ||
| 121 | + fprintf(stderr, "Error: could not get object\n"); | ||
| 122 | + return EXIT_FAILURE; | ||
| 123 | + } | ||
| 124 | |||
| 125 | - e_dbus_message_send(conn, msg, dbus_reply_cb, -1, NULL); | ||
| 126 | - dbus_message_unref(msg); | ||
| 127 | + usage = eldbus_proxy_get(obj, "org.freesmartphone.Usage"); | ||
| 128 | + if (!usage) | ||
| 129 | + { | ||
| 130 | + fprintf(stderr, "Error: could not get proxy\n"); | ||
| 131 | + return EXIT_FAILURE; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + pending = eldbus_proxy_call(usage, used == PREQUEST ? REQUEST : RELEASE, on_usage_cb, NULL, -1, "ss", resource); | ||
| 135 | + if (!pending) | ||
| 136 | + { | ||
| 137 | + fprintf(stderr, "Error: could not call\n"); | ||
| 138 | + return EXIT_FAILURE; | ||
| 139 | + } | ||
| 140 | + eldbus_proxy_unref(usage); | ||
| 141 | + eldbus_object_unref(obj); | ||
| 142 | + eldbus_connection_unref(conn); | ||
| 143 | + | ||
| 144 | + eldbus_shutdown(); | ||
| 145 | + return EXIT_SUCCESS; | ||
| 146 | } | ||
| 147 | |||
| 148 | -void dbus_reply_cb(void *data, DBusMessage *replymsg, DBusError *error) | ||
| 149 | +int request_cpu(void) | ||
| 150 | { | ||
| 151 | - if (dbus_error_is_set(error)) { | ||
| 152 | - printf("Error: %s - %s\n", error->name, error->message); | ||
| 153 | - } | ||
| 154 | + return ousaged_resource("CPU", 1); | ||
| 155 | } | ||
| 156 | |||
| 157 | +int release_cpu(void) | ||
| 158 | +{ | ||
| 159 | + return ousaged_resource("CPU" , 0); | ||
| 160 | +} | ||
| 161 | diff --git a/src/dbus-stuff.h b/src/dbus-stuff.h | ||
| 162 | index 83d4778..a3c72cb 100644 | ||
| 163 | --- a/src/dbus-stuff.h | ||
| 164 | +++ b/src/dbus-stuff.h | ||
| 165 | @@ -2,8 +2,7 @@ | ||
| 166 | * dbus.h | ||
| 167 | * | ||
| 168 | * Fri Mar 6 12:32:57 2009 | ||
| 169 | - * Copyright 2009 nidhin | ||
| 170 | - * <nidhin@nids-laptop.home> | ||
| 171 | + * Copyright 2009 nidhin <nidhin@nids-laptop.home> | ||
| 172 | ****************************************************************************/ | ||
| 173 | |||
| 174 | /* | ||
| 175 | @@ -22,11 +21,5 @@ | ||
| 176 | * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA | ||
| 177 | */ | ||
| 178 | |||
| 179 | -#include <E_DBus.h> | ||
| 180 | -#include <Elementary.h> | ||
| 181 | - | ||
| 182 | -void occupy_cpu(void); | ||
| 183 | -void release_cpu(void); | ||
| 184 | -void dbus_reply_cb(void *data, DBusMessage *replymsg, DBusError *error); | ||
| 185 | - | ||
| 186 | -E_DBus_Connection *conn; | ||
| 187 | +int request_cpu(void); | ||
| 188 | +int release_cpu(void); | ||
| 189 | diff --git a/src/main.c b/src/main.c | ||
| 190 | index 92d21de..4e4bbe2 100644 | ||
| 191 | --- a/src/main.c | ||
| 192 | +++ b/src/main.c | ||
| 193 | @@ -76,7 +76,7 @@ elm_main(int argc, char **argv) | ||
| 194 | //restore state | ||
| 195 | restore_state(); | ||
| 196 | |||
| 197 | - occupy_cpu(); | ||
| 198 | + request_cpu(); | ||
| 199 | |||
| 200 | elm_run(); | ||
| 201 | //clean up stuff | ||
| 202 | -- | ||
| 203 | 1.8.5.3 | ||
| 204 | |||
diff --git a/meta-efl/recipes-efl/e17/e-tasks_git.bb b/meta-efl/recipes-efl/e17/e-tasks_git.bb index d17e4e7934..6065157839 100644 --- a/meta-efl/recipes-efl/e17/e-tasks_git.bb +++ b/meta-efl/recipes-efl/e17/e-tasks_git.bb | |||
| @@ -4,7 +4,7 @@ AUTHOR = "cchandel" | |||
| 4 | LICENSE = "GPLv3" | 4 | LICENSE = "GPLv3" |
| 5 | LIC_FILES_CHKSUM = "file://COPYING;md5=8f0e2cd40e05189ec81232da84bd6e1a" | 5 | LIC_FILES_CHKSUM = "file://COPYING;md5=8f0e2cd40e05189ec81232da84bd6e1a" |
| 6 | SECTION = "e/apps" | 6 | SECTION = "e/apps" |
| 7 | DEPENDS = "elementary eina edbus sqlite3" | 7 | DEPENDS = "elementary eina eldbus sqlite3" |
| 8 | 8 | ||
| 9 | inherit autotools | 9 | inherit autotools |
| 10 | 10 | ||
| @@ -12,6 +12,8 @@ SRCREV = "890f5ee37d1a5fd1ceb2495950d15151d4cf756b" | |||
| 12 | PV = "0.0.2+gitr${SRCPV}" | 12 | PV = "0.0.2+gitr${SRCPV}" |
| 13 | 13 | ||
| 14 | SRC_URI = "git://github.com/shr-project/e-tasks.git" | 14 | SRC_URI = "git://github.com/shr-project/e-tasks.git" |
| 15 | SRC_URI += "file://0001-dbus-stuff-Convert-to-eldbus.patch" | ||
| 16 | |||
| 15 | S = "${WORKDIR}/git" | 17 | S = "${WORKDIR}/git" |
| 16 | 18 | ||
| 17 | do_install_append() { | 19 | do_install_append() { |
