2 * Copyright (c) 2016 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <service_app.h>
18 #include <system_settings.h>
19 #include <Elementary.h>
21 #include "$(appName).h"
25 * @brief Hook to take necessary actions before main event loop starts.
26 * Initialize the service's data.
27 * If this function returns true, the main loop of the sertvice starts.
28 * If this function returns false, the service is terminated.
30 static bool srv_create(void *user_data)
36 * @brief This callback function is called when another application.
37 * sends the launch request to the service.
39 static void srv_control(app_control_h app_control, void *user_data)
41 /* Handle the launch request. */
45 * @brief This callback function is called once after the main loop.
46 * of the service exits.
48 static void srv_terminate(void *user_data)
50 /* Release all resources. */
54 * @brief This function will be called when the language is changed.
56 static void service_lang_changed(app_event_info_h event_info, void *user_data)
60 system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
63 elm_language_set(locale);
70 * @brief Main function of the service.
72 int main(int argc, char *argv[])
76 service_app_lifecycle_callback_s event_callback = {0, };
77 app_event_handler_h handlers[5] = {NULL, };
79 event_callback.create = srv_create;
80 event_callback.terminate = srv_terminate;
81 event_callback.app_control = srv_control;
84 * If you want to handling more events,
85 * please check the service's lifecycle guide.
87 service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_lang_changed, NULL);
89 ret = service_app_main(argc, argv, &event_callback, NULL);
90 if (ret != APP_ERROR_NONE)
91 dlog_print(DLOG_ERROR, LOG_TAG, "service_app_main() is failed. err = %d", ret);