Tizen 2.4 SDK Rev6 Release
[framework/appfw/aul-1.git] / src / app_signal.c
1 /*
2  *  aul
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #define _GNU_SOURCE
23 #include <stdio.h>
24 #include <dbus/dbus-glib-lowlevel.h>
25
26 #include "app_signal.h"
27 #include "aul_api.h"
28 #include "simple_util.h"
29 #include "aul.h"
30
31
32 static int (*_app_dead_handler) (int pid, void *data);
33 static void *_app_dead_data;
34
35 static int (*_app_launch_handler) (int pid, void *data);
36 static void *_app_launch_data;
37
38 static int (*_app_launch_handler2) (int pid, const char *app_id, void *data);
39 static void *_app_launch_data2;
40
41 static int (*_booting_done_handler) (int pid, void *data);
42 static void *_booting_done_data;
43
44 static int (*_status_handler) (int pid, int status, void *data);
45 static void *_status_data;
46
47 static int (*_cooldown_handler) (const char *cooldown_status, void *data);
48 static void *_cooldown_data;
49
50 static DBusConnection *bus;
51 static int app_dbus_signal_handler_initialized = 0;
52
53 DBusError err;
54 DBusConnection* conn = NULL;
55
56 static DBusHandlerResult
57 __app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
58                        void *user_data)
59 {
60         const char *sender;
61         const char *interface;
62         const char *cooldown_status;
63         int pid = -1;
64         int status;
65
66         DBusError error;
67         dbus_error_init(&error);
68
69         sender = dbus_message_get_sender(message);
70         if (sender == NULL)
71                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
72
73         /*if (dbus_bus_get_unix_user(conn, sender, &error) != 0) {
74                 _E("reject by security issue - no allowed sender\n");
75                 dbus_error_free(&error);
76                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
77         }*/
78
79         interface = dbus_message_get_interface(message);
80         if (interface == NULL) {
81                 _E("reject by security issue - no interface\n");
82                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
83         }
84
85         if (dbus_message_is_signal(
86           message, interface, AUL_DBUS_APPDEAD_SIGNAL)) {
87                 if (_app_dead_handler) {
88                         if (dbus_message_get_args(message, &error,
89                                         DBUS_TYPE_UINT32, &pid,
90                                         DBUS_TYPE_INVALID) == FALSE) {
91                                 _E("Failed to get data: %s", error.message);
92                                 dbus_error_free(&error);
93                                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
94                         }
95                         _app_dead_handler(pid, _app_dead_data);
96                 }
97         } else if (dbus_message_is_signal(
98           message, interface, AUL_DBUS_APPLAUNCH_SIGNAL)) {
99                 if (_app_launch_handler || _app_launch_handler2) {
100                         const char *app_id = NULL;
101
102                         if (dbus_message_get_args(message, &error,
103                                         DBUS_TYPE_UINT32, &pid,
104                                         DBUS_TYPE_STRING, &app_id,
105                                         DBUS_TYPE_INVALID) == FALSE) {
106                                 _E("Failed to get data: %s", error.message);
107                                 dbus_error_free(&error);
108                                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
109                         }
110
111                         if (_app_launch_handler)
112                                 _app_launch_handler(pid, _app_launch_data);
113
114                         if (_app_launch_handler2)
115                                 _app_launch_handler2(pid, app_id, _app_launch_data2);
116                 }
117         } else if (dbus_message_is_signal(
118           message, interface, SYSTEM_SIGNAL_BOOTING_DONE)) {
119                 if (_booting_done_handler)
120                         _booting_done_handler(pid, _booting_done_data);
121         } else if (dbus_message_is_signal(
122           message, interface, RESOURCED_SIGNAL_PROCESS_STATUS)) {
123                 if (_status_handler) {
124                         if (dbus_message_get_args(message, &error,
125                                         DBUS_TYPE_INT32,&status,
126                                         DBUS_TYPE_INT32,&pid,
127                                         DBUS_TYPE_INVALID) == FALSE) {
128                                 _E("Failed to get data: %s", error.message);
129                                 dbus_error_free(&error);
130                                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
131                         }
132                         _status_handler(pid, status, _status_data);
133                 }
134         } else if (dbus_message_is_signal(
135           message, interface, SYSTEM_SIGNAL_COOLDOWN_CHANGED)) {
136                 if (_cooldown_handler) {
137                         if (dbus_message_get_args(message, &error,
138                                         DBUS_TYPE_STRING, &cooldown_status,
139                                         DBUS_TYPE_INVALID) == FALSE) {
140                                 _E("Failed to get data: %s", error.message);
141                                 dbus_error_free(&error);
142                                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
143                         }
144                         _cooldown_handler(cooldown_status, _cooldown_data);
145                 }
146         }
147
148         return DBUS_HANDLER_RESULT_HANDLED;
149 }
150
151 static int __app_dbus_signal_handler_init_with_param(const char* path, const char* interface)
152 {
153         DBusError error;
154         char rule[MAX_LOCAL_BUFSZ];
155
156         dbus_error_init(&error);
157         bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
158         if (!bus) {
159                 _E("Failed to connect to the D-BUS daemon: %s", error.message);
160                 dbus_error_free(&error);
161                 return -1;
162         }
163         dbus_connection_setup_with_g_main(bus, NULL);
164
165         snprintf(rule, MAX_LOCAL_BUFSZ,
166                  "path='%s',type='signal',interface='%s'", path, interface);
167         /* listening to messages */
168         dbus_bus_add_match(bus, rule, &error);
169         if (dbus_error_is_set(&error)) {
170                 _E("Fail to rule set: %s", error.message);
171                 dbus_error_free(&error);
172                 return -1;
173         }
174
175         if (dbus_connection_add_filter(bus,
176                 __app_dbus_signal_filter, NULL, NULL) == FALSE) {
177                 _E("add filter fail");
178                 return -1;
179         }
180
181         _D("app signal initialized");
182
183         return 0;
184 }
185
186 static int __app_dbus_signal_handler_init(void)
187 {
188         int ret = 0;
189
190         if (app_dbus_signal_handler_initialized)
191                 return 0;
192
193         ret = __app_dbus_signal_handler_init_with_param(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE);
194
195         app_dbus_signal_handler_initialized = 1;
196
197         return ret;
198 }
199
200 static int __app_dbus_signal_handler_fini_with_param(const char* path, const char* interface)
201 {
202         DBusError error;
203         char rule[MAX_LOCAL_BUFSZ];
204
205
206         dbus_error_init(&error);
207
208         dbus_connection_remove_filter(bus, __app_dbus_signal_filter, NULL);
209
210         snprintf(rule, MAX_LOCAL_BUFSZ,
211                  "path='%s',type='signal',interface='%s'", path, interface);
212         dbus_bus_remove_match(bus, rule, &error);
213         if (dbus_error_is_set(&error)) {
214                 _E("Fail to rule unset: %s", error.message);
215                 dbus_error_free(&error);
216                 return -1;
217         }
218
219         dbus_connection_close(bus);
220         dbus_connection_unref(bus);
221
222         _D("app signal finialized");
223
224         return 0;
225 }
226
227 static int __app_dbus_signal_handler_fini(void)
228 {
229         int ret = 0;
230
231         if (!app_dbus_signal_handler_initialized)
232                 return 0;
233
234         ret = __app_dbus_signal_handler_fini_with_param(AUL_DBUS_PATH, AUL_DBUS_SIGNAL_INTERFACE);
235
236         app_dbus_signal_handler_initialized = 0;
237
238         return ret;
239 }
240
241 SLPAPI int aul_listen_app_dead_signal(int (*func) (int, void *), void *data)
242 {
243         if (func) {
244                 if (__app_dbus_signal_handler_init() < 0) {
245                         _E("error app signal init");
246                         return AUL_R_ERROR;
247                 }
248         } else if (_app_launch_handler == NULL && _app_launch_handler2 == NULL) {
249                 if (__app_dbus_signal_handler_fini() < 0) {
250                         _E("error app signal fini");
251                         return AUL_R_ERROR;
252                 }
253         }
254         _app_dead_handler = func;
255         _app_dead_data = data;
256
257         return AUL_R_OK;
258 }
259
260 SLPAPI int aul_listen_app_launch_signal(int (*func) (int, void *), void *data)
261 {
262         if (func) {
263                 if (__app_dbus_signal_handler_init() < 0) {
264                         _E("error app signal init");
265                         return AUL_R_ERROR;
266                 }
267         } else if (_app_launch_handler2 == NULL && _app_dead_handler == NULL) {
268                 if (__app_dbus_signal_handler_fini() < 0) {
269                         _E("error app signal fini");
270                         return AUL_R_ERROR;
271                 }
272         }
273         _app_launch_handler = func;
274         _app_launch_data = data;
275
276         return AUL_R_OK;
277 }
278
279 SLPAPI int aul_listen_app_launch_signal_v2(int (*func) (int, const char *, void *), void *data)
280 {
281         if (func) {
282                 if (__app_dbus_signal_handler_init() < 0) {
283                         _E("error app signal init");
284                         return AUL_R_ERROR;
285                 }
286         } else if (_app_launch_handler == NULL && _app_dead_handler == NULL) {
287                 if (__app_dbus_signal_handler_fini() < 0) {
288                         _E("error app signal fini");
289                         return AUL_R_ERROR;
290                 }
291         }
292
293         _app_launch_handler2 = func;
294         _app_launch_data2 = data;
295
296         return AUL_R_OK;
297 }
298
299 SLPAPI int aul_listen_booting_done_signal(int (*func) (int, void *), void *data)
300 {
301         if (func) {
302                 if (__app_dbus_signal_handler_init_with_param(SYSTEM_PATH_CORE, SYSTEM_INTERFACE_CORE) < 0) {
303                         _E("error app signal init");
304                         return AUL_R_ERROR;
305                 }
306         } else if (_booting_done_handler == NULL) {
307                 if (__app_dbus_signal_handler_fini_with_param(SYSTEM_PATH_CORE, SYSTEM_INTERFACE_CORE) < 0) {
308                         _E("error app signal fini");
309                         return AUL_R_ERROR;
310                 }
311         }
312         _booting_done_handler = func;
313         _booting_done_data = data;
314
315         return AUL_R_OK;
316
317 }
318
319 SLPAPI int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data)
320 {
321         if (func) {
322                 if (__app_dbus_signal_handler_init_with_param(SYSTEM_PATH_SYSNOTI, SYSTEM_INTERFACE_SYSNOTI) < 0) {
323                         _E("error app signal init");
324                         return AUL_R_ERROR;
325                 }
326         } else if (_cooldown_handler == NULL) {
327                 if (__app_dbus_signal_handler_fini_with_param(SYSTEM_PATH_SYSNOTI, SYSTEM_INTERFACE_SYSNOTI) < 0) {
328                         _E("error app signal fini");
329                         return AUL_R_ERROR;
330                 }
331         }
332         _cooldown_handler = func;
333         _cooldown_data = data;
334
335         return AUL_R_OK;
336
337 }
338
339 SLPAPI int aul_listen_e17_status_signal(int (*func) (int, int, void *), void *data)
340 {
341         if (func) {
342                 if (__app_dbus_signal_handler_init_with_param(RESOURCED_PATH_CORE, RESOURCED_INTERFACE_CORE) < 0) {
343                         _E("error app signal init");
344                         return AUL_R_ERROR;
345                 }
346         }
347         _status_handler = func;
348         _status_data = data;
349
350         return AUL_R_OK;
351 }
352
353 SLPAPI int aul_update_freezer_status(int pid, const char* type)
354 {
355         DBusError err;
356         DBusConnection* conn = NULL;
357         DBusMessage* msg = NULL;
358         dbus_uint32_t serial = 0;
359
360         int ret = -1;
361
362         dbus_error_init(&err);
363
364         _W("send_update_freezer_status, pid: %d, type: %s", pid, type);
365
366         conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
367         if (!conn) {
368                 _E("Fail to dbus_bus_get : %s", err.message);
369                 return -1;
370         }
371
372         msg = dbus_message_new_signal(RESOURCED_PROC_OBJECT,
373                         RESOURCED_PROC_INTERFACE,
374                         RESOURCED_PROC_METHOD);
375         if (!msg) {
376                 _E("Could not create DBus Message.");
377                 ret = -1;
378                 goto end;
379         }
380
381         if (!dbus_message_append_args(msg,
382                         DBUS_TYPE_STRING, &type,
383                         DBUS_TYPE_INT32, &pid,
384                         DBUS_TYPE_INVALID)) {
385                 _E("Failed to append a D-Bus Message.");
386                 ret = -1;
387         }
388
389         if (!dbus_connection_send(conn, msg, &serial)) {
390                 _E("Failed to send a D-Bus Message.");
391                 ret = -1;
392         }
393
394         dbus_connection_flush(conn);
395
396 end:
397         dbus_error_free(&err);
398
399         if (msg) {
400                 dbus_message_unref(msg);
401         }
402
403         if (conn) {
404                 dbus_connection_unref(conn);
405         }
406
407         return ret;
408
409 }
410
411 int __app_status_dbus_init(void)
412 {
413         int ret = 0;
414
415         if (conn)
416                 return 0;
417
418         dbus_error_init(&err);
419         conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
420
421         return ret;
422 }
423
424 SLPAPI int aul_send_app_launch_request_signal(int pid, const char* appid, const char* pkgid, const char* type)
425 {
426         DBusMessage* msg = NULL;
427         dbus_uint32_t serial = 0;
428
429         int ret = -1;
430
431         __app_status_dbus_init();
432
433         _W("send_app_launch_signal, pid: %d, appid: %s", pid, appid);
434
435         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
436                         AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
437                         AUL_APP_STATUS_DBUS_LAUNCH_REQUEST);
438         if (!msg) {
439                 _E("Could not create DBus Message.");
440                 ret = -1;
441                 goto end;
442         }
443
444         if (!dbus_message_append_args(msg,
445                         DBUS_TYPE_INT32, &pid,
446                         DBUS_TYPE_STRING, &appid,
447                         DBUS_TYPE_STRING, &pkgid,
448                         DBUS_TYPE_STRING, &type,
449                         DBUS_TYPE_INVALID)) {
450                 _E("Failed to append a D-Bus Message.");
451                 ret = -1;
452         }
453
454         if (!dbus_connection_send(conn, msg, &serial)) {
455                 _E("Failed to send a D-Bus Message.");
456                 ret = -1;
457         }
458
459         dbus_connection_flush(conn);
460
461 end:
462         if (msg) {
463                 dbus_message_unref(msg);
464         }
465         return ret;
466 }
467
468 SLPAPI int aul_send_app_resume_request_signal(int pid, const char* appid, const char* pkgid, const char* type)
469 {
470         DBusMessage* msg = NULL;
471         dbus_uint32_t serial = 0;
472         const char       *empty_string = "";
473
474         int ret = -1;
475
476         __app_status_dbus_init();
477
478         _W("send_app_resume_signal, pid: %d, appid: %s", pid, appid);
479
480         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
481                         AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
482                         AUL_APP_STATUS_DBUS_RESUME_REQUEST);
483         if (!msg) {
484                 _E("Could not create DBus Message.");
485                 ret = -1;
486                 goto end;
487         }
488
489         if(appid) {
490                 if (!dbus_message_append_args(msg,
491                                 DBUS_TYPE_INT32, &pid,
492                                 DBUS_TYPE_STRING, &appid,
493                                 DBUS_TYPE_STRING, &pkgid,
494                                 DBUS_TYPE_STRING, &type,
495                                 DBUS_TYPE_INVALID)) {
496                         _E("Failed to append a D-Bus Message.");
497                         ret = -1;
498                 }
499         } else {
500                 if (!dbus_message_append_args(msg,
501                                 DBUS_TYPE_INT32, &pid,
502                                 DBUS_TYPE_STRING, &empty_string,
503                                 DBUS_TYPE_STRING, &empty_string,
504                                 DBUS_TYPE_STRING, &empty_string,
505                                 DBUS_TYPE_INVALID)) {
506                         _E("Failed to append a D-Bus Message.");
507                         ret = -1;
508                 }
509         }
510
511         if (!dbus_connection_send(conn, msg, &serial)) {
512                 _E("Failed to send a D-Bus Message.");
513                 ret = -1;
514         }
515
516         dbus_connection_flush(conn);
517
518 end:
519         if (msg) {
520                 dbus_message_unref(msg);
521         }
522
523         return ret;
524 }
525
526 SLPAPI int aul_send_app_terminate_request_signal(int pid, const char* appid, const char* pkgid, const char *type)
527 {
528         DBusMessage* msg = NULL;
529         dbus_uint32_t serial = 0;
530         const char       *empty_string = "";
531
532         int ret = -1;
533
534         __app_status_dbus_init();
535
536         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
537                         AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
538                         AUL_APP_STATUS_DBUS_TERMINATE_REQUEST);
539         if (!msg) {
540                 _E("Could not create DBus Message.");
541                 ret = -1;
542                 goto end;
543         }
544
545         if(appid) {
546                 if (!dbus_message_append_args(msg,
547                                 DBUS_TYPE_INT32, &pid,
548                                 DBUS_TYPE_STRING, &appid,
549                                 DBUS_TYPE_STRING, &pkgid,
550                                 DBUS_TYPE_STRING, &type,
551                                 DBUS_TYPE_INVALID)) {
552                         _E("Failed to append a D-Bus Message.");
553                         ret = -1;
554                 }
555         } else {
556                 if (!dbus_message_append_args(msg,
557                                 DBUS_TYPE_INT32, &pid,
558                                 DBUS_TYPE_STRING, &empty_string,
559                                 DBUS_TYPE_STRING, &empty_string,
560                                 DBUS_TYPE_STRING, &empty_string,
561                                 DBUS_TYPE_INVALID)) {
562                         _E("Failed to append a D-Bus Message.");
563                         ret = -1;
564                 }
565         }
566
567         if (!dbus_connection_send(conn, msg, &serial)) {
568                 _E("Failed to send a D-Bus Message.");
569                 ret = -1;
570         }
571
572         dbus_connection_flush(conn);
573
574 end:
575         if (msg) {
576                 dbus_message_unref(msg);
577         }
578
579         return ret;
580
581 }
582
583 SLPAPI int aul_send_app_status_change_signal(int pid, const char* appid, const char* pkgid, const char* status, const char *type)
584 {
585         DBusMessage* msg = NULL;
586         dbus_uint32_t serial = 0;
587         const char       *empty_string = "";
588
589         int ret = -1;
590
591         _W("send_app_status_change_signal, pid: %d, appid: %s, status: %s", pid, appid, status);
592
593         __app_status_dbus_init();
594
595         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
596                         AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
597                         AUL_APP_STATUS_DBUS_STATUS_CHANGE);
598         if (!msg) {
599                 _E("Could not create DBus Message.");
600                 ret = -1;
601                 goto end;
602         }
603
604         if(appid) {
605                 if (!dbus_message_append_args(msg,
606                                 DBUS_TYPE_INT32, &pid,
607                                 DBUS_TYPE_STRING, &appid,
608                                 DBUS_TYPE_STRING, &pkgid,
609                                 DBUS_TYPE_STRING, &status,
610                                 DBUS_TYPE_STRING, &type,
611                                 DBUS_TYPE_INVALID)) {
612                         _E("Failed to append a D-Bus Message.");
613                         ret = -1;
614                 }
615         } else {
616                 if (!dbus_message_append_args(msg,
617                                 DBUS_TYPE_INT32, &pid,
618                                 DBUS_TYPE_STRING, &empty_string,
619                                 DBUS_TYPE_STRING, &empty_string,
620                                 DBUS_TYPE_STRING, &status,
621                                 DBUS_TYPE_STRING, &type,
622                                 DBUS_TYPE_INVALID)) {
623                         _E("Failed to append a D-Bus Message.");
624                         ret = -1;
625                 }
626         }
627
628         if (!dbus_connection_send(conn, msg, &serial)) {
629                 _E("Failed to send a D-Bus Message.");
630                 ret = -1;
631         }
632
633         dbus_connection_flush(conn);
634
635 end:
636         if (msg) {
637                 dbus_message_unref(msg);
638         }
639
640         return ret;
641 }
642
643 SLPAPI int aul_send_app_terminated_signal(int pid)
644 {
645         DBusMessage* msg = NULL;
646         dbus_uint32_t serial = 0;
647
648         int ret = -1;
649
650         __app_status_dbus_init();
651
652         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
653                         AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
654                         AUL_APP_STATUS_DBUS_TERMINATED);
655         if (!msg) {
656                 _E("Could not create DBus Message.");
657                 ret = -1;
658                 goto end;
659         }
660
661         if (!dbus_message_append_args(msg,
662                         DBUS_TYPE_INT32, &pid,
663                         DBUS_TYPE_INVALID)) {
664                 _E("Failed to append a D-Bus Message.");
665                 ret = -1;
666         }
667
668         if (!dbus_connection_send(conn, msg, &serial)) {
669                 _E("Failed to send a D-Bus Message.");
670                 ret = -1;
671         }
672
673         dbus_connection_flush(conn);
674
675 end:
676         if (msg) {
677                 dbus_message_unref(msg);
678         }
679         return ret;
680 }
681
682 SLPAPI int aul_send_app_group_signal(int owner_pid, int child_pid, const char *child_pkgid)
683 {
684         DBusMessage* msg = NULL;
685         dbus_uint32_t serial = 0;
686         const char  *empty_string = "";
687
688         int ret = -1;
689
690         _W("send_app_group_signal, owner: %d, child: %d", owner_pid, child_pid);
691
692         __app_status_dbus_init();
693
694         msg = dbus_message_new_signal(AUL_APP_STATUS_DBUS_PATH,
695                                       AUL_APP_STATUS_DBUS_SIGNAL_INTERFACE,
696                                       AUL_APP_STATUS_DBUS_GROUP);
697         if (!msg) {
698                 _E("Could not create DBus Message.");
699                 ret = -1;
700                 goto end;
701         }
702
703         if (child_pkgid) {
704                 if (!dbus_message_append_args(msg,
705                                               DBUS_TYPE_INT32, &owner_pid,
706                                               DBUS_TYPE_INT32, &child_pid,
707                                               DBUS_TYPE_STRING, &child_pkgid,
708                                               DBUS_TYPE_INVALID)) {
709                         _E("Failed to append a D-Bus Message.");
710                         ret = -1;
711                 }
712         } else {
713                 if (!dbus_message_append_args(msg,
714                                               DBUS_TYPE_INT32, &owner_pid,
715                                               DBUS_TYPE_INT32, &child_pid,
716                                               DBUS_TYPE_STRING, &empty_string,
717                                               DBUS_TYPE_INVALID)) {
718                         _E("Failed to append a D-Bus Message.");
719                         ret = -1;
720                 }
721         }
722
723         if (!dbus_connection_send(conn, msg, &serial)) {
724                 _E("Failed to send a D-Bus Message.");
725                 ret = -1;
726         }
727
728         dbus_connection_flush(conn);
729
730 end:
731         if (msg) {
732                 dbus_message_unref(msg);
733         }
734
735         return ret;
736 }