diff options
Diffstat (limited to 'ugapp-wifidirect')
-rwxr-xr-x | ugapp-wifidirect/CMakeLists.txt | 41 | ||||
-rwxr-xr-x | ugapp-wifidirect/include/wfd-ugapp-util.h | 78 | ||||
-rwxr-xr-x | ugapp-wifidirect/include/wfd-ugapp.h | 52 | ||||
-rwxr-xr-x | ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml | 11 | ||||
-rwxr-xr-x | ugapp-wifidirect/src/wfd-ugapp-main.c | 372 | ||||
-rw-r--r-- | ugapp-wifidirect/src/wfd-ugapp-util.c | 73 |
6 files changed, 627 insertions, 0 deletions
diff --git a/ugapp-wifidirect/CMakeLists.txt b/ugapp-wifidirect/CMakeLists.txt new file mode 100755 index 0000000..7c4b390 --- /dev/null +++ b/ugapp-wifidirect/CMakeLists.txt @@ -0,0 +1,41 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(wifi-direct-ugapp C) +SET(PACKAGE_NAME org.tizen.wifi-direct-ugapp) + +SET(PREFIX /usr/apps/${PACKAGE_NAME}) +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(LOCALEDIR "${RESDIR}/locale") +SET(EDJDIR "${RESDIR}/edje") +SET(IMGDIR "${RESDIR}/images") + +SET(SRCS + src/wfd-ugapp-main.c + src/wfd-ugapp-util.c +) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + + +SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -DUSE_DLOG") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) + +#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.desktop.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop DESTINATION /usr/share/applications) +#for appfw new manifest +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml DESTINATION "/usr/share/packages/") diff --git a/ugapp-wifidirect/include/wfd-ugapp-util.h b/ugapp-wifidirect/include/wfd-ugapp-util.h new file mode 100755 index 0000000..7139e9a --- /dev/null +++ b/ugapp-wifidirect/include/wfd-ugapp-util.h @@ -0,0 +1,78 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.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. +* +*/ + +/** + * This file declares wifi direct application util functions. + * + * @file wfd-app-util.h + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + +#ifndef __WFD_APP_UTIL_H__ +#define __WFD_APP_UTIL_H__ + +#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] +#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" + +#ifdef USE_DLOG +#include <dlog.h> + +#undef LOG_TAG +#define LOG_TAG "WIFI_DIRECT_UGAPP" + +#define WDUA_LOGV(format, args...) LOGV(format, ##args) +#define WDUA_LOGD(format, args...) LOGD(format, ##args) +#define WDUA_LOGI(format, args...) LOGI(format, ##args) +#define WDUA_LOGW(format, args...) LOGW(format, ##args) +#define WDUA_LOGE(format, args...) LOGE(format, ##args) +#define WDUA_LOGF(format, args...) LOGF(format, ##args) + +#define __WDUA_LOG_FUNC_ENTER__ LOGV("Enter") +#define __WDUA_LOG_FUNC_EXIT__ LOGV("Quit") + +#define assertm_if(expr, fmt, args...) do { \ + if (expr) { \ + WDUA_LOGF(" ##(%s) -> assert!!## "fmt, #expr, ##args); \ + exit(1); \ + } \ +} while (0) + +#else /** _DLOG_UTIL */ +#define WDUA_LOGV(format, args...) \ + printf("[V/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) +#define WDUA_LOGD(format, args...) \ + printf("[D/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) +#define WDUA_LOGI(format, args...) \ + printf("[I/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) +#define WDUA_LOGW(format, args...) \ + printf("[W/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) +#define WDUA_LOGE(format, args...) \ + printf("[E/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) +#define WDUA_LOGF(format, args...) \ + printf("[F/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args) + +#define __WDUA_LOG_FUNC_ENTER__\ + printf("[V/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> Enter", __FILE__, __FUNCTION__, __LINE__) +#define __WDUA_LOG_FUNC_EXIT__ \ + printf("[V/WIFI_DIRECT_UGAPP] %s: %s()(%4d)> Exit", __FILE__, __FUNCTION__, __LINE__) + +#endif /** _DLOG_UTIL */ + +#endif /* __WFD_APP_UTIL_H__ */ diff --git a/ugapp-wifidirect/include/wfd-ugapp.h b/ugapp-wifidirect/include/wfd-ugapp.h new file mode 100755 index 0000000..61b7b31 --- /dev/null +++ b/ugapp-wifidirect/include/wfd-ugapp.h @@ -0,0 +1,52 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.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. +* +*/ + +/** + * This file declares wifi direct application functions. + * + * @file wfd-app.h + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + + +#ifndef __WFD_UG_APP_MAIN_H__ +#define __WFD_UG_APP_MAIN_H__ + +#include <appcore-efl.h> +#include <Ecore_X.h> +#include <Elementary.h> +#include <appsvc.h> +#include <aul.h> + + +#define PACKAGE "org.tizen.wifi-direct-ugapp" +#define LOCALEDIR "/usr/apps/org.tizen.wifi-direct-ugapp" +#define DESKTOP_ICON "/usr/apps/org.tizen.setting/res/icons/A01-1_icon_Wi-Fi_direct.png" + +typedef struct { + Evas_Object *win; + Evas_Object *bg; + Evas_Object *conform; + Evas_Object *top_layout; + Evas_Object *icon; + ui_gadget_h wifi_direct_ug; +} wfd_appdata_t; + +#endif /* __WFD_UG_APP_MAIN_H__ */ diff --git a/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml b/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml new file mode 100755 index 0000000..d9d9262 --- /dev/null +++ b/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.wifi-direct-ugapp" version="0.6.2" install-location="internal-only"> + <label>WifiDirectUgapp</label> + <author email="lastkgb.kim@samsung.com" href="www.samsung.com">Sungsik Jang</author> + <author email="jinmin@samsung.com" href="www.samsung.com">Dongwook Lee</author> + <description>WiFi Direct UG Application</description> + <ui-application appid="org.tizen.wifi-direct-ugapp" exec="/usr/apps/org.tizen.wifi-direct-ugapp/bin/wifi-direct-ugapp" nodisplay="true" multiple="false" type="capp" taskmanage="false"> + <label>WifiDirectUgapp</label> + <label xml:lang="en-us">WifiDirectUgapp</label> + </ui-application> +</manifest> diff --git a/ugapp-wifidirect/src/wfd-ugapp-main.c b/ugapp-wifidirect/src/wfd-ugapp-main.c new file mode 100755 index 0000000..c9f0b1e --- /dev/null +++ b/ugapp-wifidirect/src/wfd-ugapp-main.c @@ -0,0 +1,372 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.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. +* +*/ + +/** + * This file implements wifi direct application main functions. + * + * @file wfd-ug-app-main.c + * @author Dongwook Lee (dwmax.lee@samsung.com) + * @version 0.1 + */ + +#include <ui-gadget-module.h> +#include <libintl.h> + +#include "wfd-ugapp.h" +#include "wfd-ugapp-util.h" + + +wfd_appdata_t *g_wfd_ad = NULL; +static struct ug_cbs wifi_direct_cbs; + +wfd_appdata_t *wfd_get_appdata() +{ + return g_wfd_ad; +} + +void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + __WDUA_LOG_FUNC_ENTER__; + + Evas_Object *base = NULL; + base = ug_get_layout(ug); + + if (!base) { + WDUA_LOGE("ug_get_layout failed!"); + ug_destroy(ug); + __WDUA_LOG_FUNC_EXIT__; + return; + } + + switch (mode) { + case UG_MODE_FULLVIEW: + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ug_get_window(), base); + evas_object_show(base); + break; + default: + break; + } + + __WDUA_LOG_FUNC_EXIT__; +} + +void _ug_destroy_cb(ui_gadget_h ug, void *priv) +{ + __WDUA_LOG_FUNC_ENTER__; + + // TODO: free all memory allocation + + ug_destroy(ug); + elm_exit(); +} + +void ug_result_cb(ui_gadget_h ug, service_h service, void *priv) +{ + __WDUA_LOG_FUNC_ENTER__; + + // TODO: free all memory allocation + + __WDUA_LOG_FUNC_EXIT__; +} + +static int load_wifi_direct_ug(ui_gadget_h parent_ug, void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + wfd_appdata_t *ugd = (wfd_appdata_t *)data; + service_h handle = NULL; + + UG_INIT_EFL(ugd->win, UG_OPT_INDICATOR_ENABLE); + + memset(&wifi_direct_cbs, 0, sizeof(struct ug_cbs)); + + wifi_direct_cbs.layout_cb = _ug_layout_cb; + wifi_direct_cbs.result_cb = ug_result_cb; + wifi_direct_cbs.destroy_cb = _ug_destroy_cb; + wifi_direct_cbs.priv = ugd; + + ugd->wifi_direct_ug = ug_create(parent_ug, "setting-wifidirect-efl", UG_MODE_FULLVIEW, handle, &wifi_direct_cbs); + if (ugd->wifi_direct_ug) { + __WDUA_LOG_FUNC_EXIT__; + return TRUE; + } else { + __WDUA_LOG_FUNC_EXIT__; + return FALSE; + } + + __WDUA_LOG_FUNC_EXIT__; +} + + +static void _win_del(void *data, Evas_Object * obj, void *event) +{ + elm_exit(); +} + +static Evas_Object *_create_win(Evas_Object * parent, const char *name) +{ + Evas_Object *eo; + int w, h; + + eo = elm_win_add(parent, name, ELM_WIN_BASIC); + if (eo) { + elm_win_title_set(eo, name); + elm_win_alpha_set(eo, EINA_TRUE); + elm_win_conformant_set(eo, EINA_TRUE); + evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL); + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + evas_object_resize(eo, w, h); + evas_object_show(eo); + } + + return eo; +} + +static Evas_Object* _set_win_icon(wfd_appdata_t *ad) +{ + __WDUA_LOG_FUNC_ENTER__; + + Evas_Object *icon = evas_object_image_add(evas_object_evas_get(ad->win)); + evas_object_image_file_set(icon, DESKTOP_ICON, NULL); + elm_win_icon_object_set(ad->win, icon); + + __WDUA_LOG_FUNC_EXIT__; + return icon; +} + +static Evas_Object *_create_bg(Evas_Object *parent) +{ + __WDUA_LOG_FUNC_ENTER__; + + if (NULL == parent) { + WDUA_LOGE("Incorrect parameter\n"); + return NULL; + } + + Evas_Object *bg = elm_bg_add(parent); + if (NULL == bg) { + WDUA_LOGE("Create background failed\n"); + return NULL; + } + + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, bg); + evas_object_show(bg); + + __WDUA_LOG_FUNC_EXIT__; + return bg; +} + +static Evas_Object *_create_layout_main(Evas_Object *parent) +{ + __WDUA_LOG_FUNC_ENTER__; + + if (NULL == parent) { + WDUA_LOGE("Incorrect parameter\n"); + return NULL; + } + + Evas_Object *layout = elm_layout_add(parent); + if (NULL == layout) { + WDUA_LOGE("Create layout failed\n"); + return NULL; + } + + const char *profile = elm_config_profile_get(); + if (!strcmp(profile, "mobile")) { + elm_layout_theme_set(layout, "layout", "application", "default"); + } else if (!strcmp(profile, "desktop")) { + elm_layout_theme_set(layout, "layout", "application", "noindicator"); + } + + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(parent, layout); + evas_object_show(layout); + + __WDUA_LOG_FUNC_EXIT__; + return layout; +} + +static void _win_profile_changed_cb(void *data, Evas_Object * obj, void *event_info) +{ + __WDUA_LOG_FUNC_ENTER__; + + if (data == NULL) { + WDUA_LOGE("Incorrect parameter\n"); + return -1; + } + + wfd_appdata_t *ad = (wfd_appdata_t *)data; + const char *profile = elm_config_profile_get(); + + if (!strcmp(profile, "desktop")) { /* desktop mode */ + /* hide layout's indicator area */ + elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_HIDE); + + /* set window icon */ + if (!ad->icon) { + ad->icon = _set_win_icon(ad); + } + } + else { /* mobile mode */ + /* show layout's indicator area */ + elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); + } + + __WDUA_LOG_FUNC_EXIT__; +} + +static int _app_create(void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + wfd_appdata_t *ad = wfd_get_appdata(); + + if (data == NULL) { + WDUA_LOGE("Incorrect parameter\n"); + return -1; + } + + bindtextdomain(PACKAGE, LOCALEDIR); + + ad->win = _create_win(NULL, PACKAGE); + evas_object_smart_callback_add(ad->win, "profile,changed", _win_profile_changed_cb, ad); + + /*Add conformat for indicator */ + ad->bg = _create_bg(ad->win); + if (ad->bg == NULL) { + WDUA_LOGE("Failed to create background"); + return -1; + } + + ad->conform = elm_conformant_add(ad->win); + if (ad->conform == NULL) { + WDUA_LOGE("Failed to create elm conformant"); + return -1; + } + + elm_win_resize_object_add(ad->win, ad->conform); + evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(ad->conform); + + ad->top_layout = _create_layout_main(ad->conform); + if (ad->top_layout == NULL) { + WDUA_LOGE("Failed to create top layout"); + return -1; + } + + elm_object_content_set(ad->conform, ad->top_layout); + + int r; + + if (!ecore_x_display_get()) { + return -1; + } + + r = appcore_set_i18n(PACKAGE, NULL); + if (r != 0) { + WDUA_LOGE("appcore_set_i18n error\n"); + return -1; + } + + __WDUA_LOG_FUNC_EXIT__; + return 0; +} + +static int _app_terminate(void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + + if (data == NULL) { + WDUA_LOGE("Incorrect parameter\n"); + return -1; + } + + wfd_appdata_t *ad = (wfd_appdata_t *) data; + + if (ad->win) { + evas_object_del(ad->win); + ad->win = NULL; + } + + if (ad->bg) { + evas_object_del(ad->bg); + ad->bg = NULL; + } + + if (ad->conform) { + evas_object_del(ad->conform); + ad->conform = NULL; + } + + if (ad->top_layout) { + evas_object_del(ad->top_layout); + ad->top_layout = NULL; + } + + if (ad->icon) { + evas_object_del(ad->icon); + ad->icon = NULL; + } + + __WDUA_LOG_FUNC_EXIT__; + return 0; +} + +static int _app_pause(void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + __WDUA_LOG_FUNC_EXIT__; + return 0; +} + +static int _app_resume(void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + __WDUA_LOG_FUNC_EXIT__; + return 0; +} + +static int _app_reset(bundle *b, void *data) +{ + __WDUA_LOG_FUNC_ENTER__; + + wfd_appdata_t *ad = wfd_get_appdata(); + load_wifi_direct_ug(NULL, ad); + + __WDUA_LOG_FUNC_EXIT__; + return 0; +} + +int main(int argc, char *argv[]) +{ + wfd_appdata_t ad; + struct appcore_ops ops = { + .create = _app_create, + .terminate = _app_terminate, + .pause = _app_pause, + .resume = _app_resume, + .reset = _app_reset, + }; + + memset(&ad, 0x0, sizeof(wfd_appdata_t)); + ops.data = &ad; + g_wfd_ad = &ad; + + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); +} diff --git a/ugapp-wifidirect/src/wfd-ugapp-util.c b/ugapp-wifidirect/src/wfd-ugapp-util.c new file mode 100644 index 0000000..7cf7310 --- /dev/null +++ b/ugapp-wifidirect/src/wfd-ugapp-util.c @@ -0,0 +1,73 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.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. +* +*/ + +/** + * This file implements wifi direct application utils functions. + * + * @file wfd-app-util.c + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + + +#include <stdio.h> +#include <string.h> +#include "wfd-ugapp-util.h" + + +char *wfd_app_trim_path(const char *filewithpath) +{ +#if 0 + char *filename = NULL; + if ((filename = strrchr(filewithpath, '/')) == NULL) + return (char *) filewithpath; + else + return (filename + 1); +#else + static char *filename[100]; + char *strptr = NULL; + int start = 0; + const char *space = " "; + int len = strlen(filewithpath); + + if (len > 20) { + strptr = (char *) filewithpath + (len - 20); + start = 0; + } else if (len < 20) { + strptr = (char *) filewithpath; + start = 20 - len; + } + + strncpy((char *) filename, space, strlen(space)); + strncpy((char *) filename + start, strptr, 50); + + return (char *) filename; +#endif +} + + +int wfd_app_gettid() +{ +#ifdef __NR_gettid + return syscall(__NR_gettid); +#else + fprintf(stderr, "__NR_gettid is not defined, please include linux/unistd.h "); + return -1; +#endif +} |