%description plugin-net-popup
A smart traffic control manager extension for net popup notification plugin
-%package plugin-wearable-popup
-Summary: STC manager popup notification plugin for wearable
+%package plugin-stc-popup
+Summary: STC manager's plugin for stc popup
+BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
+
+%description plugin-stc-popup
+A smart traffic control manager extension for stc popup notification plugin
+
+%package net.stc-popup
+Summary: Service for wearable profile's popup notification
+Group: Network & Connectivity/Application
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(efl-extension)
-BuildRequires: pkgconfig(capi-system-system-settings)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(capi-system-system-settings)
-%description plugin-wearable-popup
-A smart traffic control manager extension for popup notification plugin wearable
+%define _popup_pkgdir /usr/apps/net.stc-popup
+%define _popup_bindir %{_popup_pkgdir}/bin
+%define _popup_resdir %{_popup_pkgdir}/res
+%define _popup_icondir %{_popup_pkgdir}/shared/res
+%define _popup_manifestdir /usr/share/packages
+%define _popup_licensedir %{_datarootdir}/license
+%define _popup_dbusconfdir /etc/dbus-1/system.d
+
+%description net.stc-popup
+Service for displaying popup notification in wearable profile.
%prep
%setup -q
%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DBIN_DIR=%{_bindir} \
+ -DPOPUP_BIN_DIR=%{_popup_bindir} \
-DLIB_PATH=%{_lib} \
+ -DVERSION=%{version} \
-DENABLE_DATABASE=%{enable_database} \
-DDATABASE_FULL_PATH=%{database_full_path} \
-DENABLE_STATISTICS=%{enable_statistics} \
cp resources/dbus/stc-manager.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/stc-manager.conf
%post plugin-net-popup
-mv -f %{_libdir}/stc-plugin-net-popup.so %{_libdir}/stc-plugin-popup.so
+rm %{_libdir}/stc-plugin-popup.so
+ln -s %{_libdir}/stc-plugin-net-popup.so %{_libdir}/stc-plugin-popup.so
+
+%post plugin-stc-popup
+rm %{_libdir}/stc-plugin-popup.so
+ln -s %{_libdir}/stc-plugin-stc-popup.so %{_libdir}/stc-plugin-popup.so
-%post plugin-wearable-popup
-mv -f %{_libdir}/stc-plugin-wearable-popup.so %{_libdir}/stc-plugin-popup.so
+%post net.stc-popup
+tpk-backend --preload -y net.stc-popup
%files
%manifest %{name}.manifest
%attr(644, -,-) %{_datadir}/icons/*.png
%attr(500,root,root) %{_libdir}/stc-plugin-net-popup.so
-%files plugin-wearable-popup
+%files plugin-stc-popup
%manifest %{name}.manifest
-%attr(500,root,root) %{_libdir}/stc-plugin-wearable-popup.so
-%attr(755,root,root) %{_bindir}/stc-wearable-popup
+%attr(500,root,root) %{_libdir}/stc-plugin-stc-popup.so
+
+%files net.stc-popup
+%defattr(-,root,root,-)
+%{_popup_bindir}/stc-popup
+%{_popup_resdir}/*
+%{_popup_icondir}/net.stc-popup.png
+%{_popup_manifestdir}/net.stc-popup.xml
+%{_popup_licensedir}/stc-popup
+%{_popup_dbusconfdir}/net.stc-popup.conf
+%{_userunitdir}/net.stc-popup.service
+
ADD_SUBDIRECTORY(exception)
ADD_SUBDIRECTORY(procfs)
ADD_SUBDIRECTORY(net-popup)
-ADD_SUBDIRECTORY(wearable-popup)
+ADD_SUBDIRECTORY(stc-popup)
+ADD_SUBDIRECTORY(net.stc-popup)
--- /dev/null
+#
+# STC Popup
+#
+# Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+#
+# 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.
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT("stc-popup" C)
+
+IF(NOT DEFINED PACKAGE_NAME)
+ SET(PACKAGE_NAME "net.stc-popup")
+ENDIF(NOT DEFINED PACKAGE_NAME)
+
+SET(POPUP_PREFIX "/usr/apps/${PACKAGE_NAME}")
+SET(BIN_DIR "${POPUP_PREFIX}/bin")
+SET(IMAGE_DIR "${POPUP_PREFIX}/res/images")
+SET(ICON_DIR "${POPUP_PREFIX}/shared/res")
+SET(MANIFEST_DIR "/usr/share/packages")
+SET(LICENSE_DIR "/usr/share/license")
+SET(USER_UNIT_DIR "/usr/lib/systemd/user")
+SET(DBUS_CONF_DIR "/etc/dbus-1/system.d")
+
+INCLUDE_DIRECTORIES(inc)
+AUX_SOURCE_DIRECTORY(./src SRCS)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
+ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGE_DIR}\"")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(PKGS REQUIRED
+ dlog
+ glib-2.0
+ gio-2.0
+ elementary
+ capi-appfw-application
+ efl-extension
+ capi-system-system-settings
+)
+
+FOREACH(flag ${PKGS_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS})
+CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${PACKAGE_NAME}.xml)
+
+# install binary
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR})
+
+#install manifest file
+INSTALL(FILES ${PACKAGE_NAME}.xml DESTINATION ${MANIFEST_DIR})
+
+#install icon
+INSTALL(FILES ${PACKAGE_NAME}.png DESTINATION ${ICON_DIR})
+
+#install service file
+INSTALL(FILES ${PACKAGE_NAME}.service DESTINATION ${USER_UNIT_DIR})
+
+#install dbus configuration
+INSTALL(FILES ${PACKAGE_NAME}.conf DESTINATION ${DBUS_CONF_DIR})
+
+#install License
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${LICENSE_DIR} RENAME "${PROJECT_NAME}")
+
+#install images
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/images/ DESTINATION ${IMAGE_DIR} FILES_MATCHING PATTERN "*.png")
--- /dev/null
+Copyright (c) 2000 - 2015 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.
+
--- /dev/null
+#ifndef __STC_POPUP_GDBUS_H__
+#define __STC_POPUP_GDBUS_H__
+
+#include <gio/gio.h>
+
+#define STC_MGR_SIGNAL_RSTN_CROSSED "RestrictionThresholdCrossed"
+#define STC_MGR_SIGNAL_WARN_CROSSED "WarnThresholdCrossed"
+
+typedef void (*SignalCallback) (const gchar *signal_name, GVariant *parameters, gpointer user_data);
+
+#define DEBUG_PARAMS(parameters) do { \
+ gchar *params_str = NULL; \
+ if (parameters) \
+ params_str = g_variant_print((GVariant *)parameters, TRUE); \
+ STC_LOGD("Dbus params [%s]", params_str ? params_str : "NULL"); \
+ g_free(params_str); \
+} while (0)
+
+#define DEBUG_PARAM_TYPE(parameters) do { \
+ STC_LOGD("Dbus params type [%s]", \
+ g_variant_get_type_string(parameters)); \
+} while (0)
+
+void stc_popup_subscribe_signals(SignalCallback callback, void *user_data);
+
+#endif /* __STC_POPUP_GDBUS_H__ */
--- /dev/null
+#ifndef __STC_POPUP_UI_H__
+#define __STC_POPUP_UI_H__
+
+#include <app.h>
+#include <Elementary.h>
+#include <system_settings.h>
+#include <efl_extension.h>
+
+#if !defined(PACKAGE)
+#define PACKAGE "org.tizen.stc-wearable-popup"
+#endif
+
+#define DATA_USAGE_WARN_TITLE "Near data limit"
+#define DATA_USAGE_RSTN_TITLE "Data limit"
+
+#define DATA_USAGE_WARN_BODY "You've almost reached your data limit (5.0 GB)." \
+ " Go to Settings and check."
+#define DATA_USAGE_RSTN_BODY "Data usage limit reached." \
+ " Using mobile data may result in additional charges."
+
+typedef enum {
+ POPUP_TYPE_RSTN,
+ POPUP_TYPE_WARN
+} popup_type_e;
+
+typedef struct appdata {
+ Evas_Object *win;
+ Evas_Object *conform;
+ Evas_Object *layout;
+} appdata_s;
+
+int stc_popup_app_init(int argc, char *argv[], appdata_s *ad);
+void create_popup(appdata_s *ad, popup_type_e type, const char *app_id);
+
+#endif /* __STC_POPUP_UI_H__ */
--- /dev/null
+#ifndef __STC_POPUP_UTIL_H__
+#define __STC_POPUP_UTIL_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "STC_POPUP"
+
+#define STC_LOGD(format, args...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s "format, __func__, ##args)
+#define STC_LOGI(format, args...) dlog_print(DLOG_INFO, LOG_TAG, "%s "format, __func__, ##args)
+#define STC_LOGW(format, args...) dlog_print(DLOG_WARN, LOG_TAG, "%s "format, __func__, ##args)
+#define STC_LOGE(format, args...) dlog_print(DLOG_ERROR, LOG_TAG, "%s "format, __func__, ##args)
+
+#define __STC_LOG_FUNC_ENTER__ STC_LOGD("Enter")
+#define __STC_LOG_FUNC_EXIT__ STC_LOGD("Quit")
+
+#endif /* __STC_POPUP_UTIL_H__ */
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="net.stc.popup"/>
+ <allow send_destination="net.stc.popup"/>
+ <allow receive_sender="net.stc.popup"/>
+ </policy>
+ <policy user="network_fw">
+ <allow own="net.stc.popup"/>
+ <allow send_destination="net.stc.popup"/>
+ <allow receive_sender="net.stc.popup"/>
+ </policy>
+ <policy context="default">
+ <deny own="net.stc.popup"/>
+ <deny send_destination="net.stc.popup"/>
+ <deny receive_sender="net.stc.popup"/>
+ </policy>
+</busconfig>
+
--- /dev/null
+[Unit]
+Description=STC popup
+Requires=launchpad-process-pool.service
+After=launchpad-process-pool.service stc-manager.service
+
+[Service]
+ExecStart=/bin/sh -c -l '/usr/bin/app_launcher -s net.stc-popup'
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="@PACKAGE_NAME@" version="@VERSION@" install-location="internal-only" preload="true">
+ <label>STC_POPUP</label>
+ <author email="PUT YOUR EMAIL" href="www.samsung.com">PUT YOUR NAME</author>
+ <description>STC_POPUP</description>
+ <ui-application appid="@PACKAGE_NAME@" exec="@POPUP_BIN_DIR@/@PROJECT_NAME@" launchmode="single" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+ <label>STC_POPUP</label>
+ <icon>@PACKAGE_NAME@.png</icon>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ </privileges>
+</manifest>
--- /dev/null
+#include "stc-popup-gdbus.h"
+#include "stc-popup-util.h"
+
+#define STC_MGR_DBUS_SERVICE "net.stc"
+#define STC_MGR_DBUS_IFACE_RSTN STC_MGR_DBUS_SERVICE ".restriction"
+#define STC_MGR_DBUS_RSTN_PATH "/net/stc/restriction"
+#define STC_POPUP_DBUS_SERVICE STC_MGR_DBUS_SERVICE ".popup"
+
+typedef struct {
+ GDBusConnection *connection;
+ guint owner_id;
+ guint signal_sub_id;
+ SignalCallback callback;
+} gdbusdata_s;
+
+gdbusdata_s gd;
+
+static void __signal_cb(GDBusConnection *connection, const gchar *sender_name,
+ const gchar *object_path, const gchar *interface_name,
+ const gchar *signal_name, GVariant *parameters,
+ gpointer user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ if (gd.callback)
+ gd.callback(signal_name, parameters, user_data);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+static void __gdbus_on_bus_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ gd.connection = connection;
+
+ gd.signal_sub_id =
+ g_dbus_connection_signal_subscribe(gd.connection,
+ NULL,
+ STC_MGR_DBUS_IFACE_RSTN,
+ NULL,
+ STC_MGR_DBUS_RSTN_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __signal_cb,
+ user_data,
+ NULL);
+
+ STC_LOGD("name : %s, signal_sub_id [%d]", name, gd.signal_sub_id);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+static void __gdbus_on_name_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ STC_LOGD("name : %s", name);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+static void __gdbus_on_name_lost(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ STC_LOGD("name : %s", name);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+static void _gdbus_init(SignalCallback callback, void *user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ gd.connection = NULL;
+ gd.owner_id = 0;
+ gd.signal_sub_id = 0;
+ gd.callback = callback;
+
+ gd.owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+ STC_POPUP_DBUS_SERVICE,
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ __gdbus_on_bus_acquired,
+ __gdbus_on_name_acquired,
+ __gdbus_on_name_lost,
+ user_data,
+ NULL);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+static void _gdbus_deinit(void)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ g_bus_unown_name(gd.owner_id);
+
+ gd.connection = NULL;
+ gd.owner_id = 0;
+ gd.signal_sub_id = 0;
+ gd.callback = NULL;
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+void stc_popup_subscribe_signals(SignalCallback callback, void *user_data)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ if (gd.connection != NULL) {
+ __STC_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ _gdbus_init(callback, user_data);
+
+ __STC_LOG_FUNC_EXIT__;
+}
+
+void stc_popup_unsubscribe_signals(void)
+{
+ __STC_LOG_FUNC_ENTER__;
+
+ if (gd.connection == NULL)
+ return;
+
+ g_dbus_connection_signal_unsubscribe(gd.connection, gd.signal_sub_id);
+
+ _gdbus_deinit();
+
+ __STC_LOG_FUNC_EXIT__;
+}
--- /dev/null
+#include "stc-popup-ui.h"
+#include "stc-popup-gdbus.h"
+#include <stc-popup-util.h>
+
+static void _signal_cb(const gchar *signal_name, GVariant *parameters,
+ gpointer user_data)
+{
+ STC_LOGI("[%s] received", signal_name);
+
+ if (g_strcmp0(signal_name, STC_MGR_SIGNAL_RSTN_CROSSED) == 0) {
+ guint str_length;
+ const char *app_id = g_variant_get_string(parameters,
+ &str_length);
+
+ create_popup(user_data, POPUP_TYPE_RSTN, app_id);
+
+ } else if (g_strcmp0(signal_name, STC_MGR_SIGNAL_WARN_CROSSED) == 0) {
+ guint str_length;
+ const char *app_id = g_variant_get_string(parameters,
+ &str_length);
+
+ g_variant_get(parameters, "&s", app_id);
+
+ create_popup(user_data, POPUP_TYPE_WARN, app_id);
+
+ } else {
+ STC_LOGE("Unknown signal");
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ appdata_s ad = {0,};
+ int ret = -1;
+
+ STC_LOGI("Smart Traffic Control Popup");
+
+ stc_popup_subscribe_signals(_signal_cb, &ad);
+
+ ret = stc_popup_app_init(argc, argv, &ad);
+ if (ret != TIZEN_ERROR_NONE)
+ goto done;
+
+done:
+ return ret;
+}
--- /dev/null
+#include <stc-popup-ui.h>
+#include <stc-popup-util.h>
+
+static void win_delete_request_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ ui_app_exit();
+}
+
+static void win_back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ appdata_s *ad = data;
+ /* Let window go to hide state. */
+ elm_win_lower(ad->win);
+}
+
+static void _response_button1_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+ elm_popup_dismiss(data);
+ /* Button 1 action */
+}
+
+static void _response_button2_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!data)
+ return;
+ elm_popup_dismiss(data);
+ /* Button 2 action */
+}
+
+static void _popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!obj)
+ return;
+ elm_popup_dismiss(obj);
+ win_back_cb(data, obj, event_info);
+}
+
+static void _popup_hide_finished_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ if (!obj)
+ return;
+ evas_object_del(obj);
+ win_back_cb(data, obj, event_info);
+}
+
+static void _popup_title_text_2button(appdata_s *ad, const char *title,
+ const char *body)
+{
+ Evas_Object *popup;
+ Evas_Object *btn;
+ Evas_Object *icon;
+ Evas_Object *layout;
+
+ popup = elm_popup_add(ad->win);
+ elm_object_style_set(popup, "circle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, ad);
+ evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, ad);
+
+ layout = elm_layout_add(popup);
+ elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+ elm_object_part_text_set(layout, "elm.text.title", title);
+
+ elm_object_part_text_set(layout, "elm.text", body);
+ elm_object_content_set(popup, layout);
+
+ btn = elm_button_add(popup);
+ elm_object_style_set(btn, "popup/circle/left");
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(popup, "button1", btn);
+ evas_object_smart_callback_add(btn, "clicked", _response_button1_cb, popup);
+
+ icon = elm_image_add(btn);
+ elm_image_file_set(icon, IMAGEDIR"/popup_btn_delete.png", NULL);
+ evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(btn, "elm.swallow.content", icon);
+ evas_object_show(icon);
+
+ btn = elm_button_add(popup);
+ elm_object_style_set(btn, "popup/circle/right");
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(popup, "button2", btn);
+ evas_object_smart_callback_add(btn, "clicked", _response_button2_cb, popup);
+
+ icon = elm_image_add(btn);
+ elm_image_file_set(icon, IMAGEDIR"/popup_btn_check.png", NULL);
+ evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(btn, "elm.swallow.content", icon);
+ evas_object_show(icon);
+
+ evas_object_show(popup);
+}
+
+void create_window(appdata_s *ad)
+{
+ /*
+ * Widget Tree
+ * Window
+ * - conform
+ * - layout main */
+
+ /* Window */
+ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+ elm_win_conformant_set(ad->win, EINA_TRUE);
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+
+ evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
+ eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
+
+ /* Conformant */
+ ad->conform = elm_conformant_add(ad->win);
+ evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(ad->win, ad->conform);
+ evas_object_show(ad->conform);
+
+ /* Base Layout */
+ ad->layout = elm_layout_add(ad->conform);
+ evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_layout_theme_set(ad->layout, "layout", "application", "default");
+ evas_object_show(ad->layout);
+
+ elm_object_content_set(ad->conform, ad->layout);
+
+ /* Show window after base gui is set up */
+ evas_object_show(ad->win);
+}
+
+void create_popup(appdata_s *ad, popup_type_e type, const char *app_id)
+{
+ if (ad->win != NULL)
+ elm_win_raise(ad->win);
+ else
+ create_window(ad);
+
+ switch (type) {
+ case POPUP_TYPE_RSTN:
+ _popup_title_text_2button(ad, DATA_USAGE_RSTN_TITLE,
+ DATA_USAGE_RSTN_BODY);
+ break;
+ case POPUP_TYPE_WARN:
+ _popup_title_text_2button(ad, DATA_USAGE_WARN_TITLE,
+ DATA_USAGE_WARN_BODY);
+ break;
+ default:
+ STC_LOGE("Unhandled popup type");
+ };
+}
+
+static bool app_create(void *data)
+{
+ /* Handle the app create request. */
+ return true;
+}
+
+static void app_control(app_control_h app_control, void *data)
+{
+ /* Handle the launch request. */
+}
+
+static void app_pause(void *data)
+{
+ /* Take necessary actions when application becomes invisible. */
+}
+
+static void app_resume(void *data)
+{
+ /* Take necessary actions when application becomes visible. */
+}
+
+static void app_terminate(void *data)
+{
+ /* Release all resources. */
+}
+
+static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+ char *locale = NULL;
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+ elm_language_set(locale);
+ free(locale);
+ return;
+}
+
+static void ui_app_orient_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+ return;
+}
+
+static void ui_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void ui_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void ui_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+}
+
+int stc_popup_app_init(int argc, char *argv[], appdata_s *ad)
+{
+ int ret = 0;
+
+ ui_app_lifecycle_callback_s event_callback = {0,};
+ app_event_handler_h handlers[5] = {NULL, };
+
+ event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.app_control = app_control;
+
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, ad);
+ ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, ad);
+
+ ret = ui_app_main(argc, argv, &event_callback, ad);
+ if (ret != APP_ERROR_NONE) {
+ STC_LOGE("app_main() is failed. err = %d", ret);
+ }
+
+ return ret;
+}
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stc-plugin-wearable-popup C)
+PROJECT(stc-plugin-stc-popup C)
# Set required packages
INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(wearable_popup_plugin REQUIRED
+PKG_CHECK_MODULES(stc_popup_plugin REQUIRED
dlog
- gio-2.0
- gio-unix-2.0
glib-2.0
)
-FOREACH(flag ${wearable_popup_plugin_CFLAGS})
+FOREACH(flag ${stc_popup_plugin_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
ADD_DEFINITIONS("-DUSE_DLOG")
SET(SRCS_PLUGIN
- stc-plugin-wearable-popup.c
+ stc-plugin-stc-popup.c
)
# library build
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_PLUGIN})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wearable_popup_plugin_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${stc_popup_plugin_LDFLAGS})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
# install
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "stc-plugin-popup.h"
+#include "stc-error.h"
+#include "stc-manager-util.h"
+
+#define APP_LAUNCHER_EXEC_PATH "/usr/bin/app_launcher"
+#define STC_POPUP_PACKAGE_NAME "net.stc-popup"
+
+#define MAX_SIZE_ERROR_BUFFER 256
+#define STC_POPUP_START_TIMER 10
+
+static void _no_wait_signal_handler(int sig)
+{
+ pid_t child_pid = 0;
+ int state = 0;
+
+ child_pid = waitpid(-1, &state, WNOHANG);
+
+ STC_LOGD("child_id(%d) state(%d)", child_pid, WEXITSTATUS(state));
+}
+
+static int _execute_file_no_wait(const char *file_path, char *const args[])
+{
+ pid_t pid = 0;
+ int rv = 0;
+ errno = 0;
+ register unsigned int index = 0;
+
+ struct sigaction act;
+ int state = 0;
+ char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+ act.sa_handler = _no_wait_signal_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+
+ state = sigaction(SIGCHLD, &act, 0);
+ if (state != 0) {
+ STC_LOGD("sigaction() : %d");
+ return -1;
+ }
+
+ while (args[index] != NULL) {
+ STC_LOGD("%s", args[index]);
+ index++;
+ }
+
+ if (!(pid = fork())) {
+ STC_LOGD("pid(%d), ppid (%d)", getpid(), getppid());
+ STC_LOGD("Inside child, exec (%s) command", file_path);
+
+ errno = 0;
+ if (execvp(file_path, args) == -1) {
+ STC_LOGE("Fail to execute command (%s)",
+ strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
+ return -1;
+ }
+ } else if (pid > 0) {
+ STC_LOGE("Successfully launched child process");
+ return rv;
+ }
+
+ STC_LOGD("failed to fork(%s)",
+ strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
+ return -EIO;
+}
+
+static gboolean _start_stc_popup(gpointer user_data)
+{
+ gboolean *launched = (gboolean *)user_data;
+ int ret;
+ const char *start_path = APP_LAUNCHER_EXEC_PATH;
+ char *const start_args[] = { APP_LAUNCHER_EXEC_PATH, "-s",
+ STC_POPUP_PACKAGE_NAME, NULL };
+
+ ret = _execute_file_no_wait(start_path, start_args);
+ if (ret < 0) {
+ STC_LOGD("Failed to launch stc-popup, ret : %d", ret);
+ *launched = FALSE;
+ return TRUE;
+ }
+
+ *launched = FALSE;
+ return FALSE;
+}
+
+int stc_plugin_popup_initialize(void)
+{
+ static gboolean stc_popup_launched = FALSE;
+
+ if (stc_popup_launched == FALSE)
+ g_timeout_add_seconds(STC_POPUP_START_TIMER, _start_stc_popup,
+ &stc_popup_launched);
+ else
+ return STC_ERROR_FAIL;
+
+ return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_deinitialize(void)
+{
+ /* close stc popup application */
+ return STC_ERROR_NONE;
+}
+
+int stc_plugin_popup_show(const char *content, const char *type,
+ const char *app_id, const char *iftype,
+ const char *limit)
+{
+ return 0;
+}
+
+API stc_plugin_popup_s stc_plugin_popup = {
+ .initialize_plugin =
+ stc_plugin_popup_initialize,
+ .deinitialize_plugin =
+ stc_plugin_popup_deinitialize,
+ .show_popup = stc_plugin_popup_show
+};
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stc-plugin-wearable-popup C)
-
-ADD_SUBDIRECTORY(stc-plugin)
-ADD_SUBDIRECTORY(stc-popup)
+++ /dev/null
-/*
- * Copyright (c) 2016 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 "stc-plugin-popup.h"
-#include "stc-error.h"
-#include "stc-manager-util.h"
-
-int stc_plugin_popup_initialize(void)
-{
- return STC_ERROR_NONE;
-}
-
-int stc_plugin_popup_deinitialize(void)
-{
- return STC_ERROR_NONE;
-}
-
-int stc_plugin_popup_show(const char *content, const char *type,
- const char *app_id, const char *iftype,
- const char *limit)
-{
- return STC_ERROR_NONE;
-}
-
-API stc_plugin_popup_s stc_plugin_popup = {
- .initialize_plugin =
- stc_plugin_popup_initialize,
- .deinitialize_plugin =
- stc_plugin_popup_deinitialize,
- .show_popup = stc_plugin_popup_show
-};
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(stc-wearable-popup C)
-SET(PACKAGE ${PROJECT_NAME})
-
-# Set required packages
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(wearable_popup REQUIRED
- dlog
- glib-2.0
- elementary
- capi-appfw-application
- efl-extension
- capi-system-system-settings
- )
-
-FOREACH(flag ${wearable_popup_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror -fvisibility=hidden")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
-
-ADD_DEFINITIONS("-DUSE_DLOG")
-
-INCLUDE_DIRECTORIES(inc)
-AUX_SOURCE_DIRECTORY(./src stc_wearable_srcs)
-
-ADD_EXECUTABLE(${PROJECT_NAME} ${stc_wearable_srcs})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wearable_popup_LDFLAGS} -ldl)
-
-# install
-INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
+++ /dev/null
-#ifndef __stc_wearable_popup_H__
-#define __stc_wearable_popup_H__
-
-#include <app.h>
-#include <Elementary.h>
-#include <system_settings.h>
-#include <efl_extension.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "stc-wearable-popup"
-
-#if !defined(PACKAGE)
-#define PACKAGE "org.tizen.stc-wearable-popup"
-#endif
-
-#endif /* __stc_wearable_popup_H__ */
+++ /dev/null
-#include "stc-wearable-popup.h"
-
-typedef struct appdata {
- Evas_Object *win;
- Evas_Object *conform;
- Evas_Object *label;
-} appdata_s;
-
-static void
-win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
-{
- ui_app_exit();
-}
-
-static void
-win_back_cb(void *data, Evas_Object *obj, void *event_info)
-{
- appdata_s *ad = data;
- /* Let window go to hide state. */
- elm_win_lower(ad->win);
-}
-
-static void
-create_base_gui(appdata_s *ad)
-{
- /* Window */
- /* Create and initialize elm_win.
- elm_win is mandatory to manipulate window. */
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_autodel_set(ad->win, EINA_TRUE);
-
- if (elm_win_wm_rotation_supported_get(ad->win)) {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
- eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
-
- /* Conformant */
- /* Create and initialize elm_conformant.
- elm_conformant is mandatory for base gui to have proper size
- when indicator or virtual keypad is visible. */
- ad->conform = elm_conformant_add(ad->win);
- elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
- evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, ad->conform);
- evas_object_show(ad->conform);
-
- /* Label */
- /* Create an actual view of the base gui.
- Modify this part to change the view. */
- ad->label = elm_label_add(ad->conform);
- elm_object_text_set(ad->label, "<align=center>Hello Tizen</align>");
- evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(ad->conform, ad->label);
-
- /* Show window after base gui is set up */
- evas_object_show(ad->win);
-}
-
-static bool
-app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = data;
-
- create_base_gui(ad);
-
- return true;
-}
-
-static void
-app_control(app_control_h app_control, void *data)
-{
- /* Handle the launch request. */
-}
-
-static void
-app_pause(void *data)
-{
- /* Take necessary actions when application becomes invisible. */
-}
-
-static void
-app_resume(void *data)
-{
- /* Take necessary actions when application becomes visible. */
-}
-
-static void
-app_terminate(void *data)
-{
- /* Release all resources. */
-}
-
-static void
-ui_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
- char *locale = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- return;
-}
-
-static void
-ui_app_orient_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
- return;
-}
-
-static void
-ui_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void
-ui_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void
-ui_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-int
-main(int argc, char *argv[])
-{
- appdata_s ad = {0,};
- int ret = 0;
-
- ui_app_lifecycle_callback_s event_callback = {0,};
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = app_create;
- event_callback.terminate = app_terminate;
- event_callback.pause = app_pause;
- event_callback.resume = app_resume;
- event_callback.app_control = app_control;
-
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
-
- ret = ui_app_main(argc, argv, &event_callback, &ad);
- if (ret != APP_ERROR_NONE) {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
- }
-
- return ret;
-}