#include <net_connection.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <notification.h>
#include "utils/logger.h"
#include "utils/config.h"
#include "view/tbt-common-view.h"
+#define BUNDLE_KEY_MSG "msg"
+#define BUNDLE_KEY_TIME "time"
+#define PUSH_MESSAGE_SIZE 4096
+
typedef enum {
CONNECTED_STATE = 0,
DISCONNECTED_STATE,
DISABLED_STATE
} _push_btn_state;
+typedef enum{
+ NORMAL_PUSH = 0,
+ DELAY_PUSH,
+ BACKGROUND_LAUNCH_PUSH,
+ ACTIVE_NOTIFICATION_PUSH,
+ TEMPLATE_PUSH,
+
+ ALL_PUSH_TYPES
+}_push_types_e;
+
struct _push_view
{
common_view* view;
char* push_app_id_text;
char* push_app_secret_text;
+ char* push_test_appId;
+ char* push_test_appSecret;
+ char* push_test_regId;
+
CURL *curl_handle;
_push_btn_state push_btn_state;
+ _push_types_e push_type;
+
+ Evas_Object* normal_push_btn;
+ Evas_Object* delay_push_btn;
+ Evas_Object* background_push_btn;
+ Evas_Object* active_noti_push_btn;
+ Evas_Object* template_push_btn;
+ bool is_registered;
+ bundle *msg_bundle;
+ char* text;
};
-
+/* GList for push messages */
+static GList *message_list = NULL;
+static GList *time_list = NULL;
#define CONNECTED_STATE 0
#define DISCONNECTED_STATE 1
static push_service_connection_h connection = NULL;
bool bIsNotiArrived;
-
+static void on_app_resume_cb(void *user_data);
static void _app_destroy_cb(void* this);
static Evas_Object *add_control_layout(push_view *this, Evas_Object *parent);
static void _control_button_push_service_start_pressed_cb(void *pData, Evas_Object *pObj, void *pEventInfo);
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);
+static void _button_normal_push_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static void _button_delay_push_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static void _button_background_push_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static void _button_active_noti_push_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static void _button_template_push_pressed_cb(void *data, Evas_Object *obj, void *event_info);
+static void create_notification_template();
+static void parse_notification_data(push_service_notification_h noti, void *user_data);
+static void handle_push_message(const char *data, const char *msg, long long int time_stamp, void *user_data);
+static void deliver_message(void* user_data);
+static void display_message(void* user_data);
+static void create_list_view(void* user_data);
/**
* @function push_view_add
RETVM_IF(NULL == navi, NULL, "navi is null");
push_view *this = NULL;
+
this = calloc(1, sizeof(push_view));
RETVM_IF(!this, NULL, "calloc failed");
-
this->view = calloc(1, sizeof(common_view));
RETVM_IF(!this->view, NULL, "calloc failed");
+ _tbt_app_resume_cb = on_app_resume_cb;
+
this->push_btn_state = DISCONNECTED_STATE;
push_service_update_btn_state(this);
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");
+
+
DBG("appID : %s\n",this->push_app_id_text);
DBG("appSecret : %s\n",this->push_app_secret_text);
Evas_Object *control = add_control_layout(this, this->view->layout);
elm_object_part_content_set(this->view->layout, "controlr_part", control);
+ create_notification_template();
+
if(tbt_info->is_push_from_outside == true)
{
//Get Push from outside
tbt_info->is_push_from_outside = false;
}
+ elm_object_disabled_set(this->active_noti_push_btn, true);
+ elm_object_disabled_set(this->delay_push_btn, true);
+ elm_object_disabled_set(this->message_btn, true);
+ elm_object_disabled_set(this->template_push_btn, true);
+ elm_object_disabled_set(this->normal_push_btn, true);
+ elm_object_disabled_set(this->disconnect_btn, true);
return this;
}
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, 1, 1);
+ elm_table_pack(table, this->disconnect_btn, 2, 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);
+
+ this->delay_push_btn = ui_utils_push_button_add(this, table, "Delay", _button_delay_push_pressed_cb);
+ 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);
+
+ 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);
+
+ 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);
return table;
SAFE_DELETE(view->view);
SAFE_DELETE(view);
}
+static void on_app_resume_cb(void* data)
+{
+ DBG("Inside push_app_resume_cb");
+
+ int result;
+
+ /*
+ * If connection with Push Service is succeeded,
+ * Push Receiver should request unread notification messages
+ * which are sent during disconnected state
+ */
+ result = push_service_request_unread_notification(connection);
+ RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_request_unread_notification :%s",push_service_get_error(result));
+}
static char* get_xml_element_value (xmlDocPtr doc, xmlNodePtr cur, const char* tag)
return str;
}
+static void create_notification_template()
+{
+
+
+ DBG("TEST %s", get_shared_resource_path("test.wav"));
+
+ notification_h n = NULL;
+ n = notification_create(NOTIFICATION_TYPE_NOTI);
+
+ notification_set_text(n, NOTIFICATION_TEXT_TYPE_TITLE, "template title", NULL, NOTIFICATION_TEXT_TYPE_NONE);
+ notification_set_text(n, NOTIFICATION_TEXT_TYPE_CONTENT, "template content", NULL, NOTIFICATION_TEXT_TYPE_NONE);
+ notification_set_sound(n, NOTIFICATION_SOUND_TYPE_USER_DATA, get_shared_resource_path("test.wav"));
+ notification_set_image(n, NOTIFICATION_IMAGE_TYPE_ICON, get_shared_resource_path("icon.png"));
+ notification_set_image(n, NOTIFICATION_IMAGE_TYPE_BACKGROUND, get_shared_resource_path("background.png"));
+ notification_save_as_template(n, "template_test");
+
+ notification_free(n);
+
+}
/**
* @function _control_button_push_service_start_pressed_cb
}
+static void _button_normal_push_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG("_button_normal_push_pressed_cb");
+ push_view *this = NULL;
+ this = (push_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ this->push_type = NORMAL_PUSH;
+ send_push_data_to_server(this);
+}
+
+static void _button_delay_push_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG("_button_delay_push_pressed_cb");
+ push_view *this = NULL;
+ this = (push_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ this->push_type = DELAY_PUSH;
+ send_push_data_to_server(this);
+}
+
+static void _button_background_push_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG("_button_background_push_pressed_cb");
+ push_view *this = NULL;
+ this = (push_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ this->push_type = BACKGROUND_LAUNCH_PUSH;
+ send_push_data_to_server(this);
+}
+
+static void _button_active_noti_push_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG("_button_active_noti_push_pressed_cb");
+ push_view *this = NULL;
+ this = (push_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ this->push_type = ACTIVE_NOTIFICATION_PUSH;
+ send_push_data_to_server(this);
+}
+
+static void _button_template_push_pressed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ DBG("_button_template_push_pressed_cb");
+ push_view *this = NULL;
+ this = (push_view*)data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ this->push_type = TEMPLATE_PUSH;
+ send_push_data_to_server(this);
+}
+
/**
* @function _state_changed_cb
* @since_tizen 2.3
this = (push_view*)user_data;
RETM_IF(NULL == this, "view is NULL");
+ parse_notification_data(noti, this);
+
+}
+
+
+static void parse_notification_data(push_service_notification_h noti, void *user_data)
+{
+ DBG("parse_notification_data");
+
+ push_view *this = NULL;
+ this = (push_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
int result;
- char *data=NULL; // App data loaded on the notification
- char *msg=NULL; // Noti message
- long long int time_stamp; // Time when the noti is generated
+ char *data=NULL; // App data loaded on the notification
+ char *msg=NULL; // Noti message
+ long long int time_stamp; // Time when the noti is generated
+
+ result = push_service_get_notification_data(noti, &data);
+ RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_notification_data Failed %s", push_service_get_error(result));
+ RETM_IF(NULL == data, "data is NULL");
+
+ elm_object_text_set(this->push_label, data);
+
+ result = push_service_get_notification_message(noti, &msg);
+ DBG("push_service_get_notification_message Failed %s", push_service_get_error(result));
+ //RETM_IF(NULL == msg, "Message is NULL");
+
+ DBG("#### msg: %s", msg);
+
+ result = push_service_get_notification_time(noti, &time_stamp);
+ RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_notification_time Failed %s", push_service_get_error(result));
+
+ handle_push_message(data, msg, time_stamp, this);
+
+ SAFE_DELETE(data);
+ SAFE_DELETE(msg);
+}
+
+static char* get_value_from_message(char *text, char *key)
+{
+ /* Parsing arrival message or time */
+ /* dlog_print(DLOG_DEBUG, LOG_TAG, "message : [%s] / key : [%s]", text, key); */
+ /* dlog_print(DLOG_DEBUG, LOG_TAG, "time : [%s] / key : [%s]", text, key); */
+ if (!strcmp(text, "Delayed push"))
+ return text;
+
+ char *token = strtok(text, "=&");
+ if (!strncmp(token, key, sizeof(*key))) {
+ token = strtok(NULL, "=&");
+ } else {
+ while (token != strtok(NULL, "=&")) {
+ token = strtok(NULL, "=&");
+ if (!strcmp(token, key)) {
+ token = strtok(NULL, "=&");
+ break;
+ }
+ }
+ }
+ DBG("token: %s", token);
+
+ return token;
+}
+
+static void handle_push_message(const char *data, const char *msg, long long int time_stamp, void *user_data)
+{
+ DBG("handle_push_message");
+ push_view *this = NULL;
+ this = (push_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ DBG("[Noti Data] push data : [%s]", data);
+ DBG("[Noti Data] time stamp : [%lld]", time_stamp);
+ if (!msg)
+ {
+ this->msg_bundle = NULL;
+ deliver_message(this);
+ }
+ else
+ {
+ /* Custom protocol parsing logic for sample */
+ DBG("[Noti Data] message : [%s]", msg);
+
+ /* Get action value and alertMessage value */
+ char *action = get_value_from_message(strdup(msg), "action");
+ char *alert_message = get_value_from_message(strdup(msg), "alertMessage");
+ DBG("------------- action: [%s] ---------------", action);
+ DBG("------------ alert_message: [%s] ------------", alert_message);
+
+ RETM_IF(NULL == action, "action is null");
+ RETM_IF(NULL == alert_message, "action is null");
+
+ /* Create arrival time & message */
+ char buf_msg[512];
+
+ sprintf(buf_msg, "Type : ");
+ strcat(buf_msg, action);
+ strcat(buf_msg, " / Message : ");
+ strcat(buf_msg, alert_message);
+
+ time_t timer = time(NULL);
+ struct tm *t;
+ t = localtime(&timer);
+ char buf_time[512];
+ sprintf(buf_time, "%d%02d%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
+
+ DBG("display_msg: [%s]", buf_msg);
+ DBG("display_time: [%s]", buf_time);
+
+ bundle *msg_bundle = bundle_create();
+ if (msg_bundle)
+ {
+ /* Payload push message to bundle object */
+ bundle_add_str(msg_bundle, BUNDLE_KEY_MSG, strdup(buf_msg));
+ DBG("message [%s], key [%s]", buf_msg, BUNDLE_KEY_MSG);
+ bundle_add_str(msg_bundle, BUNDLE_KEY_TIME, strdup(buf_time));
+ DBG("time [%s], key [%s]", buf_time, BUNDLE_KEY_TIME);
+ this->msg_bundle = msg_bundle;
+ deliver_message(this);
+ }
+
+ bundle_free(msg_bundle);
+ }
+ /* Custom protocol logic End */
+}
+static void save_message(const char *message)
+{
+ /* In this sample, just store to GList */
+ char *msg = NULL;
+
+ if (message) msg = strdup(message);
+ if (!msg) return;
+
+ /* This list will be appended at top of the list */
+ message_list = g_list_prepend(message_list, (gpointer)msg);
+}
+
+
+/*
+ * save_time() for storing time with its push messages
+ */
+static void save_time(const char *time)
+{
+ /* In this sample, just store to GList */
+ char *msg = NULL;
+
+ if (time) msg = strdup(time);
+ if (!msg) return;
+
+ /* This list will be appended at top of the list */
+ time_list = g_list_prepend(time_list, (gpointer)msg);
+}
+
+
+static void deliver_message(void* user_data)
+{
+ DBG("deliver_message() operates saving and showing push messages");
+ push_view *this = NULL;
+ this = (push_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+ bundle *msg_bundle = this->msg_bundle;
+
+ char *text = NULL;
+ if (msg_bundle)
+ {
+ /* Store push message */
+ int ret = bundle_get_str(msg_bundle, BUNDLE_KEY_MSG, &text);
+ if (!ret && text)
+ {
+ DBG("Push on message port : [%s]", text);
+ /* Save message if necessary */
+ save_message(text);
+ }
+
+ /* Store verification time and display push message and time */
+ ret = bundle_get_str(msg_bundle, BUNDLE_KEY_TIME, &text);
+ if (!ret && text)
+ {
+ DBG("Push on time port : [%s]", text);
+ /* Save time if necessary */
+ save_time(text);
+ /* UI display function not for changed registration state but arrived push notification */
+ }
+ }
+ else
+ {
+ DBG("For Delayed push");
+ /* For delayed push */
+ text = strdup("Delayed push");
+ save_message(text);
+ save_time("This push notification is not sent immediately");
+ //////////////////////////////////////// consider non-action:backgroundLaunch
+ }
+ this->text = text;
+ display_message(this);
+}
- result = push_service_get_notification_data(noti, &data);
- RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_notification_data Failed %s", push_service_get_error(result));
- RETM_IF(NULL == data, "data is NULL");
+static void display_message(void* user_data)
+{
- elm_object_text_set(this->push_label, data);
+ push_view *this = NULL;
+ this = (push_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+ char* text = this->text;
+ DBG("[Push Message] %s", text);
- result = push_service_get_notification_message(noti, &msg);
- RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_notification_message Failed %s", push_service_get_error(result));
- RETM_IF(NULL == msg, "Message is NULL");
+ /* Re-draw the list for verifying the arrival of push messages */
+ create_list_view(this);
- result = push_service_get_notification_time(noti, &time_stamp);
- RETM_IF(result != PUSH_SERVICE_ERROR_NONE, "push_service_get_notification_time Failed %s", push_service_get_error(result));
+ //@TODO: work is paused here start again
+}
+/* item_data structure for generating genlist */
+typedef struct item_data {
+ Elm_Object_Item *item;
+ int index;
+} item_data_s;
+static char *
+_gl_push_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ char msg_buf[PUSH_MESSAGE_SIZE];
+ char time_buf[PUSH_MESSAGE_SIZE];
+ item_data_s *id = (item_data_s *)data;
+ int index = id->index;
+ char *msg = NULL;
+
+ if (!strcmp("elm.text", part)) {
+ msg = (char *) g_list_nth_data(message_list, index);
+ snprintf(msg_buf, PUSH_MESSAGE_SIZE - 1, "%s", msg);
+ DBG("_gl_push_text_get(), message : [%s]", msg_buf);
+ return strdup(msg_buf);
+ }
- SAFE_DELETE(data);
- SAFE_DELETE(msg);
+ msg = (char *) g_list_nth_data(time_list, index);
+ snprintf(time_buf, PUSH_MESSAGE_SIZE - 1, "%s", msg);
+ DBG("_gl_push_text_get(), time : [%s]", time_buf);
+ return strdup(time_buf);
}
+static void
+create_list_view(void* user_data)
+{
+ DBG("create_list_view");
+ push_view *this = NULL;
+ this = (push_view*)user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ Evas_Object *genlist = NULL;
+
+ /* Elm_Genlist_Item_Class for list */
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+
+ /* item_data for genlist */
+ item_data_s *id;
+ guint message_length = 0;
+
+
+
+ genlist = elm_genlist_add(this->view->layout);
+ elm_genlist_block_count_set(genlist, 14);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ elm_genlist_homogeneous_set(genlist, EINA_TRUE);
+ elm_object_part_content_set(this->view->layout, "push_container", genlist);
+
+ itc->item_style = "multiline";
+ itc->func.text_get = _gl_push_text_get;
+
+ /* Make list as much as the number of lines */
+ message_length = g_list_length(message_list);
+ int i = 0;
+ for (i = 0; i < message_length; i++) {
+ id = calloc(sizeof(item_data_s), 1);
+ id->index = i;
+ /* Append genlist item for list */
+ id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, NULL, this);
+ }
+ elm_genlist_item_class_free(itc);
+}
+
+
+
/**
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));
- send_push_data_to_server(this);
+ this->is_registered = true;
+// send_push_data_to_server(this);
+ elm_object_disabled_set(this->active_noti_push_btn, false);
+ elm_object_disabled_set(this->delay_push_btn, false);
+ elm_object_disabled_set(this->message_btn, false);
+ elm_object_disabled_set(this->template_push_btn, false);
+ elm_object_disabled_set(this->normal_push_btn, false);
+ elm_object_disabled_set(this->disconnect_btn, false);
+
}
CURLcode curl_err;
struct curl_slist *header_list = NULL;
char* post_data = NULL;
- int delay = 1;
char* reg = this->reg_id;
DBG("before format_string %s", reg);
- post_data = format_string("{ \"regID\" : \"%s\", \"requestID\" : \"%s\" , \"message\" : \"badgeOption=INCREASE&badgeNumber=1&action=ALERT&alertMessage=Hi\", \"appData\" : \"Hello Tizen\", \"delayDate\" : %d}", this->reg_id,"000001", delay);
+ switch(this->push_type)
+ {
+ case NORMAL_PUSH:
+ DBG("NORMAL_PUSH");
+ post_data = format_string("{ \"regID\" : \"%s\", \"requestID\" : \"%s\" , \"message\" : \"badgeOption=INCREASE&badgeNumber=1&action=ALERT&alertMessage=Normal Push\", \"appData\" : \"Normal Push\"}", this->reg_id,"000002");
+ break;
+ case DELAY_PUSH:
+ DBG("DELAY_PUSH");
+ post_data = format_string("{ \"regID\" : \"%s\", \"requestID\" : \"%s\" , \"action\":\"backgroundLaunch\", \"appData\" : \"Delay Push\"}", this->reg_id,"000001");
+ break;
+ case BACKGROUND_LAUNCH_PUSH:
+ DBG("BACKGROUND_LAUNCH_PUSH");
+ post_data = format_string("{ \"regID\" : \"%s\", \"requestID\" : \"%s\" , \"message\":\"badgeOption=INCREASE&badgeNumber=1&action=BACKGROUNDLAUNCH&alertMessage=Background Launch\", \"appData\" : \"Background Launch\"}", this->push_test_regId,"000001");
+ break;
+ case ACTIVE_NOTIFICATION_PUSH:
+ DBG("ACTIVE_NOTIFICATION_PUSH");
+ post_data = format_string("{ \"regID\" : \"%s\", \"message\":\"setAutoRemove=true&textTypeButton1=Button1&textTypeButton2=Button2&textTypeButton3=Cancel&imageTypeButton1=indicator.png&imageTypeButton2=lock.png&imageTypeButton3=thumbnail.png&eventTypeClickOnButton1=test,test1&eventTypeClickOnButton2=test,test2&eventTypeClickOnButton3=test,good&eventTypeClickOnIcon=key,test&eventTypeClickOnThumbnail=key,test&badgeOption=INCREASE&badgeNumber=1&action=ALERT&alertMessage=Active Notification&textTypeTitle=Active Notification Title &textTypeContent=Hi How are you&textTypeGroupTitle=nono&textTypeGroupContent=yesyes&imageTypeIcon=icon.png&imageTypeIconForIndicator=indicator.png&imageTypeIconForLock=lock.png&imageTypeThumbnail=thumbnail.png&imageTypeThumbnailForLock=thumbnaillock.png&imageTypeIconSub=sub.png&imageTypeBackground=background.png&soundTypeUserData=test.wav&ledColor=100&ledOnOffTime=100,100&vibrationTypeUserData=test.png&setDisplayApplist=notificationTray|ticker|lock|indicator|active|all&lyNotiEventSingle=true&imageTypeList1=lock.png&imageTypeList2=lock.png&imageTypeList3=lock.png&imageTypeList4=lock.png&imageTypeList5=lock.png&textTypeContentForDisplayOptionIsOff=contentoptionoff&textTypeEventCount=eventcount&textTypeInfo1=push test&textTypeInfoSub1=infosub1&textTypeInfo2=info2&textTypeInfoSub2=infosub2&textTypeInfo3=info3&textTypeInfoSub3=infosub3&textTypeGroupContentForDisplayOptionIsOff=contentoptionoff&setTime=true&setTimeToText=true\", \"appData\" : \"Active Notification\", \"requestID\" : \"%s\"}", this->reg_id,"000001");
+ break;
+ case TEMPLATE_PUSH:
+ DBG("TEMPLATE_PUSH");
+ post_data = format_string("{ \"regID\" : \"%s\", \"requestID\" : \"%s\" , \"message\":\"template=template_test&action=ALERT&alertMessage=Template Push\", \"appData\" : \"Template push\"}", this->reg_id,"000001");
+ break;
+ default:
+ DBG("UNKNOWN PUSH TYPE");
+ }
+
+
DBG("post_data : %s", post_data);
// Creating header
char appID[1024];
- snprintf(appID, 1024, "appID:%s", this->push_app_id_text);
- header_list = curl_slist_append(header_list, appID);
+ if(this->push_type == BACKGROUND_LAUNCH_PUSH)
+ {
+ //
+ snprintf(appID, 1024, "appID:%s", this->push_test_appId);
+ header_list = curl_slist_append(header_list, appID);
+ }
+ else
+ {
+ 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", this->push_app_secret_text);
- header_list = curl_slist_append(header_list, appSecret);
-
-
+ if(this->push_type == BACKGROUND_LAUNCH_PUSH)
+ {
+ //
+ snprintf(appSecret, 1024, "appSecret:%s", this->push_test_appSecret);
+ header_list = curl_slist_append(header_list, appSecret);
+ }
+ else
+ {
+ snprintf(appSecret, 1024, "appSecret:%s", this->push_app_secret_text);
+ header_list = curl_slist_append(header_list, appSecret);
+ }
DBG("app_id: %s", this->push_app_id_text);
DBG("app_secret: %s",this->push_app_secret_text);
+
this->curl_handle = curl_easy_init();
DBG("Curl handle created.");