TizenRefApp-8269 [Call UI] Prepare application sceleton 27/121827/2
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 29 Mar 2017 06:46:46 +0000 (09:46 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 29 Mar 2017 06:48:48 +0000 (09:48 +0300)
Change-Id: I979aed72bbd0d25a2912db648e95b8f44aed9521

inc/call-ui.h [deleted file]
inc/config.h [new file with mode: 0644]
inc/main/Instance.h [new file with mode: 0644]
inc/main/InstanceManager.h [new file with mode: 0644]
inc/types.h [new file with mode: 0644]
src/call-ui.cpp [deleted file]
src/common.h [new file with mode: 0644]
src/main/Instance.cpp [new file with mode: 0644]
src/main/InstanceManager.cpp [new file with mode: 0644]
src/main/main.cpp [new file with mode: 0644]
ucl/inc/ucl/config.h

diff --git a/inc/call-ui.h b/inc/call-ui.h
deleted file mode 100644 (file)
index 207f0bc..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 __CALL_UI_H__
-#define __CALL_UI_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 "call-ui"
-
-#if !defined(PACKAGE)
-#define PACKAGE "org.tizen.call-ui"
-#endif
-
-#endif /* __CALL_UI_H__ */
diff --git a/inc/config.h b/inc/config.h
new file mode 100644 (file)
index 0000000..5d9d113
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 __CALLUI_CONFIG_H__
+#define __CALLUI_CONFIG_H__
+
+#define CALLUI_LOG_TAG "CALLUI"
+
+namespace callui {
+
+       constexpr auto WINDOW_NAME = "org.tizen.call-ui";
+
+       constexpr auto BASE_SCALE = 1.3;
+}
+
+#endif // __CALL_UI_CONFIG_H__
diff --git a/inc/main/Instance.h b/inc/main/Instance.h
new file mode 100644 (file)
index 0000000..5fd2eb9
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 __CALLUI_MAIN_INSTANCE_H__
+#define __CALLUI_MAIN_INSTANCE_H__
+
+#include "types.h"
+
+#include "ucl/appfw/IInstance.h"
+#include "ucl/appfw/IInstanceAppControlExt.h"
+
+#include "ucl/appfw/SysEventProvider.h"
+
+namespace callui {
+
+       class Instance :
+                       public ucl::IInstance,
+                       public ucl::IInstanceAppControlExt {
+       public:
+               Instance(ucl::SysEventProvider &sysEventProvider);
+
+               // IInstance //
+
+               virtual ucl::Result onCreate(
+                               ucl::IInstanceContext *context) final override;
+               virtual void onPause() final override;
+               virtual void onResume() final override;
+
+               // IInstanceAppControlExt //
+
+               virtual void onAppControl(app_control_h appControl) final override;
+
+       private:
+               void onBack(Evas_Object *obj, void *event_info);
+               void onSysEvent(const ucl::SysEvent sysEvent);
+
+       private:
+               ucl::SysEventProvider &m_sysEventProvider;
+               ucl::IInstanceContext *m_context;
+               ucl::WindowSRef m_win;
+       };
+}
+
+#endif // __CALLUI_MAIN_INSTANCE_H__
diff --git a/inc/main/InstanceManager.h b/inc/main/InstanceManager.h
new file mode 100644 (file)
index 0000000..7154dff
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 __CALLUI_MAIN_INSTANCE_MANAGER_H__
+#define __CALLUI_MAIN_INSTANCE_MANAGER_H__
+
+#include "types.h"
+
+#include "ucl/appfw/InstanceManagerBase.h"
+
+namespace callui {
+
+       class InstanceManager : public ucl::InstanceManagerBase {
+       public:
+               InstanceManager();
+
+               // ucl::InstanceManagerBase //
+
+               virtual ucl::IInstance *newInstance() const final override;
+       };
+}
+
+#endif // __CALLUI_MAIN_INSTANCE_MANAGER_H__
diff --git a/inc/types.h b/inc/types.h
new file mode 100644 (file)
index 0000000..efb664b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 __CALLUI_TYPES_H__
+#define __CALLUI_TYPES_H__
+
+#include "config.h"
+
+#include "ucl/util/types.h"
+#include "ucl/util/memory.h"
+#include "ucl/util/delegation.h"
+
+#endif // __CALLUI_TYPES_H_
diff --git a/src/call-ui.cpp b/src/call-ui.cpp
deleted file mode 100644 (file)
index 0cf0ecf..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * 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 "call-ui.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 = static_cast<appdata_s *>(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 = static_cast<appdata_s *>(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;
-}
diff --git a/src/common.h b/src/common.h
new file mode 100644 (file)
index 0000000..1e0964b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 __CALLUI_COMMON_H__
+#define __CALLUI_COMMON_H__
+
+#include <algorithm>
+
+#include <Ecore.h>
+
+#include "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+#include "ucl/util/shortLogs.h"
+
+#include "ucl/gui/stdTheme.h"
+#include "ucl/gui/helpers.h"
+
+#undef UCL_LOG_TAG
+#define UCL_LOG_TAG "CALLUI"
+
+#endif // __CALLUI_COMMON_H__
diff --git a/src/main/Instance.cpp b/src/main/Instance.cpp
new file mode 100644 (file)
index 0000000..79b9f52
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 "main/Instance.h"
+
+#include <system_settings.h>
+#include <efl_extension.h>
+
+#include "../common.h"
+
+namespace callui {
+
+       using namespace ucl;
+
+       Instance::Instance(SysEventProvider &sysEventProvider) :
+               m_sysEventProvider(sysEventProvider),
+               m_context(nullptr)
+       {
+       }
+
+       Result Instance::onCreate(IInstanceContext *const context)
+       {
+               m_context = context;
+
+               m_win = m_context->getWindow();
+
+               m_sysEventProvider.addEventHandler(
+                               DELEGATE(Instance::onSysEvent, this));
+
+               eext_object_event_callback_add(*m_win, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(Instance::onBack), this);
+
+               return RES_OK;
+       }
+
+       void Instance::onPause()
+       {
+               ILOG("PAUSED");
+       }
+
+       void Instance::onResume()
+       {
+               ILOG("RESUMED");
+       }
+
+       void Instance::onAppControl(app_control_h appControl)
+       {
+               char *op = {};
+               app_control_get_operation(appControl, &op);
+               ILOG("operation: %s", op);
+               free(op);
+
+               if (!m_win->isVisible()) {
+                       show(*m_win);
+               }
+       }
+
+       void Instance::onBack(Evas_Object *obj, void *event_info)
+       {
+               ILOG("Exiting the application...");
+               m_context->exitApp();
+       }
+
+       void Instance::onSysEvent(const SysEvent sysEvent)
+       {
+               switch(sysEvent) {
+               case SysEvent::LANGUAGE_CHANGED:
+                       ILOG("SysEvent::LANGUAGE_CHANGED");
+                       {
+                               char *locale = NULL;
+                               system_settings_get_value_string(
+                                               SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+                               elm_language_set(locale);
+                               free(locale);
+                       }
+                       break;
+               default:
+                       ILOG("sysEvent: %d", sysEvent);
+                       break;
+               }
+       }
+}
diff --git a/src/main/InstanceManager.cpp b/src/main/InstanceManager.cpp
new file mode 100644 (file)
index 0000000..a42e593
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 "main/InstanceManager.h"
+
+#include "main/Instance.h"
+
+namespace callui {
+
+       using namespace ucl;
+
+       InstanceManager::InstanceManager() :
+               InstanceManagerBase(AppParams().
+                               set(AppParam::WINDOW_NAME, WINDOW_NAME).
+                               set(AppParam::BASE_SCALE, BASE_SCALE))
+       {
+       }
+
+       IInstance *InstanceManager::newInstance() const
+       {
+               return new Instance(getSysEventProvider());
+       }
+}
diff --git a/src/main/main.cpp b/src/main/main.cpp
new file mode 100644 (file)
index 0000000..6133677
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 "ucl/appfw/UIApp.h"
+
+#include "main/InstanceManager.h"
+
+#include "../common.h"
+
+using namespace ucl;
+using namespace callui;
+
+int main(int argc, char *argv[])
+{
+       InstanceManager mgr;
+       const int ret = UIApp(mgr).run(argc, argv);
+       ILOG("ret: %d", ret);
+       return ret;
+}
index 588a0ee1e449869717942487d1c9560b807cc5c7..ba0a30c8aade3c477b67a6b0add80bf2a9a56bfb 100644 (file)
@@ -22,7 +22,7 @@
 
 #define UCL_DEFAULT_LOG_TAG "UCL"
 
-#define UCL_INCLUDE_DELEGATION_SHORT_MACRO_H 0
-#define UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H 0
+#define UCL_INCLUDE_DELEGATION_SHORT_MACRO_H 1
+#define UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H 1
 
 #endif // __UCL_CONFIG_H__