Tizen 2.0 Release tizen_2.0 accepted/tizen_2.0/20130216.145401 submit/tizen_2.0/20130215.191942 submit/tizen_2.0/20130216.145409 submit/tizen_2.0/20130216.152107
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:36:08 +0000 (00:36 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:36:08 +0000 (00:36 +0900)
74 files changed:
AUTHORS [new file with mode: 0755]
CMakeLists.txt [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0755]
NOTICE [new file with mode: 0755]
all_log_dump/CMakeLists.txt [new file with mode: 0755]
all_log_dump/all_log_dump.sh [new file with mode: 0755]
crash-popup/CMakeLists.txt [new file with mode: 0644]
crash-popup/popup_po/CMakeLists.txt [new file with mode: 0644]
crash-popup/popup_po/ar.po [new file with mode: 0755]
crash-popup/popup_po/az.po [new file with mode: 0755]
crash-popup/popup_po/bg.po [new file with mode: 0755]
crash-popup/popup_po/ca.po [new file with mode: 0755]
crash-popup/popup_po/cs.po [new file with mode: 0755]
crash-popup/popup_po/da.po [new file with mode: 0755]
crash-popup/popup_po/de_DE.po [new file with mode: 0755]
crash-popup/popup_po/el_GR.po [new file with mode: 0755]
crash-popup/popup_po/en.po [new file with mode: 0755]
crash-popup/popup_po/en_PH.po [new file with mode: 0755]
crash-popup/popup_po/en_US.po [new file with mode: 0755]
crash-popup/popup_po/es_ES.po [new file with mode: 0755]
crash-popup/popup_po/es_US.po [new file with mode: 0755]
crash-popup/popup_po/et.po [new file with mode: 0755]
crash-popup/popup_po/eu.po [new file with mode: 0755]
crash-popup/popup_po/fi.po [new file with mode: 0755]
crash-popup/popup_po/fr_CA.po [new file with mode: 0755]
crash-popup/popup_po/fr_FR.po [new file with mode: 0755]
crash-popup/popup_po/ga.po [new file with mode: 0755]
crash-popup/popup_po/gl.po [new file with mode: 0755]
crash-popup/popup_po/hi.po [new file with mode: 0755]
crash-popup/popup_po/hr.po [new file with mode: 0755]
crash-popup/popup_po/hu.po [new file with mode: 0755]
crash-popup/popup_po/hy.po [new file with mode: 0755]
crash-popup/popup_po/is.po [new file with mode: 0755]
crash-popup/popup_po/it_IT.po [new file with mode: 0755]
crash-popup/popup_po/ja_JP.po [new file with mode: 0755]
crash-popup/popup_po/ka.po [new file with mode: 0755]
crash-popup/popup_po/kk.po [new file with mode: 0755]
crash-popup/popup_po/ko_KR.po [new file with mode: 0755]
crash-popup/popup_po/lt.po [new file with mode: 0755]
crash-popup/popup_po/lv.po [new file with mode: 0755]
crash-popup/popup_po/mk.po [new file with mode: 0755]
crash-popup/popup_po/nb.po [new file with mode: 0755]
crash-popup/popup_po/nl_NL.po [new file with mode: 0755]
crash-popup/popup_po/pl.po [new file with mode: 0755]
crash-popup/popup_po/pt_BR.po [new file with mode: 0755]
crash-popup/popup_po/pt_PT.po [new file with mode: 0755]
crash-popup/popup_po/ro.po [new file with mode: 0755]
crash-popup/popup_po/ru_RU.po [new file with mode: 0755]
crash-popup/popup_po/sk.po [new file with mode: 0755]
crash-popup/popup_po/sl.po [new file with mode: 0755]
crash-popup/popup_po/sr.po [new file with mode: 0755]
crash-popup/popup_po/sv.po [new file with mode: 0755]
crash-popup/popup_po/tr_TR.po [new file with mode: 0755]
crash-popup/popup_po/uk.po [new file with mode: 0755]
crash-popup/popup_po/uz.po [new file with mode: 0755]
crash-popup/popup_po/zh_CN.po [new file with mode: 0755]
crash-popup/popup_po/zh_HK.po [new file with mode: 0755]
crash-popup/popup_po/zh_SG.po [new file with mode: 0755]
crash-popup/popup_po/zh_TW.po [new file with mode: 0755]
crash-popup/src/crash-popup.c [new file with mode: 0644]
crash-popup/src/crash-popup.h [new file with mode: 0644]
crash-popup/src/util_log.h [new file with mode: 0644]
crash-worker/CMakeLists.txt [new file with mode: 0644]
crash-worker/crash-worker.c [new file with mode: 0644]
crash-worker/crash-worker.h [new file with mode: 0644]
crash-worker/util.c [new file with mode: 0644]
crash-worker/util.h [new file with mode: 0644]
crash-worker/util_log.h [new file with mode: 0644]
data/org.tizen.crash-popup.png [new file with mode: 0755]
data/org.tizen.crash-popup.xml [new file with mode: 0644]
edcs/crash-popup.edc [new file with mode: 0644]
packaging/crash-worker-sdk.manifest [new file with mode: 0644]
packaging/crash-worker-sdk.spec [new file with mode: 0644]
packaging/org.tizen.crash-popup.manifest [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100755 (executable)
index 0000000..2190840
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+juho son <juho80.son at samsung dot com>
+Suchang Woo <suchang.woo at samsung dot com>
+kyungmin Park <kyungmin Park at samsung dot com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..eb3278e
--- /dev/null
@@ -0,0 +1,18 @@
+####### Crash-worker #############
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(crash-worker C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+
+# Sub modules
+ADD_SUBDIRECTORY(crash-worker)
+ADD_SUBDIRECTORY(crash-popup)
+ADD_SUBDIRECTORY(all_log_dump)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 DESTINATION /usr/share/license RENAME crash-worker)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.APLv2 DESTINATION /usr/share/license RENAME crash-popup)
+############## END ##############
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755 (executable)
index 0000000..8aa906c
--- /dev/null
@@ -0,0 +1,205 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+
+
+
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..0e0f016
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/all_log_dump/CMakeLists.txt b/all_log_dump/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..dd68dd6
--- /dev/null
@@ -0,0 +1,2 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/all_log_dump/all_log_dump.sh DESTINATION /usr/bin)
diff --git a/all_log_dump/all_log_dump.sh b/all_log_dump/all_log_dump.sh
new file mode 100755 (executable)
index 0000000..a98487d
--- /dev/null
@@ -0,0 +1,332 @@
+#!/bin/sh
+
+PARAM1=$1
+PARAM2=$2
+PARAM3=$3
+
+#--------------------------------------
+#    Setup log dump path
+#--------------------------------------
+TIMESTAMP=`date +%m%d_%H%M`
+TIMESTAMP_DFMS=`date +%Y%m%d%H%M%S`
+LOG_SRC_DIR=/opt/var/log
+LOG_DST_DIR_BASE=/opt/usr/media/SLP_debug
+if [ "$PARAM1" = "dfms" ]; then
+       LOG_DIR=factory_${PARAM2}_${PARAM3}_dumpstate${TIMESTAMP_DFMS}
+else
+       LOG_DIR=log_dump_${TIMESTAMP}
+fi
+LOG_DST_DIR=${LOG_DST_DIR_BASE}/${LOG_DIR}
+MOD_LOG_DIR=${LOG_DST_DIR}/module_log
+CP_LOG_DIR=${LOG_DST_DIR}/modem_log
+SCAN_IGNORE=${LOG_DST_DIR_BASE}/.scan_ignore
+mkdir -p ${LOG_DST_DIR_BASE}
+chown app:app ${LOG_DST_DIR_BASE}
+if [ ! -e ${SCAN_IGNORE} ]; then
+    touch ${SCAN_IGNORE}
+fi
+#--------------------------------------
+#    LCD on off control
+#--------------------------------------
+HW_NAME=`cat /proc/cpuinfo | grep Hardware | awk -F ':' '{print $2}' | tr -d ' '`
+if [ "${HW_NAME}" = "U1SLP" ] || [ "${HW_NAME}" = "U1HD" || [ "${HW_NAME}" = "TRATS" ]; then
+       LCD_BLANK=/sys/class/graphics/fb3/blank
+else
+       LCD_BLANK=/sys/class/graphics/fb0/blank
+fi
+
+lcd_on() {
+       echo 0 > ${LCD_BLANK}
+}
+
+lcd_off() {
+       echo 4 > ${LCD_BLANK}
+}
+
+lcd_blank1() {
+       lcd_on
+       usleep 200
+       lcd_off
+       usleep 200
+}
+
+lcd_blank() {
+       count=$1
+       while [ ${count} -gt 0 ]
+       do
+               lcd_blank1
+               count=`expr ${count} - 1`
+       done
+}
+
+if [ "$PARAM1" = "hardkey" ]; then
+       lcd_blank 3
+       lcd_on
+       # enable sdb
+       /usr/bin/set_usb_debug.sh --set
+       # change atd to console mode
+       pkill -SIGUSR1 atd-server
+else
+       if [ "$PARAM1" = "z" ]; then
+               LOG_ZIP_DST_FILE_NAME=$2
+       fi
+fi
+
+
+#--------------------------------------
+#    common logs - /opt/var/log
+#--------------------------------------
+COMMMON_LOG_DIR=${LOG_DST_DIR}/var_log
+mkdir -p ${COMMMON_LOG_DIR}
+cp -fr ${LOG_SRC_DIR}/* ${COMMMON_LOG_DIR}
+
+
+dlogutil -d -v time -f ${LOG_DST_DIR}/dlog_dump.log
+ps -aux > ${LOG_DST_DIR}/ps.log
+memps -a > ${LOG_DST_DIR}/memps.log
+top -bc -n 1 > ${LOG_DST_DIR}/top.log
+
+
+#--------------------------------------
+#   modem
+#--------------------------------------
+mkdir -p ${CP_LOG_DIR}
+mv -f /opt/etc/modem/err/*  ${CP_LOG_DIR}
+
+
+# call each module's log dump script
+
+#--------------------------------------
+#    bluetooth
+#--------------------------------------
+BT_DEBUG=${MOD_LOG_DIR}/bluetooth
+mkdir -p ${BT_DEBUG}
+#cp -rf /var/lib/bluetooth/* ${BT_DEBUG}
+tar -cvf ${BT_DEBUG}/bt.log.tar /var/lib/bluetooth
+
+#--------------------------------------
+#    contacts-svc
+#--------------------------------------
+CONTACT_SVC_DEBUG=${MOD_LOG_DIR}/contacts-svc
+mkdir -p ${CONTACT_SVC_DEBUG}
+cp /opt/dbspace/.contacts-svc.db ${CONTACT_SVC_DEBUG}
+
+
+#--------------------------------------
+#    eas
+#--------------------------------------
+EAS_DEBUG=${MOD_LOG_DIR}/eas
+mkdir -p ${EAS_DEBUG}
+cp /opt/usr/dbspace/.assync* ${EAS_DEBUG}
+cp /opt/usr/dbspace/.eas-common* ${EAS_DEBUG}
+cp -fa /opt/usr/data/eas-engine ${EAS_DEBUG}
+
+
+#--------------------------------------
+#    ims
+#--------------------------------------
+IMS_DEBUG=${MOD_LOG_DIR}/ims
+mkdir -p ${IMS_DEBUG}
+cp /opt/apps/com.samsung.rcs-im/data/db/.rcs-im.db ${IMS_DEBUG}
+cp /opt/share/ims/* ${IMS_DEBUG}
+
+
+
+#--------------------------------------
+#    kap
+#--------------------------------------
+KAP_DEBUG=${MOD_LOG_DIR}/kap
+mkdir -p ${KAP_DEBUG}
+vconftool get -r db/ > ${KAP_DEBUG}/vconf_db.log
+vconftool get -r memory/ > ${KAP_DEBUG}/vconf_memory.log
+
+
+
+#--------------------------------------
+#    kies-via-wifi
+#--------------------------------------
+KW_DEBUG=${MOD_LOG_DIR}/kies_via_wifi
+mkdir -p ${KW_DEBUG}
+cp -f /opt/dbspace/.kies_device.db* ${KW_DEBUG}
+
+
+#--------------------------------------
+#    mobex-for-kies
+#--------------------------------------
+TT_DEBUG=${MOD_LOG_DIR}/mobex-for-kies
+mkdir -p ${TT_DEBUG}
+cp /tmp/hostapd.log ${TT_DEBUG}
+cp -rf /opt/dbspace/.kiessyncagent.db ${TT_DEBUG}
+cp -rf /opt/data/mobex/mobex_sync_id ${TT_DEBUG}
+cp -rf /opt/data/sync-agent-framework/db/.pc_sync_* ${TT_DEBUG}
+
+vconftool get -r db/ > ${TT_DEBUG}/vconf_db.log
+vconftool get -r memory/ > ${TT_DEBUG}/vconf_memory.log
+
+
+#--------------------------------------
+#   vt
+#--------------------------------------
+VT_DEBUG=${MOD_LOG_DIR}/vt
+mkdir -p ${VT_DEBUG}
+cp -rf /opt/etc/vt_debug/  ${VT_DEBUG}
+
+
+#--------------------------------------
+#   nfc
+#--------------------------------------
+NFC_DEBUG=${MOD_LOG_DIR}/nfc
+mkdir -p ${NFC_DEBUG}
+cp -rf /opt/etc/nfc_debug/  ${NFC_DEBUG}
+cp -rf /opt/data/nfc-manager-daemon/message/  ${NFC_DEBUG}
+
+
+#--------------------------------------
+#   oma-ds
+#--------------------------------------
+OMA_DEBUG=${MOD_LOG_DIR}/oma-ds
+mkdir -p ${OMA_DEBUG}
+cp -rf /opt/dbspace/.omasyncagent.db* ${OMA_DEBUG}
+
+vconftool get -r db/ > ${OMA_DEBUG}/vconf_db.log
+vconftool get -r memory/ > ${OMA_DEBUG}/vconf_memory.log
+
+
+#--------------------------------------
+#   tethering
+#--------------------------------------
+TETH_DEBUG=${MOD_LOG_DIR}/tethering
+mkdir -p ${TETH_DEBUG}
+cp /tmp/hostapd.log ${TETH_DEBUG}
+cp -rf /tmp/dnsmasq.conf /opt/var/lib/misc/* ${TETH_DEBUG}
+
+vconftool get db/mobile_hotspot > ${TETH_DEBUG}/vconf_db.log
+vconftool get memory/mobile_hotspot > ${TETH_DEBUG}/vconf_memory.log
+iptables -t nat -L -vv > ${TETH_DEBUG}/iptables_nat.log
+iptables -L -vv > ${TETH_DEBUG}/iptables_filter.log
+
+
+#--------------------------------------
+#   winsys
+#--------------------------------------
+export DISPLAY=:0.0
+WINSYS_DEBUG=${MOD_LOG_DIR}/winsys
+mkdir -p ${WINSYS_DEBUG}
+xinfo -p 2> ${WINSYS_DEBUG}/ping.log
+xinfo -xwd_topvwins ${WINSYS_DEBUG}
+e_comp_util -l DUMP_INFO -f ${WINSYS_DEBUG}/e_comp.log
+border_win_info -p ALL -f ${WINSYS_DEBUG}/e_illume2.log
+cp -af /opt/var/log/keygrab_status.txt ${WINSYS_DEBUG}
+screenshot bmp ${WINSYS_DEBUG}/slp_screenshot.bmp
+xinfo -topvwins 2> ${WINSYS_DEBUG}/xinfo_topvwins.txt
+
+xberc clist > ${WINSYS_DEBUG}/clist.log
+
+xberc drmmode_dump > ${WINSYS_DEBUG}/drmmode_dump.log
+
+find /var/log/ -name "*Xorg*" -exec cp {} ${WINSYS_DEBUG}/ \;
+
+
+#--------------------------------------
+#   web-apps
+#--------------------------------------
+WEBAPP_DEBUG=${MOD_LOG_DIR}/webapp
+mkdir -p ${WEBAPP_DEBUG}
+
+_app_dir_prefix=/opt/apps
+_log_file=${WEBAPP_DEBUG}/web-apps.log
+
+get_widget_list() {
+        _widget_list=`sqlite3 /opt/dbspace/.wrt.db "select pkgname from WidgetInfo;"`
+        return _widget_list
+}
+
+tar_widget() {
+ _tar_pkg=$1
+ tar zcvf ${WEBAPP_DEBUG}/$_tar_pkg.tgz $_app_dir_prefix/$_tar_pkg >> $_log_file
+}
+
+check_widget_running_and_tar() {
+ _current_widget=$1
+ is_running=`aul_test is_run $_current_widget | grep "is running"`
+ if [ -n "$is_running" ]; then
+  echo "$_current_widget widget running" >> $_log_file
+  tar_widget $_current_widget
+ else
+  echo "$_current_widget widget not running" >> $_log_file
+ fi
+}
+
+tar_running_widgets() {
+ _widget_list=`sqlite3 /opt/dbspace/.wrt.db "select pkgname from WidgetInfo;"`
+ for _widget_pkg_name in $_widget_list
+ do
+  check_widget_running_and_tar $_widget_pkg_name
+ done
+}
+
+get_logs() {
+ echo "wrt-launcher -l" >> $_log_file
+ wrt-launcher -l >> $_log_file
+ echo "====================================" >> $_log_file
+}
+
+get_logs
+tar_running_widgets
+
+#--------------------------------------
+#   ChatON
+#--------------------------------------
+CHATON_DEBUG=${MOD_LOG_DIR}/chaton
+mkdir -p ${CHATON_DEBUG}
+cp -rf /opt/apps/xnq5eh9vop/shared/data/debug/  ${CHATON_DEBUG}
+cp -rf /opt/apps/xnq5eh9vop/shared/data/ssm.db  ${CHATON_DEBUG}
+
+#--------------------------------------
+#   power-manager
+#--------------------------------------
+pmctrl log
+PM_DEBUG=${MOD_LOG_DIR}/power-manager
+mkdir -p ${PM_DEBUG}
+cp -rf /opt/var/log/pm_state.log  ${PM_DEBUG}
+
+#=====================================
+# ap log dump copy
+#=====================================
+AP_LOG_DIR=${LOG_DST_DIR}/ap_log
+mkdir -p ${AP_LOG_DIR}
+cp -rf /opt/usr/share/crash/core/* ${AP_LOG_DIR}
+cp -rf /opt/usr/share/crash/dump/* ${AP_LOG_DIR}
+rm -rf /opt/usr/share/crash/core/*
+rm -rf /opt/usr/share/crash/dump/*
+rm -rf /opt/usr/share/crash/ticket/*
+
+#======================================
+#   log dump done
+#======================================
+# change owner so that dump can by read by PC via MTP
+cd /opt/usr/media
+chown app:app -R ${LOG_DST_DIR_BASE}
+chmod 777 -R ${LOG_DST_DIR_BASE}
+
+if [ "${PARAM1}" = "z" ]; then
+       tar zcf ${LOG_ZIP_DST_FILE_NAME} -C ${LOG_DST_DIR_BASE} ${LOG_DIR}
+       chown app:app ${LOG_ZIP_DST_FILE_NAME}
+       rm -rf ${LOG_DST_DIR}
+       echo tar zcf ${LOG_ZIP_DST_FILE_NAME} -C ${LOG_DST_DIR_BASE} ${LOG_DIR}
+       echo rm -rf ${LOG_DST_DIR}
+fi
+
+if [ "${PARAM1}" = "hardkey" ]; then
+
+if [ "${HW_NAME}" = "U1SLP" ] || [ "${HW_NAME}" = "U1HD" || [ "${HW_NAME}" = "TRATS" ]; then
+       echo AP > /sys/devices/platform/uart-select/path
+else
+       echo AP > /sys/devices/virtual/sec/switch/uart_sel
+fi
+
+lcd_blank 3
+lcd_on
+fi
+
+
diff --git a/crash-popup/CMakeLists.txt b/crash-popup/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d4d43a9
--- /dev/null
@@ -0,0 +1,98 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(crash-popup C)
+
+SET(SRCS
+       src/crash-popup.c
+)
+
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(EXENAME "crash-popup")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/apps/${PKGNAME}/bin")
+SET(RESDIR "${PREFIX}/apps/${PKGNAME}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(LOCALEDIR "${RESDIR}/locale")
+SET(ICONDIR "${PREFIX}/share/icons/default/small")
+SET(IMAGEDIR "${RESDIR}/images/${PACKAGE}")
+SET(EDJDIR "${RESDIR}/edje")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       appcore-efl
+       elementary
+       ecore-file
+       ecore-input
+       ecore-x
+       ecore
+       evas
+       edje
+       vconf
+       utilX
+       ecore-imf
+       appcore-common
+       ecore-imf
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+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("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
+ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
+#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+# install edj
+ADD_CUSTOM_TARGET(crash-popup.edj
+       COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/../images
+               ${CMAKE_SOURCE_DIR}/edcs/crash-popup.edc ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/crash-popup.edj
+               DEPENDS ${CMAKE_SOURCE_DIR}/edcs/crash-popup.edc
+               )
+ADD_DEPENDENCIES(${PROJECT_NAME} crash-popup.edj)
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/crash-popup.edj DESTINATION ${EDJDIR})
+
+# install images
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/images/public/ DESTINATION ${IMAGEDIR} FILES_MATCHING PATTERN "*.png")
+
+INSTALL(TARGETS ${EXENAME} DESTINATION ${BINDIR})
+
+# install xml file & icon
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PKGNAME}.xml DESTINATION ${PREFIX}/share/packages)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PKGNAME}.png DESTINATION ${ICONDIR})
+
+# i18n
+ADD_SUBDIRECTORY(popup_po)
+
diff --git a/crash-popup/popup_po/CMakeLists.txt b/crash-popup/popup_po/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3573506
--- /dev/null
@@ -0,0 +1,24 @@
+# for i18n
+
+SET(POFILES ar.po el_GR.po es_ES.po fi.po gl.po hy.po ka.po lv.po pl.po ru_RU.po sv.po zh_CN.po az.po cs.po en_PH.po es_US.po fr_CA.po hi.po is.po kk.po mk.po pt_BR.po sk.po tr_TR.po zh_HK.po bg.po da.po en.po et.po fr_FR.po hr.po it_IT.po ko_KR.po nb.po pt_PT.po sl.po uk.po zh_SG.po ca.po de_DE.po en_US.po eu.po ga.po hu.po ja_JP.po lt.po nl_NL.po ro.po sr.po uz.po zh_TW.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+       SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+       MESSAGE("PO: ${pofile}")
+       GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+       GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+       SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+       ADD_CUSTOM_COMMAND(
+                       OUTPUT ${moFile}
+                       COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+                       DEPENDS ${absPofile}
+       )
+       INSTALL(FILES ${moFile}
+                       DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+       SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(popup_po ALL DEPENDS ${moFiles})
diff --git a/crash-popup/popup_po/ar.po b/crash-popup/popup_po/ar.po
new file mode 100755 (executable)
index 0000000..ffb8821
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "اغلاق"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "تم إغلاق %s بشكل مفاجئ"
+
diff --git a/crash-popup/popup_po/az.po b/crash-popup/popup_po/az.po
new file mode 100755 (executable)
index 0000000..262033c
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Bağla"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s gözlənilməz şəkildə bağlandı"
+
diff --git a/crash-popup/popup_po/bg.po b/crash-popup/popup_po/bg.po
new file mode 100755 (executable)
index 0000000..7bb86be
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Затвори"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s се затвори неочаквано"
+
diff --git a/crash-popup/popup_po/ca.po b/crash-popup/popup_po/ca.po
new file mode 100755 (executable)
index 0000000..5fd5c34
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Tancar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s s'ha tancat de forma inesperada"
+
diff --git a/crash-popup/popup_po/cs.po b/crash-popup/popup_po/cs.po
new file mode 100755 (executable)
index 0000000..653ea30
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Zavřít"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s byla neočekávaně ukončena"
+
diff --git a/crash-popup/popup_po/da.po b/crash-popup/popup_po/da.po
new file mode 100755 (executable)
index 0000000..6150b8b
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Luk"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s lukkede uventet"
+
diff --git a/crash-popup/popup_po/de_DE.po b/crash-popup/popup_po/de_DE.po
new file mode 100755 (executable)
index 0000000..dfc4e9a
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Schließen"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s wurde unerwartet geschlossen"
+
diff --git a/crash-popup/popup_po/el_GR.po b/crash-popup/popup_po/el_GR.po
new file mode 100755 (executable)
index 0000000..e1f3c9e
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Κλείσιμο"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Η εφαρμογή %s έκλεισε με μη αναμενόμενο τρόπο"
+
diff --git a/crash-popup/popup_po/en.po b/crash-popup/popup_po/en.po
new file mode 100755 (executable)
index 0000000..d8a807d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Close"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s has closed unexpectedly"
+
diff --git a/crash-popup/popup_po/en_PH.po b/crash-popup/popup_po/en_PH.po
new file mode 100755 (executable)
index 0000000..d8a807d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Close"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s has closed unexpectedly"
+
diff --git a/crash-popup/popup_po/en_US.po b/crash-popup/popup_po/en_US.po
new file mode 100755 (executable)
index 0000000..d8a807d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Close"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s has closed unexpectedly"
+
diff --git a/crash-popup/popup_po/es_ES.po b/crash-popup/popup_po/es_ES.po
new file mode 100755 (executable)
index 0000000..91e0b0d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Cerrar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s se ha cerrado de forma inesperada"
+
diff --git a/crash-popup/popup_po/es_US.po b/crash-popup/popup_po/es_US.po
new file mode 100755 (executable)
index 0000000..0508116
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Cerrar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s se cerró inesperadamente"
+
diff --git a/crash-popup/popup_po/et.po b/crash-popup/popup_po/et.po
new file mode 100755 (executable)
index 0000000..f104118
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Sulge"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s on ootamatult suletud"
+
diff --git a/crash-popup/popup_po/eu.po b/crash-popup/popup_po/eu.po
new file mode 100755 (executable)
index 0000000..897b54c
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Itxi"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s ezustean itxi da"
+
diff --git a/crash-popup/popup_po/fi.po b/crash-popup/popup_po/fi.po
new file mode 100755 (executable)
index 0000000..2e004b0
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Sulje"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s on yllättäen suljettu"
+
diff --git a/crash-popup/popup_po/fr_CA.po b/crash-popup/popup_po/fr_CA.po
new file mode 100755 (executable)
index 0000000..db2835d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Fermer"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s a été fermé de manière inattendue"
+
diff --git a/crash-popup/popup_po/fr_FR.po b/crash-popup/popup_po/fr_FR.po
new file mode 100755 (executable)
index 0000000..db2835d
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Fermer"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s a été fermé de manière inattendue"
+
diff --git a/crash-popup/popup_po/ga.po b/crash-popup/popup_po/ga.po
new file mode 100755 (executable)
index 0000000..1e78434
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Dún"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Dúnadh %s gan choinne"
+
diff --git a/crash-popup/popup_po/gl.po b/crash-popup/popup_po/gl.po
new file mode 100755 (executable)
index 0000000..f23b184
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Cerrar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s pechouse inesperadamente"
+
diff --git a/crash-popup/popup_po/hi.po b/crash-popup/popup_po/hi.po
new file mode 100755 (executable)
index 0000000..234a552
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "बंद करें"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s अनपेक्षित ढंग से बंद हो गया है"
+
diff --git a/crash-popup/popup_po/hr.po b/crash-popup/popup_po/hr.po
new file mode 100755 (executable)
index 0000000..83f3d90
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Prekid"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s se neočekivano zatvorio"
+
diff --git a/crash-popup/popup_po/hu.po b/crash-popup/popup_po/hu.po
new file mode 100755 (executable)
index 0000000..09883cc
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Bezárás"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "A(z) %s váratlanul bezáródott"
+
diff --git a/crash-popup/popup_po/hy.po b/crash-popup/popup_po/hy.po
new file mode 100755 (executable)
index 0000000..191298a
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Փակել"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s-ն անսպասելիորեն փակվել է"
+
diff --git a/crash-popup/popup_po/is.po b/crash-popup/popup_po/is.po
new file mode 100755 (executable)
index 0000000..2cf1514
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Loka"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s var óvænt lokað"
+
diff --git a/crash-popup/popup_po/it_IT.po b/crash-popup/popup_po/it_IT.po
new file mode 100755 (executable)
index 0000000..049ee48
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Chiudi"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Chiusura improvvisa di %s"
+
diff --git a/crash-popup/popup_po/ja_JP.po b/crash-popup/popup_po/ja_JP.po
new file mode 100755 (executable)
index 0000000..5c76e2c
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "閉じる"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s​が​予期​せず​終了​しま​した。"
+
diff --git a/crash-popup/popup_po/ka.po b/crash-popup/popup_po/ka.po
new file mode 100755 (executable)
index 0000000..cacd82f
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "დახურვა"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s მოულოდნელად დაიხურა"
+
diff --git a/crash-popup/popup_po/kk.po b/crash-popup/popup_po/kk.po
new file mode 100755 (executable)
index 0000000..f786762
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Жабу"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s байқаусызда жабылды"
+
diff --git a/crash-popup/popup_po/ko_KR.po b/crash-popup/popup_po/ko_KR.po
new file mode 100755 (executable)
index 0000000..0444b85
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "닫기"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s이(가) 비정상적으로 종료되었습니다"
+
diff --git a/crash-popup/popup_po/lt.po b/crash-popup/popup_po/lt.po
new file mode 100755 (executable)
index 0000000..07cbb58
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Uždaryti"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "„%s“ netikėtai užsidarė"
+
diff --git a/crash-popup/popup_po/lv.po b/crash-popup/popup_po/lv.po
new file mode 100755 (executable)
index 0000000..b050a30
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Aizvērt"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Programma %s tika negaidīti aizvērta"
+
diff --git a/crash-popup/popup_po/mk.po b/crash-popup/popup_po/mk.po
new file mode 100755 (executable)
index 0000000..59092db
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Затвори"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s неочекувано затвори"
+
diff --git a/crash-popup/popup_po/nb.po b/crash-popup/popup_po/nb.po
new file mode 100755 (executable)
index 0000000..7e15d5c
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Lukk"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s har uventet lukket"
+
diff --git a/crash-popup/popup_po/nl_NL.po b/crash-popup/popup_po/nl_NL.po
new file mode 100755 (executable)
index 0000000..229d0d4
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Sluiten"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s is onverwacht gesloten"
+
diff --git a/crash-popup/popup_po/pl.po b/crash-popup/popup_po/pl.po
new file mode 100755 (executable)
index 0000000..6c61454
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Zamknij"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Aplikacja %s została niespodziewanie zamknięta"
+
diff --git a/crash-popup/popup_po/pt_BR.po b/crash-popup/popup_po/pt_BR.po
new file mode 100755 (executable)
index 0000000..93bda30
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Fechar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s fechou de forma inesperada"
+
diff --git a/crash-popup/popup_po/pt_PT.po b/crash-popup/popup_po/pt_PT.po
new file mode 100755 (executable)
index 0000000..8210630
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Fechar"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s foi encerrado inesperadamente"
+
diff --git a/crash-popup/popup_po/ro.po b/crash-popup/popup_po/ro.po
new file mode 100755 (executable)
index 0000000..8502281
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Închide"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s s-a închis în mod neaşteptat"
+
diff --git a/crash-popup/popup_po/ru_RU.po b/crash-popup/popup_po/ru_RU.po
new file mode 100755 (executable)
index 0000000..8f0b820
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Закрыть"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Приложение %s неожиданно закрылось"
+
diff --git a/crash-popup/popup_po/sk.po b/crash-popup/popup_po/sk.po
new file mode 100755 (executable)
index 0000000..9d24d9b
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Zavrieť"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Aplikácia %s sa neočakávane ukončila"
+
diff --git a/crash-popup/popup_po/sl.po b/crash-popup/popup_po/sl.po
new file mode 100755 (executable)
index 0000000..d3fa670
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Zapri"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Program %s se je nepričakovano zaprl"
+
diff --git a/crash-popup/popup_po/sr.po b/crash-popup/popup_po/sr.po
new file mode 100755 (executable)
index 0000000..c05e8af
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Zatvori"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "Aplikacija %s se neočekivano zatvorila"
+
diff --git a/crash-popup/popup_po/sv.po b/crash-popup/popup_po/sv.po
new file mode 100755 (executable)
index 0000000..0ab907e
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Stäng"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s stängdes oväntat"
+
diff --git a/crash-popup/popup_po/tr_TR.po b/crash-popup/popup_po/tr_TR.po
new file mode 100755 (executable)
index 0000000..d6095ae
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Kapat"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s beklenmedik şekilde kapandı"
+
diff --git a/crash-popup/popup_po/uk.po b/crash-popup/popup_po/uk.po
new file mode 100755 (executable)
index 0000000..52ff0f9
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Закрити"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s неочікувано припинила свою роботу"
+
diff --git a/crash-popup/popup_po/uz.po b/crash-popup/popup_po/uz.po
new file mode 100755 (executable)
index 0000000..d6c3858
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "Yopish"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s kutimaganda yopildi"
+
diff --git a/crash-popup/popup_po/zh_CN.po b/crash-popup/popup_po/zh_CN.po
new file mode 100755 (executable)
index 0000000..15fcc44
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "关闭"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s 已意外关闭"
+
diff --git a/crash-popup/popup_po/zh_HK.po b/crash-popup/popup_po/zh_HK.po
new file mode 100755 (executable)
index 0000000..279c48a
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "關閉"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s 已意外關閉"
+
diff --git a/crash-popup/popup_po/zh_SG.po b/crash-popup/popup_po/zh_SG.po
new file mode 100755 (executable)
index 0000000..15fcc44
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "关闭"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s 已意外关闭"
+
diff --git a/crash-popup/popup_po/zh_TW.po b/crash-popup/popup_po/zh_TW.po
new file mode 100755 (executable)
index 0000000..279c48a
--- /dev/null
@@ -0,0 +1,6 @@
+msgid "IDS_COM_BUTTON_CLOSE"
+msgstr "關閉"
+
+msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"
+msgstr "%s 已意外關閉"
+
diff --git a/crash-popup/src/crash-popup.c b/crash-popup/src/crash-popup.c
new file mode 100644 (file)
index 0000000..4e4c8d1
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * CRASH-POPUP
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 <errno.h>
+#include <appcore-efl.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <utilX.h>
+#include <vconf.h>
+#include <locale.h>
+#include <X11/Xlib.h>
+
+#include "util_log.h"
+#include "crash-popup.h"
+/**
+ * callback function of ECORE_EVENT_KEY_DOWN
+ */
+static Eina_Bool _ecore_event_key_down_cb(void *data, int type, void *event_info)
+{
+       Ecore_Event_Key * kd = (Ecore_Event_Key *) event_info;
+
+       if (0 == strcmp(kd->keyname, KEY_HOME))
+               _D("HOME key pressed");
+       return EINA_TRUE;
+}
+static void _keygrab(void *data)
+{
+       struct appdata *ad = (struct appdata *)data;
+       /* Key Grab */
+       Evas *evas = evas_object_evas_get(ad->win);
+       ad->main_xid = (Ecore_X_Window)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas));
+       ad->x_disp = ecore_x_display_get();
+       if (ad->x_disp == NULL)
+               _E("Failed to get X display");
+       if (utilx_grab_key(ad->x_disp, ad->main_xid, KEY_HOME, TOP_POSITION_GRAB) == -1)
+               _E("Grabbing KEY_HOME key is failed");
+       else
+               _D("Grabbing KEY_HOME key is successful");
+}
+static void _keyungrab(void *data)
+{
+       struct appdata *ad = (struct appdata *)data;
+
+       utilx_ungrab_key(ad->x_disp, ad->main_xid, KEY_HOME);
+       _D("Ungrabbing KEY_HOME key is successful");
+}
+
+static int lang_changed(void *data)
+{
+       return 0;
+}
+static int rotate(enum appcore_rm m, void *data)
+{
+       struct appdata *ad = data;
+       int r;
+
+       if (ad == NULL || ad->win == NULL)
+               return 0;
+       switch (m) {
+       case APPCORE_RM_PORTRAIT_NORMAL:
+               r = 0;
+               break;
+       case APPCORE_RM_PORTRAIT_REVERSE:
+               r = 180;
+               break;
+       case APPCORE_RM_LANDSCAPE_NORMAL:
+               r = 270;
+               break;
+       case APPCORE_RM_LANDSCAPE_REVERSE:
+               r = 90;
+               break;
+       default:
+               r = -1;
+               break;
+       }
+       if (r >= 0)
+               elm_win_rotation_with_resize_set(ad->win, r);
+       return 0;
+}
+static void popup_close_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       struct appdata *ad = (struct appdata *)data;
+
+       retm_if(ad == NULL, "Invalid argument:appdata is NULL\n");
+       _D("wait timer stopped\n");
+       if (ad->et) {
+               ecore_timer_del(ad->et);
+               ad->et = NULL;
+       }
+       if (ad->win) {
+               evas_object_del(ad->win);
+               ad->win = NULL;
+       }
+       elm_exit();
+}
+static void add_sorry_popup(struct appdata *ad)
+{
+       Evas_Object *pu, *bt1;
+       char buf[512] = {0, };
+       char *lang;
+       char *r;
+
+       lang = vconf_get_str(VCONFKEY_LANGSET);
+       if (lang) {
+               setenv("LANG", lang, 1);
+               setenv("LC_MESSAGES", lang, 1);
+               r = setlocale(LC_ALL, "");
+               if (r == NULL)
+                       r = setlocale(LC_ALL, lang);
+               free(lang);
+       }
+       snprintf(buf, sizeof(buf),
+                       _("IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"), ad->appname);
+       pu = elm_popup_add(ad->win);
+       elm_object_text_set(pu, buf);
+       bt1 = elm_button_add(pu);
+       snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BUTTON_CLOSE"));
+       elm_object_text_set(bt1, buf);
+       elm_object_part_content_set(pu, "button1", bt1);
+       evas_object_smart_callback_add(bt1, "clicked", popup_close_cb, ad);
+       evas_object_show(pu);
+}
+
+Evas_Object *add_main_window(const char *name, Evas_Coord *w, Evas_Coord *h)
+{
+       Evas_Object *eo;
+
+       eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+       if (eo) {
+               elm_win_title_set(eo, name);
+               elm_win_borderless_set(eo, EINA_TRUE);
+               ecore_x_window_size_get(ecore_x_window_root_first_get(), w, h);
+               evas_object_resize(eo, *w, *h);
+       }
+       return eo;
+}
+
+Eina_Bool wait_timer_cb(void *data)
+{
+       struct appdata *ad = (struct appdata *)data;
+
+       retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
+       if (ad->et) {
+               ecore_timer_del(ad->et);
+               ad->et = NULL;
+       }
+       if (ad->win) {
+               evas_object_del(ad->win);
+               ad->win = NULL;
+       }
+       elm_exit();
+       return ECORE_CALLBACK_CANCEL;
+}
+static int crash_popup(struct appdata *ad)
+{
+       int ret, val;
+       double scale;
+       int state = 0;
+       Evas_Object *win;
+       Evas_Coord w, h;
+       Ecore_X_Atom effect_state_atom;
+
+       retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
+       win = add_main_window(PACKAGE, &w, &h);
+       retvm_if(win == NULL, -1, "Failed to create window\n");
+       elm_win_alpha_set(win, EINA_TRUE);
+       evas_object_show(win);
+       ad->win = win;
+       scale = w / 720.0;
+       elm_config_scale_set(scale);
+       _D("scale(%lf)\n", scale);
+       elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
+       /* disable window effect */
+       effect_state_atom = ecore_x_atom_get("_NET_CM_WINDOW_EFFECT_ENABLE");
+       _D("window effect is (%d)\n", effect_state_atom);
+       ecore_x_window_prop_property_set(elm_win_xwindow_get(win),
+                       effect_state_atom, ECORE_X_ATOM_CARDINAL, 32, &state, 1);
+       /* start popup */
+       add_sorry_popup(ad);
+       if (ad->et) {
+               ecore_timer_del(ad->et);
+               ad->et = NULL;
+       }
+       if (!strcmp(ad->appname, "modem"))
+               return 0;
+       ret =  vconf_get_int(VCONFKEY_CRASH_AUTOCLOSE, &val);
+       if (val == 1)
+               ad->et = ecore_timer_add(5.0, wait_timer_cb, ad);
+       return 0;
+}
+static int app_create(void *data)
+{
+       struct appdata *ad = data;
+       int ret, val;
+
+       retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
+       /* create window */
+       lang_changed(ad);
+       /* add system event callback */
+       appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, lang_changed, ad);
+       appcore_set_rotation_cb(rotate, ad);
+       appcore_set_i18n("crash-popup", LOCALEDIR);
+       /* appcore measure time example */
+       _D("from AUL to %s(): %d msec\n", __func__,
+                       appcore_measure_time_from("APP_START_TIME"));
+       appcore_measure_start();
+       ret = vconf_get_int(VCONFKEY_CRASH_POPUP, &val);
+       /* val 1 means showing popup */
+       if (val == 1) {
+               crash_popup(ad);
+               ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+                               _ecore_event_key_down_cb, ad);
+               _keygrab(ad);
+       } else {
+               elm_exit();
+       }
+       return 0;
+}
+static int app_terminate(void *data)
+{
+       struct appdata *ad = data;
+
+       if (ad->et) {
+               ecore_timer_del(ad->et);
+               ad->et = NULL;
+       }
+       if (ad->win)
+               evas_object_del(ad->win);
+
+       _keyungrab(ad);
+       _D("from create to %s(): %d msec\n", __func__, appcore_measure_time());
+       return 0;
+}
+static int app_pause(void *data)
+{
+       struct appdata *ad = (struct appdata *)data;
+
+       retvm_if(ad == NULL, -1, "Invalid argument:appdata is NULL\n");
+       if (ad->win)
+               elm_win_activate(ad->win);
+       return 0;
+}
+static int app_resume(void *data)
+{
+       return 0;
+}
+static int app_reset(bundle *b, void *data)
+{
+       struct appdata *ad = data;
+
+       /* appcore measure time example */
+       _D("from AUL to %s(): %d msec\n", __func__,
+                       appcore_measure_time_from("APP_START_TIME"));
+       _D("from create to %s(): %d msec\n", __func__,
+                       appcore_measure_time());
+       if (ad->win)
+               elm_win_activate(ad->win);
+       return 0;
+}
+int main(int argc, char *argv[])
+{
+       int i = 0;
+       struct appdata ad;
+       struct appcore_ops ops = {
+               .create = app_create,
+               .terminate = app_terminate,
+               .pause = app_pause,
+               .resume = app_resume,
+               .reset = app_reset,
+       };
+
+       _D("argc(%d)\n", argc);
+       if (argc < 2) {
+               _D("argc is (%d) wrong argument\n", argc);
+               return -1;
+       }
+       for (i = 0; i < argc; i++) {
+               if (argv[i]) {
+                       _D("%d, %s\n", i+1, argv[i]);
+               } else {
+                       _E("%d argument is NULL\n", i+1);
+                       return -1;
+               }
+       }
+       if (ecore_x_init(NULL) == NULL) {
+                       _E("Cannot connect to X11 display\n");
+               return -1;
+       }
+       /* appcore measure time example */
+       _D("from AUL to %s(): %d msec\n", __func__,
+                       appcore_measure_time_from("APP_START_TIME"));
+       memset(&ad, 0x0, sizeof(struct appdata));
+       snprintf(ad.appname, sizeof(ad.appname), "%s", argv[1]);
+       ops.data = &ad;
+       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+}
diff --git a/crash-popup/src/crash-popup.h b/crash-popup/src/crash-popup.h
new file mode 100644 (file)
index 0000000..8b6aa7d
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * CRASH-POPUP
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 __CRASH_POPUP_H__
+#define __CRASH_POPUP_H__
+
+#include <Elementary.h>
+#include <Ecore_X.h>
+
+#if !defined(PACKAGE)
+#  define PACKAGE "crash-popup"
+#endif
+
+#if !defined(RESDIR)
+#  define RESDIR "/usr/apps/org.tizen.crash-popup/res"
+#endif
+
+#if !defined(LOCALEDIR)
+#  define LOCALEDIR RESDIR"/locale"
+#endif
+
+#if !defined(EDJDIR)
+#  define EDJDIR RESDIR"/edje"
+#endif
+
+#define EDJ_FILE EDJDIR "/" PACKAGE ".edj"
+#define GRP_MAIN "main"
+
+#ifndef _
+#define _(str) gettext(str)
+#endif
+
+#ifndef gettext_noop
+#define gettext_noop(str) (str)
+#endif
+
+#ifndef N_
+#define N_(str) gettext_noop(str)
+#endif
+
+#ifndef __VCONF_INTERNAL_CRASH_KEYS_H__
+#define VCONFKEY_CRASH_POPUP "db/crash/popup"
+#define VCONFKEY_CRASH_AUTOCLOSE  "db/crash/autoclose"
+#endif
+
+struct appdata
+{
+       Evas *evas;
+       Evas_Object *win, *en;
+       Ecore_X_Window main_xid;
+       Ecore_X_Display *x_disp;
+       Ecore_Timer *et;
+       char appname[256];
+       /* add more variables here */
+};
+
+#endif
+/* __CRASH_POPUP_H__ */
diff --git a/crash-popup/src/util_log.h b/crash-popup/src/util_log.h
new file mode 100644 (file)
index 0000000..799da42
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * CRASH-POPUP
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 __CRASH_POP_UTIL_LOG_H__
+#define __CRASH_POP_UTIL_LOG_H__
+
+#include <unistd.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "CRASH_POPUP"
+#define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define ret_if(expr) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+
+#endif
+/* __CRASH_POP_UTIL_LOG_H__ */
+
diff --git a/crash-worker/CMakeLists.txt b/crash-worker/CMakeLists.txt
new file mode 100644 (file)
index 0000000..da265cf
--- /dev/null
@@ -0,0 +1,62 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(crash-worker C)
+
+SET(SRCS
+       util.c
+       crash-worker.c
+)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+               appcore-efl
+               elementary
+               ecore-file
+               ecore-input
+               ecore-x
+               ecore
+               evas
+               edje
+               vconf
+               utilX
+               ecore-imf
+               appcore-common
+               ecore-imf
+               ail
+               capi-system-info
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+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("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+IF("${DEBUG_LOG_ON}" STREQUAL "")
+       ADD_DEFINITIONS("-DDEBUG_LOG_ON=\"${DEBUG_LOG_ON}\"")
+       MESSAGE("add -DDEBUG_LOG_ON")
+ENDIF("${DEBUG_LOG_ON}" STREQUAL "")
+#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
diff --git a/crash-worker/crash-worker.c b/crash-worker/crash-worker.c
new file mode 100644 (file)
index 0000000..97b8553
--- /dev/null
@@ -0,0 +1,1156 @@
+/*
+ * CRASH-WORKER
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include <ail.h>
+#include <vconf.h>
+#include <system_info.h>
+
+#include "crash-worker.h"
+#include "util.h"
+
+#define CLEAR_DUMP_PATH 1
+#define BUF_SIZE 1024
+#define DM_BUF_SIZE    (1024 * 10)
+/* This is rule for what is gathering in system */
+static cw_gather_log_rule g_crule[] = {
+       {CW_GATHER_DLOG, 1, "cp /opt/var/log/dlog* ", "/"},
+       {CW_GATHER_PS, 0, "ps -aux > ", "/ps.log"},
+       {CW_GATHER_MEMPS, 0, "memps -a > ", "/memps.log"},
+       {CW_GATHER_TOP, 0, "top -bc -n 1 > ", "/top.log"},
+       {CW_GATHER_CP, 0, "cp /opt/etc/modem/err/* ", "/"},
+       {CW_GATHER_SS, 0, "screenshot bmp ", "/slp_screenshot.bmp"},
+       {CW_GATHER_KL, 1, "cp /opt/var/log/messages ", "/"},
+       {CW_GATHER_RL, 1, "cp /opt/var/log/seq.radio.log ", "/"},
+       {CW_GATHER_XL, 1, "cp /opt/var/log/*Xorg.* ", "/"},
+       {CW_GATHER_MAX, 0, "", ""},
+};
+/* check disk available size */
+static int _check_disk_available(char *mount_dir, int check_size)
+{
+       struct statfs lstatfs;
+       int avail_size = 0;
+
+       if (mount_dir == NULL)
+               return -1;
+       if (check_size == 0)
+               return 1;
+       if (statfs(mount_dir, &lstatfs) < 0) {
+               LOGWARN("can't get statfs %s\n", mount_dir);
+               return -1;
+       }
+       avail_size = (int)(lstatfs.f_bavail * (lstatfs.f_bsize/1024));
+       if (check_size > avail_size) {
+               LOGINFO("NO %d < %d\n", check_size, avail_size);
+               return -1;
+       }
+       LOGINFO("disk availiable!(%d)\n", avail_size);
+       return 1;
+}
+/* check directory access */
+static int _check_dir_access(const char *path)
+{
+       if (access(path, F_OK) != 0)
+               return -1;
+       else
+               return 1;
+}
+/* make directory after check directory access */
+static int _make_dir(char *path)
+{
+       if (access(path, F_OK) == -1) {
+               /* make dir for  cs file */
+               if (mkdir(path, DIR_PERMS) < 0) {
+                       LOGWARN("can't make dir : %s\n", path);
+                       return -1;
+               } else
+                       return 1;
+       } else
+               return 1;
+}
+/* sort function by time order for fill file list */
+static int _dump_mtime_sort(const void *va, const void *vb)
+{
+       struct dirent *d1, *d2;
+       struct stat st1, st2;
+       char fbuf1[NAME_MAX] = {0, };
+       char fbuf2[NAME_MAX] = {0, };
+
+       d1 = *(struct dirent **)(va);
+       d2 = *(struct dirent **)(vb);
+       snprintf(fbuf1, sizeof(fbuf1), "%s/%s", CRASH_DUMP_PATH, d1->d_name);
+       if (stat(fbuf1, &st1) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf1, errno);
+               return 0;
+       }
+       snprintf(fbuf2, sizeof(fbuf2), "%s/%s", CRASH_DUMP_PATH, d2->d_name);
+       if (stat(fbuf2, &st2) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf2, errno);
+               return 0;
+       }
+       return st1.st_mtime - st2.st_mtime;
+}
+/* sort function by time order for fill file list */
+static int _report_mtime_sort(const void *va, const void *vb)
+{
+       struct dirent *d1, *d2;
+       struct stat st1, st2;
+       char fbuf1[NAME_MAX] = {0, };
+       char fbuf2[NAME_MAX] = {0, };
+
+       d1 = *(struct dirent **)(va);
+       d2 = *(struct dirent **)(vb);
+       snprintf(fbuf1, sizeof(fbuf1), "%s/%s", CRASH_REPORT_PATH, d1->d_name);
+       if (stat(fbuf1, &st1) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf1, errno);
+               return 0;
+       }
+       snprintf(fbuf2, sizeof(fbuf2), "%s/%s", CRASH_REPORT_PATH, d2->d_name);
+       if (stat(fbuf2, &st2) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf2, errno);
+               return 0;
+       }
+       return st1.st_mtime - st2.st_mtime;
+}
+/* sort function by time order for fill file list */
+static int _ticket_mtime_sort(const void *va, const void *vb)
+{
+       struct dirent *d1, *d2;
+       struct stat st1, st2;
+       char fbuf1[NAME_MAX] = {0, };
+       char fbuf2[NAME_MAX] = {0, };
+
+       d1 = *(struct dirent **)(va);
+       d2 = *(struct dirent **)(vb);
+       snprintf(fbuf1, sizeof(fbuf1), "%s/%s", CRASH_TICKET_PATH, d1->d_name);
+       if (stat(fbuf1, &st1) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf1, errno);
+               return 0;
+       }
+       snprintf(fbuf2, sizeof(fbuf2), "%s/%s", CRASH_TICKET_PATH, d2->d_name);
+       if (stat(fbuf2, &st2) == -1) {
+               LOGERR("can't get stat %s errno(%d)\n", fbuf2, errno);
+               return 0;
+       }
+       return st1.st_mtime - st2.st_mtime;
+}
+/* filter for count previous report file */
+static int _dump_filter(const struct dirent *dirent)
+{
+       if (!(strncmp(dirent->d_name, ".", 1)) ||
+                       !(strcmp(dirent->d_name, ".."))) {
+               return 0;
+       } else {
+               if (dirent->d_type == DT_DIR)
+                       return 0;
+               char *gz = strrchr(dirent->d_name, '.');
+               if (gz == NULL)
+                       return 0;
+               if (!strncmp(gz, ".gz", 3))
+                       return 1;
+               return 0;
+       }
+}
+/* filter for count previous report file */
+static int _report_filter(const struct dirent *dirent)
+{
+       if (!(strncmp(dirent->d_name, ".", 1)) ||
+                       !(strcmp(dirent->d_name, ".."))) {
+               return 0;
+       } else {
+               if (dirent->d_type == DT_DIR)
+                       return 0;
+               char *gz = strrchr(dirent->d_name, '.');
+               if (gz == NULL)
+                       return 0;
+               if (!strncmp(gz, ".cs", 3))
+                       return 1;
+               return 0;
+       }
+}
+/* filter for count previous ticket file */
+static int _ticket_filter(const struct dirent *dirent)
+{
+       if (!(strncmp(dirent->d_name, ".", 1)) ||
+                       !(strcmp(dirent->d_name, ".."))) {
+               return 0;
+       } else {
+               if (dirent->d_type == DT_DIR)
+                       return 0;
+               char *gz = strrchr(dirent->d_name, '.');
+               if (gz == NULL)
+                       return 0;
+               if (!strncmp(gz, ".ct", 3))
+                       return 1;
+               return 0;
+       }
+}
+/* count previous dump file */
+static int _count_pre_dump(struct dirent ***filelist)
+{
+       int ret = 0;
+
+       if (filelist == NULL)
+               return -1;
+       ret = scandir(CRASH_DUMP_PATH, filelist, _dump_filter, (int (*)(const struct dirent **, const struct dirent **))_dump_mtime_sort);
+       if (ret < 0) {
+               LOGERR("scandir error\n");
+               return -1;
+       }
+       return ret;
+}
+/* count previous report file */
+static int _count_pre_report(struct dirent ***filelist)
+{
+       int ret = 0;
+
+       if (filelist == NULL)
+               return -1;
+       ret = scandir(CRASH_REPORT_PATH, filelist, _report_filter, (int (*)(const struct dirent **, const struct dirent **))_report_mtime_sort);
+       if (ret < 0) {
+               LOGERR("scandir error\n");
+               return -1;
+       }
+       return ret;
+}
+/* count previous ticket file */
+static int _count_pre_ticket(struct dirent ***filelist)
+{
+       int ret = 0;
+
+       if (filelist == NULL)
+               return -1;
+       ret = scandir(CRASH_TICKET_PATH, filelist, _ticket_filter, (int (*)(const struct dirent **, const struct dirent **))_ticket_mtime_sort);
+       if (ret < 0) {
+               LOGERR("scandir error\n");
+               return -1;
+       }
+       return ret;
+}
+static int _del_ticket_contents(char *ticketname)
+{
+       char path[PATH_LEN] = {0,};
+       char buf[NAME_MAX] = {0,};
+       char fbuf[NAME_MAX] = {0,};
+       int ret = 0;
+       struct stat fstat;
+       FILE *fp;
+
+       if (ticketname == NULL)
+               return -1;
+       snprintf(path, sizeof(path), "%s/%s", CRASH_TICKET_PATH, ticketname);
+       ret = access(path, F_OK);
+       if (ret == 0) {
+               fp = fopen(path, "rb");
+               if (fp == NULL) {
+                       LOGERR("crash ticket open error\n");
+                       return -1;
+               }
+               fseek(fp, 0, SEEK_SET);
+               while (fgets(buf, sizeof(buf), fp)) {
+                       char *p = strchr(buf, '\n');
+                       if (p)
+                               *p = '\0';
+                       snprintf(fbuf, sizeof(fbuf), "%s", buf);
+                       ret = access(fbuf, F_OK);
+                       if (ret == 0) {
+                               if (lstat(fbuf, &fstat) < 0)
+                                       continue;
+                               if (S_ISDIR(fstat.st_mode)) {
+                                       if (delete_dir_contents(fbuf, 1, NULL) < 0) {
+                                               LOGERR("can't delete path crash dir(%s)", fbuf);
+                                               continue;
+                                       }
+                               } else {
+                                       if (unlink(fbuf) < 0) {
+                                               LOGERR("can't delete crash file (%s)", fbuf);
+                                               continue;
+                                       }
+                               }
+                               LOGDEBUG("delete is (%s)", fbuf);
+                       }
+               }
+               fclose(fp);
+               unlink(path);/*delete ticket*/
+               return 1;
+       } else
+               return -1;
+}
+/* delete previous ticket and dump file */
+static void _delete_pre_ticket(struct dirent **filelist, int del_num)
+{
+       int i = 0;
+
+       for (i = 0; i < del_num + 1; i++) {
+               if (_del_ticket_contents(filelist[i]->d_name) != 1)
+                       LOGERR("can't delete ticket and contents(%s)\n",
+                                       filelist[i]->d_name);
+               else
+                       LOGINFO("delete ticket and contents(%s)\n",
+                                       filelist[i]->d_name);
+       }
+}
+/* delete previous dump file */
+static void _delete_pre_dump(struct dirent **filelist, int del_num)
+{
+       int i = 0;
+       char fbuf[PATH_LEN] = {0, };  /* file buff */
+
+       for (i = 0; i < del_num + 1; i++) {
+               snprintf(fbuf, sizeof(fbuf),
+                               "%s/%s", CRASH_DUMP_PATH,
+                               filelist[i]->d_name);
+               if (unlink(fbuf) < 0)
+                       LOGERR("can't unlink (%s)\n", fbuf);
+               else
+                       LOGINFO("unlink(%s)\n", fbuf);
+       }
+}
+/* delete previous report file */
+static void _delete_pre_report(struct dirent **filelist, int del_num)
+{
+       int i = 0;
+       char fbuf[PATH_LEN] = {0, };  /* file buff */
+
+       for (i = 0; i < del_num + 1; i++) {
+               snprintf(fbuf, sizeof(fbuf),
+                               "%s/%s", CRASH_REPORT_PATH,
+                               filelist[i]->d_name);
+               if (unlink(fbuf) < 0)
+                       LOGERR("can't unlink (%s)\n", fbuf);
+               else
+                       LOGINFO("unlink(%s)\n", fbuf);
+       }
+}
+/* free dirent list */
+static int _free_filelist(struct dirent **filelist, int list_num)
+{
+       int i = 0;
+
+       if (filelist == NULL || list_num == 0)
+               return -1;
+       for (i = 0; i < list_num; i++) {
+               if (filelist[i])
+                       free(filelist[i]);
+       }
+       free(filelist);
+       return 1;
+}
+/* ail filter list function for getting package information */
+static ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
+{
+       char *str;
+       FILE *fp = (FILE *)user_data;
+
+       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
+       fprintf(fp, "Package Name: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PKGID_STR, &str);
+       fprintf(fp, "Package ID : %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &str);
+       fprintf(fp, "Version: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+       fprintf(fp, "Package Type: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &str);
+       fprintf(fp, "App Name: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_APPID_STR, &str);
+       fprintf(fp, "App ID: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_TYPE_STR, &str);
+       fprintf(fp, "Type: %s\n", str);
+       ail_appinfo_get_str(appinfo, AIL_PROP_CATEGORIES_STR, &str);
+       fprintf(fp, "Categories: %s\n", str);
+       return AIL_CB_RET_CONTINUE;
+}
+/* ail filter list function for getting application ID */
+static ail_cb_ret_e appinfo_get_appid_func(const ail_appinfo_h appinfo,
+               void *user_data)
+{
+       char *str;
+
+       if (user_data == NULL)
+               return AIL_ERROR_FAIL;
+       ail_error_e ret = AIL_ERROR_OK;
+       ret = ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_APPID_STR, &str);
+       strncpy((char *)user_data, str, strlen(str));
+       return ret;
+}
+/* get application ID by ail filter */
+static int _get_app_id(char *exepath, char *app_id)
+{
+       ail_filter_h f;
+       int count = 0;
+       int ret = 0;
+
+       if (ail_filter_new(&f) != AIL_ERROR_OK)
+               return -1;
+       if (ail_filter_add_str(f, AIL_PROP_EXEC_STR, exepath) != AIL_ERROR_OK) {
+               ail_filter_destroy(f);
+               return -1;
+       }
+       if (ail_filter_count_appinfo(f, &count) != AIL_ERROR_OK)
+               LOGERR("Error: failed to count appinfo\n");
+       if (count) {
+               ret = ail_filter_list_appinfo_foreach(f,
+                               appinfo_get_appid_func, (void *)app_id);
+               if (ret == AIL_ERROR_OK && app_id[0] != '\0') {
+                       LOGINFO("ail filter list get appid (%s)\n", app_id);
+                       ret = 1;
+               }
+       }
+       if (!count)
+               ret = -1;
+       if (f)
+               ail_filter_destroy(f);
+       return ret;
+}
+static int _set_crash_time_info(struct crashinfo *cinfo, char *timesecstr)
+{
+       if (timesecstr == NULL)
+               return -1;
+       snprintf(cinfo->timesec, sizeof(cinfo->timesec), "%s", timesecstr);
+       cinfo->crash_time = atol(cinfo->timesec);
+       /*gmtime_r(&cur_time, &ctime);*/
+       localtime_r(&(cinfo->crash_time), &(cinfo->crash_tm));
+       strftime(cinfo->timestr, sizeof(cinfo->timestr), "%Y%m%d%H%M%S", &(cinfo->crash_tm));
+       return 1;
+}
+/* write crash base information at crash report file */
+static cw_ret_type cw_write_crash_base_info(struct crashinfo *cinfo)
+{
+       char *p_exepath = NULL;
+       char *timestr[64];
+       char *timeoffsetstr[16];
+
+       if (cinfo == NULL || cinfo->csfd == 0)
+               return CW_RETURN_INVALID_PARAMETER;
+       /* print version info */
+       fprintf_fd(cinfo->csfd, "\n%s\n", CRASH_CRASHINFO_TITLE);
+       if (cinfo->mode == CW_MODE_COL) {
+               fprintf_fd(cinfo->csfd,
+                               "Process Name: %s\n", cinfo->processname);
+       } else {
+               p_exepath = strrchr(cinfo->exepath, '/');
+               if (p_exepath != NULL && p_exepath[0] != '\0')
+                       fprintf_fd(cinfo->csfd,
+                                       "Process Name: %s\n", p_exepath);
+       }
+       fprintf_fd(cinfo->csfd, "PID: %s\n", cinfo->pid);
+       strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S(GMT%z)", &(cinfo->crash_tm));
+       fprintf_fd(cinfo->csfd, "Date: %s\n", timestr, timeoffsetstr);
+       fprintf_fd(cinfo->csfd, "Executable File Path: %s\n", cinfo->exepath);
+       if (cinfo->mode == CW_MODE_COL)
+               fprintf_fd(cinfo->csfd, "Signal: %s\n", cinfo->signal);
+       return CW_RETURN_OK;
+}
+/* write system version information at crash report file */
+static cw_ret_type cw_write_version_info(struct crashinfo *cinfo)
+{
+       char *tizenversion = NULL;
+       char *model = NULL;
+       char *buildstring = NULL;
+       char *builddate = NULL;
+       char *buildtime = NULL;
+
+       if (cinfo == NULL || cinfo->csfd == 0)
+               return CW_RETURN_INVALID_PARAMETER;
+       int fd = cinfo->csfd;
+       /* print version info */
+       fprintf_fd(fd, "%s\n", CRASH_SW_VERSIONINFO_TITLE);
+       if (system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &model) < 0)
+               return CW_RETURN_ERROR;
+       if (model) {
+               fprintf_fd(fd, "Model: %s\n", model);
+               free(model);
+       }
+       if (system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION,
+                               &tizenversion) < 0) {
+               return CW_RETURN_ERROR;
+       }
+       if  (tizenversion) {
+               fprintf_fd(fd, "Tizen-Version: %s\n", tizenversion);
+               free(tizenversion);
+       }
+       if (system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING,
+                               &buildstring) < 0) {
+               return CW_RETURN_ERROR;
+       }
+       if (buildstring) {
+               fprintf_fd(fd, "Build-Number: %s\n", buildstring);
+               free(buildstring);
+       }
+       if (system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_DATE,
+                               &builddate) < 0) {
+               return CW_RETURN_ERROR;
+       }
+       if (system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_TIME,
+                               &buildtime) < 0) {
+               return CW_RETURN_ERROR;
+       }
+       if (builddate && buildtime)
+               fprintf_fd(fd, "Build-Date: %s %s\n", builddate, buildtime);
+       if (builddate)
+               free(builddate);
+       if (buildtime)
+               free(buildtime);
+       return CW_RETURN_OK;
+}
+/* write system memory information at crash report file */
+static cw_ret_type cw_write_mem_info(struct crashinfo *cinfo)
+{
+       int meminfo = 0;
+       char linebuf[BUF_SIZE] = {0, };
+       char infoname[20];
+       char memsize1[24];
+
+       if (cinfo == NULL || cinfo->csfd == 0)
+               return CW_RETURN_INVALID_PARAMETER;
+       int fd = cinfo->csfd;
+       /* print meminfo */
+       fprintf_fd(fd, "\n%s\n", CRASH_MEMINFO_TITLE);
+       meminfo = open(MEMINFO_PATH, O_RDONLY);
+       if (meminfo < 0) {
+               LOGERR("can't open %s\n", MEMINFO_PATH);
+               return CW_RETURN_ERROR;
+       } else {
+               while (fgets_fd(linebuf, BUF_SIZE, meminfo) != NULL) {
+                       sscanf(linebuf, "%s %s %*s", infoname, memsize1);
+                       if (strcmp("MemTotal:", infoname) == 0) {
+                               fprintf_fd(fd, "%s %s KB\n", infoname,
+                                               memsize1);
+                       } else if (strcmp("MemFree:", infoname) == 0) {
+                               fprintf_fd(fd, "%s %s KB\n", infoname,
+                                               memsize1);
+                       } else if (strcmp("Buffers:", infoname) == 0) {
+                               fprintf_fd(fd, "%s  %s KB\n",
+                                               infoname, memsize1);
+                       } else if (strcmp("Cached:", infoname) == 0) {
+                               fprintf_fd(fd, "%s   %s KB\n",
+                                               infoname, memsize1);
+                               break;
+                       }
+               }
+               close(meminfo);
+       }
+       return CW_RETURN_OK;
+}
+/* write dlogdump at crash report file */
+static cw_ret_type cw_write_dlogdump(struct crashinfo *cinfo)
+{
+       int readnum = 0;
+       int pos = 0;
+       FILE *mfp = NULL;
+       FILE *csfp = NULL;
+       char *tbuf = NULL;
+       char mbuf[PATH_LEN] = {0, };
+       char cbuf[PATH_LEN] = {0, };
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       csfp = fopen(cinfo->reportfile, "a+");
+       retvm_if(csfp == NULL, CW_RETURN_INVALID_PARAMETER,
+                       "Failed to open (%s)\n", cinfo->reportfile);
+       tbuf = (char *)malloc(DM_BUF_SIZE);
+       if (tbuf == NULL) {
+               fclose(csfp);
+               return CW_RETURN_OUT_OF_MEMORY;
+       }
+       fprintf(csfp, "\n%s\n", CRASH_DLOG_TITLE);
+       snprintf(mbuf, sizeof(mbuf), "%s/%s_%s.dlogdump", cinfo->dumppath,
+                       cinfo->processname, cinfo->timestr);
+       mfp = fopen(mbuf, "r");
+       if (mfp == NULL) {
+               LOGERR("Failed to open %s\n", mbuf);
+               fclose(csfp);
+               free(tbuf);
+               return CW_RETURN_ERROR;
+       }
+       snprintf(mbuf, sizeof(mbuf), "%s%s%s",
+                       cinfo->modestr, cinfo->processname, cinfo->timesec);
+       while (fgets(cbuf, PATH_LEN, mfp)) {
+               int len = strlen(cbuf);
+               if (!len)
+                       continue;
+               cbuf[len] = '\0';
+               if (strstr(cbuf, mbuf) != NULL)
+                       pos = ftell(mfp);
+       }
+       /* check data size from end postion */
+       if (fseek(mfp, (pos-DM_BUF_SIZE - 1), SEEK_SET) < 0) {
+               fseek(mfp, 0L, SEEK_SET);
+               readnum = fread(tbuf, 1, DM_BUF_SIZE, mfp);
+       } else {
+               readnum = fread(tbuf, 1, DM_BUF_SIZE, mfp);
+       }
+       tbuf[readnum] = '\0';
+       fprintf(csfp, "%s\n", tbuf);
+       fprintf(csfp, "%s\n", CRASH_DLOG_TITLE_E);
+       fclose(csfp);
+       fclose(mfp);
+       free(tbuf);
+       return CW_RETURN_OK;
+}
+static cw_ret_type cw_conf(struct crashstatus *cstatus)
+{
+       if (access(TIZEN_DEBUG_MODE_FILE, F_OK) == 0) {
+               cstatus->b_debug_mode = 1;
+               LOGDEBUG("debug mode on\n");
+       } else {
+               cstatus->b_debug_mode = 0;
+               LOGDEBUG("debug mode off\n");
+       }
+       return CW_RETURN_OK;
+}
+/* crash info struct initialize */
+static cw_ret_type cw_info_init(struct crashinfo *cinfo)
+{
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       cinfo->b_core_dump = 0;
+       cinfo->b_info_file = 0;
+       cinfo->b_dlog_dump = 0;
+       cinfo->b_app_id = 0;
+       if (_get_app_id(cinfo->exepath, cinfo->app_id) != 1) {
+               snprintf(cinfo->app_id, sizeof(cinfo->app_id),
+                               "%s", cinfo->processname);
+       } else
+               cinfo->b_app_id = 1;
+       snprintf(cinfo->dumppath, sizeof(cinfo->dumppath),
+                       "%s/%s_%s", CRASH_DUMP_PATH,
+                       cinfo->processname,     cinfo->timestr);
+       snprintf(cinfo->reportfile, sizeof(cinfo->reportfile),
+                       "%s/%s_%s.cs", CRASH_REPORT_PATH,
+                       cinfo->app_id, cinfo->timestr);
+       snprintf(cinfo->infofile, sizeof(cinfo->infofile),
+                       "%s/%s_%s.info", CRASH_INFO_PATH,
+                       cinfo->pid, cinfo->timesec);
+       snprintf(cinfo->pkginfofile, sizeof(cinfo->pkginfofile),
+                       "%s/pkg.info", cinfo->dumppath);
+       snprintf(cinfo->dumpzipfile, sizeof(cinfo->dumpzipfile),
+                       "%s/%s_%s.tar.gz", CRASH_DUMP_PATH,
+                       cinfo->app_id, cinfo->timestr);
+       return CW_RETURN_OK;
+}
+/*
+ * check /opt/usr mount status
+ * if can't access, try to mount
+ * if fail to mount, wait and recheck to access
+ */
+static cw_ret_type cw_check_mount_ready(void)
+{
+       int i = 0;
+       for (i = 0; i < CRASH_CHECK_MOUNT_TRY_NUM; i++) {
+               if (_check_dir_access(CRASH_CHECK_DISK_PATH) != 1) {
+                       LOGINFO("can't access %s wait %d sec\n",
+                                       CRASH_CHECK_DISK_PATH, CRASH_CHECK_MOUNT_WAIT_TIME);
+                       if (mount(TIZEN_OPT_USR_MOUNT,
+                                               CRASH_CHECK_DISK_PATH,
+                                               TIZEN_OPT_USR_TYPE,
+                                               0, NULL) != 0)
+                               sleep(CRASH_CHECK_MOUNT_WAIT_TIME);
+               } else
+                       return CW_RETURN_OK;
+       }
+       return CW_RETURN_ERROR;
+}
+/*
+ * check previous ticket, dump and report file
+ * check disk available and reserve disk
+ */
+static cw_ret_type cw_init(struct crashinfo *cinfo,
+               struct crashstatus *cstatus)
+{
+       int del_num = 0;
+
+       if (cinfo == NULL || cstatus == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       /*cstatus->b_wifi_avail = _check_wifi_status();*/
+       cstatus->n_pre_report =
+               _count_pre_report(&(cstatus->reportlist));
+       if (cstatus->n_pre_report != 0 &&
+                       CRASH_CHECK_REPORT_MAX_NUM <= cstatus->n_pre_report) {
+               del_num = cstatus->n_pre_report - CRASH_CHECK_REPORT_MAX_NUM;
+               _delete_pre_report(cstatus->reportlist, del_num);
+       } else {
+               LOGDEBUG("previous report file num is [%d]\n",
+                               cstatus->n_pre_report);
+       }
+       cstatus->n_pre_ticket =
+               _count_pre_ticket(&(cstatus->ticketlist));
+       cstatus->n_pre_dump =
+               _count_pre_dump(&(cstatus->dumplist));
+       /*
+          for (i = 0; i < cstatus->n_pre_ticket; i++)
+          LOGDEBUG("[%d] %s\n", i, cstatus->ticketlist[i]->d_name);
+        */
+       if (cstatus->b_debug_mode == 1) {
+               if (cstatus->n_pre_dump != 0 &&
+                               CRASH_CHECK_DUMP_MAX_NUM <= cstatus->n_pre_dump) {
+                       del_num = cstatus->n_pre_dump - CRASH_CHECK_DUMP_MAX_NUM;
+                       _delete_pre_dump(cstatus->dumplist, del_num);
+                       _delete_pre_ticket(cstatus->ticketlist, del_num);
+                       cstatus->b_disk_avail =
+                               _check_disk_available(CRASH_CHECK_DISK_PATH,
+                                               CRASH_CHECK_SIZE);
+               } else {
+                       LOGDEBUG("previous ticket and dump file num is [%d]\n",
+                                       cstatus->n_pre_ticket);
+               }
+       } else {
+               if (cstatus->n_pre_ticket != 0) {
+                       delete_dir_contents(CRASH_TICKET_PATH, 0, NULL);
+                       delete_dir_contents(CRASH_DUMP_PATH, 0, NULL);
+                       delete_dir_contents(CRASH_CORE_PATH, 0, NULL);
+               }
+       }
+       cstatus->b_disk_avail =
+               _check_disk_available(CRASH_CHECK_DISK_PATH, CRASH_CHECK_SIZE);
+       /* check disk available size */
+       if (cstatus->b_disk_avail != 1) {
+               delete_dir_contents(CRASH_TICKET_PATH, 0, NULL);
+               delete_dir_contents(CRASH_DUMP_PATH, 0, NULL);
+       }
+       if (cw_info_init(cinfo) < 0) {
+               LOGERR("can't cw_info_init\n");
+               return CW_RETURN_ERROR;
+       }
+       return CW_RETURN_OK;
+}
+/* make dump directory */
+static cw_ret_type cw_make_dump_dir(struct crashinfo *cinfo)
+{
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       /* make debug directory if  absent */
+       if (_make_dir(CRASH_SAVE_PATH) != 1)
+               return CW_RETURN_ERROR;
+       if (_make_dir(cinfo->dumppath) != 1)
+               return CW_RETURN_ERROR;
+       LOGINFO("dump dir(%s)\n", cinfo->dumppath);
+       return CW_RETURN_OK;
+}
+/* dump /dev/log_main, /dev/log_system and /dev/log_radio*/
+static cw_ret_type cw_dump_dlog(struct crashinfo *cinfo)
+{
+       int ret = 0;
+       char cbuf[PATH_LEN] = {0, };  /* commad buff */
+       char buf[NAME_MAX] = {0, };  /* buffer */
+
+       if (cinfo == NULL)
+               return -1;
+       retvm_if(cinfo == NULL, CW_RETURN_INVALID_PARAMETER,
+                       "Invalid argument: cinfo is NULL\n");
+       retvm_if(cinfo->reportfile == NULL, CW_RETURN_INVALID_PARAMETER,
+                       "Invalid argument: cinfo->reportfile is NULL\n");
+       snprintf(buf, sizeof(buf), "%s/%s_%s.dlogdump", cinfo->dumppath,
+                       cinfo->processname, cinfo->timestr);
+       LOGDEBUG("make main log file in %s\n", buf);
+       snprintf(cbuf, sizeof(cbuf), "dlogutil -v time -d -r 2000 -n 1 -f %s *:d", buf);
+       ret = system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cbuf);
+       if (0 <= ret)
+               cinfo->b_dlog_dump = 1;
+       memset(cbuf, 0, sizeof(cbuf));
+       snprintf(buf, sizeof(buf), "%s/radio.log", cinfo->dumppath);
+       LOGDEBUG("make radio log file in %s\n", buf);
+       snprintf(cbuf, sizeof(cbuf),
+                       "dlogutil -v time -b radio -d -r 2000 -n 1 -f %s *:v", buf);
+       system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cbuf);
+       return CW_RETURN_OK;
+}
+/* copy from libsys info file to dump path */
+static cw_ret_type cw_get_libsys_info(struct crashinfo *cinfo)
+{
+       int ret = 0;
+       char cbuf[PATH_LEN] = {0, };  /* commad buff */
+       char dbuf[NAME_MAX] = {0, };
+
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       snprintf(dbuf, sizeof(dbuf),
+                       "%s/%s_%s.info",
+                       cinfo->dumppath, cinfo->processname, cinfo->timestr);
+       if (file_exist(cinfo->infofile) != 1)
+               return CW_RETURN_ERROR;
+       LOGDEBUG("libsys info from %s to %s\n", cinfo->infofile, dbuf);
+#ifdef INTERNAL_COPY_FUNC
+       if (copy_file(cinfo->infofile, dbuf) == 1) {
+               cinfo->b_info_file = 1;
+               return CW_RETURN_OK;
+       } else {
+               LOGWARN("copy failed\n");
+               return CW_RETURN_ERROR;
+       }
+#else
+       snprintf(cbuf, sizeof(cbuf),
+                       "cp %s %s", cinfo->infofile, dbuf);
+       ret = system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cbuf);
+       if (0 <= ret)
+               cinfo->b_info_file = 1;
+#endif
+       return CW_RETURN_OK;
+}
+/* get pakage information from ail or rpm */
+static cw_ret_type cw_get_pkg_info(struct crashinfo *cinfo)
+{
+       FILE *fp;
+       cw_ret_type ret = CW_RETURN_OK;
+       char cbuf[PATH_LEN] = {0, };
+
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       if (cinfo->b_app_id == 1) {
+               ail_filter_h f;
+               if (ail_filter_new(&f) != AIL_ERROR_OK)
+                       return CW_RETURN_ERROR;
+               if (ail_filter_add_str(f, AIL_PROP_EXEC_STR, cinfo->exepath)
+                               != AIL_ERROR_OK) {
+                       ail_filter_destroy(f);
+                       return CW_RETURN_ERROR;
+               }
+               fp = fopen(cinfo->pkginfofile, "w");
+               if(fp == NULL) {
+                       ail_filter_destroy(f);
+                       return  CW_RETURN_ERROR;
+               }
+               fseek(fp, 0L, SEEK_END);
+               fprintf(fp, "\n%s\n", CRASH_PACKAGEINFO_TITLE);
+               if (ail_filter_list_appinfo_foreach(f,
+                                       appinfo_list_func, (void *)fp)
+                               != AIL_ERROR_OK)
+                       ret = CW_RETURN_ERROR;
+               fclose(fp);
+               if (f)
+                       ail_filter_destroy(f);
+       } else {
+               fp = fopen(cinfo->pkginfofile, "w");
+               retvm_if(fp == NULL, CW_RETURN_INVALID_PARAMETER,
+                               "Failed to open %s\n", cinfo->pkginfofile);
+               fseek(fp, 0L, SEEK_END);
+               fprintf(fp, "\n%s\n", CRASH_PACKAGEINFO_TITLE);
+               fclose(fp);
+               snprintf(cbuf, sizeof(cbuf), "rpm -qif %s >> %s",
+                               cinfo->exepath, cinfo->pkginfofile);
+               LOGDEBUG("cbuf (%s)\n", cbuf);
+               if (system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cbuf) < 0)
+                       ret = CW_RETURN_ERROR;
+       }
+       return ret;
+}
+/* copy core dump file */
+static cw_ret_type cw_copy_coredump(struct crashinfo *cinfo)
+{
+       char sbuf[NAME_MAX] = {0, };
+       char dbuf[NAME_MAX] = {0, };
+       char cmdb[PATH_LEN] = {0, };
+
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       snprintf(sbuf, sizeof(sbuf), "%s/%s_*",
+                       CRASH_CORE_PATH, cinfo->pid);
+       snprintf(dbuf, sizeof(dbuf), "%s/%s_%s.coredump",
+                       cinfo->dumppath, cinfo->processname, cinfo->timestr);
+       LOGDEBUG("copy core dump from %s to %s\n", sbuf, dbuf);
+       snprintf(cmdb, sizeof(cmdb), "mv %s %s", sbuf, dbuf);
+       if (system(cmdb) < 0)
+               return CW_RETURN_ERROR;
+       return CW_RETURN_OK;
+}
+/* gather etc files with rule */
+static cw_ret_type cw_gather_etc_files(struct crashinfo *cinfo)
+{
+       int i;
+       char cbuf[PATH_LEN] = {0, };
+
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       for (i = 0; i < CW_GATHER_MAX; i++) {
+               if (g_crule[i].dump_on) {
+                       snprintf(cbuf, sizeof(cbuf), "%s%s%s",
+                                       g_crule[i].cmd, cinfo->dumppath, g_crule[i].dst);
+                       if (g_crule[i].log_type == CW_GATHER_SS)
+                               system(cbuf);
+                       else
+                               system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cbuf);
+                       LOGDEBUG("gather info (%s)\n", cbuf);
+                       memset(cbuf, 0, sizeof(cbuf));
+               }
+       }
+       return CW_RETURN_OK;
+}
+/* create and write report file */
+static cw_ret_type cw_write_report(struct crashinfo *cinfo)
+{
+       if (cinfo == NULL || cinfo->reportfile[0] == '\0')
+               return CW_RETURN_INVALID_PARAMETER;
+       LOGINFO("crash report file is %s\n", cinfo->reportfile);
+       /* create cs file */
+       cinfo->csfd = creat(cinfo->reportfile, FILE_PERMS);
+       if (cinfo->csfd < 0) {
+               LOGWARN("can't create %s. errno = %s\n",
+                               cinfo->reportfile, strerror(errno));
+               return CW_RETURN_ERROR;
+       }
+       chown(cinfo->reportfile, 0, 5000);
+       chmod(cinfo->reportfile, 0766);
+       if (cw_write_version_info(cinfo) != CW_RETURN_OK)
+               LOGWARN("can't write version info\n");
+       if (cw_write_crash_base_info(cinfo) != CW_RETURN_OK)
+               LOGWARN("can't write base info\n");
+#if 0
+       if (_write_mem_info(cinfo) < 0)
+               LOGERR("can't write mem info info\n");
+#endif
+       close(cinfo->csfd);
+       if (cinfo->b_info_file) {
+               if (cat_file(cinfo->infofile, cinfo->reportfile) < 0)
+                       LOGWARN("can't cat libsys info file\n");
+       }
+       if (cat_file(cinfo->pkginfofile, cinfo->reportfile) < 0)
+               LOGWARN("can't write pkg info\n");
+       if (cw_dump_dlog(cinfo) != CW_RETURN_OK) {
+               LOGWARN("can't cw_dump_dlog\n");
+       }
+       if (cinfo->b_dlog_dump) {
+               if (cw_write_dlogdump(cinfo) != CW_RETURN_OK)
+                       LOGWARN("can't write dlogdump\n");
+       }
+       return CW_RETURN_OK;
+}
+/* make dump tar file */
+static cw_ret_type cw_make_zip_file(struct crashinfo *cinfo)
+{
+       int ret = 0;
+       struct stat file_info;
+       char cmdb[PATH_LEN] = {0, };
+
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       snprintf(cmdb, sizeof(cmdb), "cp %s %s/%s_%s.cs",
+                       cinfo->reportfile, cinfo->dumppath, cinfo->app_id, cinfo->timestr);
+       ret = system_command_with_timeout(CRASH_SYSTEM_CMD_TIMEOUT, cmdb);
+       snprintf(cmdb, sizeof(cmdb), "tar zcf %s -C %s %s_%s",
+                       cinfo->dumpzipfile, CRASH_DUMP_PATH,
+                       cinfo->processname, cinfo->timestr);
+       ret = system(cmdb);
+       LOGDEBUG("compress(%s)\n", cmdb);
+       ret = stat(cinfo->dumpzipfile, &file_info);
+       retvm_if(ret < -1, -1, "Failed to tar (%s)\n", cinfo->dumpzipfile);
+       chown(cinfo->dumpzipfile, 0, 5000);
+       if (chmod(cinfo->dumpzipfile, 0766) < 0)
+               LOGWARN("can't chmod (%s)\n", cinfo->dumpzipfile);
+       else
+               LOGDEBUG("chmod (%s)\n", cinfo->dumpzipfile);
+       return ret;
+}
+/* remove libsys information file*/
+static cw_ret_type cw_clean(struct crashinfo *cinfo)
+{
+       if (cinfo == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       char cmdb[PATH_LEN] = {0, };
+       if (unlink(cinfo->infofile) < 0)
+               LOGWARN("can't unlink (%s)\n", cinfo->infofile);
+#ifdef CLEAR_DUMP_PATH
+       if (delete_dir_contents(cinfo->dumppath, 1, NULL) < 0) {
+               LOGWARN("can't delete_dir_contents (%s)\n", cinfo->dumppath);
+       }
+       if (cinfo->csfd)
+               close(cinfo->csfd);
+#endif
+       return CW_RETURN_OK;
+}
+/*
+ * clean work file(core dump and libsys info) and
+ * free previous list
+ */
+static void cw_exit(struct crashinfo *cinfo,
+               struct crashstatus *cstatus)
+{
+       if (cstatus == NULL || cinfo == NULL)
+               return;
+       cw_clean(cinfo);
+       _free_filelist(cstatus->reportlist, cstatus->n_pre_report);
+       _free_filelist(cstatus->ticketlist, cstatus->n_pre_ticket);
+       _free_filelist(cstatus->dumplist, cstatus->n_pre_dump);
+}
+/*
+ * add ticket which is notification file for mobile care
+ * It has dump and report file path
+ */
+static cw_ret_type cw_add_ticket(char *app_id, char *timestr,
+               char *reportfile, char *dumpfile)
+{
+       FILE *fp = NULL;
+       char path[PATH_LEN] = {0, };
+
+       if (app_id == NULL || timestr == NULL ||
+                       reportfile  == NULL || dumpfile  == NULL)
+               return CW_RETURN_INVALID_PARAMETER;
+       snprintf(path, sizeof(path), "%s/%s_%s.ct",
+                       CRASH_TICKET_PATH, app_id, timestr);
+       fp = fopen(path, "a+");
+       retvm_if(fp == NULL, CW_RETURN_ERROR, "Failed to fopen (%s)\n", path);
+       fprintf(fp, "%s\n", reportfile);
+       fprintf(fp, "%s\n", dumpfile);
+       fclose(fp);
+       chown(path, 0, 5000);
+       if (chmod(path, 0766) < 0)
+               LOGWARN("can't chmod (%s)\n", path);
+       else
+               LOGDEBUG("chmod (%s)\n", path);
+       return CW_RETURN_OK;
+}
+/* crash worker function */
+static void crash_worker(struct appdata *ad)
+{
+       retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
+       struct crashinfo *cinfo = &(ad->csinfo);
+       retm_if(cinfo == NULL, "can't get crashinfo pointer\n");
+       struct crashstatus *cstatus = &(ad->cstatus);
+       LOGWARN("crash_worker start(%s%s%s)\n",
+                       cinfo->modestr, cinfo->processname, cinfo->timesec);
+       LOGDEBUG("mode(%s)\n", cinfo->modestr);
+       LOGDEBUG("processname(%s)\n", cinfo->processname);
+       LOGDEBUG("time(%s)\n", cinfo->timestr);
+       LOGDEBUG("pid(%s)\n", cinfo->pid);
+       if (cinfo->mode == CW_MODE_COL)
+               LOGDEBUG("signal(%s)\n", cinfo->signal);
+       else
+               LOGDEBUG("exepath(%s)\n", cinfo->exepath);
+       if (cinfo->mode == CW_MODE_MOD) {
+               LOGDEBUG("modem crash work_thread_cb exited\n");
+               return;
+       }
+       if (cw_conf(cstatus) != CW_RETURN_OK)
+               LOGWARN("can't get crash worker configuration\n");
+
+       if (cw_check_mount_ready() != CW_RETURN_OK) {
+               LOGERR("can't cw_check_mount_ready\n");
+               return;
+       }
+       if (cw_init(cinfo, cstatus) != CW_RETURN_OK) {
+               LOGERR("can't cw_init\n");
+               return;
+       }
+       if (cw_make_dump_dir(cinfo) != CW_RETURN_OK) {
+               LOGERR("can't cw_make_dump_dir\n");
+               return;
+       }
+       if (cw_get_pkg_info(cinfo) != CW_RETURN_OK) {
+               LOGWARN("can't cw_get_pkg_info\n");
+       }
+       if (cw_get_libsys_info(cinfo) != CW_RETURN_OK) {
+               LOGWARN("can't cw_get_libsys_info\n");
+       }
+       if (cw_write_report(cinfo) != CW_RETURN_OK)
+               LOGWARN("can't cw_write_report\n");
+       if (cw_copy_coredump(cinfo) != CW_RETURN_OK)
+               LOGWARN("can't cw_copy_coredump\n");
+       if (cstatus->b_debug_mode == 1) {
+               if (cw_gather_etc_files(cinfo) != CW_RETURN_OK) {
+                       LOGWARN("can't cw_gather_info_files\n");
+               }
+       }
+       if (cstatus->b_debug_mode == 1) {
+               if (cw_make_zip_file(cinfo) != CW_RETURN_OK) {
+                       LOGWARN("can't cw_make_zip_file\n");
+               } else {
+                       if (cw_add_ticket(cinfo->app_id, cinfo->timestr,
+                                               cinfo->reportfile, cinfo->dumpzipfile)
+                                       != CW_RETURN_OK) {
+                               LOGWARN("can't _add_ticket (%s, %s)\n",
+                                               cinfo->reportfile, cinfo->dumpzipfile);
+                       }
+               }
+       }
+       cw_exit(cinfo, cstatus);
+       LOGWARN("crash_worker done\n");
+       return;
+}
+/* allocation appdata and check argument num and variable*/
+int main(int argc, char *argv[])
+{
+       int i;
+       time_t cur_time;
+       struct tm ctime;
+       struct appdata *ad = (struct appdata *)malloc(sizeof(struct appdata));
+       retvm_if(ad == NULL, -1, "can't alloc struct crasinfo\n");
+       struct crashinfo *cinfo = &(ad->csinfo);
+       LOGDEBUG("argc(%d)\n", argc);
+       if (argc < CRASH_ARG_NUM) {
+               LOGERR("argc is (%d) wrong argument\n", argc);
+               return -1;
+       }
+       if (CRASH_ARG_NUM < argc) {
+               LOGERR("argc is (%d) wrong argument\n", argc);
+               return -1;
+       }
+       for (i = 0; i < argc; i++) {
+               if (argv[i]) {
+                       LOGDEBUG("%d, %s\n", i, argv[i]);
+               } else {
+                       LOGERR("%d argument is NULL\n", i);
+                       return -1;
+               }
+       }
+       /* input crash info structure from arguments */
+       snprintf(cinfo->modestr, sizeof(cinfo->modestr), "%s", argv[1]);
+       switch (cinfo->modestr[0]) {
+       case 'S':
+               cinfo->mode = CW_MODE_SYA;
+               break;
+       case 'M':
+               cinfo->mode = CW_MODE_MOD;
+               break;
+       case 'C':
+               cinfo->mode = CW_MODE_COL;
+               break;
+       case 'A':
+               cinfo->mode = CW_MODE_API;
+               break;
+       default:
+               LOGERR("arg %s is wrong\n", cinfo->modestr);
+               return -1;
+       }
+       snprintf(cinfo->processname, sizeof(cinfo->processname), "%s", argv[2]);
+       _set_crash_time_info(cinfo, argv[3]);
+       snprintf(cinfo->pid, sizeof(cinfo->pid), "%s", argv[4]);
+       /*if it is launched from core-launcher
+          , 5' argument is signal information*/
+       if (cinfo->mode == CW_MODE_COL)
+               snprintf(cinfo->signal, sizeof(cinfo->signal), "%s", argv[5]);
+       else
+               snprintf(cinfo->exepath, sizeof(cinfo->exepath), "%s", argv[5]);
+       /* call crash_worker */
+       crash_worker(ad);
+       if (ad) {
+               free(ad);
+               ad = NULL;
+       }
+       return 0;
+}
diff --git a/crash-worker/crash-worker.h b/crash-worker/crash-worker.h
new file mode 100644 (file)
index 0000000..07e85e4
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * CRASH-WORKER
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 __CRASH_WORKER_H__
+#define __CRASH_WORKER_H__
+
+#define TIZEN_OPT_USR_MOUNT "/dev/mmcblk0p7"
+#define TIZEN_OPT_USR_TYPE "ext4"
+#define TIZEN_DEBUG_MODE_FILE "/opt/etc/.coredump"
+#define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
+#define FILE_PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
+
+#define VIP_PATH       "/tmp/vip"
+#define PERMANENT_PATH "/tmp/permanent"
+#define VERINFO_PATH   "/etc/info.ini"
+#define MEMINFO_PATH   "/proc/meminfo"
+
+#define CRASH_PID_MAX 7
+#define CRASH_MODE_MAX 2
+#define CRASH_SIGNAL_MAX 8
+#define CRASH_TIME_MAX 65
+#define CRASH_PROCESSNAME_MAX NAME_MAX
+#define PATH_LEN (NAME_MAX + NAME_MAX)
+
+#define CRASH_ARG_NUM 6
+#define CRASH_SYSTEM_CMD_TIMEOUT 10
+
+#define CRASH_CHECK_MOUNT_TRY_NUM 2
+#define CRASH_CHECK_MOUNT_WAIT_TIME 5
+#define CRASH_CHECK_DUMP_MAX_NUM 10
+#define CRASH_CHECK_REPORT_MAX_NUM 100
+#define CRASH_CHECK_SIZE (1024 * 512)
+
+#define CRASH_UNKNOWN  "unknown"
+#define CRASH_TEMP_LIST        "/tmp/.list"
+
+#define CRASH_CHECK_DISK_PATH  "/opt/usr"
+#define CRASH_SYSTEM_PATH      "/opt/share/crash"
+#define CRASH_INFO_PATH        "/opt/share/crash/info"
+
+#define CRASH_SAVE_PATH        "/opt/usr/share/crash"
+#define CRASH_CORE_PATH        "/opt/usr/share/crash/core"
+#define CRASH_TICKET_PATH      "/opt/usr/share/crash/ticket"
+#define CRASH_DUMP_PATH        "/opt/usr/share/crash/dump"
+#define CRASH_REPORT_PATH      "/opt/usr/share/crash/report"
+
+#define CRASH_CALLSTACKINFO_TITLE "Callstack Information"
+#define CRASH_CALLSTACKINFO_TITLE_E "End of Call Stack"
+#define CRASH_CRASHINFO_TITLE "Crash Information"
+#define CRASH_DLOG_TITLE "Latest Debug Message Information"
+#define CRASH_DLOG_TITLE_E "End of latest debug message"
+#define CRASH_PACKAGEINFO_TITLE "Package Information"
+#define CRASH_MAPSINFO_TITLE "Maps Information"
+#define CRASH_MAPSINFO_TITLE_E "End of Maps Information"
+#define CRASH_MEMINFO_TITLE "Memory Information"
+#define CRASH_REGISTERINFO_TITLE "Register Information"
+#define CRASH_SW_VERSIONINFO_TITLE "S/W Version Information"
+
+#define CRASH_MODE_STR_MOD "M" /* called modem */
+#define CRASH_MODE_STR_COL "C" /* called core launcher */
+#define CRASH_MODE_STR_SYA "S" /* called sys assert */
+#define CRASH_MODE_STR_API "A" /* called Tizen API */
+
+#ifndef __VCONF_INTERNAL_CRASH_KEYS_H__
+#define VCONFKEY_CRASH_AUTOSEND "db/crash/autosend"
+#define VCONFKEY_CRASH_AUTOCLOSE "db/crash/autoclose"
+#define VCONFKEY_CRASH_PROGRESS "db/crash/progress"
+#define VCONFKEY_CRASH_SENDFLAG "db/crash/sendflag"
+#define VCONFKEY_CRASH_POPUP "db/crash/popup"
+#endif
+
+typedef enum {
+       CW_RETURN_OK = 0,                       /**< General success */
+       CW_RETURN_ERROR = -1,                    /**< General error */
+       CW_RETURN_INVALID_PARAMETER = -2,       /**< Invalid parameter */
+       CW_RETURN_OUT_OF_MEMORY = -3,           /**< Out of memory */
+} cw_ret_type;
+
+typedef enum {
+       CW_MODE_MOD = 0x4D,      /**<called modem*/
+       CW_MODE_COL = 0x43,     /**< called core-launcher*/
+       CW_MODE_SYA = 0x53,     /**<called libsys-assert */
+       CW_MODE_API = 0x41,     /** called API */
+} cw_mode_type;
+
+typedef enum {
+       CW_GATHER_DLOG = 0, /* dlog */
+       CW_GATHER_PS = 1, /* ps */
+       CW_GATHER_MEMPS = 2, /* memps */
+       CW_GATHER_TOP = 3, /* top */
+       CW_GATHER_CP = 4, /* CP crash log */
+       CW_GATHER_SS = 5, /* screen shot */
+       CW_GATHER_KL = 6, /* kernel log */
+       CW_GATHER_RL = 7, /* radio log */
+       CW_GATHER_XL = 8, /* Xorg log */
+       CW_GATHER_MAX,
+} cw_gather_log_type;
+
+typedef struct
+{
+       cw_gather_log_type log_type;
+       int dump_on;
+       const char *cmd;
+       const char *dst;
+} cw_gather_log_rule;
+
+struct crashstatus
+{
+       int b_debug_mode;
+       int b_disk_avail;
+       int b_wifi_avail;
+       int n_pre_dump;
+       int n_pre_report;
+       int n_pre_ticket;
+       struct dirent **dumplist;
+       struct dirent **reportlist;
+       struct dirent **ticketlist;
+};
+
+struct crashinfo
+{
+       int csfd;
+       int b_app_id;
+       int b_core_dump;
+       int b_info_file;
+       int b_dlog_dump;
+       time_t crash_time;
+       struct tm crash_tm;
+/* crash_worker arguments */
+       char modestr[CRASH_MODE_MAX];
+       char processname[CRASH_PROCESSNAME_MAX];
+       char timesec[CRASH_TIME_MAX];
+       char pid[CRASH_PID_MAX];
+       char exepath[PATH_LEN];
+       char signal[CRASH_SIGNAL_MAX];
+
+       cw_mode_type mode;
+       char app_id[CRASH_PROCESSNAME_MAX];
+       char timestr[CRASH_TIME_MAX];
+       char dumppath[PATH_LEN];
+       char dumpzipfile[PATH_LEN];
+       char reportfile[NAME_MAX];
+       char infofile[NAME_MAX];
+       char pkginfofile[NAME_MAX];
+
+#ifdef SEND_FUNC_ENABLE
+       char modelname[NAME_MAX];
+       char version[NAME_MAX];
+       char buildinfo[PATH_LEN];
+       char methodinfo[PATH_LEN];
+       char lastcallstackinfo[PATH_LEN];
+#endif
+       /* add more variables here */
+};
+
+struct appdata
+{
+       struct crashstatus cstatus;
+       struct crashinfo csinfo;
+};
+#endif
+/* __CRASH_WORKER_H__ */
+
diff --git a/crash-worker/util.c b/crash-worker/util.c
new file mode 100644 (file)
index 0000000..48467db
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * CRASH-WORKER
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <limits.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
+#include <wait.h>
+#include "util.h"
+
+int writepid(char *pidpath)
+{
+       FILE *fp;
+
+       fp = fopen(pidpath, "w");
+       if (fp != NULL) {
+               fprintf(fp, "%d", getpid());
+               fclose(fp);
+       }
+       return 0;
+}
+
+/**
+ * @brief read the pid
+ *
+ * get a pid and write it to pidpath
+ *
+ * @param[in] pidpath pid file path
+ * @return  pid : success, -1 : failed
+ */
+int readpid(char *pidpath)
+{
+       FILE *fp;
+       int ret = -1;
+
+       fp = fopen(pidpath, "r");
+       if (fp != NULL) {
+               fscanf(fp, "%5d", &ret);
+               fclose(fp);
+       }
+       return ret;
+}
+/**
+ * @brief MANAGERize function
+ *
+ * fork the process, kill the parent process
+ * and replace all the standard fds to /dev/null.
+ *
+ * @return 0 : success, -1 : fork() error
+ */
+int daemonize(void)
+{
+       pid_t pid;
+
+       pid = fork();
+       if (pid < 0)
+               return -1;
+       else if (pid != 0)
+               exit(0);
+       setsid();
+       chdir("/");
+       close(0);
+       close(1);
+       close(2);
+       open("/dev/null", O_RDONLY);
+       open("/dev/null", O_RDWR);
+       dup(1);
+       return 0;
+}
+/**
+ * @brief  function to run a process
+ *
+ * fork the process, and run the other process if it is child.
+ *
+ * @return new process pid on success, -1 on error
+ */
+int exec_process(char *name)
+{
+       int ret, pid;
+       int i;
+
+       if (name[0] == '\0')
+               return 0;
+       pid = fork();
+       switch (pid) {
+       case -1:
+               LOGERR("Fork error");
+               ret = -1;
+               break;
+       case 0:
+               for (i = 0; i < _NSIG; i++)
+                       signal(i, SIG_DFL);
+               execlp(name, name, NULL);
+               LOGERR("execlp() error : %s\n", strerror(errno));
+               exit(-1);
+               break;
+       default:
+               ret = pid;
+               break;
+       }
+       return ret;
+}
+int system_command(char *command)
+{
+       int pid = 0,
+               status = 0;
+       const char *environ[] = { NULL };
+
+       if (command == NULL)
+               return -1;
+       pid = fork();
+       if (pid == -1)
+               return -1;
+       if (pid == 0) {
+               char *argv[4];
+               argv[0] = "sh";
+               argv[1] = "-c";
+               argv[2] = (char *)command;
+               argv[3] = 0;
+               execve("/bin/sh", argv, (char **)environ);
+               exit(127);
+       }
+       do {
+               if (waitpid(pid, &status, 0) == -1) {
+                       if (errno != EINTR)
+                               return -1;
+               } else {
+                       return status;
+               }
+       } while (1);
+
+       return status;
+}
+int system_command_with_timeout(int timeout_seconds, char *command)
+{
+       const char *environ[] = { NULL };
+
+       if (command == NULL)
+               return -1;
+       clock_t start = clock();
+       pid_t pid = fork();
+       /* handle error case */
+       if (pid < 0) {
+               LOGERR("fork: %s\n", strerror(errno));
+               return pid;
+       }
+       /* handle child case */
+       if (pid == 0) {
+               char *argv[4];
+               argv[0] = "sh";
+               argv[1] = "-c";
+               argv[2] = (char *)command;
+               argv[3] = 0;
+
+               execve("/bin/sh", argv, (char **)environ);
+               LOGINFO("exec(%s): %s\n", command, strerror(errno));
+               _exit(-1);
+       }
+       /* handle parent case */
+       for (;;) {
+               int status;
+               pid_t p = waitpid(pid, &status, WNOHANG);
+               float elapsed = (float) (clock() - start) / CLOCKS_PER_SEC;
+               if (p == pid) {
+                       if (WIFSIGNALED(status))
+                               LOGINFO("%s: Killed by signal %d\n", command, WTERMSIG(status));
+                       else if (WIFEXITED(status) && WEXITSTATUS(status) > 0)
+                               LOGINFO("%s: Exit code %d\n", command, WEXITSTATUS(status));
+                       return status;
+               }
+               if (timeout_seconds && elapsed > timeout_seconds) {
+                       LOGINFO("%s: Timed out after %.1fs (killing pid %d)\n",
+                                       command, elapsed, pid);
+                       kill(pid, SIGTERM);
+                       return -1;
+               }
+               /* poll every 0.1 sec */
+               usleep(100000);
+       }
+}
+int run_command(int timeout_seconds, const char *command, ...)
+{
+       clock_t start = clock();
+       pid_t pid = fork();
+
+       /* handle error case */
+       if (pid < 0) {
+               LOGERR("fork: %s\n", strerror(errno));
+               return pid;
+       }
+
+       /* handle child case */
+       if (pid == 0) {
+               const char *args[1024] = {command};
+               size_t arg;
+
+               va_list ap;
+               va_start(ap, command);
+               for (arg = 1; arg < sizeof(args) / sizeof(args[0]); ++arg) {
+                       args[arg] = va_arg(ap, const char *);
+                       if (args[arg] == NULL)
+                               break;
+               }
+               execvp(command, (char **) args);
+               LOGINFO("exec(%s): %s\n", command, strerror(errno));
+               _exit(-1);
+       }
+       /* handle parent case */
+       for (;;) {
+               int status;
+               pid_t p = waitpid(pid, &status, WNOHANG);
+               float elapsed = (float) (clock() - start) / CLOCKS_PER_SEC;
+               if (p == pid) {
+                       if (WIFSIGNALED(status))
+                               LOGINFO("%s: Killed by signal %d\n", command, WTERMSIG(status));
+                       else if (WIFEXITED(status) && WEXITSTATUS(status) > 0)
+                               LOGINFO("%s: Exit code %d\n", command, WEXITSTATUS(status));
+                       return status;
+               }
+               if (timeout_seconds && elapsed > timeout_seconds) {
+                       LOGINFO("%s: Timed out after %.1fs (killing pid %d)\n",
+                                       command, elapsed, pid);
+                       kill(pid, SIGTERM);
+                       return -1;
+               }
+               /* poll every 0.1 sec */
+               usleep(100000);
+       }
+}
+char *fgets_fd(char *s, int n, int fd)
+{
+       char c;
+       register char *cs;
+       int num = 0;
+
+       cs = s;
+       while (--n > 0 && (num = read(fd, &c, 1) > 0)) {
+               if ((*cs++ = c) == '\n')
+                       break;
+       }
+       *cs = '\0';
+       return (num == 0 && cs == s) ? NULL : s;
+}
+
+/* WARNING : formatted string buffer is limited to 1024 byte */
+int fprintf_fd(int fd, const char *fmt, ...)
+{
+       int n;
+       int ret;
+       char buff[1024];
+       va_list args;
+
+       va_start(args, fmt);
+       n = vsnprintf(buff, 1024 - 1, fmt, args);
+       ret = write(fd, buff, n);
+       va_end(args);
+       return ret;
+}
+int file_exist(const char *file)
+{
+       FILE *fp;
+
+       fp = fopen(file, "r");
+       if (fp == NULL)
+               return -1;
+       fclose(fp);
+       return 1;
+}
+int write_fd(int fd, const void *buf, int len)
+{
+       int count;
+       int total;
+       total = 0;
+       while (len) {
+               count = write(fd, buf, len);
+               if (count < 0) {
+                       if (total)
+                               return total;
+                       return count;
+               }
+               total += count;
+               buf = ((const char *)buf) + count;
+               len -= count;
+       }
+       return total;
+}
+int copy_file(char *src, char *dst)
+{
+       int sfd;
+       int dfd;
+       char buf[PIPE_BUF];
+
+       retvm_if(src == NULL, -1, "Invalid argument: source is NULL\n");
+       retvm_if(dst == NULL, -1, "Invalid argument: destination is NULL\n");
+       sfd = open(src, O_RDONLY);
+       if (sfd < 0) {
+               LOGERR("Failed to open (%s)\n", src);
+               return -1;
+       }
+       dfd = open(dst, O_WRONLY|O_CREAT|O_EXCL, 0644);
+       if (dfd < 0) {
+               close(sfd);
+               LOGERR("Failed to open (%s)\n", dst);
+               return -1;
+       }
+       for (;;) {
+               int ret = read(sfd, buf, sizeof(buf));
+               if (ret > 0)
+                       ret = write_fd(dfd, buf, ret);
+               if (ret <= 0)
+                       break;
+       }
+       close(sfd);
+       close(dfd);
+       LOGINFO("copy (%s) to (%s)\n", src, dst);
+       return 1;
+}
+int cat_file(char *src, char *dst)
+{
+       int sfd;
+       int dfd;
+       char buf[PIPE_BUF];
+
+       retvm_if(src == NULL, -1, "Invalid argument: source is NULL\n");
+       retvm_if(dst == NULL, -1, "Invalid argument: destination is NULL\n");
+       sfd = open(src, O_RDONLY);
+       if (sfd < 0) {
+               LOGERR("Failed to open (%s)\n", src);
+               return -1;
+       }
+       dfd = open(dst, O_WRONLY|O_APPEND);
+       if (dfd < 0) {
+               close(sfd);
+               LOGERR("Failed to open (%s)\n", dst);
+               return -1;
+       }
+       for (;;) {
+               int ret = read(sfd, buf, sizeof(buf));
+               if (ret > 0)
+                       ret = write_fd(dfd, buf, ret);
+               if (ret <= 0)
+                       break;
+       }
+       close(sfd);
+       close(dfd);
+       LOGINFO("copy (%s) to (%s)\n", src, dst);
+       return 1;
+}
+int get_file_end_pos(char *file)
+{
+       int pos = 0;
+       FILE *fp = NULL;
+
+       fp = fopen(file, "r+");
+       retvm_if(fp == NULL, -1, "Failed to open %s\n", file);
+       fseek(fp, 0L, SEEK_END);
+       pos = ftell(fp);
+       if (fp)
+               fclose(fp);
+       return pos;
+}
+static int _delete_dir_contents(DIR *d, const char *ignore)
+{
+       int result = 0;
+       struct dirent *de;
+       int dfd;
+
+       dfd = dirfd(d);
+       if (dfd < 0)
+               return -1;
+       while ((de = readdir(d))) {
+               const char *name = de->d_name;
+               /* skip the ignore name if provided */
+               if (ignore && !strcmp(name, ignore))
+                       continue;
+               if (de->d_type == DT_DIR) {
+                       int subfd;
+                       DIR *subdir;
+                       /* always skip "." and ".." */
+                       if (name[0] == '.') {
+                               if (name[1] == 0)
+                                       continue;
+                               if ((name[1] == '.') && (name[2] == 0))
+                                       continue;
+                       }
+                       subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+                       if (subfd < 0) {
+                               LOGERR("Couldn't openat %s: %s\n", name, strerror(errno));
+                               result = -1;
+                               continue;
+                       }
+                       subdir = fdopendir(subfd);
+                       if (subdir == NULL) {
+                               LOGERR("Couldn't fdopendir %s: %s\n", name, strerror(errno));
+                               close(subfd);
+                               result = -1;
+                               continue;
+                       }
+                       if (_delete_dir_contents(subdir, 0))
+                               result = -1;
+                       closedir(subdir);
+                       if (unlinkat(dfd, name, AT_REMOVEDIR) < 0) {
+                               LOGERR("Couldn't unlinkat %s: %s\n", name, strerror(errno));
+                               result = -1;
+                       }
+               } else {
+                       if (unlinkat(dfd, name, 0) < 0) {
+                               LOGE("Couldn't unlinkat %s: %s\n", name, strerror(errno));
+                               result = -1;
+                       }
+               }
+       }
+       return result;
+}
+int delete_dir_contents(const char *pathname,
+               int also_delete_dir,
+               const char *ignore)
+{
+       int res = 0;
+       DIR *d;
+
+       d = opendir(pathname);
+       if (d == NULL) {
+               LOGERR("Couldn't opendir %s: %s\n", pathname, strerror(errno));
+               return -errno;
+       }
+       res = _delete_dir_contents(d, ignore);
+       closedir(d);
+       if (also_delete_dir) {
+               if (rmdir(pathname)) {
+                       LOGERR("Couldn't rmdir %s: %s\n", pathname, strerror(errno));
+                       res = -1;
+               }
+       }
+       return res;
+}
+/**
+ * @}
+ */
diff --git a/crash-worker/util.h b/crash-worker/util.h
new file mode 100644 (file)
index 0000000..b03d425
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * CRASH-WORKER
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 __DEF_UTIL_H__
+#define __DEF_UTIL_H__
+
+#include "util_log.h"
+/**
+ * @addtogroup CRASH_MANAGER
+ * @{
+ */
+
+/*
+ * @brief write the pid
+ *
+ * get a pid and write it to pidpath
+ *
+ * @param[in] pidpath pid file path
+ * @return 0 (always)
+ */
+extern int writepid(char *pidpath);
+
+/*
+ * @brief read the pid
+ *
+ * get a pid and write it to pidpath
+ *
+ * @param[in] pidpath pid file path
+ * @return  pid : success, -1 : failed
+ */
+extern int readpid(char *pidpath);
+
+/*
+ * @brief MANAGERize function 
+ *
+ * fork the process, kill the parent process 
+ * and replace all the standard fds to /dev/null.
+ *
+ * @return 0 : success, -1 : fork() error
+ */
+extern int daemonize(void);
+
+/**
+ * @brief  function to run a process
+ *
+ * fork the process, and run the other process if it is child.
+ *
+ * @return new process pid on success, -1 on error
+ */
+extern int exec_process(char *name);
+
+extern int system_command(char *command);
+
+extern int system_command_with_timeout(int timeout_seconds, char *command);
+
+extern int run_command(int timeout_seconds, const char *command, ...);
+
+extern char *fgets_fd(char *s, int n, int fd);
+
+extern int fprintf_fd(int fd, const char *fmt, ...);
+
+extern int file_exist(const char *file);
+
+extern int write_fd(int fd, const void *buf, int len);
+
+extern int copy_file(char *src, char *dst);
+
+extern int cat_file(char *src, char *dst);
+
+extern int get_file_end_pos(char *file);
+
+extern int delete_dir_contents(const char *pathname, int also_delete_dir, const char *ignore);
+
+/**
+ * @}
+ */
+#endif
diff --git a/crash-worker/util_log.h b/crash-worker/util_log.h
new file mode 100644 (file)
index 0000000..462294e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * CRASH-WORKER
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+ *
+ * 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 __CRASH_WORKER_UTIL_LOG_H__
+#define __CRASH_WORKER_UTIL_LOG_H__
+
+#include <unistd.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "CRASH_WORKER"
+
+#ifdef DEBUG_LOG_ON
+#define LOGDEBUG(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#else
+#define LOGDEBUG(fmt, arg...) ((void)0)
+#endif
+
+#define LOGINFO(fmt, arg...) LOGI("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define LOGWARN(fmt, arg...) LOGW("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define LOGERR(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if(expr) { \
+               LOGERR(fmt, ##arg); \
+               LOGERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if(expr) { \
+               LOGERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if(expr) { \
+               LOGERR(fmt, ##arg); \
+               LOGERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define ret_if(expr) do { \
+       if(expr) { \
+               LOGERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+
+#endif
+/* __CRASH_WORKER_UTIL_LOG_H__ */
diff --git a/data/org.tizen.crash-popup.png b/data/org.tizen.crash-popup.png
new file mode 100755 (executable)
index 0000000..5e2ed60
Binary files /dev/null and b/data/org.tizen.crash-popup.png differ
diff --git a/data/org.tizen.crash-popup.xml b/data/org.tizen.crash-popup.xml
new file mode 100644 (file)
index 0000000..f67671d
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.crash-popup" version="0.1.2" install-location="internal-only">
+       <label>crash-popup</label>
+       <description>Crash-popup Application</description>
+       <ui-application appid="org.tizen.crash-popup" exec="/usr/apps/org.tizen.crash-popup/bin/crash-popup" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+               <icon>org.tizen.crash-popup.png</icon>
+               <label>crash-popup</label>
+       </ui-application>
+</manifest>
diff --git a/edcs/crash-popup.edc b/edcs/crash-popup.edc
new file mode 100644 (file)
index 0000000..5c1bdd9
--- /dev/null
@@ -0,0 +1,140 @@
+#define FONT_NAME "GP45_ArabCJK_TouchWiz"
+
+collections {
+       group {
+               name, "main";
+
+               parts {
+                       part { name, "background";
+                               type, RECT;
+                               description {
+                                       state, "default" 0.0;
+                                       color, 0 0 0 255;
+                               }
+                       }
+
+                       part { name, "txt_title";
+                               type, TEXT;
+                               mouse_events, 0;
+                               description {
+                                       state, "default" 0.0;
+                                       rel1 { relative, 0.0 0.0; to, background; }
+                                       rel2 { relative, 1.0 0.5; to, background; }
+                                       text { font, FONT_NAME; size, 30; align, 0.5 0.5; }
+                                       color, 255 255 255 255;
+                               }
+                       }
+
+                       part { name, "txt_mesg";
+                               type, TEXT;
+                               mouse_events, 0;
+                               description {
+                                       state, "default" 0.0;
+                                       rel1 { relative, 0.0 0.5; to, background; }
+                                       rel2 { relative, 1.0 1.0; to, background; }
+                                       text { font, FONT_NAME; size, 30; align, 0.5 0.5; }
+                                       color, 255 255 255 255;
+                               }
+                       }
+               }
+
+               programs {
+                       program {
+                               name, "click_exit";
+                               source, "background";
+                               signal, "mouse,clicked,1";
+                               action, SIGNAL_EMIT "EXIT" "EDJ";
+                       }
+               }
+       }
+
+
+group {
+      name: "autoscroll_conform";
+      parts{
+         part {
+            name: "bg";
+            type: RECT;
+            mouse_events: 1;
+            scale:1;
+            description {
+               state: "default" 0.0;
+               color: 0 0 0 0;
+               rel1.relative: 0.0 0.0;
+               rel2.relative: 1.0 1.0;
+            }
+         }
+         part{
+            name: "top_padding";
+            type: RECT;
+            scale: 1; //allow scaling
+            description {
+               state: "default" 0.0;
+               visible: 0;
+               min : 0 1; //minimum size for gap filler
+               fixed: 0 1;
+               rel1 {
+                  relative: 0.0 0.0;
+                  to:bg;
+               }
+               rel2 {
+                  relative: 1.0 0.0;
+                  to:bg;
+               }
+            }
+          }
+          part {
+            name: "left_padding";
+            type: RECT;
+            scale: 1;
+            description {
+               state: "default" 0.0;
+               visible: 0;
+               min : 0 0; //minimum size for gap filler
+               fixed: 1 0;
+               rel1 {
+                  relative: 0.0 0.0;
+                  to: "bg";
+               }
+               rel2 {
+                  relative: 0.0 1.0;
+                  to: "bg";
+               }
+               align: 0.0 0.0;
+            }
+         }
+          part {
+            name: "bg_conform";
+            type: RECT;
+            mouse_events: 0;
+            scale:1;
+            description {
+               state: "default" 0.0;
+               visible: 0;
+               rel1 {
+                  relative: 0.0 1.0;
+                  to_y:top_padding;
+               }
+               align: 0.0 0.0;
+            }
+         }
+         part {
+            name: "conform_part";
+            type: SWALLOW;
+            mouse_events: 1;
+            scale:1;
+            description {
+               fixed: 1 1;
+               state: "default" 0.0;
+               rel1 {
+                  relative: 1.0 0.0;
+                  to_x:left_padding;
+                  to_y:bg_conform;
+               }
+               align: 0.0 0.0;
+            }
+         }
+      }
+   }
+
+}
diff --git a/packaging/crash-worker-sdk.manifest b/packaging/crash-worker-sdk.manifest
new file mode 100644 (file)
index 0000000..a7573ab
--- /dev/null
@@ -0,0 +1,22 @@
+<manifest>
+       <define>
+               <domain name="crash-worker"/>
+       <request>
+               <smack request="sys-assert::core" type="rwxat" />
+               <smack request="system::app_logging" type="rwxat" />
+               <smack request="system::homedir" type="rwxat" />
+               <smack request="system::vconf" type="rwxat" />
+               <smack request="system::media" type="rwxat" />
+               <smack request="system::share" type="rwxat" />
+               <smack request="system::use_internet" type="r" />
+               <smack request="ail::db" type="rw" />
+               <smack request="dbus" type="rwx" />
+       </request>
+       </define>
+       <request>
+               <domain name="crash-worker"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/bin/all_log_dump.sh" label="_" exec_label="none"/>
+       </assign>
+</manifest>
diff --git a/packaging/crash-worker-sdk.spec b/packaging/crash-worker-sdk.spec
new file mode 100644 (file)
index 0000000..f726bdf
--- /dev/null
@@ -0,0 +1,112 @@
+Name:      crash-worker-sdk
+Summary:    Crash-worker-sdk
+Version: 0.1.3
+Release:    3
+Group:      Framework/system
+License:    Apache License, Version 2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1001:    crash-worker-sdk.manifest
+Source1002:    org.tizen.crash-popup.manifest
+BuildRequires:  pkgconfig(appcore-common)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(ecore-imf)
+BuildRequires:  pkgconfig(ecore-file)
+BuildRequires:  pkgconfig(ecore-x)
+BuildRequires:  pkgconfig(ecore-input)
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(ecore-evas)
+BuildRequires:  pkgconfig(evas)
+BuildRequires:  pkgconfig(edje)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(utilX)
+BuildRequires:  pkgconfig(heynoti)
+BuildRequires:  pkgconfig(iniparser)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(ail)
+
+BuildRequires:  cmake
+BuildRequires:  edje-tools
+BuildRequires:  gettext-devel
+
+Requires: sys-assert
+Requires(post):   /usr/bin/vconftool
+Requires(post): coreutils
+%description
+crash-worker
+
+%package -n org.tizen.crash-popup
+Summary:    crash-popup application
+Group:      main
+Requires:   %{name} = %{version}-%{release}
+
+%description -n org.tizen.crash-popup
+crash-popup application
+
+%prep
+%setup -q
+
+%build
+cp %{SOURCE1001} .
+cp %{SOURCE1002} .
+%define DEBUG_LOG_ON 1
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/usr/share/license
+
+%post
+mkdir -p /opt/usr/share/crash/report
+chown root:crash /opt/usr/share/crash/report
+chmod 775 /opt/usr/share/crash/report
+
+chown root:crash /opt/usr/share/crash
+chmod 775 /opt/usr/share/crash
+
+mkdir -p /opt/usr/share/crash/core
+chown root:crash /opt/usr/share/crash/core
+chmod 775 /opt/usr/share/crash/core
+
+mkdir -p /opt/usr/share/crash/dump
+chown root:crash /opt/usr/share/crash/dump
+chmod 775 /opt/usr/share/crash/dump
+
+mkdir -p /opt/usr/share/crash/ticket
+chown root:crash /opt/usr/share/crash/ticket
+chmod 775 /opt/usr/share/crash/ticket
+
+if [ -f %{_libdir}/rpm-plugins/msm.so ]; then
+       find /opt/usr/share/crash -print0 | xargs -0 chsmack -a 'sys-assert::core'
+       find /opt/usr/share/crash -type d -print0 | xargs -0 chsmack -t
+fi
+
+vconftool set -t int db/crash/popup "1" -f
+vconftool set -t int db/crash/autoclose "0" -f
+vconftool set -t int db/crash/autosend "1" -f
+vconftool set -t int db/crash/progress "0" -f
+vconftool set -t int db/crash/sendflag "0" -f
+%postun
+
+%files
+%manifest crash-worker-sdk.manifest
+%defattr(-,root,root,-)
+/usr/bin/crash-worker
+/usr/share/license/crash-worker
+%attr(0744,root,root)/usr/bin/all_log_dump.sh
+
+
+%files -n org.tizen.crash-popup
+%manifest org.tizen.crash-popup.manifest
+%defattr(-,root,root,-)
+/usr/share/packages/org.tizen.crash-popup.xml
+/usr/share/icons/default/small/org.tizen.crash-popup.png
+/usr/apps/org.tizen.crash-popup/bin/crash-popup
+/usr/apps/org.tizen.crash-popup/res/edje/crash-popup.edj
+/usr/apps/org.tizen.crash-popup/res/locale/*/LC_MESSAGES/crash-popup.mo
+/usr/share/license/crash-popup
diff --git a/packaging/org.tizen.crash-popup.manifest b/packaging/org.tizen.crash-popup.manifest
new file mode 100644 (file)
index 0000000..c995665
--- /dev/null
@@ -0,0 +1,33 @@
+<manifest>
+       <define>
+               <domain name="crash-popup"/>
+               <request>
+                       <smack request="sys-assert::core" type="rwxat" />
+                       <smack request="system::app_logging" type="rwxat" />
+                       <smack request="system::homedir" type="rwxat" />
+                       <smack request="system::vconf" type="rwxat" />
+                       <smack request="system::media" type="rwxat" />
+                       <smack request="system::share" type="rwxat" />
+                       <smack request="pulseaudio" type="rwxat" />
+                       <smack request="system::use_internet" type="r" />
+                       <smack request="ail::db" type="rw" />
+                       <smack request="isf" type="rx" />
+                       <smack request="xorg" type="w" />
+                       <smack request="sound_server" type="rw" />
+                       <smack request="com.samsung.indicator" type="rw" />
+                       <smack request="com.samsung.setting" type="rwx" />
+                       <smack request="dbus" type="rwx" />
+               </request>
+               <permit>
+                       <smack permit="e17" type="rw" />
+                       <smack permit="com.samsung.app-tray" type="rx" />
+                       <smack permit="com.samsung.setting" type="rwxat" />
+               </permit>
+       </define>
+       <request>
+               <domain name="crash-popup"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/share/icons/default/small/org.tizen.crash-popup.png" label="_" exec_label="none"/>
+       </assign>
+</manifest>