summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:46:41 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:46:41 +0900
commit148959c2ec0e202910c578064f8da39ee95fb608 (patch)
tree10e31e61be138965b02d375d438d193e1ff8bb93
parent40f0c22bd3903e4260b8cc7f756fdc07b2522f6a (diff)
downloadstatus-148959c2ec0e202910c578064f8da39ee95fb608.tar.gz
status-148959c2ec0e202910c578064f8da39ee95fb608.tar.bz2
status-148959c2ec0e202910c578064f8da39ee95fb608.zip
Tizen 2.1 base
-rw-r--r--CMakeLists.txt61
-rwxr-xr-xLICENSE204
-rw-r--r--debian/changelog7
-rw-r--r--debian/compat1
-rw-r--r--debian/control25
-rw-r--r--debian/dirs0
-rw-r--r--debian/libstatus-dev.install.in2
-rw-r--r--debian/libstatus.install.in1
-rw-r--r--debian/libstatus.postinst.in13
-rwxr-xr-xdebian/rules114
-rwxr-xr-xinclude/status-internal.h53
-rwxr-xr-xinclude/status-monitor.h103
-rwxr-xr-xinclude/status-type.h72
-rwxr-xr-xinclude/status.h61
-rwxr-xr-xinclude/status_log.h77
-rwxr-xr-xpackaging/status.spec68
-rwxr-xr-xsrc/status-monitor.c388
-rwxr-xr-xsrc/status.c104
-rw-r--r--status-monitor.pc.in11
-rwxr-xr-xstatus.manifest5
-rw-r--r--status.pc.in11
-rw-r--r--test/Makefile3
-rwxr-xr-xtest/monitor_test.c267
-rwxr-xr-xtest/post_test.c223
24 files changed, 1874 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..88c724f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,61 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(status C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR "\${exec_prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.0.1")
+
+SET(CMAKE_SKIP_BUILD_RPATH true)
+
+SET(INSTALL_HEADERS
+ status.h
+ status-type.h
+ status-monitor.h
+)
+
+SET(SUBMODULES
+ status
+ status-monitor
+)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
+ vconf
+ aul
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -O2")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DSTATUS_USE_DLOG")
+
+FOREACH(lib_file ${SUBMODULES})
+ ADD_LIBRARY(${lib_file} SHARED src/${lib_file}.c)
+ TARGET_LINK_LIBRARIES(${lib_file} ${pkgs_LDFLAGS})
+ SET_TARGET_PROPERTIES(${lib_file} PROPERTIES SOVERSION ${VERSION_MAJOR})
+ SET_TARGET_PROPERTIES(${lib_file} PROPERTIES VERSION ${VERSION})
+ INSTALL(TARGETS ${lib_file} DESTINATION lib COMPONENT RuntimeLibraries)
+ENDFOREACH(lib_file)
+
+FOREACH(pcfile ${SUBMODULES})
+ CONFIGURE_FILE(${pcfile}.pc.in ${pcfile}.pc @ONLY)
+ SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${pcfile}.pc")
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pcfile}.pc DESTINATION lib/pkgconfig)
+ENDFOREACH(pcfile)
+
+FOREACH(hfile ${INSTALL_HEADERS})
+ INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/${hfile} DESTINATION include/${PROJECT_NAME})
+ENDFOREACH(hfile)
+
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..a06208b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ 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/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..d242148
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,7 @@
+status (0.0.1-1) unstable; urgency=low
+
+ * Initial Release.
+ * Git: slp/pkgs/s/status
+ * Tag: status_0.0.1-1
+
+ -- Jeonghoon Park <jh1979.park@samsung.com> Mon, 27 Feb 2012 14:14:00 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..bb9ac6f
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,25 @@
+Source: status
+Section: libs
+Priority: optional
+Maintainer: Jeonghoon Park <jh1979.park@samsung.com>, Young-joo Park <yjoo93.park@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libslp-setting-dev, libaul-1-dev
+Standards-Version: 3.7.2
+
+Package: libstatus
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Status supporting library (shared object)
+
+Package: libstatus-dev
+Section: libs
+Architecture: any
+Depends: libstatus (= ${Source-Version})
+Description: Status supporting library (development)
+
+Package: libstatus-dbg
+Section: debug
+Architecture: any
+Depends: ${misc:Depends}, libstatus (= ${Source-Version})
+Description: Status supporting library (unstripped)
+
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/dirs
diff --git a/debian/libstatus-dev.install.in b/debian/libstatus-dev.install.in
new file mode 100644
index 0000000..1bc0c16
--- /dev/null
+++ b/debian/libstatus-dev.install.in
@@ -0,0 +1,2 @@
+@PREFIX@/include/@PROJECT_NAME@/*.h
+@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/libstatus.install.in b/debian/libstatus.install.in
new file mode 100644
index 0000000..bf766f0
--- /dev/null
+++ b/debian/libstatus.install.in
@@ -0,0 +1 @@
+@PREFIX@/lib/*.so*
diff --git a/debian/libstatus.postinst.in b/debian/libstatus.postinst.in
new file mode 100644
index 0000000..c203d4f
--- /dev/null
+++ b/debian/libstatus.postinst.in
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ${USER} = "root" ]
+then
+ vconftool set -t int memory/private/libstatus/music/state 0 -i -u 5000
+ vconftool set -t int memory/private/libstatus/radio/state 0 -i -u 5000
+ vconftool set -t int memory/private/libstatus/vr/state 0 -i -u 5000
+ vconftool set -t int memory/private/libstatus/music/pid -1 -i -u 5000
+ vconftool set -t int memory/private/libstatus/radio/pid -1 -i -u 5000
+ vconftool set -t int memory/private/libstatus/vr/pid -1 -i -u 5000
+ vconftool set -t string memory/private/libstatus/message "" -i -u 5000
+fi
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..29c3de4
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,114 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -Werror -Winline
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+PROJECT_NAME ?= status
+
+BUILDDIR ?= $(CURDIR)/cmake-tmp
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -lm
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ cd $(BUILDDIR) && $(MAKE)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@PROJECT_NAME@#$(PROJECT_NAME)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ rm -rf $(BUILDDIR)
+ #rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile install_manifest.txt
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ cd $(BUILDDIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installchangelogs
+# dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=libstatus-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/include/status-internal.h b/include/status-internal.h
new file mode 100755
index 0000000..619ec6f
--- /dev/null
+++ b/include/status-internal.h
@@ -0,0 +1,53 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STATUS_INTERNAL_DEF_H__
+#define __STATUS_INTERNAL_DEF_H__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define STATUS_MESSAGE_KEY "memory/private/libstatus/message"
+#define STATUS_BG_MUSIC_STATE_KEY "memory/private/libstatus/music/state"
+#define STATUS_BG_MUSIC_PID_KEY "memory/private/libstatus/music/pid"
+#define STATUS_BG_RADIO_STATE_KEY "memory/private/libstatus/radio/state"
+#define STATUS_BG_RADIO_PID_KEY "memory/private/libstatus/radio/pid"
+#define STATUS_BG_VR_STATE_KEY "memory/private/libstatus/vr/state"
+#define STATUS_BG_VR_PID_KEY "memory/private/libstatus/vr/pid"
+
+static const char *background_state_keys[STATUS_BACKGROUND_TYPE_NUM] = {
+ [STATUS_BACKGROUND_TYPE_MUSIC] = STATUS_BG_MUSIC_STATE_KEY,
+ [STATUS_BACKGROUND_TYPE_RADIO] = STATUS_BG_RADIO_STATE_KEY,
+ [STATUS_BACKGROUND_TYPE_VOICE_RECORDING] = STATUS_BG_VR_STATE_KEY,
+};
+
+static const char *background_pid_keys[STATUS_BACKGROUND_TYPE_NUM] = {
+ [STATUS_BACKGROUND_TYPE_MUSIC] = STATUS_BG_MUSIC_PID_KEY,
+ [STATUS_BACKGROUND_TYPE_RADIO] = STATUS_BG_RADIO_PID_KEY,
+ [STATUS_BACKGROUND_TYPE_VOICE_RECORDING] = STATUS_BG_VR_PID_KEY,
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __STATUS_INTERNAL_DEF_H__ */
+
diff --git a/include/status-monitor.h b/include/status-monitor.h
new file mode 100755
index 0000000..3afc293
--- /dev/null
+++ b/include/status-monitor.h
@@ -0,0 +1,103 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STATUS_MONITOR_DEF_H__
+#define __STATUS_MONITOR_DEF_H__
+
+#include <status-type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup STATUS_MONITOR_LIBRARY notification status monitor Library
+ * @brief This notification status monitor library used to display simple plain message on indicator
+ */
+
+/**
+ * @ingroup STATUS_MONITOR_LIBRARY
+ * @defgroup STATUS_MONITOR_TYPE notification status monitor type
+ * @brief notification status monitor side type
+ */
+
+/**
+ * @addtogroup STATUS_MONITOR_TYPE
+ * @{
+ */
+
+ /**
+ * @brief Called when new message is posted
+ * @param[in] message The message posted
+ * @param[in] data user data
+ * @pre status_monitor_message_cb_set() used to register this callback
+ * @see status_monitor_message_cb_set()
+ */
+typedef void (*status_message_cb)(const char *message, void *data);
+
+/**
+* @brief This callback type will be deprecated
+*/
+typedef void (*status_background_state_cb)(const status_background_type_e type,
+ status_background_state_e state, void *data);
+
+/**
+ * @addtogroup STATUS_MONITOR_LIBRARY
+ * @{
+ */
+
+/**
+* @brief register callback for receiving message
+* @param[in] callback The callback function
+* @param[in] data user_data
+*/
+int status_monitor_message_cb_set(status_message_cb callback, void *user_data);
+
+/**
+* @brief This function will be deprecated
+*/
+int status_monitor_state_cb_set(const status_background_type_e type,
+ status_background_state_cb callback, void *user_data);
+
+/**
+* @brief unregister callback for receiving message
+* @param[in] callback The callback function
+* @param[in] data user_data
+*/
+int status_monitor_message_cb_unset(void);
+
+/**
+* @brief This function will be deprecated
+*/
+int status_monitor_state_cb_unset(const status_background_type_e type);
+
+/**
+* @brief This function will be deprecated
+*/
+int status_monitor_state_get(const status_background_type_e type,
+ status_background_state_e *state);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __STATUS_MONITOR_DEF_H__ */
+
diff --git a/include/status-type.h b/include/status-type.h
new file mode 100755
index 0000000..8139add
--- /dev/null
+++ b/include/status-type.h
@@ -0,0 +1,72 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STATUS_TYPE_DEF_H__
+#define __STATUS_TYPE_DEF_H__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup STATUS_LIBRARY_TYPE notification status type
+ * @brief Tnotification status type.
+ */
+
+/**
+ * @addtogroup STATUS_LIBRARY_TYPE
+ * @{
+ */
+
+/**
+ * @breief This enumeration type will be deprecated
+ */
+typedef enum _status_background_type_e {
+ STATUS_BACKGROUND_TYPE_MUSIC = 0,
+ STATUS_BACKGROUND_TYPE_RADIO,
+ STATUS_BACKGROUND_TYPE_VOICE_RECORDING,
+ STATUS_BACKGROUND_TYPE_NUM,
+} status_background_type_e;
+
+/**
+ * @breief This enumeration type will be deprecated
+ */
+typedef enum _status_background_state_e {
+ STATUS_BACKGROUND_STATE_STOP = 0,
+ STATUS_BACKGROUND_STATE_PAUSE,
+ STATUS_BACKGROUND_STATE_RUN,
+ STATUS_BACKGROUND_STATE_NUM,
+} status_background_state_e;
+
+/**
+ * @breief Enumeration describing error code of notification library
+ */
+enum _status_error_e {
+ STATUS_ERROR_NONE = 0, /**< Success */
+ STATUS_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter */
+ STATUS_ERROR_IO_ERROR = -2, /**< I/O error */
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __STATUS_TYPE_DEF_H__ */
+
diff --git a/include/status.h b/include/status.h
new file mode 100755
index 0000000..5f3c13b
--- /dev/null
+++ b/include/status.h
@@ -0,0 +1,61 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __STATUS_DEF_H__
+#define __STATUS_DEF_H__
+
+#include <status-type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup STATUS_CLIENT_LIBRARY notification status client Library
+ * @brief This notification status client library used to post simple plain message on indicator
+ */
+
+/**
+ * @addtogroup STATUS_CLIENT_LIBRARY
+ * @{
+ */
+
+/**
+ * @brief This function send string(message) to status monitor
+ * @details Send the message to notification status monitor.
+ * @param[in] message messages you want to post
+ * @return #STATUS_ERROR_NONE if success, other value if failure
+ * @see #_status_error_e
+ */
+int status_message_post(const char *message);
+
+/**
+* @brief This function will be deprecated
+*/
+int status_background_status_post(const status_background_type_e type,
+ const status_background_state_e state);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __STATUS_DEF_H__ */
+
diff --git a/include/status_log.h b/include/status_log.h
new file mode 100755
index 0000000..8c385f3
--- /dev/null
+++ b/include/status_log.h
@@ -0,0 +1,77 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#ifndef __STATUS_LOG_DEF_H__
+#define __STATUS_LOG_DEF_H__
+
+#ifdef STATUS_USE_DLOG
+
+#include <dlog.h>
+
+#define DBG(fmt , args...) \
+ do{ \
+ LOGD("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+ } while(0)
+
+#define INFO(fmt , args...) \
+ do{ \
+ LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+ } while(0)
+
+#define WARN(fmt , args...) \
+ do{ \
+ LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+ } while(0)
+
+#define ERR(fmt , args...) \
+ do{ \
+ LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+ } while(0)
+
+#else /* STATUS_USE_DLOG */
+
+#include <stdio.h>
+
+#define DBG(fmt , args...) \
+ do{ \
+ printf("[D][%s : %d] "fmt"\n", __func__,__LINE__,##args ); \
+ } while(0)
+
+#define INFO(fmt , args...) \
+ do{ \
+ printf("[I][%s : %d] "fmt"\n", __func__,__LINE__,##args ); \
+ } while(0)
+
+#define WARN(fmt , args...) \
+ do{ \
+ printf("[W][%s : %d] "fmt"\n", __func__,__LINE__,##args ); \
+ } while(0)
+
+#define ERR(fmt , args...) \
+ do{ \
+ printf("[E][%s : %d] "fmt"\n", __func__,__LINE__,##args ); \
+ } while(0)
+
+#endif /* STATUS_USE_DLOG */
+
+#endif /* __STATUS_LOG_DEF_H__ */
diff --git a/packaging/status.spec b/packaging/status.spec
new file mode 100755
index 0000000..df26f35
--- /dev/null
+++ b/packaging/status.spec
@@ -0,0 +1,68 @@
+Name: status
+Summary: status library
+Version: 0.0.1
+Release: 2
+Group: TBD
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(aul)
+BuildRequires: cmake
+Requires(post): /sbin/ldconfig
+requires(postun): /sbin/ldconfig
+%description
+Status library.
+
+%prep
+%setup -q
+
+%package devel
+Summary: Status library (devel)
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Status library (devel).
+
+%build
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+mkdir -p %{buildroot}/usr/share/license
+cp -f LICENSE %{buildroot}/usr/share/license/%{name}
+
+
+%post
+init_vconf()
+{
+ vconftool set -t int memory/private/libstatus/music/state 0 -i -g 5000
+ vconftool set -t int memory/private/libstatus/radio/state 0 -i -g 5000
+ vconftool set -t int memory/private/libstatus/vr/state 0 -i -g 5000
+ vconftool set -t int memory/private/libstatus/music/pid -1 -i -g 5000
+ vconftool set -t int memory/private/libstatus/radio/pid -1 -i -g 5000
+ vconftool set -t int memory/private/libstatus/vr/pid -1 -i -g 5000
+ vconftool set -t string memory/private/libstatus/message "" -i -g 5000
+}
+
+/sbin/ldconfig
+init_vconf
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest status.manifest
+%defattr(-,root,root,-)
+%{_libdir}/*.so*
+/usr/share/license/%{name}
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/%{name}/*.h
+%{_libdir}/pkgconfig/*.pc
+
diff --git a/src/status-monitor.c b/src/status-monitor.c
new file mode 100755
index 0000000..56b18c2
--- /dev/null
+++ b/src/status-monitor.c
@@ -0,0 +1,388 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <vconf.h>
+#include <aul.h>
+
+#include "status-type.h"
+#include "status_log.h"
+#include "status-monitor.h"
+#include "status-internal.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "status-monitor"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+struct _message_cb_data {
+ status_message_cb callback;
+ void *data;
+};
+
+struct _state_cb_data {
+ status_background_state_cb callback;
+ void *data;
+};
+
+static struct _message_cb_data md;
+static struct _state_cb_data sd[STATUS_BACKGROUND_TYPE_NUM];
+static int state_pid[STATUS_BACKGROUND_TYPE_NUM] = {
+ [STATUS_BACKGROUND_TYPE_MUSIC] = -1,
+ [STATUS_BACKGROUND_TYPE_RADIO] = -1,
+ [STATUS_BACKGROUND_TYPE_VOICE_RECORDING] = -1,
+};
+static int dead_tracker_initialize;
+
+static void __status_message_change_cb(keynode_t *node, void *user_data)
+{
+ int type;
+ char *message = NULL;
+
+ if (!node) {
+ ERR("key node is NULL");
+ return;
+ }
+
+ if (!md.callback)
+ return;
+
+ type = vconf_keynode_get_type(node);
+ if (type != VCONF_TYPE_STRING) {
+ ERR("invail node type : %d", type);
+ return;
+ }
+
+ message = vconf_keynode_get_str(node);
+ if (!message) {
+ ERR("fail to get message");
+ return;
+ }
+
+ if (strlen(message) <= 0){
+ DBG("message has only NULL");
+ return;
+ }
+
+ DBG("message : %s", message);
+ md.callback(message, md.data);
+}
+
+EXPORT_API
+int status_monitor_message_cb_set(status_message_cb callback, void *user_data)
+{
+ int ret = 0;
+ if (!callback)
+ return STATUS_ERROR_INVALID_PARAMETER;
+
+ ret = vconf_notify_key_changed(STATUS_MESSAGE_KEY,
+ __status_message_change_cb, NULL);
+ if (ret && errno != EALREADY) {
+ ERR("fail to set message cb");
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+
+ md.callback = callback;
+ md.data = user_data;
+
+ return STATUS_ERROR_NONE;
+}
+
+EXPORT_API
+int status_monitor_message_cb_unset(void)
+{
+ vconf_ignore_key_changed(STATUS_MESSAGE_KEY,
+ __status_message_change_cb);
+ md.callback = NULL;
+ md.data = NULL;
+
+ return STATUS_ERROR_NONE;
+}
+
+static int __status_state_reset(status_background_type_e type)
+{
+ int ret = 0;
+ const int pid = -1;
+ const int state = STATUS_BACKGROUND_STATE_STOP;
+
+ if (type < STATUS_BACKGROUND_TYPE_MUSIC
+ || type >= STATUS_BACKGROUND_TYPE_NUM) {
+ ERR("invaild type : %d", type);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = vconf_set_int(background_pid_keys[type], pid);
+ if (ret) {
+ ERR("fail to reset [%s]", background_pid_keys[type]);
+ return STATUS_ERROR_IO_ERROR;
+ }
+ ret = vconf_set_int(background_state_keys[type], state);
+ if (ret) {
+ ERR("fail to reset [%s]", background_state_keys[type]);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ return STATUS_ERROR_NONE;
+}
+
+
+static int __state_get_val(const status_background_type_e type,
+ status_background_state_e *state)
+{
+ int k_state = 0;
+ int ret = 0;
+
+ if (!state)
+ return STATUS_ERROR_INVALID_PARAMETER;
+
+ ret = vconf_get_int(background_state_keys[type], &k_state);
+ if (ret) {
+ ERR("fail to get state of [%s]", background_state_keys[type]);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ *state = k_state;
+
+ return STATUS_ERROR_NONE;
+}
+
+static inline int __state_cb_call(keynode_t *node,
+ const status_background_type_e type)
+{
+ status_background_state_e state = STATUS_BACKGROUND_STATE_STOP;
+ int ret = 0;
+
+ if (!sd[type].callback)
+ return 0;
+
+ if (node == NULL) {
+ ret = __state_get_val(type, &state);
+ if (ret)
+ return ret;
+ } else {
+ int type;
+ type = vconf_keynode_get_type(node);
+ if (type != VCONF_TYPE_INT) {
+ ERR("invail node type : %d", type);
+ return -1;
+ }
+ state = vconf_keynode_get_int(node);
+ if (state < 0) {
+ ERR("fail to get state : %d", state);
+ return -1;
+ }
+ }
+
+ DBG("type[%d], state[%d]", type, state);
+ sd[type].callback(type, state, sd[type].data);
+
+ return 0;
+}
+
+static void __status_music_change_cb(keynode_t *node, void *user_data)
+{
+ __state_cb_call(node, STATUS_BACKGROUND_TYPE_MUSIC);
+}
+
+static void __status_radio_change_cb(keynode_t *node, void *user_data)
+{
+ __state_cb_call(node, STATUS_BACKGROUND_TYPE_RADIO);
+}
+
+static void __status_vr_change_cb(keynode_t *node, void *user_data)
+{
+ __state_cb_call(node, STATUS_BACKGROUND_TYPE_VOICE_RECORDING);
+}
+
+static vconf_callback_fn state_cbs[STATUS_BACKGROUND_TYPE_NUM] = {
+ [STATUS_BACKGROUND_TYPE_MUSIC] = __status_music_change_cb,
+ [STATUS_BACKGROUND_TYPE_RADIO] = __status_radio_change_cb,
+ [STATUS_BACKGROUND_TYPE_VOICE_RECORDING] = __status_vr_change_cb,
+
+};
+
+static int _dead_tracker(const int pid, void *data)
+{
+ int i = 0;
+
+ DBG("pid[%d] is dead", pid);
+ for (i = 0; i < STATUS_BACKGROUND_TYPE_NUM; i++) {
+ if (state_pid[i] == pid) {
+ DBG("type[%d] - pid[%d] is dead", i, pid);
+ __status_state_reset(i);
+ }
+ }
+
+ return 0;
+}
+
+static inline void __update_stored_pid(status_background_type_e type,
+ keynode_t *node)
+{
+ int pid = -1;
+ if (!node)
+ return;
+
+ pid = vconf_keynode_get_int(node);
+
+ state_pid[type] = pid;
+ DBG("pid[%d], type[%d]", pid, type);
+}
+
+static void _music_pid_changed_cb(keynode_t *node, void *user_data)
+{
+ __update_stored_pid(STATUS_BACKGROUND_TYPE_MUSIC, node);
+}
+
+static void _radio_pid_changed_cb(keynode_t *node, void *user_data)
+{
+ __update_stored_pid(STATUS_BACKGROUND_TYPE_RADIO, node);
+}
+
+static void _vr_pid_changed_cb(keynode_t *node, void *user_data)
+{
+ __update_stored_pid(STATUS_BACKGROUND_TYPE_VOICE_RECORDING, node);
+}
+
+static vconf_callback_fn _pid_cbs[STATUS_BACKGROUND_TYPE_NUM] = {
+ [STATUS_BACKGROUND_TYPE_MUSIC] = _music_pid_changed_cb,
+ [STATUS_BACKGROUND_TYPE_RADIO] = _radio_pid_changed_cb,
+ [STATUS_BACKGROUND_TYPE_VOICE_RECORDING] = _vr_pid_changed_cb,
+};
+
+static int __dead_tracker_init(void)
+{
+ int ret = 0;
+
+ if (dead_tracker_initialize)
+ return 0;
+
+ ret = aul_listen_app_dead_signal(_dead_tracker, NULL);
+ if (ret != AUL_R_OK) {
+ ERR("fail to aul_listen_app_dead_signal() - %d", ret);
+ return -1;
+ }
+
+ dead_tracker_initialize = 1;
+
+ return 0;
+}
+
+static void __dead_tracker_fini(void)
+{
+ int i = 0;
+ int all_cb_removed = 1;
+
+ if (!dead_tracker_initialize)
+ return;
+
+ for (i = 0; i < STATUS_BACKGROUND_TYPE_NUM; i++)
+ all_cb_removed &= !(sd[i].callback);
+
+ if (all_cb_removed) {
+ aul_listen_app_dead_signal(NULL, NULL);
+ dead_tracker_initialize = 0;
+ }
+
+ return;
+}
+
+EXPORT_API
+int status_monitor_state_cb_set(const status_background_type_e type,
+ status_background_state_cb callback, void *user_data)
+{
+ int ret = 0;
+ int pid = -1;
+
+ if (type < STATUS_BACKGROUND_TYPE_MUSIC
+ || type >= STATUS_BACKGROUND_TYPE_NUM) {
+ ERR("invaild type : %d", type);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!callback)
+ return STATUS_ERROR_INVALID_PARAMETER;
+
+ ret = vconf_notify_key_changed(background_state_keys[type],
+ state_cbs[type], NULL);
+ if (ret && errno != EALREADY) {
+ ERR("fail to cb set for [%d]", type);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ ret = vconf_notify_key_changed(background_pid_keys[type],
+ _pid_cbs[type], NULL);
+ if (ret && errno != EALREADY)
+ ERR("fail to set pid cb for [%d]", type);
+
+ vconf_get_int(background_pid_keys[type], &pid);
+ state_pid[type] = pid;
+
+ __dead_tracker_init();
+
+ sd[type].callback = callback;
+ sd[type].data = user_data;
+
+ return STATUS_ERROR_NONE;
+}
+
+EXPORT_API
+int status_monitor_state_cb_unset(const status_background_type_e type)
+{
+ if (type < STATUS_BACKGROUND_TYPE_MUSIC
+ || type >= STATUS_BACKGROUND_TYPE_NUM) {
+ ERR("invaild type : %d", type);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ vconf_ignore_key_changed(background_state_keys[type], state_cbs[type]);
+ vconf_ignore_key_changed(background_pid_keys[type], _pid_cbs[type]);
+ sd[type].callback = NULL;
+ sd[type].data = NULL;
+ state_pid[type] = -1;
+
+ __dead_tracker_fini();
+
+ return STATUS_ERROR_NONE;
+}
+
+EXPORT_API
+int status_monitor_state_get(const status_background_type_e type,
+ status_background_state_e *state)
+{
+ if (type < STATUS_BACKGROUND_TYPE_MUSIC
+ || type >= STATUS_BACKGROUND_TYPE_NUM) {
+ ERR("invaild type : %d", type);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return __state_get_val(type, state);
+}
+
diff --git a/src/status.c b/src/status.c
new file mode 100755
index 0000000..a86ca56
--- /dev/null
+++ b/src/status.c
@@ -0,0 +1,104 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <vconf.h>
+
+#include "status-type.h"
+#include "status_log.h"
+#include "status.h"
+#include "status-internal.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "status"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+EXPORT_API
+int status_message_post(const char *message)
+{
+ int ret = 0;
+
+ if (!message) {
+ ERR("message is NULL");
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (strlen(message) <= 0) {
+ ERR("message has only NULL");
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+
+ ret = vconf_set_str(STATUS_MESSAGE_KEY, message);
+ if (ret) {
+ ERR("fail to set message [%s]", message);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ return STATUS_ERROR_NONE;
+}
+
+EXPORT_API
+int status_background_status_post(const status_background_type_e type,
+ const status_background_state_e state)
+{
+ int pid = -1;
+ int ret = 0;
+
+ if (type < STATUS_BACKGROUND_TYPE_MUSIC
+ || type >= STATUS_BACKGROUND_TYPE_NUM) {
+ ERR("invaild type [%d]", type);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (state < STATUS_BACKGROUND_STATE_STOP
+ || state >= STATUS_BACKGROUND_STATE_NUM) {
+ ERR("invaild state [%d]", state);
+ return STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (state != STATUS_BACKGROUND_STATE_STOP)
+ pid = getpid();
+
+ ret = vconf_set_int(background_pid_keys[type], pid);
+ if (ret) {
+ ERR("fail to set [%s], pid[%d]",
+ background_pid_keys[type], pid);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ ret = vconf_set_int(background_state_keys[type], state);
+ if (ret) {
+ ERR("fail to set [%s], state[%d]",
+ background_state_keys[type], state);
+ return STATUS_ERROR_IO_ERROR;
+ }
+
+ return STATUS_ERROR_NONE;
+}
+
diff --git a/status-monitor.pc.in b/status-monitor.pc.in
new file mode 100644
index 0000000..19d00bb
--- /dev/null
+++ b/status-monitor.pc.in
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: status-monitor
+Description: status monitor supporting library
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -lstatus-monitor
+Cflags: -I${includedir}
diff --git a/status.manifest b/status.manifest
new file mode 100755
index 0000000..97e8c31
--- /dev/null
+++ b/status.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/status.pc.in b/status.pc.in
new file mode 100644
index 0000000..897c7d0
--- /dev/null
+++ b/status.pc.in
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: status
+Description: status supporting library
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -lstatus
+Cflags: -I${includedir}
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..ec1aacb
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+all:
+ gcc -Wall post_test.c -o post_test `pkg-config status glib-2.0 --libs --cflags` -I.
+ gcc -Wall monitor_test.c -o monitor_test `pkg-config status-monitor glib-2.0 --libs --cflags` -I.
diff --git a/test/monitor_test.c b/test/monitor_test.c
new file mode 100755
index 0000000..a3fd7da
--- /dev/null
+++ b/test/monitor_test.c
@@ -0,0 +1,267 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <status-monitor.h>
+
+#define MAX_STRING_LEN 256
+#define CLEAR_STDIN {gint ch; while((ch=getchar())!=EOF&&ch!='\n'); }
+
+static GIOChannel *stdin_channel;
+static GMainLoop *loop;
+
+typedef void (*menu_cb)(void);
+
+struct menu_item {
+ gchar *cmd;
+ gchar *desc;
+ menu_cb func;
+};
+
+static void _monitor_message_cb(const char *message, void *data)
+{
+ printf("new message received : %s\n", message);
+}
+
+static void _monitor_state_cb(status_background_type_e type,
+ status_background_state_e state, void *data)
+{
+ switch (type) {
+ case STATUS_BACKGROUND_TYPE_MUSIC:
+ printf("music state changed : state[%d]\n", state);
+ break;
+ case STATUS_BACKGROUND_TYPE_RADIO:
+ printf("radio state changed : state[%d]\n", state);
+ break;
+ case STATUS_BACKGROUND_TYPE_VOICE_RECORDING:
+ printf("voice recorder state changed : state[%d]\n", state);
+ break;
+ default:
+ printf("unknown type - [%d] \n", type);
+ break;
+ }
+
+}
+
+static void do_quit(void)
+{
+ g_main_loop_quit(loop);
+}
+
+static void do_message_monitor_set(void)
+{
+ int ret = 0;
+
+ ret = status_monitor_message_cb_set(_monitor_message_cb, NULL);
+ if (ret != STATUS_ERROR_NONE) {
+ printf("fail to status_monitor_message_cb_set - %d \n", ret);
+ return;
+ }
+
+ printf("success to status_monitor_message_cb_set\n");
+}
+
+static void do_message_monitor_unset(void)
+{
+ int ret = 0;
+
+ ret = status_monitor_message_cb_unset();
+ if (ret != STATUS_ERROR_NONE) {
+ printf("fail to status_monitor_message_cb_unset - %d \n", ret);
+ return;
+ }
+
+ printf("success to status_monitor_message_cb_unset\n");
+}
+
+static int _get_type(status_background_type_e *type)
+{
+ int input_type;
+ int ret;
+ int pass = 0;
+ do {
+ g_print("Select type : \n");
+ g_print("0. Music\n");
+ g_print("1. Radio\n");
+ g_print("2. Voice recorder\n");
+ ret = scanf("%d", &input_type);
+ if (ret <= 0) {
+ g_print("invaild input\n\n");
+ input_type = -1;
+ }
+ CLEAR_STDIN;
+
+ if (input_type >= 0 && input_type <= 2)
+ pass = 1;
+ } while (pass != 1);
+
+ if (type)
+ *type = (status_background_type_e)input_type;
+
+ return 0;
+}
+
+static void do_state_monitor_set(void)
+{
+ int ret = 0;
+ status_background_type_e type;
+
+ if (_get_type(&type)) {
+ g_print("fail to get type \n");
+ return;
+ }
+
+ ret = status_monitor_state_cb_set(type, _monitor_state_cb, NULL);
+ if (ret != STATUS_ERROR_NONE) {
+ printf("fail to status_monitor_state_cb_set"\
+ "- type[%d], err[%d] \n", type, ret);
+ return;
+ }
+
+ printf("success to status_monitor_state_cb_set - type[%d]\n", type);
+}
+
+static void do_state_monitor_unset(void)
+{
+ int ret = 0;
+ status_background_type_e type;
+
+ if (_get_type(&type)) {
+ g_print("fail to get type \n");
+ return;
+ }
+
+ ret = status_monitor_state_cb_unset(type);
+ if (ret != STATUS_ERROR_NONE) {
+ printf("fail to status_monitor_state_cb_unset"\
+ "- type[%d], err[%d] \n", type, ret);
+ return;
+ }
+
+ printf("success to status_monitor_state_cb_unset - type[%d]\n", type);
+}
+
+static void do_state_get(void)
+{
+ int ret = 0;
+ status_background_type_e type;
+ status_background_state_e state = STATUS_BACKGROUND_STATE_STOP;
+
+ if (_get_type(&type)) {
+ g_print("fail to get type \n");
+ return;
+ }
+
+ ret = status_monitor_state_get(type, &state);
+ if (ret != STATUS_ERROR_NONE) {
+ printf("fail to status_monitor_state_get"\
+ "- type[%d], err[%d] \n", type, ret);
+ return;
+ }
+ printf("success to status_monitor_state_get \n");
+ printf("type[%d], state[%d]\n", type, state);
+
+}
+
+static struct menu_item g_monitor_menu[] = {
+ {"q", "quit", do_quit},
+ {"w", "test message monitor set", do_message_monitor_set},
+ {"e", "test message monitor unset", do_message_monitor_unset},
+ {"s", "test background state monitor set", do_state_monitor_set},
+ {"a", "test background state monitor unset", do_state_monitor_unset},
+ {"g", "test background state get", do_state_get},
+ {NULL, NULL, NULL},
+};
+
+static void
+monitor_display_menu(void)
+{
+ gint i = 0;
+
+ g_print("\n");
+
+ g_print("select commands \n");
+ while (g_monitor_menu[i].cmd) {
+ g_print("[%s] %s\n", g_monitor_menu[i].cmd,
+ g_monitor_menu[i].desc);
+ i++;
+ }
+
+ g_print("\n");
+ g_print(">>> ");
+
+}
+
+static void
+_monitor_parse_command(gchar *cmd)
+{
+ gint i = 0;
+
+ while (g_monitor_menu[i].cmd) {
+ if (g_strcmp0(g_monitor_menu[i].cmd, cmd) == 0) {
+ if (g_monitor_menu[i].func)
+ g_monitor_menu[i].func();
+ return;
+ }
+ i++;
+ }
+ monitor_display_menu();
+
+}
+
+
+static gboolean
+_monitor_input_cb(GIOChannel *channel)
+{
+ gchar buf[MAX_STRING_LEN+3];
+ gsize len;
+
+ g_io_channel_read(channel, buf, MAX_STRING_LEN, &len);
+ buf[len] = 0x00;
+ g_strstrip(buf);
+
+ _monitor_parse_command(buf);
+
+ return TRUE;
+
+}
+
+int main(int argc, char **argv)
+{
+ loop = g_main_loop_new(NULL, FALSE);
+
+ stdin_channel = g_io_channel_unix_new (0);
+ g_io_add_watch(stdin_channel, G_IO_IN,
+ (GIOFunc)_monitor_input_cb, NULL);
+
+ monitor_display_menu();
+
+ g_main_loop_run(loop);
+
+ g_io_channel_unref(stdin_channel);
+ g_main_loop_unref(loop);
+
+ return 0;
+}
+
+
diff --git a/test/post_test.c b/test/post_test.c
new file mode 100755
index 0000000..7932180
--- /dev/null
+++ b/test/post_test.c
@@ -0,0 +1,223 @@
+/*
+ * libstatus
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
+ * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <status.h>
+
+#define MAX_STRING_LEN 256
+#define CLEAR_STDIN {gint ch; while((ch=getchar())!=EOF&&ch!='\n'); }
+
+static GIOChannel *stdin_channel;
+static GMainLoop *loop;
+
+typedef void (*menu_cb)(void);
+
+struct menu_item {
+ gchar *cmd;
+ gchar *desc;
+ menu_cb func;
+};
+
+static void do_quit(void)
+{
+ g_main_loop_quit(loop);
+}
+
+
+static void do_message_post(void)
+{
+ int ret;
+
+ ret = status_message_post("test status message post && aaa");
+ if (ret) {
+ g_print("fail to status_message_post() : %d\n", ret);
+ return;
+ }
+
+ g_print("success to status_message_post()\n");
+}
+
+static int _get_type(status_background_type_e *type)
+{
+ int input_type;
+ int ret;
+ int pass = 0;
+ do {
+ g_print("Select type : \n");
+ g_print("0. Music\n");
+ g_print("1. Radio\n");
+ g_print("2. Voice recorder\n");
+ ret = scanf("%d", &input_type);
+ if (ret <= 0) {
+ g_print("invaild input\n\n");
+ input_type = -1;
+ }
+ CLEAR_STDIN;
+
+ if (input_type >= 0 && input_type <= 2)
+ pass = 1;
+ } while (pass != 1);
+
+ if (type)
+ *type = (status_background_type_e)input_type;
+
+ return 0;
+}
+
+static int _get_state(status_background_state_e *state)
+{
+ int input_state;
+ int ret;
+ int pass = 0;
+ do {
+ g_print("Select state : \n");
+ g_print("0. STOP \n");
+ g_print("1. PAUSE \n");
+ g_print("2. RUN \n");
+ ret = scanf("%d", &input_state);
+ if (ret <= 0) {
+ g_print("invaild input\n\n");
+ input_state = -1;
+ }
+ CLEAR_STDIN;
+
+ if (input_state >= 0 && input_state <= 2)
+ pass = 1;
+ } while (pass != 1);
+
+ if (state)
+ *state = (status_background_state_e)input_state;
+
+ return 0;
+}
+
+
+static void do_background_state_post(void)
+{
+ int ret;
+ status_background_type_e type;
+ status_background_state_e state;
+
+ if (_get_type(&type)) {
+ g_print("fail to get type \n");
+ return;
+ }
+
+ if (_get_state(&state)) {
+ g_print("fail to get state \n");
+ return;
+ }
+
+ ret = status_background_status_post(type, state);
+ if (ret) {
+ g_print("fail to status_background_status_post() "\
+ "[%d][%d]: %d\n", type, state, ret);
+ return;
+ }
+
+ g_print("success to status_background_status_post()\n");
+}
+
+
+static struct menu_item g_post_menu[] = {
+ {"q", "quit", do_quit},
+ {"m", "test message post", do_message_post},
+ {"s", "test background state post", do_background_state_post},
+ {NULL, NULL, NULL},
+};
+
+static void
+post_display_menu(void)
+{
+ gint i = 0;
+
+ g_print("\n");
+
+ g_print("select commands \n");
+ while (g_post_menu[i].cmd) {
+ g_print("[%s] %s\n", g_post_menu[i].cmd, g_post_menu[i].desc);
+ i++;
+ }
+
+ g_print("\n");
+ g_print(">>> ");
+
+}
+
+static void
+_post_parse_command(gchar *cmd)
+{
+ gint i = 0;
+
+ while (g_post_menu[i].cmd) {
+ if (g_strcmp0(g_post_menu[i].cmd, cmd) == 0) {
+ if (g_post_menu[i].func)
+ g_post_menu[i].func();
+ return;
+ }
+ i++;
+ }
+ post_display_menu();
+
+}
+
+
+static gboolean
+_post_input_cb(GIOChannel *channel)
+{
+ gchar buf[MAX_STRING_LEN+3];
+ gsize len;
+
+ g_io_channel_read(channel, buf, MAX_STRING_LEN, &len);
+ buf[len] = 0x00;
+ g_strstrip(buf);
+
+ _post_parse_command(buf);
+
+ return TRUE;
+
+}
+
+int main(int argc, char **argv)
+{
+ int i = 0;
+ status_background_state_e state = STATUS_BACKGROUND_STATE_STOP;
+ loop = g_main_loop_new(NULL, FALSE);
+
+ stdin_channel = g_io_channel_unix_new (0);
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)_post_input_cb, NULL);
+
+ post_display_menu();
+
+ g_main_loop_run(loop);
+
+ for (i = 0; i < STATUS_BACKGROUND_TYPE_NUM; i++)
+ status_background_status_post(i, state);
+
+ g_io_channel_unref(stdin_channel);
+ g_main_loop_unref(loop);
+
+ return 0;
+}
+
+