[TBT][tizen_3.0_wearable][push appID and appSecret moved to seperate file] 97/93297/1
authornazib.ullah <nazib.ullah@samsung.com>
Fri, 21 Oct 2016 13:15:41 +0000 (19:15 +0600)
committernazib.ullah <nazib.ullah@samsung.com>
Fri, 21 Oct 2016 13:17:32 +0000 (19:17 +0600)
Change-Id: Ia001fce080fccbeba7816aabe8f0d9426ea6ac5f

release/binary-arm/install.sh
release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk
release/binary-arm/tbt_push_auth.xml [new file with mode: 0644]
release/binary-x86/install.sh
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk
release/binary-x86/tbt_push_auth.xml [new file with mode: 0644]
tbtcoreapp/inc/utils/config.h
tbtcoreapp/src/view/tbt-push-view.c

index 1662e95a37516814d7af8345fa8e6dc8e7043d61..f949e77758eca29c5ce773b100996041926d2970 100644 (file)
@@ -40,6 +40,7 @@ sdb push org.tizen.tbtcoreapp-1.0.0-arm.tpk /tmp
 sdb push dog_1024_960.gif /opt/home/owner/media/Images
 sdb push SampleMP3.mp3 /opt/home/owner/media/Sounds
 sdb push sampleH263.3gp /opt/home/owner/media/Videos
+sdb push tbt_push_auth.xml /home/owner/media/Others
 
 sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_dataprovider-1.0.0-arm.tpk
 sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_serviceapp-1.0.0-arm.tpk
index ad3595e78882f244d28323ea27533136c22776f2..c905926503634fb0cdaa7e10049b1af7bb113c84 100644 (file)
Binary files a/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ
diff --git a/release/binary-arm/tbt_push_auth.xml b/release/binary-arm/tbt_push_auth.xml
new file mode 100644 (file)
index 0000000..0ef94a4
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<push_auth>
+   <appID>da58f09b7dcd898f</appID>
+   <appSecret>E55A746761233098DDD1114F652AFE51</appSecret>
+</push_auth>
index ca4a2a6ae527b6cd0c4ac2873fd71baff477d5cf..524176a032c37eb4f2fd640333ba9f5effd82077 100644 (file)
@@ -40,6 +40,7 @@ sdb push org.tizen.tbtcoreapp-1.0.0-i386.tpk /tmp
 sdb push dog_1024_960.gif /opt/home/owner/media/Images
 sdb push SampleMP3.mp3 /opt/home/owner/media/Sounds
 sdb push sampleH263.3gp /opt/home/owner/media/Videos
+sdb push tbt_push_auth.xml /home/owner/media/Others
 
 sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_dataprovider-1.0.0-i386.tpk
 sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_serviceapp-1.0.0-i386.tpk
index 7009eea2348b5ccba05271b030455efba6b4df0f..dfe87a64a75334ff9d169c2c67523bb02896c530 100644 (file)
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
new file mode 100644 (file)
index 0000000..0ef94a4
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<push_auth>
+   <appID>da58f09b7dcd898f</appID>
+   <appSecret>E55A746761233098DDD1114F652AFE51</appSecret>
+</push_auth>
index 56525e085c20df69027e6f5d01bbdd49c54f49ef..bec1b4142d9d48268e87905dc34f18e30723991e 100644 (file)
@@ -51,11 +51,6 @@ static int device_height = -1;
 
 extern bool __is_efl_test_running;
 
-//Push:
-#define PUSH_APP_ID "da58f09b7dcd898f"
-#define PUSH_APP_SECRET "E55A746761233098DDD1114F652AFE51"
-
-
 // *_X_POS, *_Y_POS, *_WIDTH, *_HEIGHT are virtual (relative) coords of grid widget
 #define MAX_WIDTH 100
 #define MAX_HEIGHT 100
index 19ba02d1b9d81f674f55f9eaa091ceb0a1855d23..7b78f73e2bd818b9068f547f6009ce6fb212714f 100644 (file)
@@ -32,6 +32,8 @@
 #include <Elementary.h>
 #include <locations.h>
 #include <net_connection.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
 
 #include "utils/logger.h"
 #include "utils/config.h"
@@ -91,7 +93,7 @@ static char* push_service_get_server_address(char* reg_id);
 static size_t _curl_response_cb(char *ptr, size_t size, size_t nmemb, void *userdata);
 static void push_service_update_btn_state(void* user_data);
 static char* push_service_get_error(int error_code);
-
+static char* get_xml_element_value (xmlDocPtr doc, xmlNodePtr cur, const char* tag);
 
 /**
  * @function           push_view_add
@@ -121,8 +123,31 @@ push_view *push_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item
 
        RETVM_IF(NULL == this->view, NULL, "navi is null");
 
-       this->push_app_id_text =  PUSH_APP_ID;
-       this->push_app_secret_text = PUSH_APP_SECRET;
+       //get appID and appSecret from file
+       char auth_file_path[256]={'\0',};
+
+    snprintf(auth_file_path, sizeof(auth_file_path), "%s/%s",TBT_LOGGING_DIR,"tbt_push_auth.xml");
+    DBG("auth_file_path file set = %s", auth_file_path);
+
+    xmlDoc *doc = NULL;
+    xmlNode *root_element = NULL;
+
+    doc = xmlReadFile(auth_file_path, NULL, 0);
+
+    if (doc == NULL) {
+        DBG("error: could not parse file %s\n",auth_file_path);
+    }
+    root_element = xmlDocGetRootElement(doc);
+
+       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");
+
+    DBG("appID : %s\n",this->push_app_id_text);
+    DBG("appSecret : %s\n",this->push_app_secret_text);
+
+    xmlFreeDoc(doc);
+    xmlCleanupParser();
+
        this->push_label = ui_utils_label_add(this->view->layout, "Push");
        elm_object_part_content_set(this->view->layout, "1txt", this->push_label);
 
@@ -216,6 +241,24 @@ static void _app_destroy_cb(void* this)
 }
 
 
+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;
+}
+
+
 /**
  * @function           _control_button_push_service_start_pressed_cb
  * @since_tizen                2.3
@@ -466,11 +509,11 @@ static void send_push_data_to_server(void* user_data)
 
        // Creating header
        char appID[1024];
-       snprintf(appID, 1024, "appID:%s", PUSH_APP_ID);
+       snprintf(appID, 1024, "appID:%s", this->push_app_id_text);
        header_list = curl_slist_append(header_list, appID);
 
        char appSecret[1024];
-       snprintf(appSecret, 1024, "appSecret:%s", PUSH_APP_SECRET);
+       snprintf(appSecret, 1024, "appSecret:%s", this->push_app_secret_text);
        header_list = curl_slist_append(header_list, appSecret);