Merge lp:~sforshee/powerd/remove-dbus-pid-arg into lp:powerd

Proposed by Seth Forshee
Status: Merged
Approved by: Matt Fischer
Approved revision: 68
Merged at revision: 60
Proposed branch: lp:~sforshee/powerd/remove-dbus-pid-arg
Merge into: lp:powerd
Diff against target: 543 lines (+69/-119)
7 files modified
cli/powerd-cli.c (+43/-80)
data/com.canonical.powerd.xml (+2/-4)
src/display-request.c (+10/-13)
src/display.c (+1/-1)
src/power-request.c (+9/-12)
src/powerd-internal.h (+4/-7)
src/powerd.cpp (+0/-2)
To merge this branch: bzr merge lp:~sforshee/powerd/remove-dbus-pid-arg
Reviewer Review Type Date Requested Status
Matt Fischer (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+172590@code.launchpad.net

Commit message

Remove pid arguments from dbus API

Description of the change

Remove pid arguments from dbus API

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matt Fischer (mfisch) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cli/powerd-cli.c'
--- cli/powerd-cli.c 2013-07-01 21:58:56 +0000
+++ cli/powerd-cli.c 2013-07-02 15:12:55 +0000
@@ -43,11 +43,13 @@
4343
44GDBusProxy *powerd_proxy = NULL;44GDBusProxy *powerd_proxy = NULL;
45char test_dbusname[128] = "";45char test_dbusname[128] = "";
46pid_t mypid;46
47/* For tests */
48GDBusConnection *powerd_cli_bus;
49const char *powerd_cli_bus_name;
4750
48struct PublicSysRequest {51struct PublicSysRequest {
49 const gchar *owner;52 const gchar *owner;
50 pid_t pid;
51 int state;53 int state;
52};54};
5355
@@ -55,14 +57,11 @@
55 const gchar *owner;57 const gchar *owner;
56 enum powerd_display_state state;58 enum powerd_display_state state;
57 enum powerd_display_brightness brightness;59 enum powerd_display_brightness brightness;
58 pid_t pid;
59 guint32 flags;60 guint32 flags;
60};61};
6162
62static GMainLoop *main_loop = NULL;63static GMainLoop *main_loop = NULL;
63static powerd_cookie_t main_cookie;64static powerd_cookie_t main_cookie;
64static gboolean checkForPid(pid_t pid, int count, GArray *requests,
65 gboolean isSys);
66static gboolean checkForDbusName(const char *dbusname, int count,65static gboolean checkForDbusName(const char *dbusname, int count,
67 GArray *requests, gboolean isSys);66 GArray *requests, gboolean isSys);
68static void sig_handler(int signum);67static void sig_handler(int signum);
@@ -112,7 +111,7 @@
112111
113 ret = g_dbus_proxy_call_sync(powerd_proxy,112 ret = g_dbus_proxy_call_sync(powerd_proxy,
114 "requestSysState",113 "requestSysState",
115 g_variant_new("(ii)", state, mypid),114 g_variant_new("(i)", state),
116 G_DBUS_CALL_FLAGS_NONE,115 G_DBUS_CALL_FLAGS_NONE,
117 -1,116 -1,
118 NULL,117 NULL,
@@ -152,8 +151,7 @@
152151
153 ret = g_dbus_proxy_call_sync(powerd_proxy,152 ret = g_dbus_proxy_call_sync(powerd_proxy,
154 "requestDisplayState",153 "requestDisplayState",
155 g_variant_new("(iiiu)", pdr.state, pdr.brightness, pdr.pid,154 g_variant_new("(iiu)", pdr.state, pdr.brightness, pdr.flags),
156 pdr.flags),
157 G_DBUS_CALL_FLAGS_NONE,155 G_DBUS_CALL_FLAGS_NONE,
158 -1,156 -1,
159 NULL,157 NULL,
@@ -229,14 +227,12 @@
229 g_error_free(error);227 g_error_free(error);
230 }228 }
231 else {229 else {
232 g_variant_get(ret, "(a(sii))", &iter);230 g_variant_get(ret, "(a(si))", &iter);
233 g_message("Current Sys Requests:");231 g_message("Current Sys Requests:");
234 while ((item = g_variant_iter_next_value (iter))) {232 while ((item = g_variant_iter_next_value (iter))) {
235 g_variant_get_child (item, 0, "s", &psr.owner);233 g_variant_get_child (item, 0, "s", &psr.owner);
236 g_variant_get_child (item, 1, "i", &psr.pid);234 g_variant_get_child (item, 1, "i", &psr.state);
237 g_variant_get_child (item, 2, "i", &psr.state);235 g_message(" Owner: %s, State: %d", psr.owner, psr.state);
238 g_message(" Owner: %s, Pid: %d, State: %d", psr.owner,
239 psr.pid, psr.state);
240 g_array_append_val(retarray, psr);236 g_array_append_val(retarray, psr);
241 g_variant_unref(item);237 g_variant_unref(item);
242 }238 }
@@ -269,17 +265,15 @@
269 g_error_free(error);265 g_error_free(error);
270 }266 }
271 else {267 else {
272 g_variant_get(ret, "(a(siiiu))", &iter);268 g_variant_get(ret, "(a(siiu))", &iter);
273 g_message("Current Display Requests:");269 g_message("Current Display Requests:");
274 while ((item = g_variant_iter_next_value (iter))) {270 while ((item = g_variant_iter_next_value (iter))) {
275 g_variant_get_child(item, 0, "s", &pdr.owner);271 g_variant_get_child(item, 0, "s", &pdr.owner);
276 g_variant_get_child(item, 1, "i", &pdr.pid);272 g_variant_get_child(item, 1, "i", &pdr.state);
277 g_variant_get_child(item, 2, "i", &pdr.state);273 g_variant_get_child(item, 2, "i", &pdr.brightness);
278 g_variant_get_child(item, 3, "i", &pdr.brightness);274 g_variant_get_child(item, 3, "u", &pdr.flags);
279 g_variant_get_child(item, 4, "u", &pdr.flags);275 g_message(" Owner: %s, State: %d, Brightness: %d, "\
280 g_message(" Owner: %s, Pid: %d, State: %d, Brightness: %d, "\276 "Flags: %u", pdr.owner, pdr.state, pdr.brightness, pdr.flags);
281 "Flags: %u", pdr.owner, pdr.pid, pdr.state, pdr.brightness,
282 pdr.flags);
283 g_array_append_val(retarray, pdr);277 g_array_append_val(retarray, pdr);
284 g_variant_unref(item);278 g_variant_unref(item);
285 }279 }
@@ -373,7 +367,7 @@
373 // Make sure clean-up didn't remove our request, note we don't pass367 // Make sure clean-up didn't remove our request, note we don't pass
374 // the child PID here.368 // the child PID here.
375 requests = listSysRequests();369 requests = listSysRequests();
376 do_test(checkForPid(mypid, 1, requests, TRUE));370 do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE));
377 g_array_free(requests, TRUE);371 g_array_free(requests, TRUE);
378372
379 /* Close pid */373 /* Close pid */
@@ -384,7 +378,7 @@
384 //cleanup378 //cleanup
385 do_test(clearSysState(main_cookie) == TRUE);379 do_test(clearSysState(main_cookie) == TRUE);
386 requests = listSysRequests();380 requests = listSysRequests();
387 do_test(checkForPid(mypid, 0, requests, TRUE));381 do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE));
388 g_array_free(requests, TRUE);382 g_array_free(requests, TRUE);
389}383}
390384
@@ -461,7 +455,7 @@
461 // Make sure we have at least NUM_REQUESTS + 1455 // Make sure we have at least NUM_REQUESTS + 1
462 requests = listSysRequests();456 requests = listSysRequests();
463 do_test(requests->len >= TEST_NUM_SYS_REQUESTS+1);457 do_test(requests->len >= TEST_NUM_SYS_REQUESTS+1);
464 do_test(checkForPid(mypid, TEST_NUM_SYS_REQUESTS+1, requests, TRUE));458 do_test(checkForDbusName(powerd_cli_bus_name, TEST_NUM_SYS_REQUESTS+1, requests, TRUE));
465 g_array_free(requests, TRUE);459 g_array_free(requests, TRUE);
466460
467 for (i = 0; i < TEST_NUM_SYS_REQUESTS; i++)461 for (i = 0; i < TEST_NUM_SYS_REQUESTS; i++)
@@ -470,7 +464,7 @@
470 // We should still have at least 1 request here464 // We should still have at least 1 request here
471 requests = listSysRequests();465 requests = listSysRequests();
472 do_test(requests->len >= 1);466 do_test(requests->len >= 1);
473 do_test(checkForPid(mypid, 1, requests, TRUE));467 do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE));
474 g_array_free(requests, TRUE);468 g_array_free(requests, TRUE);
475469
476 // Now try and freeing the same cookies again. They should all be470 // Now try and freeing the same cookies again. They should all be
@@ -484,7 +478,7 @@
484 // We should still have at least 1 request here478 // We should still have at least 1 request here
485 requests = listSysRequests();479 requests = listSysRequests();
486 do_test(requests->len >= 1);480 do_test(requests->len >= 1);
487 do_test(checkForPid(mypid, 1, requests, TRUE));481 do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE));
488 g_array_free(requests, TRUE);482 g_array_free(requests, TRUE);
489483
490 //cannot request the suspend state, this will fail484 //cannot request the suspend state, this will fail
@@ -496,7 +490,7 @@
496490
497 //cleanup491 //cleanup
498 do_test(clearSysState(main_cookie) == TRUE);492 do_test(clearSysState(main_cookie) == TRUE);
499 do_test(checkForPid(mypid, 0, requests, TRUE));493 do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE));
500}494}
501495
502static void496static void
@@ -511,8 +505,6 @@
511 // Hold active state request as long we're running tests505 // Hold active state request as long we're running tests
512 requestSysState(POWERD_SYS_STATE_ACTIVE, &main_cookie);506 requestSysState(POWERD_SYS_STATE_ACTIVE, &main_cookie);
513507
514 pdr.pid = mypid;
515
516 state = 0;508 state = 0;
517 brightness = 0;509 brightness = 0;
518 for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) {510 for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) {
@@ -531,7 +523,7 @@
531 requests = listDisplayRequests();523 requests = listDisplayRequests();
532 do_test(requests->len >= TEST_NUM_DISP_REQUESTS);524 do_test(requests->len >= TEST_NUM_DISP_REQUESTS);
533 // We should see our PID NUM_REQUESTS times525 // We should see our PID NUM_REQUESTS times
534 do_test(checkForPid(mypid, TEST_NUM_DISP_REQUESTS, requests, FALSE));526 do_test(checkForDbusName(powerd_cli_bus_name, TEST_NUM_DISP_REQUESTS, requests, FALSE));
535 g_array_free(requests, TRUE);527 g_array_free(requests, TRUE);
536528
537 for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++)529 for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++)
@@ -539,7 +531,7 @@
539531
540 requests = listDisplayRequests();532 requests = listDisplayRequests();
541 // We aren't holding anymore with this PID533 // We aren't holding anymore with this PID
542 do_test(checkForPid(mypid, 0, requests, FALSE));534 do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, FALSE));
543 g_array_free(requests, TRUE);535 g_array_free(requests, TRUE);
544536
545 // Now try and freeing the same cookies again. They should all be537 // Now try and freeing the same cookies again. They should all be
@@ -595,50 +587,10 @@
595587
596 //cleanup588 //cleanup
597 do_test(clearSysState(main_cookie) == TRUE);589 do_test(clearSysState(main_cookie) == TRUE);
598 do_test(checkForPid(mypid, 0, requests, TRUE));590 do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE));
599}591}
600592
601// Check that pid appears count times in a list of sys/disp requests593// Check that dbus owner appears count times in a list of sys/disp requests
602static gboolean
603checkForPid(pid_t pid,
604 int count,
605 GArray *requests,
606 gboolean isSys)
607{
608 int i;
609 int found = 0;
610 struct PublicSysRequest *psr;
611 struct PublicDispRequest *pdr;
612
613 if (requests == NULL) {
614 g_warning("requests is invalid");
615 return FALSE;
616 }
617
618 for (i=0; i<requests->len; i++)
619 {
620 if (isSys) {
621 psr = &g_array_index(requests, struct PublicSysRequest, i);
622 if (psr->pid == pid) {
623 found++;
624 }
625 }
626 else {
627 pdr = &g_array_index(requests, struct PublicDispRequest, i);
628 if (pdr->pid == pid) {
629 found++;
630 }
631 }
632 }
633
634 if (found != count) {
635 g_warning("Expected %d requests from PID, found %d", count, found);
636 return FALSE;
637 }
638 return TRUE;
639}
640
641// Check that pid appears count times in a list of sys/disp requests
642static gboolean594static gboolean
643checkForDbusName(const char *dbusname,595checkForDbusName(const char *dbusname,
644 int count,596 int count,
@@ -689,7 +641,6 @@
689static gboolean641static gboolean
690buildDisplayRequest(char **argv,642buildDisplayRequest(char **argv,
691 int argc,643 int argc,
692 pid_t pid,
693 struct PublicDispRequest *pdr)644 struct PublicDispRequest *pdr)
694{645{
695 int i;646 int i;
@@ -834,9 +785,6 @@
834 return -1;785 return -1;
835 }786 }
836787
837 mypid = getpid();
838 g_debug("Running as pid %d\n", mypid);
839
840 if (!strcmp(argv[1],"list")) {788 if (!strcmp(argv[1],"list")) {
841 requests = listSysRequests();789 requests = listSysRequests();
842 g_array_free(requests, TRUE);790 g_array_free(requests, TRUE);
@@ -862,7 +810,7 @@
862 usage(argv[0]);810 usage(argv[0]);
863 return -1;811 return -1;
864 }812 }
865 if (buildDisplayRequest(argv,argc,mypid,&pdr) == FALSE) {813 if (buildDisplayRequest(argv,argc,&pdr) == FALSE) {
866 usage(argv[0]);814 usage(argv[0]);
867 return -1;815 return -1;
868 }816 }
@@ -902,9 +850,24 @@
902 }850 }
903 }851 }
904 else if (!strcmp(argv[1],"test")) {852 else if (!strcmp(argv[1],"test")) {
853 powerd_cli_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
854 if (!powerd_cli_bus) {
855 fprintf(stderr, "Could not connect to message bus\n");
856 exit(-1);
857 }
858 powerd_cli_bus_name = g_dbus_connection_get_unique_name(powerd_cli_bus);
859 if (!powerd_cli_bus_name) {
860 fprintf(stderr, "Could not get unique bus name\n");
861 exit(-1);
862 }
863
905 runDbusNameVanishTests(argv[0]);864 runDbusNameVanishTests(argv[0]);
906 runSysTests();865 runSysTests();
907 runDisplayTests();866 runDisplayTests();
867
868 g_object_unref(powerd_cli_bus);
869 powerd_cli_bus = NULL;
870 powerd_cli_bus_name = NULL;
908 }871 }
909 else if (!strcmp(argv[1],"listen")) {872 else if (!strcmp(argv[1],"listen")) {
910 listenForSignals(powerd_proxy);873 listenForSignals(powerd_proxy);
911874
=== modified file 'data/com.canonical.powerd.xml'
--- data/com.canonical.powerd.xml 2013-06-13 20:18:18 +0000
+++ data/com.canonical.powerd.xml 2013-07-02 15:12:55 +0000
@@ -6,7 +6,6 @@
6 <!-- Functions -->6 <!-- Functions -->
7 <method name="requestSysState">7 <method name="requestSysState">
8 <arg type="i" name="state" direction="in" />8 <arg type="i" name="state" direction="in" />
9 <arg type="i" name="pid" direction="in" />
10 <arg type="s" name="cookie" direction="out" />9 <arg type="s" name="cookie" direction="out" />
11 </method>10 </method>
1211
@@ -17,7 +16,6 @@
17 <method name="requestDisplayState">16 <method name="requestDisplayState">
18 <arg type="i" name="state" direction="in" />17 <arg type="i" name="state" direction="in" />
19 <arg type="i" name="brightness" direction="in" />18 <arg type="i" name="brightness" direction="in" />
20 <arg type="i" name="pid" direction="in" />
21 <arg type="u" name="flags" direction="in" />19 <arg type="u" name="flags" direction="in" />
22 <arg type="s" name="cookie" direction="out" />20 <arg type="s" name="cookie" direction="out" />
23 </method>21 </method>
@@ -35,11 +33,11 @@
3533
36 <!-- for debug/testing -->34 <!-- for debug/testing -->
37 <method name="listSysRequests">35 <method name="listSysRequests">
38 <arg type="a(sii)" name="requestList" direction="out" />36 <arg type="a(si)" name="requestList" direction="out" />
39 </method>37 </method>
4038
41 <method name="listDisplayRequests">39 <method name="listDisplayRequests">
42 <arg type="a(siiiu)" name="requestList" direction="out" />40 <arg type="a(siiu)" name="requestList" direction="out" />
43 </method>41 </method>
4442
45 <!-- Signals -->43 <!-- Signals -->
4644
=== modified file 'src/display-request.c'
--- src/display-request.c 2013-07-01 21:23:32 +0000
+++ src/display-request.c 2013-07-02 15:12:55 +0000
@@ -145,7 +145,6 @@
145 __remove_request(&ireq->req);145 __remove_request(&ireq->req);
146 __add_request(new_req);146 __add_request(new_req);
147147
148 /* Update all fields except the pid */
149 ireq->req.state = new_req->state;148 ireq->req.state = new_req->state;
150 ireq->req.brightness = new_req->brightness;149 ireq->req.brightness = new_req->brightness;
151 ireq->req.flags = new_req->flags;150 ireq->req.flags = new_req->flags;
@@ -278,8 +277,7 @@
278277
279gboolean handle_add_display_request(PowerdSource *obj,278gboolean handle_add_display_request(PowerdSource *obj,
280 GDBusMethodInvocation *invocation,279 GDBusMethodInvocation *invocation,
281 int state, int brightness, int pid,280 int state, int brightness, guint32 flags)
282 guint32 flags)
283{281{
284 struct powerd_display_request req = {0,};282 struct powerd_display_request req = {0,};
285 const char *owner;283 const char *owner;
@@ -287,12 +285,11 @@
287 int ret;285 int ret;
288286
289 owner = g_dbus_method_invocation_get_sender(invocation);287 owner = g_dbus_method_invocation_get_sender(invocation);
290 powerd_debug("%s from %s (%d): state %d brightness %d flags %#08x",288 powerd_debug("%s from %s: state %d brightness %d flags %#08x",
291 __func__, owner, pid, state, brightness, flags);289 __func__, owner, state, brightness, flags);
292290
293 req.state = state;291 req.state = state;
294 req.brightness = brightness;292 req.brightness = brightness;
295 req.pid = pid;
296 req.flags = flags;293 req.flags = flags;
297294
298 ret = __powerd_add_display_request(&req, owner);295 ret = __powerd_add_display_request(&req, owner);
@@ -387,12 +384,12 @@
387 char cookie_str[UUID_STR_LEN];384 char cookie_str[UUID_STR_LEN];
388385
389 uuid_unparse(req->cookie, cookie_str);386 uuid_unparse(req->cookie, cookie_str);
390 powerd_debug(" owner: %s, pid: %d, cookie: %s, state: %d, brightness: %d, flags: %#08x",387 powerd_debug(" owner: %s, cookie: %s, state: %d, brightness: %d, flags: %#08x",
391 ireq->owner, req->pid, cookie_str, req->state,388 ireq->owner, cookie_str, req->state, req->brightness,
392 req->brightness, req->flags);389 req->flags);
393390
394 g_variant_builder_add(builder, "(siiiu)", ireq->owner, req->pid,391 g_variant_builder_add(builder, "(siiu)", ireq->owner, req->state,
395 req->state, req->brightness, req->flags);392 req->brightness, req->flags);
396}393}
397394
398static int build_display_request_list(GVariantBuilder *builder)395static int build_display_request_list(GVariantBuilder *builder)
@@ -409,13 +406,13 @@
409 GVariantBuilder *builder;406 GVariantBuilder *builder;
410 int count;407 int count;
411408
412 builder = g_variant_builder_new(G_VARIANT_TYPE("a(siiiu)"));409 builder = g_variant_builder_new(G_VARIANT_TYPE("a(siiu)"));
413 count = build_display_request_list(builder);410 count = build_display_request_list(builder);
414 if (count > 0) {411 if (count > 0) {
415 list = g_variant_builder_end(builder);412 list = g_variant_builder_end(builder);
416 } else {413 } else {
417 g_variant_builder_clear(builder);414 g_variant_builder_clear(builder);
418 list = g_variant_new_array(G_VARIANT_TYPE("(siiiu)"), NULL, 0);415 list = g_variant_new_array(G_VARIANT_TYPE("(siiu)"), NULL, 0);
419 }416 }
420417
421 tuple = g_variant_new_tuple(&list, 1);418 tuple = g_variant_new_tuple(&list, 1);
422419
=== modified file 'src/display.c'
--- src/display.c 2013-06-28 16:08:55 +0000
+++ src/display.c 2013-07-02 15:12:55 +0000
@@ -182,7 +182,7 @@
182 case POWERD_DISPLAY_STATE_ON:182 case POWERD_DISPLAY_STATE_ON:
183 if (actual_screen_state != POWERD_DISPLAY_STATE_ON) {183 if (actual_screen_state != POWERD_DISPLAY_STATE_ON) {
184 powerd_debug("Requesting active state internally");184 powerd_debug("Requesting active state internally");
185 ret = request_sys_state_internal(POWERD_SYS_STATE_ACTIVE, getpid(),185 ret = request_sys_state_internal(POWERD_SYS_STATE_ACTIVE,
186 &internal_request_cookie, NULL);186 &internal_request_cookie, NULL);
187 if (!ret)187 if (!ret)
188 powerd_warn("Request for active state failed");188 powerd_warn("Request for active state failed");
189189
=== modified file 'src/power-request.c'
--- src/power-request.c 2013-07-01 21:23:32 +0000
+++ src/power-request.c 2013-07-02 15:12:55 +0000
@@ -41,7 +41,6 @@
41struct SysStateRequest {41struct SysStateRequest {
42 gchar *owner;42 gchar *owner;
43 uuid_t cookie;43 uuid_t cookie;
44 int pid;
45 enum SysPowerStates state;44 enum SysPowerStates state;
46};45};
4746
@@ -163,12 +162,11 @@
163162
164 /* XXX: For debug, remove later */163 /* XXX: For debug, remove later */
165 uuid_unparse(sr->cookie, cookie_str);164 uuid_unparse(sr->cookie, cookie_str);
166 powerd_debug(" Owner: %s, Pid: %d, Cookie: %s, State: %s (%d)",165 powerd_debug(" Owner: %s, Cookie: %s, State: %s (%d)",
167 sr->owner, sr->pid, cookie_str,166 sr->owner, cookie_str, state_to_string(sr->state), sr->state);
168 state_to_string(sr->state), sr->state);
169167
170 if (builder)168 if (builder)
171 g_variant_builder_add(builder, "(sii)", sr->owner, sr->pid, sr->state);169 g_variant_builder_add(builder, "(si)", sr->owner, sr->state);
172}170}
173171
174/*172/*
@@ -198,14 +196,14 @@
198 GVariantBuilder *builder;196 GVariantBuilder *builder;
199 guint count = 0;197 guint count = 0;
200198
201 builder = g_variant_builder_new(G_VARIANT_TYPE("a(sii)"));199 builder = g_variant_builder_new(G_VARIANT_TYPE("a(si)"));
202 count = list_sys_requests_internal(builder);200 count = list_sys_requests_internal(builder);
203 if (count>0) {201 if (count>0) {
204 list = g_variant_builder_end(builder);202 list = g_variant_builder_end(builder);
205 }203 }
206 else {204 else {
207 g_variant_builder_clear(builder);205 g_variant_builder_clear(builder);
208 list = g_variant_new_array(G_VARIANT_TYPE("(sii)"), NULL, 0);206 list = g_variant_new_array(G_VARIANT_TYPE("(si)"), NULL, 0);
209 }207 }
210 tuple = g_variant_new_tuple(&list,1);208 tuple = g_variant_new_tuple(&list,1);
211 g_dbus_method_invocation_return_value(invocation, tuple);209 g_dbus_method_invocation_return_value(invocation, tuple);
@@ -225,7 +223,7 @@
225223
226/* Note: owner is NULL for internal usage */224/* Note: owner is NULL for internal usage */
227gboolean225gboolean
228request_sys_state_internal(int state, int pid, uuid_t *cookie, const gchar *owner)226request_sys_state_internal(int state, uuid_t *cookie, const gchar *owner)
229{227{
230 struct SysStateRequest *sr = NULL;228 struct SysStateRequest *sr = NULL;
231229
@@ -242,7 +240,6 @@
242240
243 sr = g_new(struct SysStateRequest, 1);241 sr = g_new(struct SysStateRequest, 1);
244 sr->state = (enum SysPowerStates)state;242 sr->state = (enum SysPowerStates)state;
245 sr->pid = pid;
246 if (owner) {243 if (owner) {
247 sr->owner = g_strdup(owner);244 sr->owner = g_strdup(owner);
248 }245 }
@@ -258,7 +255,7 @@
258}255}
259256
260gboolean257gboolean
261handle_request_sys_state (PowerdSource *obj, GDBusMethodInvocation *invocation, int state, int pid)258handle_request_sys_state (PowerdSource *obj, GDBusMethodInvocation *invocation, int state)
262{259{
263 gboolean retval;260 gboolean retval;
264 const char *owner;261 const char *owner;
@@ -266,10 +263,10 @@
266 char ext_cookie[UUID_STR_LEN];263 char ext_cookie[UUID_STR_LEN];
267264
268 owner = g_dbus_method_invocation_get_sender(invocation);265 owner = g_dbus_method_invocation_get_sender(invocation);
269 powerd_debug("handle_requestSysState from %s: %d - %s (%d)", owner, pid,266 powerd_debug("handle_requestSysState from %s - %s (%d)", owner,
270 state_to_string(state), state);267 state_to_string(state), state);
271268
272 retval = request_sys_state_internal(state, pid, &cookie, owner);269 retval = request_sys_state_internal(state, &cookie, owner);
273 if (retval == TRUE) {270 if (retval == TRUE) {
274 powerd_debug("handle_requestSysState - SUCCESS");271 powerd_debug("handle_requestSysState - SUCCESS");
275 uuid_unparse(cookie, ext_cookie);272 uuid_unparse(cookie, ext_cookie);
276273
=== modified file 'src/powerd-internal.h'
--- src/powerd-internal.h 2013-07-01 17:02:32 +0000
+++ src/powerd-internal.h 2013-07-02 15:12:55 +0000
@@ -37,7 +37,6 @@
37 uuid_t cookie;37 uuid_t cookie;
38 enum powerd_display_state state;38 enum powerd_display_state state;
39 enum powerd_display_brightness brightness;39 enum powerd_display_brightness brightness;
40 pid_t pid;
41 guint32 flags;40 guint32 flags;
42};41};
4342
@@ -87,8 +86,7 @@
87void display_request_deinit(void);86void display_request_deinit(void);
88gboolean handle_add_display_request(PowerdSource *obj,87gboolean handle_add_display_request(PowerdSource *obj,
89 GDBusMethodInvocation *invocation,88 GDBusMethodInvocation *invocation,
90 int state, int brightness, int pid,89 int state, int brightness, guint32 flags);
91 guint32 flags);
92gboolean handle_update_display_request(PowerdSource *obj,90gboolean handle_update_display_request(PowerdSource *obj,
93 GDBusMethodInvocation *invocation,91 GDBusMethodInvocation *invocation,
94 const gchar *ext_cookie, int state,92 const gchar *ext_cookie, int state,
@@ -104,13 +102,12 @@
104gboolean handle_list_sys_requests(PowerdSource *obj,102gboolean handle_list_sys_requests(PowerdSource *obj,
105 GDBusMethodInvocation *invocation);103 GDBusMethodInvocation *invocation);
106gboolean handle_request_sys_state(PowerdSource *obj,104gboolean handle_request_sys_state(PowerdSource *obj,
107 GDBusMethodInvocation *invocation,105 GDBusMethodInvocation *invocation, int state);
108 int state, int pid);
109gboolean handle_clear_sys_state(PowerdSource *obj,106gboolean handle_clear_sys_state(PowerdSource *obj,
110 GDBusMethodInvocation *invocation,107 GDBusMethodInvocation *invocation,
111 gchar *cookie);108 gchar *cookie);
112gboolean request_sys_state_internal(int state, int pid,109gboolean request_sys_state_internal(int state, uuid_t *cookie,
113 uuid_t *cookie, const gchar *owner);110 const gchar *owner);
114gboolean clear_sys_state_internal(uuid_t cookie);111gboolean clear_sys_state_internal(uuid_t cookie);
115void update_system_state(void);112void update_system_state(void);
116void power_request_init(void);113void power_request_init(void);
117114
=== modified file 'src/powerd.cpp'
--- src/powerd.cpp 2013-07-01 17:02:32 +0000
+++ src/powerd.cpp 2013-07-02 15:12:55 +0000
@@ -107,7 +107,6 @@
107 {0,}, /* cookie */107 {0,}, /* cookie */
108 POWERD_DISPLAY_STATE_ON, /* state */108 POWERD_DISPLAY_STATE_ON, /* state */
109 POWERD_DISPLAY_BRIGHTNESS_BRIGHT, /* brightness */109 POWERD_DISPLAY_BRIGHTNESS_BRIGHT, /* brightness */
110 0, /* pid */
111 0 /* flags */110 0 /* flags */
112};111};
113112
@@ -116,7 +115,6 @@
116 {0,}, /* cookie */115 {0,}, /* cookie */
117 POWERD_DISPLAY_STATE_DONT_CARE, /* state */116 POWERD_DISPLAY_STATE_DONT_CARE, /* state */
118 POWERD_DISPLAY_BRIGHTNESS_DONT_CARE, /* brightness */117 POWERD_DISPLAY_BRIGHTNESS_DONT_CARE, /* brightness */
119 0, /* pid */
120 POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */118 POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */
121};119};
122120

Subscribers

People subscribed via source and target branches