#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"
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
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);
}
+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
// 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);