Initial commit for car-controller
authorjunkyu han <junkyu.han@samsung.com>
Thu, 4 Jan 2018 05:59:43 +0000 (14:59 +0900)
committerjunkyu han <junkyu.han@samsung.com>
Thu, 4 Jan 2018 05:59:43 +0000 (14:59 +0900)
CMakeLists.txt [new file with mode: 0644]
README.md
inc/log.h [new file with mode: 0644]
org.tizen.car-controller.manifest [new file with mode: 0644]
packaging/car-controller.spec [new file with mode: 0644]
res/edje/app.edc [new file with mode: 0644]
shared/res/default_icon.png [new file with mode: 0644]
src/app.c [new file with mode: 0644]
tizen-manifest.xml.in [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e17ba00
--- /dev/null
@@ -0,0 +1,52 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(${P_NAME} C)
+
+SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin")
+SET(CMAKE_VERBOSE_MAKEFILE 0)
+
+SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
+SET(PROJECT_RESOURCES_DIR "${PROJECT_ROOT_DIR}/res")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(APP_PKGS REQUIRED
+       dlog
+       capi-appfw-application
+       capi-ui-efl-util
+       elementary
+       efl-extension
+)
+
+FOREACH (flag ${APP_PKGS_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+       ${PROJECT_ROOT_DIR}/src/app.c
+)
+
+ADD_CUSTOM_COMMAND(OUTPUT app.edj
+               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/res/images/
+                       ${CMAKE_SOURCE_DIR}/res/edje/app.edc ${CMAKE_BINARY_DIR}/app.edj
+               DEPENDS ${CMAKE_SOURCE_DIR}/res/edje/app.edc
+)
+
+ADD_CUSTOM_TARGET(edj_build DEPENDS app.edj)
+ADD_DEPENDENCIES(${PROJECT_NAME} edj_build)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
+
+CONFIGURE_FILE(${PROJECT_ROOT_DIR}/tizen-manifest.xml.in ${ORG_PREFIX}.${PROJECT_NAME}.xml @ONLY)
+# Install
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_EXEC_PREFIX})
+INSTALL(FILES ${ORG_PREFIX}.${PROJECT_NAME}.xml DESTINATION ${SYS_PACKAGES_DIR})
+INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/default_icon.png DESTINATION ${SYS_ICONS_DIR} RENAME ${PROJECT_NAME}.png)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/app.edj DESTINATION /usr/share/edje)
+
+# End of a file
index 0c1affb..073d825 100755 (executable)
--- a/README.md
+++ b/README.md
@@ -1,2 +1 @@
-# gear-racing-controller \r
-Wearable gear-racing-controller development\r
+# car-controller
diff --git a/inc/log.h b/inc/log.h
new file mode 100644 (file)
index 0000000..3d0d4a0
--- /dev/null
+++ b/inc/log.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * 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 __CAR_APP_LOG_H__
+#define __CAR_APP_LOG_H__
+
+#include <dlog.h>
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "CAR_CON"
+
+#if !defined(_D)
+#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_I)
+#define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return val; \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if (expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define ret_if(expr) do { \
+       if (expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define goto_if(expr, val) do { \
+       if (expr) { \
+               _E("(%s) -> goto", #expr); \
+               goto val; \
+       } \
+} while (0)
+
+#define break_if(expr) { \
+       if (expr) { \
+               _E("(%s) -> break", #expr); \
+               break; \
+       } \
+}
+
+#define continue_if(expr) { \
+       if (expr) { \
+               _E("(%s) -> continue", #expr); \
+               continue; \
+       } \
+}
+
+typedef enum {
+       LOG_TYPE_DLOG = 0,
+       LOG_TYPE_FILE,
+       LOG_TYPE_ALL,
+} log_type;
+
+int log_print(log_priority prio, const char *tag, const char *fmt, ...);
+int log_type_set(log_type type);
+void log_file_close(void);
+
+#endif /* __CAR_APP_LOG_H__ */
diff --git a/org.tizen.car-controller.manifest b/org.tizen.car-controller.manifest
new file mode 100644 (file)
index 0000000..af9b883
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>\r
+       <request>\r
+               <domain name="_" />\r
+       </request>\r
+</manifest>\r
diff --git a/packaging/car-controller.spec b/packaging/car-controller.spec
new file mode 100644 (file)
index 0000000..c579b43
--- /dev/null
@@ -0,0 +1,80 @@
+%define P_NAME car-controller
+%define ORG_PREFIX org.tizen
+%define APP_LABEL "Car Controller"
+
+Name:       %{ORG_PREFIX}.%{P_NAME}
+%define alias %{name}
+Summary:    Car Application
+Version:    0.0.1
+Release:    1
+License:    Flora-1.1
+Provides:   %{name} = %{version}-%{release}
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires:  cmake
+BuildRequires:  hash-signer
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(capi-ui-efl-util)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(efl-extension)
+BuildRequires:  pkgconfig(dlog)
+
+%description
+Car Controller application
+
+%prep
+%setup -q
+
+%build
+
+%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias}
+%define _pkg_shared_dir %{_pkg_dir}/shared
+%define _pkg_data_dir %{_pkg_dir}/data
+%define _pkg_res_dir %{_pkg_dir}/res
+%define _sys_icons_dir %{_pkg_shared_dir}/res
+%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES}
+%define _sys_license_dir %{TZ_SYS_SHARE}/license
+
+
+%ifarch %{arm}
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_TARGET"
+export FFLAGS="$FFLAGS -DTIZEN_BUILD_TARGET"
+%else
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR"
+export FFLAGS="$FFLAGS -DTIZEN_BUILD_EMULATOR"
+%endif
+
+cmake . -DP_NAME=%{P_NAME} \
+       -DORG_PREFIX=%{ORG_PREFIX} \
+       -DAPP_LABEL=%{APP_LABEL} \
+       -DINSTALL_PREFIX=%{_pkg_dir} \
+       -DSYS_ICONS_DIR=%{_sys_icons_dir} \
+       -DSYS_PACKAGES_DIR=%{_sys_packages_dir} \
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%define tizen_sign 1
+%define tizen_sign_base %{_pkg_dir}
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{alias}.manifest
+%defattr(-,root,root,-)
+%{_pkg_dir}/bin/%{P_NAME}
+%{_sys_packages_dir}/%{alias}.xml
+%{_sys_icons_dir}/*.png
+%{_pkg_dir}/author-signature.xml
+%{_pkg_dir}/signature1.xml
+/usr/share/edje/app.edj
diff --git a/res/edje/app.edc b/res/edje/app.edc
new file mode 100644 (file)
index 0000000..2d73800
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 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.
+ */ 
+
+collections {
+       group {
+               name: "main_page";
+               parts {
+                       part {
+                               name: "center_bg";
+                               type: RECT;
+                               description {
+                                       state: "default" 0.0;
+                                       align: 0.5 0.5;
+                                       rel1 { relative: 0.0 0.0; }
+                                       rel2 { relative: 1.0 1.0; }
+                                       color : 0 0 0 255;
+                               }
+                       }
+                       part {
+                               name: "center_text";
+                               type: TEXT;
+                               description {
+                                       state: "default" 0.0;
+                                       align: 0.5 0.5;
+                                       rel1 { relative: 0.5 0.5; to: "center_bg"; }
+                                       rel2 { relative: 0.5 0.5; to: "center_bg"; }
+                                       text {
+                                               text: "Center";
+                                               font: "Tizen:style=regular"; size: 40; align: 0.5 0.5;
+                                       }
+                                       color : 250 250 250 255;
+                                       min: 200 200;
+                               }
+                       }
+               }
+       }
+}
diff --git a/shared/res/default_icon.png b/shared/res/default_icon.png
new file mode 100644 (file)
index 0000000..9765b1b
Binary files /dev/null and b/shared/res/default_icon.png differ
diff --git a/src/app.c b/src/app.c
new file mode 100644 (file)
index 0000000..61d9367
--- /dev/null
+++ b/src/app.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: junkyu Han <junkyu.han@samsung.com>
+ *
+ * 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 <stdio.h>
+#include <unistd.h>
+#include <Elementary.h>
+#include <efl_extension.h>
+#include <app.h>
+#include "log.h"
+
+static void _win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static void _back_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static Evas_Object *_create_window(char *pkg_name)
+{
+       Evas_Object *win = NULL;
+
+       win = elm_win_util_standard_add("car-controller", "car-controller");
+       elm_win_conformant_set(win, EINA_TRUE);
+       elm_win_autodel_set(win, EINA_TRUE);
+
+       /* Rotation setting */
+       if (elm_win_wm_rotation_supported_get(win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(win, (const int *)(&rots), 4);
+       }
+
+       evas_object_smart_callback_add(win, "delete,request", _win_delete_request_cb, NULL);
+
+       evas_object_show(win);
+
+       return win;
+}
+
+static Evas_Object *_create_conformant(Evas_Object *parent)
+{
+       Evas_Object *conform = NULL;
+
+       conform = elm_conformant_add(parent);
+       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(parent, conform);
+
+       evas_object_show(conform);
+
+       return conform;
+}
+
+static Evas_Object *_create_layout(Evas_Object *parent)
+{
+       Evas_Object *layout = NULL;
+
+       layout = elm_layout_add(parent);
+       elm_layout_file_set(layout, "/usr/share/edje/app.edj", "main_page");
+
+       /* Layout size setting */
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, _back_button_cb, NULL);
+
+       elm_object_content_set(parent, layout);
+
+       evas_object_show(layout);
+
+       return layout;
+}
+
+static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+       return;
+}
+
+static bool app_create(void *user_data)
+{
+       Evas_Object *win = NULL;
+       Evas_Object *conform = NULL;
+       Evas_Object *layout = NULL;
+
+       win = _create_window("car-controller");
+       if (!win) {
+               _D("Failed to create window");
+               return false;
+       }
+
+       conform = _create_conformant(win);
+       if (!conform) {
+               _D("Failed to create conformant");
+               return false;
+       }
+
+       layout = _create_layout(conform);
+       if (!layout) {
+               _D("Failed to create layout");
+               return false;
+       }
+
+       return true;
+}
+
+static void app_control(app_control_h app_control, void *user_data)
+{
+       return;
+}
+
+static void app_resume(void *user_data)
+{
+       return;
+}
+
+static void app_pause(void *user_data)
+{
+       return;
+}
+
+static void app_terminate(void *user_data)
+{
+       return;
+}
+
+int main(int argc, char* argv[])
+{
+       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_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, NULL);
+
+       ret = ui_app_main(argc, argv, &event_callback, NULL);
+
+       return ret;
+}
+
diff --git a/tizen-manifest.xml.in b/tizen-manifest.xml.in
new file mode 100644 (file)
index 0000000..c5a61d5
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="@ORG_PREFIX@.@PROJECT_NAME@" version="1.0.0">
+    <profile name="mobile"/>
+    <service-application appid="@ORG_PREFIX@.@PROJECT_NAME@" auto-restart="false" exec="@PROJECT_NAME@" multiple="false" nodisplay="true" on-boot="true" taskmanage="false" type="capp">
+        <label>@APP_LABEL@</label>
+        <icon>@PROJECT_NAME@.png</icon>
+    </service-application>
+    <privileges>
+               <privilege>http://tizen.org/privilege/network.get</privilege>
+               <privilege>http://tizen.org/privilege/internet</privilege>
+               <privilege>http://tizen.org/privilege/peripheralio</privilege>
+    </privileges>
+</manifest>