Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:51:02 +0000 (00:51 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:51:02 +0000 (00:51 +0900)
26 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0755]
NOTICE [new file with mode: 0755]
boot-mgr/CMakeLists.txt [new file with mode: 0755]
boot-mgr/starter.c [new file with mode: 0755]
boot-mgr/starter.h [new file with mode: 0755]
boot-mgr/x11.c [new file with mode: 0755]
boot-mgr/x11.h [new file with mode: 0755]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/rules [new file with mode: 0755]
debian/starter.install.in [new file with mode: 0755]
debian/starter.postinst [new file with mode: 0755]
lock-mgr/CMakeLists.txt [new file with mode: 0755]
lock-mgr/include/lock-daemon.h [new file with mode: 0755]
lock-mgr/include/lockd-debug.h [new file with mode: 0755]
lock-mgr/include/lockd-process-mgr.h [new file with mode: 0755]
lock-mgr/src/lock-daemon.c [new file with mode: 0755]
lock-mgr/src/lockd-debug.c [new file with mode: 0755]
lock-mgr/src/lockd-process-mgr.c [new file with mode: 0755]
packaging/starter.spec [new file with mode: 0644]
rd3starter [new file with mode: 0755]
rd4starter [new file with mode: 0755]
starter [new file with mode: 0755]
starter.desktop.in [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..53e401c
--- /dev/null
@@ -0,0 +1,28 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(starter C)
+
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(DATADIR "${PREFIX}/share")
+SET(LOCALEDIR "${DATADIR}/locale")
+
+SET(LOCK_MGR lock-mgr)
+SET(BOOT_MGR boot-mgr)
+
+ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${LOCK_MGR})
+ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${BOOT_MGR})
+
+# install desktop file & icon
+CONFIGURE_FILE(${PROJECT_NAME}.desktop.in ${PROJECT_NAME}.desktop)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION share/applications)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/rd4starter DESTINATION /etc/init.d
+               PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/rd3starter DESTINATION /etc/init.d
+               PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+               GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+#INSTALL to /etc/init.d
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..ded3804
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\ No newline at end of file
diff --git a/boot-mgr/CMakeLists.txt b/boot-mgr/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..6dfcd8b
--- /dev/null
@@ -0,0 +1,42 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(starter C)
+
+SET(SRCS starter.c x11.c)
+
+SET(CMAKE_BINARY_LOCK_DAEMON_DIR "${CMAKE_BINARY_DIR}/${LOCK_MGR}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${LOCK_MGR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED elementary vconf x11 heynoti aul ecore evas ecore-evas x11 dlog ecore-x utilX ecore-input)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${PREFIX}/lib -pie")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+#TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} -L${CMAKE_BINARY_LOCK_DAEMON_DIR} -llock-daemon ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
diff --git a/boot-mgr/starter.c b/boot-mgr/starter.c
new file mode 100755 (executable)
index 0000000..4e07eed
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <Elementary.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <poll.h>
+
+#include <aul.h>
+#include <vconf.h>
+#include <heynoti.h>
+
+#include "starter.h"
+#include "x11.h"
+#include "lock-daemon.h"
+#include "lockd-debug.h"
+
+#ifndef PACKAGE_NAME
+#define PACKAGE_NAME "org.tizen.starter"
+#endif
+
+#define PWLOCK_PKG "org.tizen.pwlock"
+#define VCONFKEY_START "memory/startapps/sequence"
+#define PWLOCK_FIRST_BOOT "db/setting/pwlock_boot"
+#define DEFAULT_THEME "tizen"
+#define PWLOCK_PATH "/opt/apps/org.tizen.pwlock/bin/pwlock"
+#define HIB_CAPTURING "/opt/etc/.hib_capturing"
+
+static void lock_menu_screen(void)
+{
+       vconf_set_int(VCONFKEY_START, 0);
+}
+
+static void unlock_menu_screen(void)
+{
+       int r;
+       int show_menu;
+
+       show_menu = 0;
+       r = vconf_get_int(VCONFKEY_START, &show_menu);
+       if (r || !show_menu) {
+               vconf_set_int(VCONFKEY_START, 1);
+       }
+}
+
+static void _set_elm_theme(void)
+{
+       char *vstr;
+       char *theme;
+       vstr = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
+       if (vstr == NULL)
+               theme = DEFAULT_THEME;
+       else
+               theme = vstr;
+
+       _DBG("theme vconf[%s]\n set[%s]\n", vstr, theme);
+       elm_theme_all_set(theme);
+
+       if (vstr)
+               free(vstr);
+}
+
+static void _set_elm_entry(void)
+{
+       int v;
+       int r;
+
+       r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOCAPITAL_ALLOW_BOOL, &v);
+       if (!r) {
+               prop_int_set("ENLIGHTENMENT_AUTOCAPITAL_ALLOW", v);
+               _DBG("vconf autocatipal[%d]", v);
+       }
+
+       r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOPERIOD_ALLOW_BOOL, &v);
+       if (!r) {
+               prop_int_set("ENLIGHTENMENT_AUTOPERIOD_ALLOW", v);
+               _DBG("vconf autoperiod[%d]", v);
+       }
+}
+
+static int _launch_pwlock(void)
+{
+       int r;
+
+       _DBG("%s", __func__);
+
+       r = aul_launch_app(PWLOCK_PKG, NULL);
+       if (r < 0) {
+               _ERR("PWLock launch error: error(%d)", r);
+               if (r == AUL_R_ETIMEOUT) {
+                       _DBG("Launch pwlock is failed for AUL_R_ETIMEOUT, again launch pwlock");
+                       r = aul_launch_app(PWLOCK_PKG, NULL);
+                       if (r < 0) {
+                               _ERR("2'nd PWLock launch error: error(%d)", r);
+                               return -1;
+                       } else {
+                               _DBG("Launch pwlock");
+                               return 0;
+                       }
+               } else {
+                       return -1;
+               }
+       } else {
+               _DBG("Launch pwlock");
+               return 0;
+       }
+}
+
+static void hib_leave(void *data)
+{
+       struct appdata *ad = data;
+       if (ad == NULL) {
+               fprintf(stderr, "Invalid argument: appdata is NULL\n");
+               return;
+       }
+
+       _DBG("%s", __func__);
+       _set_elm_theme();
+       start_lock_daemon();
+       if (_launch_pwlock() < 0) {
+               _ERR("launch pwlock error");
+       }
+}
+
+static int add_noti(struct appdata *ad)
+{
+       int fd;
+       int r;
+       _DBG("%s %d\n", __func__, __LINE__);
+
+       if (ad == NULL) {
+               fprintf(stderr, "Invalid argument: appdata is NULL\n");
+               return -1;
+       }
+
+       fd = heynoti_init();
+       if (fd == -1) {
+               _ERR("Noti init error");
+               return -1;
+       }
+       ad->noti = fd;
+
+       r = heynoti_subscribe(fd, "HIBERNATION_PRELEAVE", hib_leave, ad);
+       if (r == -1) {
+               _ERR("Noti subs error");
+               return -1;
+       }
+
+       r = heynoti_attach_handler(fd);
+       if (r == -1) {
+               _ERR("Noti attach error");
+               return -1;
+       }
+
+       _DBG("Waiting for hib leave");
+       _DBG("%s %d\n", __func__, __LINE__);
+
+       return 0;
+}
+
+static int _init(struct appdata *ad)
+{
+       int fd;
+       int r;
+
+       memset(ad, 0, sizeof(struct appdata));
+
+       ad->noti = -1;
+       gettimeofday(&ad->tv_start, NULL);
+
+       lock_menu_screen();
+       _set_elm_theme();
+       _set_elm_entry();
+
+       _DBG("%s %d\n", __func__, __LINE__);
+       fd = open(HIB_CAPTURING, O_RDONLY);
+       _DBG("fd = %d\n", fd);
+       if (fd == -1) {
+               _DBG("fd = %d\n", fd);
+               start_lock_daemon();
+               if (_launch_pwlock() < 0) {
+                       _ERR("launch pwlock error");
+               }
+               r = 0;
+       } else {
+               close(fd);
+               r = add_noti(ad);
+       }
+
+       if (vconf_set_int("memory/hibernation/starter_ready", 1))
+               _ERR("vconf_set_int FAIL");
+       else
+               _ERR("vconf_set_int OK\n");
+
+       return r;
+}
+
+static void _fini(struct appdata *ad)
+{
+       struct timeval tv, res;
+
+       if (ad == NULL) {
+               fprintf(stderr, "Invalid argument: appdata is NULL\n");
+               return;
+       }
+       if (ad->noti != -1)
+               heynoti_close(ad->noti);
+
+       unlock_menu_screen();
+
+       gettimeofday(&tv, NULL);
+       timersub(&tv, &ad->tv_start, &res);
+       _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
+}
+
+int main(int argc, char *argv[])
+{
+       struct appdata ad;
+
+       set_window_scale();
+
+       elm_init(argc, argv);
+
+       _init(&ad);
+
+       elm_run();
+
+       _fini(&ad);
+
+       elm_shutdown();
+
+       return 0;
+}
diff --git a/boot-mgr/starter.h b/boot-mgr/starter.h
new file mode 100755 (executable)
index 0000000..d651bcb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STARTER_H__
+#define __STARTER_H__
+
+#include <sys/time.h>
+
+struct appdata {
+       struct timeval tv_start;
+       int noti;
+};
+
+#endif                         /* __STARTER_H__ */
diff --git a/boot-mgr/x11.c b/boot-mgr/x11.c
new file mode 100755 (executable)
index 0000000..820f4a2
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+#define DEFAULT_WINDOW_H 1280
+
+void prop_string_set(const char *name, const char *value)
+{
+       Display *d;
+       Atom a_name;
+       Atom a_UTF8;
+       XTextProperty xtp;
+
+       if (name == NULL || value == NULL || value[0] == '\0')
+               return;
+
+       d = XOpenDisplay(NULL);
+       if (d == NULL)
+               return;
+
+       a_name = XInternAtom(d, name, False);
+       if (a_name == None)
+               goto exit;
+
+       a_UTF8 = XInternAtom(d, "UTF8_STRING", False);
+       if (a_UTF8 == None)
+               goto exit;
+
+       xtp.value = (unsigned char *)value;
+       xtp.format = 8;
+       xtp.encoding = a_UTF8;
+       xtp.nitems = strlen(value);
+
+       XSetTextProperty(d, DefaultRootWindow(d), &xtp, a_name);
+
+ exit:
+       XCloseDisplay(d);
+}
+
+void prop_int_set(const char *name, unsigned int val)
+{
+       Display *d;
+       Atom a_name;
+
+       if (name == NULL)
+               return;
+
+       d = XOpenDisplay(NULL);
+       if (d == NULL)
+               return;
+
+       a_name = XInternAtom(d, name, False);
+       if (a_name == None)
+               goto exit;
+
+       XChangeProperty(d, DefaultRootWindow(d), a_name, XA_CARDINAL, 32,
+                       PropModeReplace, (unsigned char *)&val, 1);
+
+ exit:
+       XCloseDisplay(d);
+}
+
+void set_window_scale(void)
+{
+       double root_width = 0.0, root_height = 0.0;
+       char buf[128] = { 0, };
+       Display *disp;
+       int screen_num;
+
+       disp = XOpenDisplay(NULL);
+       if (disp == NULL)
+               return;
+
+       screen_num = DefaultScreen(disp);
+
+       root_width = DisplayWidth(disp, screen_num);
+       root_height = DisplayHeight(disp, screen_num);
+
+       XCloseDisplay(disp);
+
+       snprintf(buf, sizeof(buf), "%lf", root_height / DEFAULT_WINDOW_H);
+
+       if (root_width == 800 && root_height == 1280) {
+               snprintf(buf, sizeof(buf), "0.71");
+       }
+
+       setenv("ELM_SCALE", buf, 1);
+       setenv("SCALE_FACTOR", buf, 1);
+}
diff --git a/boot-mgr/x11.h b/boot-mgr/x11.h
new file mode 100755 (executable)
index 0000000..dca365b
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STARTER_X11_H__
+#define __STARTER_X11_H__
+
+void prop_string_set(const char *name, const char *value);
+void prop_int_set(const char *name, unsigned int val);
+void set_window_scale(void);
+
+#endif                         /* __STARTER_X11_H__ */
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..14b40c5
--- /dev/null
@@ -0,0 +1,31 @@
+starter (0.3.42) unstable; urgency=low
+
+  * fix pwlock pkg name
+  * Git: pkgs/s/starter
+  * Tag: starter_0.3.42
+
+ -- Seungtaek Chung <seungtaek.chung@samsung.com>  Thu, 29 Dec 2011 10:26:08 +0900
+
+starter (0.3.41) unstable; urgency=low
+
+  * remove lock screen operation
+  * Git: pkgs/s/starter
+  * Tag: starter_0.3.41
+
+ -- Seungtaek Chung <seungtaek.chung@samsung.com>  Wed, 28 Dec 2011 17:52:53 +0900
+
+starter (0.3.40) unstable; urgency=low
+
+  * update pkgname to org.tizen
+  * Git: pkgs/s/starter
+  * Tag: starter_0.3.40
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com>  Fri, 23 Dec 2011 16:03:47 +0900
+
+starter (0.3.39) unstable; urgency=low
+
+  * Initial released
+  * Git: pkgs/s/starter
+  * Tag: starter_0.3.39
+
+ -- Seungtaek Chung <seungtaek.chung@samsung.com>  Wed, 07 Dec 2011 23:01:58 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..ae2c243
--- /dev/null
@@ -0,0 +1,19 @@
+Source: starter
+Section: devel
+Priority: extra
+Maintainer: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+Build-Depends: debhelper (>= 5), libappcore-efl-dev, libglib2.0-dev, libslp-tapi-dev, libslp-setting-dev, libheynoti-dev, libaul-1-dev, libx11-dev, libelm-dev, libefreet-dev, dlog-dev, libecore-dev, libsvi-dev, libslp-utilx-dev, libail-0-dev, libui-gadget-dev
+Standards-Version: 3.7.2
+
+Package: starter
+Section: admin
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: starter
+
+Package: starter-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: starter (unstripped)
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..861febf
--- /dev/null
@@ -0,0 +1,112 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /usr/share
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+       CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       cd $(CMAKE_BUILD_DIR) && $(MAKE)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       rm -rf $(CMAKE_BUILD_DIR)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=starter-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/starter.install.in b/debian/starter.install.in
new file mode 100755 (executable)
index 0000000..45ba987
--- /dev/null
@@ -0,0 +1,4 @@
+@PREFIX@/bin/*
+@PREFIX@/share/*
+@PREFIX@/lib/*
+/etc/init.d/*
diff --git a/debian/starter.postinst b/debian/starter.postinst
new file mode 100755 (executable)
index 0000000..54da911
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+vconftool set -t int "memory/startapps/sequence" 0 -i -u 5000 -g 5000
+
+vconftool set -t string db/lockscreen/pkgname "org.tizen.idle-lock" -u 5000 -g 5000
+
+vconftool -i set -t int memory/idle_lock/state "0" -u 5000 -g 5000
+
+ln -sf /etc/init.d/rd4starter /etc/rc.d/rc4.d/S81starter
+ln -sf /etc/init.d/rd3starter /etc/rc.d/rc3.d/S43starter
+
+sync
diff --git a/lock-mgr/CMakeLists.txt b/lock-mgr/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..081f2ac
--- /dev/null
@@ -0,0 +1,45 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(lock-daemon C)
+
+SET(PREFIX "/usr")
+SET(EXEC_PREFIX "${PREFIX}/bin")
+SET(LIBDIR "${PREFIX}/lib")
+SET(CONFDIR "/etc")
+SET(VERSION 0.1.0)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_lock_daemon REQUIRED
+       elementary
+       appcore-efl
+       heynoti
+       aul
+       vconf
+       ecore
+       evas
+       ecore-evas
+       eet
+       x11
+       dlog
+       ecore-x
+       utilX
+       ecore-input
+       glib-2.0
+       ui-gadget
+       bundle
+)
+FOREACH (flag ${pkgs_lock_daemon_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_DEFINITIONS(${EXTRA_CFLAGS})
+ADD_LIBRARY(${PROJECT_NAME} SHARED
+       src/lock-daemon.c
+       src/lockd-debug.c
+       src/lockd-process-mgr.c
+)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_lock_daemon_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
+
+# End of a file
diff --git a/lock-mgr/include/lock-daemon.h b/lock-mgr/include/lock-daemon.h
new file mode 100755 (executable)
index 0000000..d4589ca
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __LOCK_DAEMON_H__
+#define __LOCK_DAEMON_H__
+
+int start_lock_daemon();
+
+#endif                         /* __LOCK_DAEMON_H__ */
diff --git a/lock-mgr/include/lockd-debug.h b/lock-mgr/include/lockd-debug.h
new file mode 100755 (executable)
index 0000000..e22c86a
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __LOCKD_DEBUG_H__
+#define __LOCKD_DEBUG_H__
+
+#include <stdio.h>
+#include <dlog.h>
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+
+#define LOG_TAG "starter"
+
+#define ENABLE_LOG_SYSTEM
+
+void lockd_log_t(char *fmt, ...);
+
+#ifdef ENABLE_LOG_SYSTEM
+#define STARTER_ERR(fmt, arg...)  LOGE("["LOG_TAG"%s:%d:E] "fmt, __FILE__, __LINE__, ##arg)
+#define STARTER_DBG(fmt, arg...)  LOGD("["LOG_TAG"%s:%d:D] "fmt, __FILE__, __LINE__, ##arg)
+#else
+#define STARTER_ERR(fmt, arg...)
+#define STARTER_DBG(fmt, arg...)
+#endif
+
+#ifdef ENABLE_LOG_SYSTEM
+#define _ERR(fmt, arg...) do { STARTER_ERR(fmt, ##arg); lockd_log_t("["LOG_TAG":%d:E] "fmt, __LINE__, ##arg); } while (0)
+#define _DBG(fmt, arg...) do { STARTER_DBG(fmt, ##arg); lockd_log_t("["LOG_TAG":%d:D] "fmt, __LINE__, ##arg); } while (0)
+
+#define LOCKD_ERR(fmt, arg...) _ERR(fmt, ##arg)
+#define LOCKD_DBG(fmt, arg...) _DBG(fmt, ##arg)
+#else
+#define _ERR(...)
+#define _DBG(...)
+
+#define LOCKD_ERR(...)
+#define LOCKD_ERR(...)
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#endif                         /* __LOCKD_DEBUG_H__ */
diff --git a/lock-mgr/include/lockd-process-mgr.h b/lock-mgr/include/lockd-process-mgr.h
new file mode 100755 (executable)
index 0000000..a4becb3
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __LOCKD_PROCESS_MGR_H__
+#define __LOCKD_PROCESS_MGR_H__
+
+int lockd_process_mgr_start_lock(void *data, int (*dead_cb) (int, void *),
+                                int phone_lock_state);
+
+void lockd_process_mgr_restart_lock(int phone_lock_state);
+
+int lockd_process_mgr_start_phone_lock(void);
+
+void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid);
+
+int lockd_process_mgr_check_lock(int pid);
+
+#endif                         /* __LOCKD_PROCESS_MGR_H__ */
diff --git a/lock-mgr/src/lock-daemon.c b/lock-mgr/src/lock-daemon.c
new file mode 100755 (executable)
index 0000000..5dfefcf
--- /dev/null
@@ -0,0 +1,508 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <Elementary.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <glib.h>
+#include <poll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <errno.h>
+
+#include "lockd-debug.h"
+#include "lock-daemon.h"
+#include "lockd-process-mgr.h"
+
+static int phone_lock_pid;
+
+struct lockd_data {
+       int phone_lock_app_pid;
+       int phone_lock_state;
+};
+
+struct ucred {
+       pid_t pid;
+       uid_t uid;
+       gid_t gid;
+};
+
+#define VCONFKEY_PHONE_LOCK_VERIFICATION "memory/lockscreen/phone_lock_verification"
+#define PHLOCK_SOCK_PREFIX "/tmp/phlock"
+#define PHLOCK_SOCK_MAXBUFF 65535
+#define PHLOCK_APP_CMDLINE "/opt/apps/org.tizen.phone-lock/bin/phone-lock"
+
+static void lockd_launch_app_lockscreen(struct lockd_data *lockd);
+
+static void _lockd_notify_pm_state_cb(keynode_t * node, void *data)
+{
+       LOCKD_DBG("PM state Notification!!");
+
+       struct lockd_data *lockd = (struct lockd_data *)data;
+       int val = -1;
+
+       if (lockd == NULL) {
+               LOCKD_ERR("lockd is NULL");
+               return;
+       }
+
+       if (vconf_get_int(VCONFKEY_PM_STATE, &val) < 0) {
+               LOCKD_ERR("Cannot get VCONFKEY_PM_STATE");
+               return;
+       }
+
+       if (val == VCONFKEY_PM_STATE_LCDOFF) {
+               lockd_launch_app_lockscreen(lockd);
+       }
+}
+
+static void
+_lockd_notify_lock_state_cb(keynode_t * node, void *data)
+{
+       LOCKD_DBG("lock state changed!!");
+
+       struct lockd_data *lockd = (struct lockd_data *)data;
+       int val = -1;
+
+       if (lockd == NULL) {
+               LOCKD_ERR("lockd is NULL");
+               return;
+       }
+
+       if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
+               LOCKD_ERR("Cannot get VCONFKEY_IDLE_LOCK_STATE");
+               return;
+       }
+
+       if (val == VCONFKEY_IDLE_UNLOCK) {
+               LOCKD_DBG("unlocked..!!");
+       }
+}
+
+static void
+_lockd_notify_phone_lock_verification_cb(keynode_t * node, void *data)
+{
+       LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+       struct lockd_data *lockd = (struct lockd_data *)data;
+       int val = -1;
+
+       if (lockd == NULL) {
+               LOCKD_ERR("lockd is NULL");
+               return;
+       }
+
+       if (vconf_get_bool(VCONFKEY_PHONE_LOCK_VERIFICATION, &val) < 0) {
+               LOCKD_ERR("Cannot get VCONFKEY_PHONE_LOCK_VERIFICATION");
+               return;
+       }
+
+       if (val == TRUE) {
+               vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
+       }
+}
+
+static void lockd_launch_app_lockscreen(struct lockd_data *lockd)
+{
+       LOCKD_DBG("launch app lock screen");
+
+       int call_state = -1, bootlock_state = -1;
+
+       vconf_get_bool(VCONFKEY_SETAPPL_STATE_POWER_ON_LOCK_BOOL,
+                      &bootlock_state);
+
+       if (bootlock_state) {
+               lockd->phone_lock_state = 1;
+       } else {
+               lockd->phone_lock_state = 0;
+       }
+
+       vconf_get_int(VCONFKEY_CALL_STATE, &call_state);
+       if (call_state != VCONFKEY_CALL_OFF) {
+               LOCKD_DBG
+                   ("Current call state(%d) does not allow to launch lock screen.",
+                    call_state);
+               return;
+       }
+
+       if (lockd->phone_lock_state == 1) {
+               vconf_set_bool(VCONFKEY_PHONE_LOCK_VERIFICATION, FALSE);
+               /* Check phone lock application is already exit */
+               if (lockd_process_mgr_check_lock(lockd->phone_lock_app_pid) == TRUE) {
+                       LOCKD_DBG("phone lock App is already running.");
+                       return;
+               }
+               vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_LOCK);
+               lockd->phone_lock_app_pid =
+                   lockd_process_mgr_start_phone_lock();
+               phone_lock_pid = lockd->phone_lock_app_pid;
+               LOCKD_DBG("%s, %d, phone_lock_pid = %d", __func__, __LINE__,
+                         phone_lock_pid);
+       }
+}
+
+inline static void lockd_set_sock_option(int fd, int cli)
+{
+       int size;
+       struct timeval tv = { 1, 200 * 1000 };
+
+       size = PHLOCK_SOCK_MAXBUFF;
+       setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+       setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+       if (cli)
+               setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+}
+
+static int lockd_create_sock(void)
+{
+       struct sockaddr_un saddr;
+       int fd;
+
+       fd = socket(AF_UNIX, SOCK_STREAM, 0);
+       if (fd < 0) {
+               if (errno == EINVAL) {
+                       fd = socket(AF_UNIX, SOCK_STREAM, 0);
+                       if (fd < 0) {
+                               LOCKD_DBG
+                                   ("second chance - socket create error");
+                               return -1;
+                       }
+               } else {
+                       LOCKD_DBG("socket error");
+                       return -1;
+               }
+       }
+
+       bzero(&saddr, sizeof(saddr));
+       saddr.sun_family = AF_UNIX;
+
+       strncpy(saddr.sun_path, PHLOCK_SOCK_PREFIX, strlen(PHLOCK_SOCK_PREFIX));
+       saddr.sun_path[strlen(PHLOCK_SOCK_PREFIX)] = 0;
+
+       unlink(saddr.sun_path);
+
+       if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+               LOCKD_DBG("bind error");
+               return -1;
+       }
+
+       if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+               LOCKD_DBG("failed to change the socket permission");
+               return -1;
+       }
+
+       lockd_set_sock_option(fd, 0);
+
+       if (listen(fd, 10) == -1) {
+               LOCKD_DBG("listen error");
+               return -1;
+       }
+
+       return fd;
+}
+
+static gboolean lockd_glib_check(GSource * src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if ((tmp->revents & (POLLIN | POLLPRI)))
+                       return TRUE;
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return FALSE;
+}
+
+static char *lockd_read_cmdline_from_proc(int pid)
+{
+       int memsize = 32;
+       char path[32];
+       char *cmdline = NULL, *tempptr = NULL;
+       FILE *fp = NULL;
+
+       snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
+
+       fp = fopen(path, "r");
+       if (fp == NULL) {
+               LOCKD_DBG("Cannot open cmdline on pid[%d]", pid);
+               return NULL;
+       }
+
+       cmdline = malloc(32);
+       if (cmdline == NULL) {
+               LOCKD_DBG("%s", "Out of memory");
+               fclose(fp);
+               return NULL;
+       }
+
+       bzero(cmdline, memsize);
+       if (fgets(cmdline, 32, fp) == NULL) {
+               LOCKD_DBG("%s", "Cannot read cmdline");
+               free(cmdline);
+               fclose(fp);
+               return NULL;
+       }
+
+       while (cmdline[memsize - 2] != 0) {
+               cmdline[memsize - 1] = (char)fgetc(fp);
+               tempptr = realloc(cmdline, memsize + 32);
+               if (tempptr == NULL) {
+                       fclose(fp);
+                       LOCKD_DBG("%s", "Out of memory");
+                       return NULL;
+               }
+               cmdline = tempptr;
+               bzero(cmdline + memsize, 32);
+               fgets(cmdline + memsize, 32, fp);
+               memsize += 32;
+       }
+
+       if (fp != NULL)
+               fclose(fp);
+       return cmdline;
+}
+
+static int lockd_sock_handler(int fd)
+{
+       int cl;
+       int len;
+       int sun_size;
+       int clifd = -1;
+       char cmd[PHLOCK_SOCK_MAXBUFF];
+       char *cmdline = NULL;
+
+       struct ucred cr;
+       struct sockaddr_un lockd_addr;
+
+       cl = sizeof(cr);
+       sun_size = sizeof(struct sockaddr_un);
+
+       if ((clifd =
+            accept(fd, (struct sockaddr *)&lockd_addr,
+                   (socklen_t *) & sun_size)) == -1) {
+               if (errno != EINTR)
+                       LOCKD_DBG("accept error");
+               return -1;
+       }
+
+       if (getsockopt(clifd, SOL_SOCKET, SO_PEERCRED, &cr, (socklen_t *) & cl)
+           < 0) {
+               LOCKD_DBG("peer information error");
+               close(clifd);
+               return -1;
+       }
+       LOCKD_DBG("Peer's pid=%d, uid=%d, gid=%d\n", cr.pid, cr.uid, cr.gid);
+
+       memset(cmd, 0, PHLOCK_SOCK_MAXBUFF);
+
+       lockd_set_sock_option(clifd, 1);
+
+       len = recv(clifd, cmd, PHLOCK_SOCK_MAXBUFF, 0);
+
+       if (cmd == NULL) {
+               LOCKD_DBG("recv error, cmd is NULL");
+               close(clifd);
+               return -1;
+       }
+
+       if (len != strlen(cmd)) {
+               LOCKD_DBG("recv error %d %d", len, strlen(cmd));
+               close(clifd);
+               return -1;
+       }
+
+       LOCKD_DBG("cmd %s", cmd);
+
+       cmdline = lockd_read_cmdline_from_proc(cr.pid);
+       if (cmdline == NULL) {
+               LOCKD_DBG("Error on opening /proc/%d/cmdline", cr.pid);
+               return -1;
+       }
+
+       LOCKD_DBG("/proc/%d/cmdline : %s", cr.pid, cmdline);
+
+       if ((!strncmp(cmdline, PHLOCK_APP_CMDLINE, strlen(cmdline)))
+           && (phone_lock_pid == cr.pid)) {
+               LOCKD_DBG("pid [%d] %s is verified, unlock..!!\n", cr.pid,
+                         cmdline);
+               lockd_process_mgr_terminate_phone_lock(phone_lock_pid);
+               phone_lock_pid = 0;
+               vconf_set_bool(VCONFKEY_PHONE_LOCK_VERIFICATION, TRUE);
+       }
+
+       return 0;
+}
+
+static gboolean lockd_glib_handler(gpointer data)
+{
+       GPollFD *gpollfd = (GPollFD *) data;
+       if (lockd_sock_handler(gpollfd->fd) < 0) {
+               LOCKD_DBG("lockd_sock_handler is failed..!!");
+       }
+       return TRUE;
+}
+
+static gboolean lockd_glib_dispatch(GSource * src, GSourceFunc callback,
+                                   gpointer data)
+{
+       callback(data);
+       return TRUE;
+}
+
+static gboolean lockd_glib_prepare(GSource * src, gint * timeout)
+{
+       return FALSE;
+}
+
+static GSourceFuncs funcs = {
+       .prepare = lockd_glib_prepare,
+       .check = lockd_glib_check,
+       .dispatch = lockd_glib_dispatch,
+       .finalize = NULL
+};
+
+static int lockd_init_sock(void)
+{
+       int fd;
+       GPollFD *gpollfd;
+       GSource *src;
+       int ret;
+
+       fd = lockd_create_sock();
+       if (fd < 0) {
+               LOCKD_DBG("lock daemon create sock failed..!!");
+       }
+
+       src = g_source_new(&funcs, sizeof(GSource));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       g_source_add_poll(src, gpollfd);
+       g_source_set_callback(src, (GSourceFunc) lockd_glib_handler,
+                             (gpointer) gpollfd, NULL);
+       g_source_set_priority(src, G_PRIORITY_LOW);
+
+       ret = g_source_attach(src, NULL);
+       if (ret == 0)
+               return -1;
+
+       g_source_unref(src);
+
+       return 0;
+}
+
+static void lockd_init_vconf(struct lockd_data *lockd)
+{
+       int val = -1;
+
+       if (vconf_notify_key_changed
+           (VCONFKEY_PM_STATE, _lockd_notify_pm_state_cb, lockd) != 0) {
+               LOCKD_ERR("Fail vconf_notify_key_changed : VCONFKEY_PM_STATE");
+       }
+
+       if (vconf_notify_key_changed
+           (VCONFKEY_PHONE_LOCK_VERIFICATION,
+            _lockd_notify_phone_lock_verification_cb, lockd) != 0) {
+               if (vconf_get_bool(VCONFKEY_PHONE_LOCK_VERIFICATION, &val) < 0) {
+                       LOCKD_ERR
+                           ("Cannot get VCONFKEY_PHONE_LOCK_VERIFICATION");
+                       vconf_set_bool(VCONFKEY_PHONE_LOCK_VERIFICATION, 0);
+                       if (vconf_notify_key_changed
+                           (VCONFKEY_PHONE_LOCK_VERIFICATION,
+                            _lockd_notify_phone_lock_verification_cb,
+                            lockd) != 0) {
+                               LOCKD_ERR
+                                   ("Fail vconf_notify_key_changed : VCONFKEY_PHONE_LOCK_VERIFICATION");
+                       }
+               } else {
+                       LOCKD_ERR
+                           ("Fail vconf_notify_key_changed : VCONFKEY_PHONE_LOCK_VERIFICATION");
+               }
+       }
+
+       if (vconf_notify_key_changed
+           (VCONFKEY_IDLE_LOCK_STATE,
+            _lockd_notify_lock_state_cb,
+            lockd) != 0) {
+               LOCKD_ERR
+                   ("[Error] vconf notify : lock state");
+       }
+       
+}
+
+static void lockd_start_lock_daemon(void *data)
+{
+       struct lockd_data *lockd = NULL;
+       int r = 0;
+
+       lockd = (struct lockd_data *)data;
+
+       if (!lockd) {
+               return;
+       }
+
+       LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+       lockd_init_vconf(lockd);
+
+       r = lockd_init_sock();
+       if (r < 0) {
+               LOCKD_DBG("lockd init socket failed: %d", r);
+       }
+
+       LOCKD_DBG("%s, %d", __func__, __LINE__);
+}
+
+int start_lock_daemon()
+{
+       struct lockd_data *lockd = NULL;
+       int val = -1;
+
+       LOCKD_DBG("%s, %d", __func__, __LINE__);
+
+       lockd = (struct lockd_data *)malloc(sizeof(struct lockd_data));
+       memset(lockd, 0x0, sizeof(struct lockd_data));
+       lockd_start_lock_daemon(lockd);
+
+       vconf_get_bool(VCONFKEY_SETAPPL_STATE_POWER_ON_LOCK_BOOL, &val);
+       LOCKD_DBG("%s, %d, val = %d", __func__, __LINE__, val);
+
+       if (val) {
+               lockd_launch_app_lockscreen(lockd);
+       }
+
+       return 0;
+}
diff --git a/lock-mgr/src/lockd-debug.c b/lock-mgr/src/lockd-debug.c
new file mode 100755 (executable)
index 0000000..ea43831
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include "lockd-debug.h"
+
+#define LINEMAX 256
+#define MAXFILELEN     1048576
+#define LOGFILE "/tmp/starter.log"
+
+void lockd_log_t(char *fmt, ...)
+{
+       va_list ap;
+       FILE *fd = 0;
+       char buf[LINEMAX] = { 0, };
+       char debugString[LINEMAX] = { 0, };
+
+       va_start(ap, fmt);
+       vsnprintf(buf, sizeof(buf), fmt, ap);
+       va_end(ap);
+       int fileLen = 0;
+       struct tm local_t;
+       time_t current_time = 0;
+       bzero((char *)&debugString, LINEMAX);
+       time(&current_time);
+       gmtime_r(&current_time, &local_t);
+       int len = snprintf(debugString, sizeof(debugString),
+                          "[%d-%02d-%02d, %02d:%02d:%02d]: ",
+                          local_t.tm_year + 1900, local_t.tm_mon + 1,
+                          local_t.tm_mday, local_t.tm_hour, local_t.tm_min,
+                          local_t.tm_sec);
+       if (len == -1) {
+               return;
+       } else {
+               debugString[len] = '\0';
+       }
+       len = g_strlcat(debugString, buf, LINEMAX);
+       if (len >= LINEMAX) {
+               return;
+       } else {
+               debugString[len] = '\n';
+       }
+       if ((fd = fopen(LOGFILE, "at+")) == NULL) {
+               LOCKD_DBG("File fopen fail for writing Pwlock information");
+       } else {
+               int pid = -1;
+               if (fwrite(debugString, strlen(debugString), 1, fd) < 1) {
+                       LOCKD_DBG
+                           ("File fwrite fail for writing Pwlock information");
+                       fclose(fd);
+                       if ((pid = fork()) < 0) {
+                       } else if (pid == 0) {
+                               execl("/bin/rm", "rm", "-f", LOGFILE,
+                                     (char *)0);
+                       }
+               } else {
+                       fseek(fd, 0l, SEEK_END);
+                       fileLen = ftell(fd);
+                       if (fileLen > MAXFILELEN) {
+                               fclose(fd);
+                               if ((pid = fork()) < 0) {
+                                       return;
+                               } else if (pid == 0) {
+                                       execl("/bin/rm", "rm", "-f", LOGFILE,
+                                             (char *)0);
+                               }
+                       } else
+                               fclose(fd);
+               }
+       }
+}
diff --git a/lock-mgr/src/lockd-process-mgr.c b/lock-mgr/src/lockd-process-mgr.c
new file mode 100755 (executable)
index 0000000..1d5eaf6
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ *  starter
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <aul.h>
+
+#include "lockd-debug.h"
+#include "lockd-process-mgr.h"
+
+#define LOCKD_PHONE_LOCK_PKG_NAME "org.tizen.phone-lock"
+
+int lockd_process_mgr_start_phone_lock(void)
+{
+       int pid = 0;
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       bundle_add(b, "pwlock_type", "running_lock");
+       bundle_add(b, "window_type", "alpha");
+
+       pid = aul_launch_app(LOCKD_PHONE_LOCK_PKG_NAME, b);
+       LOCKD_DBG("aul_launch_app(%s, b), pid = %d", LOCKD_PHONE_LOCK_PKG_NAME,
+                 pid);
+       if (b)
+               bundle_free(b);
+
+       return pid;
+}
+
+void lockd_process_mgr_terminate_phone_lock(int phone_lock_pid)
+{
+       LOCKD_DBG("Terminate Phone Lock(pid : %d)", phone_lock_pid);
+       aul_terminate_pid(phone_lock_pid);
+}
+
+int lockd_process_mgr_check_lock(int pid)
+{
+       char buf[128];
+       LOCKD_DBG("%s, %d", __func__, __LINE__);
+       if (aul_app_get_pkgname_bypid(pid, buf, sizeof(buf)) < 0) {
+               LOCKD_DBG("no such pkg by pid %d\n", pid);
+       } else {
+               LOCKD_DBG("lock screen pkgname = %s, pid = %d\n", buf, pid);
+               if (aul_app_is_running(buf) == TRUE) {
+                       LOCKD_DBG("%s [pid = %d] is running\n", buf, pid);
+                       return TRUE;
+               } else {
+                       LOCKD_DBG("[pid = %d] is exist but %s is not running\n",
+                                 pid, buf);
+               }
+       }
+       return FALSE;
+}
diff --git a/packaging/starter.spec b/packaging/starter.spec
new file mode 100644 (file)
index 0000000..e9c2f3f
--- /dev/null
@@ -0,0 +1,49 @@
+Name:       starter
+Summary:    starter
+Version:    0.3
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    TO_BE/FILLED_IN
+Source0:    starter-%{version}.tar.gz
+Requires(post): /usr/bin/vconftool
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(tapi-priv)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(heynoti)
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(x11)
+
+%description
+Description: Starter
+
+
+%prep
+%setup -q
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+%build
+
+make %{?jobs:-j%jobs}
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post
+vconftool set -t int "memory/startapps/sequence" 0 -i -u 5000 -g 5000
+
+ln -sf /etc/init.d/rd4starter /etc/rc.d/rc4.d/S81starter
+ln -sf /etc/init.d/rd3starter /etc/rc.d/rc3.d/S43starter
+
+sync
+
+%files
+%defattr(-,root,root,-)
+%{_sysconfdir}/init.d/rd4starter
+%{_sysconfdir}/init.d/rd3starter
+%{_datadir}/applications/starter.desktop
+%{_bindir}/starter
+
diff --git a/rd3starter b/rd3starter
new file mode 100755 (executable)
index 0000000..745eafa
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# commented and this was moved to isf-panel-efl code
+#while [ ! -f /tmp/.wm_ready ];
+#do
+#      sleep 0.1
+#done
+
+/usr/bin/starter &
+
diff --git a/rd4starter b/rd4starter
new file mode 100755 (executable)
index 0000000..60f35e6
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+/usr/bin/starter &
+
diff --git a/starter b/starter
new file mode 100755 (executable)
index 0000000..b5c0fa6
--- /dev/null
+++ b/starter
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+CURRENT_RUNLEVEL=`basename $PWD`
+# CURRENT_RUNLEVEL could be "rc3.d" or "rc4.d"
+
+if [ x"$CURRENT_RUNLEVEL" == x"rc3.d" ]; then
+       while [ ! -f /tmp/.wm_ready ];
+       do
+               sleep 0.1
+       done
+fi
+
+/usr/bin/starter &
+
diff --git a/starter.desktop.in b/starter.desktop.in
new file mode 100755 (executable)
index 0000000..593ecc3
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=@PROJECT_NAME@
+Exec=@BINDIR@/@PROJECT_NAME@
+Icon=elementary
+Terminal=false
+Type=Application
+Categories=Application;Utility;
+
+X-SLP-BaseLayoutWidth=720
+X-SLP-BaseLayoutHeight=1280