Merge lp:~sforshee/powerd/remove-dbus-pid-arg into lp:powerd
- remove-dbus-pid-arg
- Merge into trunk
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 |
Related bugs: |
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)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cli/powerd-cli.c' | |||
2 | --- cli/powerd-cli.c 2013-07-01 21:58:56 +0000 | |||
3 | +++ cli/powerd-cli.c 2013-07-02 15:12:55 +0000 | |||
4 | @@ -43,11 +43,13 @@ | |||
5 | 43 | 43 | ||
6 | 44 | GDBusProxy *powerd_proxy = NULL; | 44 | GDBusProxy *powerd_proxy = NULL; |
7 | 45 | char test_dbusname[128] = ""; | 45 | char test_dbusname[128] = ""; |
9 | 46 | pid_t mypid; | 46 | |
10 | 47 | /* For tests */ | ||
11 | 48 | GDBusConnection *powerd_cli_bus; | ||
12 | 49 | const char *powerd_cli_bus_name; | ||
13 | 47 | 50 | ||
14 | 48 | struct PublicSysRequest { | 51 | struct PublicSysRequest { |
15 | 49 | const gchar *owner; | 52 | const gchar *owner; |
16 | 50 | pid_t pid; | ||
17 | 51 | int state; | 53 | int state; |
18 | 52 | }; | 54 | }; |
19 | 53 | 55 | ||
20 | @@ -55,14 +57,11 @@ | |||
21 | 55 | const gchar *owner; | 57 | const gchar *owner; |
22 | 56 | enum powerd_display_state state; | 58 | enum powerd_display_state state; |
23 | 57 | enum powerd_display_brightness brightness; | 59 | enum powerd_display_brightness brightness; |
24 | 58 | pid_t pid; | ||
25 | 59 | guint32 flags; | 60 | guint32 flags; |
26 | 60 | }; | 61 | }; |
27 | 61 | 62 | ||
28 | 62 | static GMainLoop *main_loop = NULL; | 63 | static GMainLoop *main_loop = NULL; |
29 | 63 | static powerd_cookie_t main_cookie; | 64 | static powerd_cookie_t main_cookie; |
30 | 64 | static gboolean checkForPid(pid_t pid, int count, GArray *requests, | ||
31 | 65 | gboolean isSys); | ||
32 | 66 | static gboolean checkForDbusName(const char *dbusname, int count, | 65 | static gboolean checkForDbusName(const char *dbusname, int count, |
33 | 67 | GArray *requests, gboolean isSys); | 66 | GArray *requests, gboolean isSys); |
34 | 68 | static void sig_handler(int signum); | 67 | static void sig_handler(int signum); |
35 | @@ -112,7 +111,7 @@ | |||
36 | 112 | 111 | ||
37 | 113 | ret = g_dbus_proxy_call_sync(powerd_proxy, | 112 | ret = g_dbus_proxy_call_sync(powerd_proxy, |
38 | 114 | "requestSysState", | 113 | "requestSysState", |
40 | 115 | g_variant_new("(ii)", state, mypid), | 114 | g_variant_new("(i)", state), |
41 | 116 | G_DBUS_CALL_FLAGS_NONE, | 115 | G_DBUS_CALL_FLAGS_NONE, |
42 | 117 | -1, | 116 | -1, |
43 | 118 | NULL, | 117 | NULL, |
44 | @@ -152,8 +151,7 @@ | |||
45 | 152 | 151 | ||
46 | 153 | ret = g_dbus_proxy_call_sync(powerd_proxy, | 152 | ret = g_dbus_proxy_call_sync(powerd_proxy, |
47 | 154 | "requestDisplayState", | 153 | "requestDisplayState", |
50 | 155 | g_variant_new("(iiiu)", pdr.state, pdr.brightness, pdr.pid, | 154 | g_variant_new("(iiu)", pdr.state, pdr.brightness, pdr.flags), |
49 | 156 | pdr.flags), | ||
51 | 157 | G_DBUS_CALL_FLAGS_NONE, | 155 | G_DBUS_CALL_FLAGS_NONE, |
52 | 158 | -1, | 156 | -1, |
53 | 159 | NULL, | 157 | NULL, |
54 | @@ -229,14 +227,12 @@ | |||
55 | 229 | g_error_free(error); | 227 | g_error_free(error); |
56 | 230 | } | 228 | } |
57 | 231 | else { | 229 | else { |
59 | 232 | g_variant_get(ret, "(a(sii))", &iter); | 230 | g_variant_get(ret, "(a(si))", &iter); |
60 | 233 | g_message("Current Sys Requests:"); | 231 | g_message("Current Sys Requests:"); |
61 | 234 | while ((item = g_variant_iter_next_value (iter))) { | 232 | while ((item = g_variant_iter_next_value (iter))) { |
62 | 235 | g_variant_get_child (item, 0, "s", &psr.owner); | 233 | g_variant_get_child (item, 0, "s", &psr.owner); |
67 | 236 | g_variant_get_child (item, 1, "i", &psr.pid); | 234 | g_variant_get_child (item, 1, "i", &psr.state); |
68 | 237 | g_variant_get_child (item, 2, "i", &psr.state); | 235 | g_message(" Owner: %s, State: %d", psr.owner, psr.state); |
65 | 238 | g_message(" Owner: %s, Pid: %d, State: %d", psr.owner, | ||
66 | 239 | psr.pid, psr.state); | ||
69 | 240 | g_array_append_val(retarray, psr); | 236 | g_array_append_val(retarray, psr); |
70 | 241 | g_variant_unref(item); | 237 | g_variant_unref(item); |
71 | 242 | } | 238 | } |
72 | @@ -269,17 +265,15 @@ | |||
73 | 269 | g_error_free(error); | 265 | g_error_free(error); |
74 | 270 | } | 266 | } |
75 | 271 | else { | 267 | else { |
77 | 272 | g_variant_get(ret, "(a(siiiu))", &iter); | 268 | g_variant_get(ret, "(a(siiu))", &iter); |
78 | 273 | g_message("Current Display Requests:"); | 269 | g_message("Current Display Requests:"); |
79 | 274 | while ((item = g_variant_iter_next_value (iter))) { | 270 | while ((item = g_variant_iter_next_value (iter))) { |
80 | 275 | g_variant_get_child(item, 0, "s", &pdr.owner); | 271 | g_variant_get_child(item, 0, "s", &pdr.owner); |
88 | 276 | g_variant_get_child(item, 1, "i", &pdr.pid); | 272 | g_variant_get_child(item, 1, "i", &pdr.state); |
89 | 277 | g_variant_get_child(item, 2, "i", &pdr.state); | 273 | g_variant_get_child(item, 2, "i", &pdr.brightness); |
90 | 278 | g_variant_get_child(item, 3, "i", &pdr.brightness); | 274 | g_variant_get_child(item, 3, "u", &pdr.flags); |
91 | 279 | g_variant_get_child(item, 4, "u", &pdr.flags); | 275 | g_message(" Owner: %s, State: %d, Brightness: %d, "\ |
92 | 280 | g_message(" Owner: %s, Pid: %d, State: %d, Brightness: %d, "\ | 276 | "Flags: %u", pdr.owner, pdr.state, pdr.brightness, pdr.flags); |
86 | 281 | "Flags: %u", pdr.owner, pdr.pid, pdr.state, pdr.brightness, | ||
87 | 282 | pdr.flags); | ||
93 | 283 | g_array_append_val(retarray, pdr); | 277 | g_array_append_val(retarray, pdr); |
94 | 284 | g_variant_unref(item); | 278 | g_variant_unref(item); |
95 | 285 | } | 279 | } |
96 | @@ -373,7 +367,7 @@ | |||
97 | 373 | // Make sure clean-up didn't remove our request, note we don't pass | 367 | // Make sure clean-up didn't remove our request, note we don't pass |
98 | 374 | // the child PID here. | 368 | // the child PID here. |
99 | 375 | requests = listSysRequests(); | 369 | requests = listSysRequests(); |
101 | 376 | do_test(checkForPid(mypid, 1, requests, TRUE)); | 370 | do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE)); |
102 | 377 | g_array_free(requests, TRUE); | 371 | g_array_free(requests, TRUE); |
103 | 378 | 372 | ||
104 | 379 | /* Close pid */ | 373 | /* Close pid */ |
105 | @@ -384,7 +378,7 @@ | |||
106 | 384 | //cleanup | 378 | //cleanup |
107 | 385 | do_test(clearSysState(main_cookie) == TRUE); | 379 | do_test(clearSysState(main_cookie) == TRUE); |
108 | 386 | requests = listSysRequests(); | 380 | requests = listSysRequests(); |
110 | 387 | do_test(checkForPid(mypid, 0, requests, TRUE)); | 381 | do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE)); |
111 | 388 | g_array_free(requests, TRUE); | 382 | g_array_free(requests, TRUE); |
112 | 389 | } | 383 | } |
113 | 390 | 384 | ||
114 | @@ -461,7 +455,7 @@ | |||
115 | 461 | // Make sure we have at least NUM_REQUESTS + 1 | 455 | // Make sure we have at least NUM_REQUESTS + 1 |
116 | 462 | requests = listSysRequests(); | 456 | requests = listSysRequests(); |
117 | 463 | do_test(requests->len >= TEST_NUM_SYS_REQUESTS+1); | 457 | do_test(requests->len >= TEST_NUM_SYS_REQUESTS+1); |
119 | 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)); |
120 | 465 | g_array_free(requests, TRUE); | 459 | g_array_free(requests, TRUE); |
121 | 466 | 460 | ||
122 | 467 | for (i = 0; i < TEST_NUM_SYS_REQUESTS; i++) | 461 | for (i = 0; i < TEST_NUM_SYS_REQUESTS; i++) |
123 | @@ -470,7 +464,7 @@ | |||
124 | 470 | // We should still have at least 1 request here | 464 | // We should still have at least 1 request here |
125 | 471 | requests = listSysRequests(); | 465 | requests = listSysRequests(); |
126 | 472 | do_test(requests->len >= 1); | 466 | do_test(requests->len >= 1); |
128 | 473 | do_test(checkForPid(mypid, 1, requests, TRUE)); | 467 | do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE)); |
129 | 474 | g_array_free(requests, TRUE); | 468 | g_array_free(requests, TRUE); |
130 | 475 | 469 | ||
131 | 476 | // Now try and freeing the same cookies again. They should all be | 470 | // Now try and freeing the same cookies again. They should all be |
132 | @@ -484,7 +478,7 @@ | |||
133 | 484 | // We should still have at least 1 request here | 478 | // We should still have at least 1 request here |
134 | 485 | requests = listSysRequests(); | 479 | requests = listSysRequests(); |
135 | 486 | do_test(requests->len >= 1); | 480 | do_test(requests->len >= 1); |
137 | 487 | do_test(checkForPid(mypid, 1, requests, TRUE)); | 481 | do_test(checkForDbusName(powerd_cli_bus_name, 1, requests, TRUE)); |
138 | 488 | g_array_free(requests, TRUE); | 482 | g_array_free(requests, TRUE); |
139 | 489 | 483 | ||
140 | 490 | //cannot request the suspend state, this will fail | 484 | //cannot request the suspend state, this will fail |
141 | @@ -496,7 +490,7 @@ | |||
142 | 496 | 490 | ||
143 | 497 | //cleanup | 491 | //cleanup |
144 | 498 | do_test(clearSysState(main_cookie) == TRUE); | 492 | do_test(clearSysState(main_cookie) == TRUE); |
146 | 499 | do_test(checkForPid(mypid, 0, requests, TRUE)); | 493 | do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE)); |
147 | 500 | } | 494 | } |
148 | 501 | 495 | ||
149 | 502 | static void | 496 | static void |
150 | @@ -511,8 +505,6 @@ | |||
151 | 511 | // Hold active state request as long we're running tests | 505 | // Hold active state request as long we're running tests |
152 | 512 | requestSysState(POWERD_SYS_STATE_ACTIVE, &main_cookie); | 506 | requestSysState(POWERD_SYS_STATE_ACTIVE, &main_cookie); |
153 | 513 | 507 | ||
154 | 514 | pdr.pid = mypid; | ||
155 | 515 | |||
156 | 516 | state = 0; | 508 | state = 0; |
157 | 517 | brightness = 0; | 509 | brightness = 0; |
158 | 518 | for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) { | 510 | for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) { |
159 | @@ -531,7 +523,7 @@ | |||
160 | 531 | requests = listDisplayRequests(); | 523 | requests = listDisplayRequests(); |
161 | 532 | do_test(requests->len >= TEST_NUM_DISP_REQUESTS); | 524 | do_test(requests->len >= TEST_NUM_DISP_REQUESTS); |
162 | 533 | // We should see our PID NUM_REQUESTS times | 525 | // We should see our PID NUM_REQUESTS times |
164 | 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)); |
165 | 535 | g_array_free(requests, TRUE); | 527 | g_array_free(requests, TRUE); |
166 | 536 | 528 | ||
167 | 537 | for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) | 529 | for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) |
168 | @@ -539,7 +531,7 @@ | |||
169 | 539 | 531 | ||
170 | 540 | requests = listDisplayRequests(); | 532 | requests = listDisplayRequests(); |
171 | 541 | // We aren't holding anymore with this PID | 533 | // We aren't holding anymore with this PID |
173 | 542 | do_test(checkForPid(mypid, 0, requests, FALSE)); | 534 | do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, FALSE)); |
174 | 543 | g_array_free(requests, TRUE); | 535 | g_array_free(requests, TRUE); |
175 | 544 | 536 | ||
176 | 545 | // Now try and freeing the same cookies again. They should all be | 537 | // Now try and freeing the same cookies again. They should all be |
177 | @@ -595,50 +587,10 @@ | |||
178 | 595 | 587 | ||
179 | 596 | //cleanup | 588 | //cleanup |
180 | 597 | do_test(clearSysState(main_cookie) == TRUE); | 589 | do_test(clearSysState(main_cookie) == TRUE); |
225 | 598 | do_test(checkForPid(mypid, 0, requests, TRUE)); | 590 | do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE)); |
226 | 599 | } | 591 | } |
227 | 600 | 592 | ||
228 | 601 | // Check that pid appears count times in a list of sys/disp requests | 593 | // Check that dbus owner appears count times in a list of sys/disp requests |
185 | 602 | static gboolean | ||
186 | 603 | checkForPid(pid_t pid, | ||
187 | 604 | int count, | ||
188 | 605 | GArray *requests, | ||
189 | 606 | gboolean isSys) | ||
190 | 607 | { | ||
191 | 608 | int i; | ||
192 | 609 | int found = 0; | ||
193 | 610 | struct PublicSysRequest *psr; | ||
194 | 611 | struct PublicDispRequest *pdr; | ||
195 | 612 | |||
196 | 613 | if (requests == NULL) { | ||
197 | 614 | g_warning("requests is invalid"); | ||
198 | 615 | return FALSE; | ||
199 | 616 | } | ||
200 | 617 | |||
201 | 618 | for (i=0; i<requests->len; i++) | ||
202 | 619 | { | ||
203 | 620 | if (isSys) { | ||
204 | 621 | psr = &g_array_index(requests, struct PublicSysRequest, i); | ||
205 | 622 | if (psr->pid == pid) { | ||
206 | 623 | found++; | ||
207 | 624 | } | ||
208 | 625 | } | ||
209 | 626 | else { | ||
210 | 627 | pdr = &g_array_index(requests, struct PublicDispRequest, i); | ||
211 | 628 | if (pdr->pid == pid) { | ||
212 | 629 | found++; | ||
213 | 630 | } | ||
214 | 631 | } | ||
215 | 632 | } | ||
216 | 633 | |||
217 | 634 | if (found != count) { | ||
218 | 635 | g_warning("Expected %d requests from PID, found %d", count, found); | ||
219 | 636 | return FALSE; | ||
220 | 637 | } | ||
221 | 638 | return TRUE; | ||
222 | 639 | } | ||
223 | 640 | |||
224 | 641 | // Check that pid appears count times in a list of sys/disp requests | ||
229 | 642 | static gboolean | 594 | static gboolean |
230 | 643 | checkForDbusName(const char *dbusname, | 595 | checkForDbusName(const char *dbusname, |
231 | 644 | int count, | 596 | int count, |
232 | @@ -689,7 +641,6 @@ | |||
233 | 689 | static gboolean | 641 | static gboolean |
234 | 690 | buildDisplayRequest(char **argv, | 642 | buildDisplayRequest(char **argv, |
235 | 691 | int argc, | 643 | int argc, |
236 | 692 | pid_t pid, | ||
237 | 693 | struct PublicDispRequest *pdr) | 644 | struct PublicDispRequest *pdr) |
238 | 694 | { | 645 | { |
239 | 695 | int i; | 646 | int i; |
240 | @@ -834,9 +785,6 @@ | |||
241 | 834 | return -1; | 785 | return -1; |
242 | 835 | } | 786 | } |
243 | 836 | 787 | ||
244 | 837 | mypid = getpid(); | ||
245 | 838 | g_debug("Running as pid %d\n", mypid); | ||
246 | 839 | |||
247 | 840 | if (!strcmp(argv[1],"list")) { | 788 | if (!strcmp(argv[1],"list")) { |
248 | 841 | requests = listSysRequests(); | 789 | requests = listSysRequests(); |
249 | 842 | g_array_free(requests, TRUE); | 790 | g_array_free(requests, TRUE); |
250 | @@ -862,7 +810,7 @@ | |||
251 | 862 | usage(argv[0]); | 810 | usage(argv[0]); |
252 | 863 | return -1; | 811 | return -1; |
253 | 864 | } | 812 | } |
255 | 865 | if (buildDisplayRequest(argv,argc,mypid,&pdr) == FALSE) { | 813 | if (buildDisplayRequest(argv,argc,&pdr) == FALSE) { |
256 | 866 | usage(argv[0]); | 814 | usage(argv[0]); |
257 | 867 | return -1; | 815 | return -1; |
258 | 868 | } | 816 | } |
259 | @@ -902,9 +850,24 @@ | |||
260 | 902 | } | 850 | } |
261 | 903 | } | 851 | } |
262 | 904 | else if (!strcmp(argv[1],"test")) { | 852 | else if (!strcmp(argv[1],"test")) { |
263 | 853 | powerd_cli_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); | ||
264 | 854 | if (!powerd_cli_bus) { | ||
265 | 855 | fprintf(stderr, "Could not connect to message bus\n"); | ||
266 | 856 | exit(-1); | ||
267 | 857 | } | ||
268 | 858 | powerd_cli_bus_name = g_dbus_connection_get_unique_name(powerd_cli_bus); | ||
269 | 859 | if (!powerd_cli_bus_name) { | ||
270 | 860 | fprintf(stderr, "Could not get unique bus name\n"); | ||
271 | 861 | exit(-1); | ||
272 | 862 | } | ||
273 | 863 | |||
274 | 905 | runDbusNameVanishTests(argv[0]); | 864 | runDbusNameVanishTests(argv[0]); |
275 | 906 | runSysTests(); | 865 | runSysTests(); |
276 | 907 | runDisplayTests(); | 866 | runDisplayTests(); |
277 | 867 | |||
278 | 868 | g_object_unref(powerd_cli_bus); | ||
279 | 869 | powerd_cli_bus = NULL; | ||
280 | 870 | powerd_cli_bus_name = NULL; | ||
281 | 908 | } | 871 | } |
282 | 909 | else if (!strcmp(argv[1],"listen")) { | 872 | else if (!strcmp(argv[1],"listen")) { |
283 | 910 | listenForSignals(powerd_proxy); | 873 | listenForSignals(powerd_proxy); |
284 | 911 | 874 | ||
285 | === modified file 'data/com.canonical.powerd.xml' | |||
286 | --- data/com.canonical.powerd.xml 2013-06-13 20:18:18 +0000 | |||
287 | +++ data/com.canonical.powerd.xml 2013-07-02 15:12:55 +0000 | |||
288 | @@ -6,7 +6,6 @@ | |||
289 | 6 | <!-- Functions --> | 6 | <!-- Functions --> |
290 | 7 | <method name="requestSysState"> | 7 | <method name="requestSysState"> |
291 | 8 | <arg type="i" name="state" direction="in" /> | 8 | <arg type="i" name="state" direction="in" /> |
292 | 9 | <arg type="i" name="pid" direction="in" /> | ||
293 | 10 | <arg type="s" name="cookie" direction="out" /> | 9 | <arg type="s" name="cookie" direction="out" /> |
294 | 11 | </method> | 10 | </method> |
295 | 12 | 11 | ||
296 | @@ -17,7 +16,6 @@ | |||
297 | 17 | <method name="requestDisplayState"> | 16 | <method name="requestDisplayState"> |
298 | 18 | <arg type="i" name="state" direction="in" /> | 17 | <arg type="i" name="state" direction="in" /> |
299 | 19 | <arg type="i" name="brightness" direction="in" /> | 18 | <arg type="i" name="brightness" direction="in" /> |
300 | 20 | <arg type="i" name="pid" direction="in" /> | ||
301 | 21 | <arg type="u" name="flags" direction="in" /> | 19 | <arg type="u" name="flags" direction="in" /> |
302 | 22 | <arg type="s" name="cookie" direction="out" /> | 20 | <arg type="s" name="cookie" direction="out" /> |
303 | 23 | </method> | 21 | </method> |
304 | @@ -35,11 +33,11 @@ | |||
305 | 35 | 33 | ||
306 | 36 | <!-- for debug/testing --> | 34 | <!-- for debug/testing --> |
307 | 37 | <method name="listSysRequests"> | 35 | <method name="listSysRequests"> |
309 | 38 | <arg type="a(sii)" name="requestList" direction="out" /> | 36 | <arg type="a(si)" name="requestList" direction="out" /> |
310 | 39 | </method> | 37 | </method> |
311 | 40 | 38 | ||
312 | 41 | <method name="listDisplayRequests"> | 39 | <method name="listDisplayRequests"> |
314 | 42 | <arg type="a(siiiu)" name="requestList" direction="out" /> | 40 | <arg type="a(siiu)" name="requestList" direction="out" /> |
315 | 43 | </method> | 41 | </method> |
316 | 44 | 42 | ||
317 | 45 | <!-- Signals --> | 43 | <!-- Signals --> |
318 | 46 | 44 | ||
319 | === modified file 'src/display-request.c' | |||
320 | --- src/display-request.c 2013-07-01 21:23:32 +0000 | |||
321 | +++ src/display-request.c 2013-07-02 15:12:55 +0000 | |||
322 | @@ -145,7 +145,6 @@ | |||
323 | 145 | __remove_request(&ireq->req); | 145 | __remove_request(&ireq->req); |
324 | 146 | __add_request(new_req); | 146 | __add_request(new_req); |
325 | 147 | 147 | ||
326 | 148 | /* Update all fields except the pid */ | ||
327 | 149 | ireq->req.state = new_req->state; | 148 | ireq->req.state = new_req->state; |
328 | 150 | ireq->req.brightness = new_req->brightness; | 149 | ireq->req.brightness = new_req->brightness; |
329 | 151 | ireq->req.flags = new_req->flags; | 150 | ireq->req.flags = new_req->flags; |
330 | @@ -278,8 +277,7 @@ | |||
331 | 278 | 277 | ||
332 | 279 | gboolean handle_add_display_request(PowerdSource *obj, | 278 | gboolean handle_add_display_request(PowerdSource *obj, |
333 | 280 | GDBusMethodInvocation *invocation, | 279 | GDBusMethodInvocation *invocation, |
336 | 281 | int state, int brightness, int pid, | 280 | int state, int brightness, guint32 flags) |
335 | 282 | guint32 flags) | ||
337 | 283 | { | 281 | { |
338 | 284 | struct powerd_display_request req = {0,}; | 282 | struct powerd_display_request req = {0,}; |
339 | 285 | const char *owner; | 283 | const char *owner; |
340 | @@ -287,12 +285,11 @@ | |||
341 | 287 | int ret; | 285 | int ret; |
342 | 288 | 286 | ||
343 | 289 | owner = g_dbus_method_invocation_get_sender(invocation); | 287 | owner = g_dbus_method_invocation_get_sender(invocation); |
346 | 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", |
347 | 291 | __func__, owner, pid, state, brightness, flags); | 289 | __func__, owner, state, brightness, flags); |
348 | 292 | 290 | ||
349 | 293 | req.state = state; | 291 | req.state = state; |
350 | 294 | req.brightness = brightness; | 292 | req.brightness = brightness; |
351 | 295 | req.pid = pid; | ||
352 | 296 | req.flags = flags; | 293 | req.flags = flags; |
353 | 297 | 294 | ||
354 | 298 | ret = __powerd_add_display_request(&req, owner); | 295 | ret = __powerd_add_display_request(&req, owner); |
355 | @@ -387,12 +384,12 @@ | |||
356 | 387 | char cookie_str[UUID_STR_LEN]; | 384 | char cookie_str[UUID_STR_LEN]; |
357 | 388 | 385 | ||
358 | 389 | uuid_unparse(req->cookie, cookie_str); | 386 | uuid_unparse(req->cookie, cookie_str); |
362 | 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", |
363 | 391 | ireq->owner, req->pid, cookie_str, req->state, | 388 | ireq->owner, cookie_str, req->state, req->brightness, |
364 | 392 | req->brightness, req->flags); | 389 | req->flags); |
365 | 393 | 390 | ||
368 | 394 | g_variant_builder_add(builder, "(siiiu)", ireq->owner, req->pid, | 391 | g_variant_builder_add(builder, "(siiu)", ireq->owner, req->state, |
369 | 395 | req->state, req->brightness, req->flags); | 392 | req->brightness, req->flags); |
370 | 396 | } | 393 | } |
371 | 397 | 394 | ||
372 | 398 | static int build_display_request_list(GVariantBuilder *builder) | 395 | static int build_display_request_list(GVariantBuilder *builder) |
373 | @@ -409,13 +406,13 @@ | |||
374 | 409 | GVariantBuilder *builder; | 406 | GVariantBuilder *builder; |
375 | 410 | int count; | 407 | int count; |
376 | 411 | 408 | ||
378 | 412 | builder = g_variant_builder_new(G_VARIANT_TYPE("a(siiiu)")); | 409 | builder = g_variant_builder_new(G_VARIANT_TYPE("a(siiu)")); |
379 | 413 | count = build_display_request_list(builder); | 410 | count = build_display_request_list(builder); |
380 | 414 | if (count > 0) { | 411 | if (count > 0) { |
381 | 415 | list = g_variant_builder_end(builder); | 412 | list = g_variant_builder_end(builder); |
382 | 416 | } else { | 413 | } else { |
383 | 417 | g_variant_builder_clear(builder); | 414 | g_variant_builder_clear(builder); |
385 | 418 | list = g_variant_new_array(G_VARIANT_TYPE("(siiiu)"), NULL, 0); | 415 | list = g_variant_new_array(G_VARIANT_TYPE("(siiu)"), NULL, 0); |
386 | 419 | } | 416 | } |
387 | 420 | 417 | ||
388 | 421 | tuple = g_variant_new_tuple(&list, 1); | 418 | tuple = g_variant_new_tuple(&list, 1); |
389 | 422 | 419 | ||
390 | === modified file 'src/display.c' | |||
391 | --- src/display.c 2013-06-28 16:08:55 +0000 | |||
392 | +++ src/display.c 2013-07-02 15:12:55 +0000 | |||
393 | @@ -182,7 +182,7 @@ | |||
394 | 182 | case POWERD_DISPLAY_STATE_ON: | 182 | case POWERD_DISPLAY_STATE_ON: |
395 | 183 | if (actual_screen_state != POWERD_DISPLAY_STATE_ON) { | 183 | if (actual_screen_state != POWERD_DISPLAY_STATE_ON) { |
396 | 184 | powerd_debug("Requesting active state internally"); | 184 | powerd_debug("Requesting active state internally"); |
398 | 185 | ret = request_sys_state_internal(POWERD_SYS_STATE_ACTIVE, getpid(), | 185 | ret = request_sys_state_internal(POWERD_SYS_STATE_ACTIVE, |
399 | 186 | &internal_request_cookie, NULL); | 186 | &internal_request_cookie, NULL); |
400 | 187 | if (!ret) | 187 | if (!ret) |
401 | 188 | powerd_warn("Request for active state failed"); | 188 | powerd_warn("Request for active state failed"); |
402 | 189 | 189 | ||
403 | === modified file 'src/power-request.c' | |||
404 | --- src/power-request.c 2013-07-01 21:23:32 +0000 | |||
405 | +++ src/power-request.c 2013-07-02 15:12:55 +0000 | |||
406 | @@ -41,7 +41,6 @@ | |||
407 | 41 | struct SysStateRequest { | 41 | struct SysStateRequest { |
408 | 42 | gchar *owner; | 42 | gchar *owner; |
409 | 43 | uuid_t cookie; | 43 | uuid_t cookie; |
410 | 44 | int pid; | ||
411 | 45 | enum SysPowerStates state; | 44 | enum SysPowerStates state; |
412 | 46 | }; | 45 | }; |
413 | 47 | 46 | ||
414 | @@ -163,12 +162,11 @@ | |||
415 | 163 | 162 | ||
416 | 164 | /* XXX: For debug, remove later */ | 163 | /* XXX: For debug, remove later */ |
417 | 165 | uuid_unparse(sr->cookie, cookie_str); | 164 | uuid_unparse(sr->cookie, cookie_str); |
421 | 166 | powerd_debug(" Owner: %s, Pid: %d, Cookie: %s, State: %s (%d)", | 165 | powerd_debug(" Owner: %s, Cookie: %s, State: %s (%d)", |
422 | 167 | sr->owner, sr->pid, cookie_str, | 166 | sr->owner, cookie_str, state_to_string(sr->state), sr->state); |
420 | 168 | state_to_string(sr->state), sr->state); | ||
423 | 169 | 167 | ||
424 | 170 | if (builder) | 168 | if (builder) |
426 | 171 | g_variant_builder_add(builder, "(sii)", sr->owner, sr->pid, sr->state); | 169 | g_variant_builder_add(builder, "(si)", sr->owner, sr->state); |
427 | 172 | } | 170 | } |
428 | 173 | 171 | ||
429 | 174 | /* | 172 | /* |
430 | @@ -198,14 +196,14 @@ | |||
431 | 198 | GVariantBuilder *builder; | 196 | GVariantBuilder *builder; |
432 | 199 | guint count = 0; | 197 | guint count = 0; |
433 | 200 | 198 | ||
435 | 201 | builder = g_variant_builder_new(G_VARIANT_TYPE("a(sii)")); | 199 | builder = g_variant_builder_new(G_VARIANT_TYPE("a(si)")); |
436 | 202 | count = list_sys_requests_internal(builder); | 200 | count = list_sys_requests_internal(builder); |
437 | 203 | if (count>0) { | 201 | if (count>0) { |
438 | 204 | list = g_variant_builder_end(builder); | 202 | list = g_variant_builder_end(builder); |
439 | 205 | } | 203 | } |
440 | 206 | else { | 204 | else { |
441 | 207 | g_variant_builder_clear(builder); | 205 | g_variant_builder_clear(builder); |
443 | 208 | list = g_variant_new_array(G_VARIANT_TYPE("(sii)"), NULL, 0); | 206 | list = g_variant_new_array(G_VARIANT_TYPE("(si)"), NULL, 0); |
444 | 209 | } | 207 | } |
445 | 210 | tuple = g_variant_new_tuple(&list,1); | 208 | tuple = g_variant_new_tuple(&list,1); |
446 | 211 | g_dbus_method_invocation_return_value(invocation, tuple); | 209 | g_dbus_method_invocation_return_value(invocation, tuple); |
447 | @@ -225,7 +223,7 @@ | |||
448 | 225 | 223 | ||
449 | 226 | /* Note: owner is NULL for internal usage */ | 224 | /* Note: owner is NULL for internal usage */ |
450 | 227 | gboolean | 225 | gboolean |
452 | 228 | request_sys_state_internal(int state, int pid, uuid_t *cookie, const gchar *owner) | 226 | request_sys_state_internal(int state, uuid_t *cookie, const gchar *owner) |
453 | 229 | { | 227 | { |
454 | 230 | struct SysStateRequest *sr = NULL; | 228 | struct SysStateRequest *sr = NULL; |
455 | 231 | 229 | ||
456 | @@ -242,7 +240,6 @@ | |||
457 | 242 | 240 | ||
458 | 243 | sr = g_new(struct SysStateRequest, 1); | 241 | sr = g_new(struct SysStateRequest, 1); |
459 | 244 | sr->state = (enum SysPowerStates)state; | 242 | sr->state = (enum SysPowerStates)state; |
460 | 245 | sr->pid = pid; | ||
461 | 246 | if (owner) { | 243 | if (owner) { |
462 | 247 | sr->owner = g_strdup(owner); | 244 | sr->owner = g_strdup(owner); |
463 | 248 | } | 245 | } |
464 | @@ -258,7 +255,7 @@ | |||
465 | 258 | } | 255 | } |
466 | 259 | 256 | ||
467 | 260 | gboolean | 257 | gboolean |
469 | 261 | handle_request_sys_state (PowerdSource *obj, GDBusMethodInvocation *invocation, int state, int pid) | 258 | handle_request_sys_state (PowerdSource *obj, GDBusMethodInvocation *invocation, int state) |
470 | 262 | { | 259 | { |
471 | 263 | gboolean retval; | 260 | gboolean retval; |
472 | 264 | const char *owner; | 261 | const char *owner; |
473 | @@ -266,10 +263,10 @@ | |||
474 | 266 | char ext_cookie[UUID_STR_LEN]; | 263 | char ext_cookie[UUID_STR_LEN]; |
475 | 267 | 264 | ||
476 | 268 | owner = g_dbus_method_invocation_get_sender(invocation); | 265 | owner = g_dbus_method_invocation_get_sender(invocation); |
478 | 269 | powerd_debug("handle_requestSysState from %s: %d - %s (%d)", owner, pid, | 266 | powerd_debug("handle_requestSysState from %s - %s (%d)", owner, |
479 | 270 | state_to_string(state), state); | 267 | state_to_string(state), state); |
480 | 271 | 268 | ||
482 | 272 | retval = request_sys_state_internal(state, pid, &cookie, owner); | 269 | retval = request_sys_state_internal(state, &cookie, owner); |
483 | 273 | if (retval == TRUE) { | 270 | if (retval == TRUE) { |
484 | 274 | powerd_debug("handle_requestSysState - SUCCESS"); | 271 | powerd_debug("handle_requestSysState - SUCCESS"); |
485 | 275 | uuid_unparse(cookie, ext_cookie); | 272 | uuid_unparse(cookie, ext_cookie); |
486 | 276 | 273 | ||
487 | === modified file 'src/powerd-internal.h' | |||
488 | --- src/powerd-internal.h 2013-07-01 17:02:32 +0000 | |||
489 | +++ src/powerd-internal.h 2013-07-02 15:12:55 +0000 | |||
490 | @@ -37,7 +37,6 @@ | |||
491 | 37 | uuid_t cookie; | 37 | uuid_t cookie; |
492 | 38 | enum powerd_display_state state; | 38 | enum powerd_display_state state; |
493 | 39 | enum powerd_display_brightness brightness; | 39 | enum powerd_display_brightness brightness; |
494 | 40 | pid_t pid; | ||
495 | 41 | guint32 flags; | 40 | guint32 flags; |
496 | 42 | }; | 41 | }; |
497 | 43 | 42 | ||
498 | @@ -87,8 +86,7 @@ | |||
499 | 87 | void display_request_deinit(void); | 86 | void display_request_deinit(void); |
500 | 88 | gboolean handle_add_display_request(PowerdSource *obj, | 87 | gboolean handle_add_display_request(PowerdSource *obj, |
501 | 89 | GDBusMethodInvocation *invocation, | 88 | GDBusMethodInvocation *invocation, |
504 | 90 | int state, int brightness, int pid, | 89 | int state, int brightness, guint32 flags); |
503 | 91 | guint32 flags); | ||
505 | 92 | gboolean handle_update_display_request(PowerdSource *obj, | 90 | gboolean handle_update_display_request(PowerdSource *obj, |
506 | 93 | GDBusMethodInvocation *invocation, | 91 | GDBusMethodInvocation *invocation, |
507 | 94 | const gchar *ext_cookie, int state, | 92 | const gchar *ext_cookie, int state, |
508 | @@ -104,13 +102,12 @@ | |||
509 | 104 | gboolean handle_list_sys_requests(PowerdSource *obj, | 102 | gboolean handle_list_sys_requests(PowerdSource *obj, |
510 | 105 | GDBusMethodInvocation *invocation); | 103 | GDBusMethodInvocation *invocation); |
511 | 106 | gboolean handle_request_sys_state(PowerdSource *obj, | 104 | gboolean handle_request_sys_state(PowerdSource *obj, |
514 | 107 | GDBusMethodInvocation *invocation, | 105 | GDBusMethodInvocation *invocation, int state); |
513 | 108 | int state, int pid); | ||
515 | 109 | gboolean handle_clear_sys_state(PowerdSource *obj, | 106 | gboolean handle_clear_sys_state(PowerdSource *obj, |
516 | 110 | GDBusMethodInvocation *invocation, | 107 | GDBusMethodInvocation *invocation, |
517 | 111 | gchar *cookie); | 108 | gchar *cookie); |
520 | 112 | gboolean request_sys_state_internal(int state, int pid, | 109 | gboolean request_sys_state_internal(int state, uuid_t *cookie, |
521 | 113 | uuid_t *cookie, const gchar *owner); | 110 | const gchar *owner); |
522 | 114 | gboolean clear_sys_state_internal(uuid_t cookie); | 111 | gboolean clear_sys_state_internal(uuid_t cookie); |
523 | 115 | void update_system_state(void); | 112 | void update_system_state(void); |
524 | 116 | void power_request_init(void); | 113 | void power_request_init(void); |
525 | 117 | 114 | ||
526 | === modified file 'src/powerd.cpp' | |||
527 | --- src/powerd.cpp 2013-07-01 17:02:32 +0000 | |||
528 | +++ src/powerd.cpp 2013-07-02 15:12:55 +0000 | |||
529 | @@ -107,7 +107,6 @@ | |||
530 | 107 | {0,}, /* cookie */ | 107 | {0,}, /* cookie */ |
531 | 108 | POWERD_DISPLAY_STATE_ON, /* state */ | 108 | POWERD_DISPLAY_STATE_ON, /* state */ |
532 | 109 | POWERD_DISPLAY_BRIGHTNESS_BRIGHT, /* brightness */ | 109 | POWERD_DISPLAY_BRIGHTNESS_BRIGHT, /* brightness */ |
533 | 110 | 0, /* pid */ | ||
534 | 111 | 0 /* flags */ | 110 | 0 /* flags */ |
535 | 112 | }; | 111 | }; |
536 | 113 | 112 | ||
537 | @@ -116,7 +115,6 @@ | |||
538 | 116 | {0,}, /* cookie */ | 115 | {0,}, /* cookie */ |
539 | 117 | POWERD_DISPLAY_STATE_DONT_CARE, /* state */ | 116 | POWERD_DISPLAY_STATE_DONT_CARE, /* state */ |
540 | 118 | POWERD_DISPLAY_BRIGHTNESS_DONT_CARE, /* brightness */ | 117 | POWERD_DISPLAY_BRIGHTNESS_DONT_CARE, /* brightness */ |
541 | 119 | 0, /* pid */ | ||
542 | 120 | POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */ | 118 | POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */ |
543 | 121 | }; | 119 | }; |
544 | 122 | 120 |
PASSED: Continuous integration, rev:68 jenkins. qa.ubuntu. com/job/ powerd- ci/81/ jenkins. qa.ubuntu. com/job/ powerd- saucy-armhf- ci/35 jenkins. qa.ubuntu. com/job/ powerd- saucy-armhf- ci/35/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ powerd- ci/81/rebuild
http://