From: nazib.ullah Date: Mon, 12 Dec 2016 04:59:36 +0000 (+0600) Subject: [TBT][tizen_3.0_mobile][Background Launch push and Pushtestapp added] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d97d5c6bb6aed0066491e0fb3a591ff1e8514b60;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][tizen_3.0_mobile][Background Launch push and Pushtestapp added] Change-Id: Ica989009f752ef70789b8743140784bac372d315 --- diff --git a/release/binary-aarch64/org.tizen.tbt_pushtestapp-1.0.0-aarch64.tpk b/release/binary-aarch64/org.tizen.tbt_pushtestapp-1.0.0-aarch64.tpk new file mode 100644 index 0000000..94c53e1 Binary files /dev/null and b/release/binary-aarch64/org.tizen.tbt_pushtestapp-1.0.0-aarch64.tpk differ diff --git a/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk b/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk index 2633941..db581bd 100644 Binary files a/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk and b/release/binary-aarch64/org.tizen.tbtcoreapp-1.0.0-aarch64.tpk differ diff --git a/release/binary-aarch64/tbt_push_auth.xml b/release/binary-aarch64/tbt_push_auth.xml index 14317ad..d50be68 100644 --- a/release/binary-aarch64/tbt_push_auth.xml +++ b/release/binary-aarch64/tbt_push_auth.xml @@ -2,4 +2,7 @@ + + + diff --git a/release/binary-armv7l/org.tizen.tbt_pushtestapp-1.0.0-arm.tpk b/release/binary-armv7l/org.tizen.tbt_pushtestapp-1.0.0-arm.tpk new file mode 100644 index 0000000..d5750b3 Binary files /dev/null and b/release/binary-armv7l/org.tizen.tbt_pushtestapp-1.0.0-arm.tpk differ diff --git a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk index 4874e53..c41fc28 100644 Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ diff --git a/release/binary-armv7l/tbt_push_auth.xml b/release/binary-armv7l/tbt_push_auth.xml index 14317ad..d50be68 100644 --- a/release/binary-armv7l/tbt_push_auth.xml +++ b/release/binary-armv7l/tbt_push_auth.xml @@ -2,4 +2,7 @@ + + + diff --git a/release/binary-x86/org.tizen.tbt_pushtestapp-1.0.0-i386.tpk b/release/binary-x86/org.tizen.tbt_pushtestapp-1.0.0-i386.tpk new file mode 100644 index 0000000..904b482 Binary files /dev/null and b/release/binary-x86/org.tizen.tbt_pushtestapp-1.0.0-i386.tpk differ diff --git a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk index becd9bd..7156437 100644 Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk differ diff --git a/release/binary-x86/tbt_push_auth.xml b/release/binary-x86/tbt_push_auth.xml index 14317ad..d50be68 100644 --- a/release/binary-x86/tbt_push_auth.xml +++ b/release/binary-x86/tbt_push_auth.xml @@ -2,4 +2,7 @@ + + + diff --git a/release/binary-x86_64/org.tizen.tbt_pushtestapp-1.0.0-x86_64.tpk b/release/binary-x86_64/org.tizen.tbt_pushtestapp-1.0.0-x86_64.tpk new file mode 100644 index 0000000..5d2eccf Binary files /dev/null and b/release/binary-x86_64/org.tizen.tbt_pushtestapp-1.0.0-x86_64.tpk differ diff --git a/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk b/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk index 7e9585c..61fdc20 100644 Binary files a/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk and b/release/binary-x86_64/org.tizen.tbtcoreapp-1.0.0-x86_64.tpk differ diff --git a/release/binary-x86_64/tbt_push_auth.xml b/release/binary-x86_64/tbt_push_auth.xml index 14317ad..d50be68 100644 --- a/release/binary-x86_64/tbt_push_auth.xml +++ b/release/binary-x86_64/tbt_push_auth.xml @@ -2,4 +2,7 @@ + + + diff --git a/tbt_pushtestapp/.cproject b/tbt_pushtestapp/.cproject new file mode 100644 index 0000000..261e20f --- /dev/null +++ b/tbt_pushtestapp/.cproject @@ -0,0 +1,619 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tbt_pushtestapp/.exportMap b/tbt_pushtestapp/.exportMap new file mode 100644 index 0000000..43e310e --- /dev/null +++ b/tbt_pushtestapp/.exportMap @@ -0,0 +1,4 @@ +{ + global: main; + local: *; +}; diff --git a/tbt_pushtestapp/.gitignore b/tbt_pushtestapp/.gitignore new file mode 100644 index 0000000..ffab4a7 --- /dev/null +++ b/tbt_pushtestapp/.gitignore @@ -0,0 +1,3 @@ +/SA_Report +/Debug +/.sign diff --git a/tbt_pushtestapp/.package-stamp b/tbt_pushtestapp/.package-stamp new file mode 100644 index 0000000..40cbe59 --- /dev/null +++ b/tbt_pushtestapp/.package-stamp @@ -0,0 +1 @@ +TPK \ No newline at end of file diff --git a/tbt_pushtestapp/.project b/tbt_pushtestapp/.project new file mode 100644 index 0000000..73f5aca --- /dev/null +++ b/tbt_pushtestapp/.project @@ -0,0 +1,46 @@ + + + tbt_pushtestapp + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + 1478751868388 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + + 1478751868552 + + 6 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-project_def.prop + + + + diff --git a/tbt_pushtestapp/.rds_delta b/tbt_pushtestapp/.rds_delta new file mode 100644 index 0000000..570eefe --- /dev/null +++ b/tbt_pushtestapp/.rds_delta @@ -0,0 +1,6 @@ +#delete +#add +#modify +author-signature.xml +signature1.xml +bin/tbt_pushtestapp diff --git a/tbt_pushtestapp/.sdk_delta.info b/tbt_pushtestapp/.sdk_delta.info new file mode 100644 index 0000000..ba48c4f Binary files /dev/null and b/tbt_pushtestapp/.sdk_delta.info differ diff --git a/tbt_pushtestapp/.tproject b/tbt_pushtestapp/.tproject new file mode 100644 index 0000000..56660b2 --- /dev/null +++ b/tbt_pushtestapp/.tproject @@ -0,0 +1,12 @@ + + + + + mobile-3.0 + + + + + + + diff --git a/tbt_pushtestapp/inc/logger.h b/tbt_pushtestapp/inc/logger.h new file mode 100644 index 0000000..772ceab --- /dev/null +++ b/tbt_pushtestapp/inc/logger.h @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2014 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. + *******************************************************************************/ + +/** + * @file logger.h + * @brief This file provide necessary macro for logging information. + * @since_tizen 2.3 + * @author Amlan Chowdhury (amlan.c@samsung.com) + * @date October, 2014 + * @bug + * @credit + */ +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#include + +#define LOG_TAG_CORE "[TBT_CORE]_" + +#define DLOG(prio, fmt, arg...) dlog_print(prio, LOG_TAG_CORE, "%s (Line: %d) > " fmt, __func__, __LINE__, ##arg) +#define DBG(fmt, arg...) DLOG(DLOG_DEBUG, fmt, ##arg) +#define ERR(fmt, arg...) DLOG(DLOG_ERROR, fmt, ##arg) + +#define RETM_IF(expr, fmt, arg...) \ +{ \ + if (expr) \ + { \ + ERR(fmt, ##arg); \ + return; \ + } \ +} + +#define RETVM_IF(expr, val, fmt, arg...) \ +{ \ + if (expr) \ + { \ + ERR(fmt, ##arg); \ + return (val); \ + } \ +} + +#define SAFE_DELETE(a) if( (a) != NULL ) free (a); (a) = NULL; + +#endif /* __LOGGER_H__ */ diff --git a/tbt_pushtestapp/inc/tbt_pushtestapp.h b/tbt_pushtestapp/inc/tbt_pushtestapp.h new file mode 100644 index 0000000..1c77b20 --- /dev/null +++ b/tbt_pushtestapp/inc/tbt_pushtestapp.h @@ -0,0 +1,33 @@ +#ifndef __tbt_pushtestapp_H__ +#define __tbt_pushtestapp_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "logger.h" + + + +#if !defined(PACKAGE) +#define PACKAGE "org.tizen.tbt_pushtestapp" +#endif + +#define EDJ_FILE "edje/tbt_pushtestapp.edj" +#define GRP_MAIN "main" + + +#endif /* __tbt_pushtestapp_H__ */ diff --git a/tbt_pushtestapp/project_def.prop b/tbt_pushtestapp/project_def.prop new file mode 100644 index 0000000..10cce2d --- /dev/null +++ b/tbt_pushtestapp/project_def.prop @@ -0,0 +1,11 @@ +APPNAME = tbt_pushtestapp + +type = app +profile = mobile-3.0 + +USER_SRCS = src/tbt_pushtestapp.c +USER_DEFS = +USER_INC_DIRS = inc +USER_OBJS = +USER_LIBS = +USER_EDCS = res/edje/tbt_pushtestapp.edc diff --git a/tbt_pushtestapp/res/edje/tbt_pushtestapp.edc b/tbt_pushtestapp/res/edje/tbt_pushtestapp.edc new file mode 100644 index 0000000..083dc42 --- /dev/null +++ b/tbt_pushtestapp/res/edje/tbt_pushtestapp.edc @@ -0,0 +1,14 @@ +collections { + group { name: "main"; + parts { + part { name: "txt_title"; + type: TEXT; + mouse_events: 0; + description { state: "default" 0.0; + text { text: "Hello Tizen"; font: "Tizen:style=regular"; size: 20; min: 1 1; align: 0.5 0; ellipsis: -1; } + color: 0 0 0 255; + } + } + } + } +} diff --git a/tbt_pushtestapp/shared/res/tbt_pushtestapp.png b/tbt_pushtestapp/shared/res/tbt_pushtestapp.png new file mode 100644 index 0000000..9765b1b Binary files /dev/null and b/tbt_pushtestapp/shared/res/tbt_pushtestapp.png differ diff --git a/tbt_pushtestapp/src/tbt_pushtestapp.c b/tbt_pushtestapp/src/tbt_pushtestapp.c new file mode 100644 index 0000000..1e3aebc --- /dev/null +++ b/tbt_pushtestapp/src/tbt_pushtestapp.c @@ -0,0 +1,526 @@ +#include "tbt_pushtestapp.h" + +#define PUSH_APP_ID "00f829f1fd898590" +#define PUSH_APP_SECRET "5eMue+osQCi4Pbhdw+bltGC8PbEAAA==" + +typedef struct appdata{ + Evas_Object* win; + Evas_Object* layout; + Evas_Object* conform; + + char* push_app_id_text; + char* push_app_secret_text; + char* reg_id; + xmlDocPtr doc; + xmlNodePtr root_node_ptr; + +} appdata_s; + +static char* TBT_PUSH_XML_DIR; +static char auth_file_path[256]={'\0',}; + +static push_service_connection_h connection = NULL; + +static void start_push_operation(void* data); +static void _notify_cb(push_service_notification_h noti, void *user_data); +static void _on_state_registered(void *user_data); +static void _on_state_unregistered(void *user_data); +static void _state_changed_cb(push_service_state_e state, const char *err, void *user_data); +static char* push_service_get_error(int error_code); +static void _result_cb(push_service_result_e result, const char *msg, void *user_data); +static char* get_storage_error(int ret); +static void init_xml_operation(void* data); +static int set_xml_element_value (xmlDocPtr doc, xmlNodePtr cur, const char* tag, const char* value); +static char* get_notification_error(int ret); + +static void create_notification() +{ + //create notification + int ret; + notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI); + ret = notification_set_text(noti,NOTIFICATION_TEXT_TYPE_TITLE, "IDS_APP_BODY_IM_TITLE", "I'm Title", NOTIFICATION_VARIABLE_TYPE_NONE); + RETM_IF(ret != NOTIFICATION_ERROR_NONE, "package_manager_set_event_cb failed : %s", get_notification_error(ret)); + ret = notification_status_message_post("Push Test App Launched in Background"); + RETM_IF(ret != NOTIFICATION_ERROR_NONE, "notification_status_message_post failed : %s", get_notification_error(ret)); +} + +static void +win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) +{ + ui_app_exit(); +} + +static void +layout_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 +app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max) +{ + char *res_path = app_get_resource_path(); + if (res_path) { + snprintf(edj_path_out, edj_path_max, "%s%s", res_path, edj_file_in); + free(res_path); + } +} + +static void +create_base_gui(appdata_s *ad) +{ + char edj_path[PATH_MAX] = {0, }; + + /* Window */ + /* Create and initialize elm_win. + elm_win is mandatory to manipulate 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); + + /* 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); + + /* Base Layout */ + /* Create an actual view of the base gui. + Modify this part to change the view. */ + app_get_resource(EDJ_FILE, edj_path, (int)PATH_MAX); + ad->layout = elm_layout_add(ad->win); + elm_layout_file_set(ad->layout, edj_path, GRP_MAIN); + evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + eext_object_event_callback_add(ad->layout, EEXT_CALLBACK_BACK, layout_back_cb, ad); + elm_object_content_set(ad->conform, ad->layout); + + /* Show window after base gui is set up */ + evas_object_show(ad->win); + + start_push_operation(ad); + +} + +static void _notify_cb(push_service_notification_h noti, void *user_data) +{ + DBG("Inside _notify_cb"); + RETM_IF(NULL == noti, "Null Notification"); + + appdata_s *this = NULL; + this = (appdata_s*)user_data; + RETM_IF(NULL == this, "view is NULL"); + + //parse_notification_data(noti, this); + +} + +static void _on_state_registered(void *user_data) +{ + DBG("_on_state_registered"); + int result; + appdata_s *this = NULL; + this = (appdata_s*)user_data; + RETM_IF(NULL == this, "view is NULL"); + + this->reg_id = NULL; + this->reg_id = calloc(1,sizeof(char)*1024); + + result = push_service_get_registration_id(connection, &this->reg_id); + DBG("reg_id: %s", this->reg_id); + RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_registration_id Failed %s", push_service_get_error(result)); + + result = set_xml_element_value (this->doc, this->root_node_ptr, "TestappRegID", this->reg_id); + if(result != 0){ + ERR("regID not updated in tbt_push_auth.xml"); + } + xmlSaveFormatFile (auth_file_path, this->doc, 0); + + if (this->doc != NULL) { + xmlFreeDoc(this->doc); + } + xmlCleanupParser(); + +} + +static void _result_cb(push_service_result_e result, const char *msg, void *user_data) +{ + DBG("Inside _result_cb"); + RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "Registration ERROR %s", push_service_get_error(result)); +} + + +static void _on_state_unregistered(void *user_data) +{ + DBG("_on_state_unregistered"); + + int result; + result = push_service_register(connection, _result_cb, user_data); + DBG("_on_state_unregistered result: %s", push_service_get_error(result)); +} + + +static void _state_changed_cb(push_service_state_e state, const char *err, void *user_data) +{ + DBG("Inside _state_changed_cb"); + + switch (state) + { + case PUSH_SERVICE_STATE_UNREGISTERED: + DBG("Arrived at STATE_UNREGISTERED"); + _on_state_unregistered(user_data); + break; + + case PUSH_SERVICE_STATE_REGISTERED: + DBG("Arrived at STATE_REGISTERED"); + _on_state_registered(user_data); + break; + + case PUSH_SERVICE_STATE_ERROR: + DBG("Arrived at STATE_ERROR"); + break; + + default: + DBG("Unknown State"); + break; + } +} + + +static int set_xml_element_value (xmlDocPtr doc, xmlNodePtr cur, const char* tag, const char* value) +{ + int result = -1; + DBG("set_xml_element_value"); + if(!cur){ + DBG("root node is NULL"); + return -1; + } + cur = cur->xmlChildrenNode; + + while (cur != NULL) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)tag))) { + xmlNodeSetContent(cur, (const xmlChar *)value); + result = 0; + } + cur = cur->next; + } + + return result; +} + +static int _supportedStorageID; +static bool _storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) +{ + if(type == STORAGE_TYPE_INTERNAL) + { + // save storage id + _supportedStorageID=storage_id; + return false; + } + return true; +} + +static char* get_xml_element_value (xmlDocPtr doc, xmlNodePtr cur, const char* tag) +{ + + xmlChar *key; + char* str; + cur = cur->xmlChildrenNode; + while (cur != NULL) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)tag))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + str = strdup((char*)key); + xmlFree(key); + } + cur = cur->next; + } + return str; +} + +static void start_push_operation(void* data) +{ + DBG("start_push_operation"); + + appdata_s *this = NULL; + this = (appdata_s*)data; + RETM_IF(NULL == this, "view is NULL"); + + int ret = storage_foreach_device_supported(_storage_device_supported_cb,NULL); + RETM_IF(ret<0,"storage_foreach_device_supported failed : %s",get_storage_error(ret)); + + ret = storage_get_directory(_supportedStorageID,STORAGE_DIRECTORY_OTHERS,&TBT_PUSH_XML_DIR); + RETM_IF(ret<0,"storage_foreach_device_supported failed : %s",get_storage_error(ret)); + + init_xml_operation(this); + + this->push_app_id_text = get_xml_element_value(this->doc, this->root_node_ptr, "TestappID"); + DBG("appID: %s", this->push_app_id_text); + //this->push_app_id_text = PUSH_APP_ID; + ret = push_service_connect(this->push_app_id_text, _state_changed_cb, _notify_cb, this, &connection); + RETM_IF(ret != PUSH_SERVICE_ERROR_NONE, "push_service_connect :%s",push_service_get_error(ret)); + + +} + +static void init_xml_operation(void* data) +{ + DBG("init_xml_operation"); + appdata_s *this = NULL; + this = (appdata_s*)data; + RETM_IF(NULL == this, "view is NULL"); + xmlInitParser(); + + snprintf(auth_file_path, sizeof(auth_file_path), "%s/%s",TBT_PUSH_XML_DIR,"tbt_push_auth.xml"); + DBG("auth_file_path file set = %s", auth_file_path); + + this->doc = xmlParseFile(auth_file_path); + if (this->doc == NULL ) { + ERR("Document not parsed successfully. \n"); + } + + this->root_node_ptr = xmlDocGetRootElement(this->doc); + if (this->root_node_ptr == NULL ) { + ERR("Empty document. \n"); + } + +} + +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); + DBG("Crete Notification"); + create_notification(); + return true; +} + +static void +app_control(app_control_h app_control, void *data) +{ + DBG("push test app app_control"); + /* 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. */ + create_notification(); +} + +static void +app_terminate(void *data) +{ + /* Release all resources. */ + + appdata_s *this = NULL; + this = (appdata_s*)data; + RETM_IF(NULL == this, "view is NULL"); + + if(connection != NULL) + { + DBG(" Before Push Service Disconnect result "); + push_service_disconnect(connection); + connection = NULL; + } + SAFE_DELETE(this->reg_id); + +} + +static void +ui_app_lang_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LANGUAGE_CHANGED*/ + + int ret; + char *language; + + ret = app_event_get_language(event_info, &language); + if (ret != APP_ERROR_NONE) { + DBG("app_event_get_language() failed. Err = %d.", ret); + return; + } + + if (language != NULL) { + elm_language_set(language); + free(language); + } +} + +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) { + DBG("ui_app_main() is failed. err = %d", ret); + } + + return ret; +} + +static char* push_service_get_error(int error_code) +{ + if (error_code == PUSH_SERVICE_ERROR_NONE) + { + return "PUSH_SERVICE_ERROR_NONE"; + } + else if (error_code == PUSH_SERVICE_ERROR_OUT_OF_MEMORY) + { + return "PUSH_SERVICE_ERROR_OUT_OF_MEMORY"; + } + else if (error_code == PUSH_SERVICE_ERROR_INVALID_PARAMETER) + { + return "PUSH_SERVICE_ERROR_INVALID_PARAMETER"; + } + else if (error_code == PUSH_SERVICE_ERROR_NOT_CONNECTED) + { + return "PUSH_SERVICE_ERROR_NOT_CONNECTED"; + } + else if (error_code == PUSH_SERVICE_ERROR_NO_DATA) + { + return "PUSH_SERVICE_ERROR_NO_DATA"; + } + else if (error_code == PUSH_SERVICE_ERROR_OPERATION_FAILED) + { + return "PUSH_SERVICE_ERROR_OPERATION_FAILED"; + } + else if (error_code == PUSH_SERVICE_ERROR_PERMISSION_DENIED) + { + return "PUSH_SERVICE_ERROR_PERMISSION_DENIED"; + } + else + { + return "Unknown ERROR"; + } + +} + +static char* get_storage_error(int ret) +{ + +switch(ret) +{ + case STORAGE_ERROR_NONE: + return "STORAGE_ERROR_NONE"; + case STORAGE_ERROR_INVALID_PARAMETER: + return "STORAGE_ERROR_INVALID_PARAMETER"; + case STORAGE_ERROR_OUT_OF_MEMORY: + return "STORAGE_ERROR_OUT_OF_MEMORY"; + case STORAGE_ERROR_NOT_SUPPORTED: + return "STORAGE_ERROR_NOT_SUPPORTED"; + case STORAGE_ERROR_OPERATION_FAILED: + return "STORAGE_ERROR_OPERATION_FAILED"; + } + return NULL; +} + +static char* get_notification_error(int ret) +{ + char* err_msg = NULL; + switch (ret) { + case NOTIFICATION_ERROR_NONE: + err_msg = "NOTIFICATION_ERROR_NONE"; + break; + case NOTIFICATION_ERROR_INVALID_PARAMETER: + err_msg = "NOTIFICATION_ERROR_INVALID_PARAMETER"; + break; + case NOTIFICATION_ERROR_OUT_OF_MEMORY: + err_msg = "NOTIFICATION_ERROR_OUT_OF_MEMORY"; + break; + case NOTIFICATION_ERROR_FROM_DB: + err_msg = " NOTIFICATION_ERROR_FROM_DB"; + break; + case NOTIFICATION_ERROR_ALREADY_EXIST_ID: + err_msg = " NOTIFICATION_ERROR_ALREADY_EXIST_ID"; + break; + case NOTIFICATION_ERROR_FROM_DBUS: + err_msg = "NOTIFICATION_ERROR_FROM_DBUS"; + break; + case NOTIFICATION_ERROR_NOT_EXIST_ID: + err_msg = "NOTIFICATION_ERROR_NOT_EXIST_ID"; + break; + case NOTIFICATION_ERROR_IO_ERROR: + err_msg = "NOTIFICATION_ERROR_IO_ERROR"; + break; + case NOTIFICATION_ERROR_SERVICE_NOT_READY: + err_msg = "NOTIFICATION_ERROR_SERVICE_NOT_READY"; + break; + case NOTIFICATION_ERROR_PERMISSION_DENIED: + err_msg = "NOTIFICATION_ERROR_PERMISSION_DENIED"; + break; + default: + err_msg = "Unknown Error"; + break; + } + + return err_msg; +} + diff --git a/tbt_pushtestapp/tizen-manifest.xml b/tbt_pushtestapp/tizen-manifest.xml new file mode 100644 index 0000000..ab1a22b --- /dev/null +++ b/tbt_pushtestapp/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + + tbt_pushtestapp.png + + + http://tizen.org/privilege/mediastorage + http://tizen.org/privilege/network.get + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/push + http://tizen.org/privilege/internet + http://tizen.org/privilege/notification + + diff --git a/tbtcoreapp/src/main-app.c b/tbtcoreapp/src/main-app.c index c5ca729..3020eee 100644 --- a/tbtcoreapp/src/main-app.c +++ b/tbtcoreapp/src/main-app.c @@ -36,6 +36,10 @@ #include #include +/* Extra data type come from Push Service */ +#define EXTRA_DATA_FROM_REGISTRATION_CHANGE "registration_change" +#define EXTRA_DATA_FROM_NOTIFICATION "notification" + struct _app_data { @@ -312,6 +316,23 @@ static void _app_control(app_control_h app_control, void *user_data) if(uri==NULL)DBG("URI = NULL"); else DBG("URI = %s",uri); + char *value = NULL; + + app_control_get_extra_data(app_control, APP_CONTROL_DATA_PUSH_LAUNCH_TYPE, &value); + if (value) + { + if (!strcmp(value, EXTRA_DATA_FROM_NOTIFICATION)) + { + /* Add your code here when push messages arrive */ + DBG("EXTRA_DATA_FROM_NOTIFICATION"); + } + else if (!strcmp(value, EXTRA_DATA_FROM_REGISTRATION_CHANGE)) + { + /* Add your code here when registration state is changed */ + DBG("EXTRA_DATA_FROM_REGISTRATION_CHANGE"); + } + } + if(strcmp(operation, "libpush.operation.handle") == 0) { diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 70abb33..5a59802 100755 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -1752,17 +1752,19 @@ static tbt_info tbtapps[] = .parent = "Push Service", .apptype = TBT_APP_PUSH_SERVICE, .icon_name = "dummy", - .info = "1. Press Start button to start the push service and a successful response will be displayed.
" - "2. Press Normal button, a Normal push message will be shown in list.
" - "3. Press Delay button and then press Normal button a Normal push message followed by a delay push message will be shown in list.
" - "4. Press Active button and a Active push message will be shown.
" - "5. Press Template button and a Template push message will be shown in list.
" - "6. Press Normal button and immediately press home button to move app to pause state, a Normal push notification will be shown in Notification panel.
" - "7. Press Active button and immediately press home button to move app to pause state, a Active push notification will be shown in Notification panel.
" - "8. Press Template button and immediately press home button to move app to pause state, a push notification with custom icon and sound will be shown in Notification panel.
" - "9. When new push notification will come a increasing badge number will be shown on app icon.
" - "10. If app is open and pressed Message button will show the message it is not read.
" - "11. Press button Disconnect to Disconnect Push Service.", + .info = "1. Make sure a) Internet is connected. b) kill app instance of tbt_pushtestapp from background and c) tbt_push_auth.xml file in /home//media/Others directory.
" + "2. Press Start button to start the push service and a successful response will be displayed.
" + "3. Press Normal button, a Normal push message will be shown in list.
" + "4. Press Delay button and then press Normal button a Normal push message followed by a delay push message will be shown in list.
" + "5. Press Background Launch button, a notification with Push Test App Launched in Background message will be shown" + "6. Press Active button and a Active push message will be shown.
" + "7. Press Template button and a Template push message will be shown in list.
" + "8. Press Normal button and immediately press home button to move app to pause state, a Normal push notification will be shown in Notification panel.
" + "9. Press Active button and immediately press home button to move app to pause state, a Active push notification will be shown in Notification panel.
" + "10. Press Template button and immediately press home button to move app to pause state, a push notification with custom icon and sound will be shown in Notification panel.
" + "11. When new push notification will come a increasing badge number will be shown on app icon.
" + "12. If app is open and pressed Message button will show the message it is not read.
" + "13. Press button Disconnect to Disconnect Push Service.", .result = 0, .required_features_count = 1, .features_required = {FEATURE_NETWORK_PUSH} diff --git a/tbtcoreapp/src/view/tbt-push-view.c b/tbtcoreapp/src/view/tbt-push-view.c index 8418d72..034ed16 100644 --- a/tbtcoreapp/src/view/tbt-push-view.c +++ b/tbtcoreapp/src/view/tbt-push-view.c @@ -186,9 +186,9 @@ push_view *push_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item this->push_app_id_text = get_xml_element_value(doc, root_element, "appID"); this->push_app_secret_text = get_xml_element_value(doc, root_element, "appSecret"); -// this->push_test_appId = get_xml_element_value(doc, root_element, "TestappID"); -// this->push_test_appSecret = get_xml_element_value(doc, root_element, "TestappSecret"); -// this->push_test_regId = get_xml_element_value(doc, root_element, "TestappRegID"); + this->push_test_appId = get_xml_element_value(doc, root_element, "TestappID"); + this->push_test_appSecret = get_xml_element_value(doc, root_element, "TestappSecret"); + this->push_test_regId = get_xml_element_value(doc, root_element, "TestappRegID"); DBG("appID : %s\n",this->push_app_id_text); @@ -255,11 +255,11 @@ static Evas_Object *add_control_layout(push_view *this, Evas_Object *parent) elm_table_pack(table, this->start_btn, 0, 0, 1, 1); this->message_btn = ui_utils_push_button_add(this, table, "Message", _control_button_push_service_get_message_pressed_cb); - elm_table_pack(table, this->message_btn, 1, 0, 1, 1); + elm_table_pack(table, this->message_btn, 1, 0, 2, 1); this->disconnect_btn = ui_utils_push_button_add(this, table, "Disconnect", _control_button_push_service_disconnect_pressed_cb); - elm_table_pack(table, this->disconnect_btn, 2, 0, 2, 1); + elm_table_pack(table, this->disconnect_btn, 3, 0, 2, 1); this->normal_push_btn = ui_utils_push_button_add(this, table, "Normal", _button_normal_push_pressed_cb); elm_table_pack(table, this->normal_push_btn, 0, 1, 1, 1); @@ -268,13 +268,13 @@ static Evas_Object *add_control_layout(push_view *this, Evas_Object *parent) elm_table_pack(table, this->delay_push_btn, 1, 1, 1, 1); this->background_push_btn = ui_utils_push_button_add(this, table, "Background", _button_background_push_pressed_cb); -// elm_table_pack(table, this->background_push_btn, 2, 1, 1, 1); + elm_table_pack(table, this->background_push_btn, 2, 1, 1, 1); this->active_noti_push_btn = ui_utils_push_button_add(this, table, "Active", _button_active_noti_push_pressed_cb); - elm_table_pack(table, this->active_noti_push_btn, 2, 1, 1, 1); + elm_table_pack(table, this->active_noti_push_btn, 3, 1, 1, 1); this->template_push_btn = ui_utils_push_button_add(this, table, "Template", _button_template_push_pressed_cb); - elm_table_pack(table, this->template_push_btn, 3, 1, 1, 1); + elm_table_pack(table, this->template_push_btn, 4, 1, 1, 1); return table;