rollback the boilerplate
[apps/home/starter.git] / lock-mgr / src / lockd-process-mgr.c
1 /*
2  *  starter
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@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 #include <vconf.h>
23 #include <vconf-keys.h>
24
25 #include <aul.h>
26
27 #include "lockd-debug.h"
28 #include "lockd-process-mgr.h"
29
30 #define LOCKD_PHONE_LOCK_PKG_NAME "org.tizen.phone-lock"
31
32 int lockd_process_mgr_start_phone_lock(void)
33 {
34         int pid = 0;
35         bundle *b = NULL;
36
37         b = bundle_create();
38
39         bundle_add(b, "pwlock_type", "running_lock");
40         bundle_add(b, "window_type", "alpha");
41
42         pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
43         LOCKD_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
44                   pid);
45         if (b)
46                 bundle_free(b);
47
48         return pid;
49 }
50
51 void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid)
52 {
53         LOCKD_DBG("Terminate Phone Lock(pid : %d)", phone_lock_pid);
54         aul_terminate_pid(phone_lock_pid);
55 }
56
57 int lockd_process_mgr_check_lock(int pid)
58 {
59         char buf[128];
60         LOCKD_DBG("%s, %d", __func__, __LINE__);
61         if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
62                 LOCKD_DBG("no such pkg by pid %d\n", pid);
63         } else {
64                 LOCKD_DBG("lock screen pkgname = %s, pid = %d\n", buf, pid);
65                 if (aul_app_is_running(buf) == TRUE) {
66                         LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
67                         return TRUE;
68                 } else {
69                         LOCKD_DBG("[pid = %d] is exist but %s is not running\n",
70                                   pid, buf);
71                 }
72         }
73         return FALSE;
74 }