wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Push / PushManager.cpp
index 5880bb0..235c24c 100644 (file)
@@ -74,7 +74,7 @@ static std::string _get_internal_error(int err)
     }
 
     if (!success) {
-        LogError("Platform error %d <%s>", err, msg.c_str());
+        LoggerE("Platform error %d <%s>", err, msg.c_str());
     }
 
     return msg;
@@ -149,9 +149,9 @@ static void get_param(const char *msg, const char *name, char **value)
 
 static int get_current_app_id_and_pkg_id(char **app_id, char **pkg_id)
 {
-    LogDebug("get_current_pkg_id enter");
+    LoggerD("get_current_pkg_id enter");
     int parent_pid = getppid();
-    LogDebug("parent pid : " << parent_pid);
+    LoggerD("parent pid : " << parent_pid);
     char *_app_id = NULL;
     char *_pkg_id = NULL;
 
@@ -159,29 +159,29 @@ static int get_current_app_id_and_pkg_id(char **app_id, char **pkg_id)
 
     int ret = app_manager_get_app_id(parent_pid, &_app_id);
     if ((ret != APP_MANAGER_ERROR_NONE) || (_app_id == NULL)) {
-        LogDebug("Cannot get app id from pid : " << parent_pid);
+        LoggerD("Cannot get app id from pid : " << parent_pid);
         return ret;
     } else {
-        LogDebug("app_id : " << _app_id);
+        LoggerD("app_id : " << _app_id);
     }
 
     ret = app_manager_get_app_info(_app_id, &handle);
     if (ret != APP_MANAGER_ERROR_NONE)
     {
-        LogDebug("Fail to get appinfo by " << _app_id);
+        LoggerD("Fail to get appinfo by " << _app_id);
         return ret;
     }
 
     ret = app_info_get_package(handle, &_pkg_id);
     if ((ret != APP_MANAGER_ERROR_NONE) || (_pkg_id == NULL))
     {
-        LogDebug("Fail to get pkg_id by " << _app_id);
+        LoggerD("Fail to get pkg_id by " << _app_id);
     }
 
     ret = app_info_destroy(handle);
     if (ret != APP_MANAGER_ERROR_NONE)
     {
-        LogDebug("Fail to get destory appinfo");
+        LoggerD("Fail to get destory appinfo");
         return ret;
     }
 
@@ -193,11 +193,11 @@ static int get_current_app_id_and_pkg_id(char **app_id, char **pkg_id)
 
 static void push_connection_state_cb(push_state_e state, const char *err, void *user_data)
 {
-    LogInfo("Push connection state cb with state: "<< state <<", err: "<< err);
+    LoggerI("Push connection state cb with state: "<< state <<", err: "<< err);
 
     PushManager *thisPushManager = static_cast<PushManager*>(user_data);
     if (!thisPushManager) {
-        LogError("user_data of push_connection_state_cb() is NULL.");
+        LoggerE("user_data of push_connection_state_cb() is NULL.");
     } else {
        thisPushManager->m_connectionState = state;
     }
@@ -211,7 +211,7 @@ static void push_notify_cb(push_notification_h noti, void *user_data)
     char *alertMessage = NULL;
     long long int date = -1;
 
-    LogInfo("Push notification cb");
+    LoggerI("Push notification cb");
 
     try {
         PushManager *thisPushManager = static_cast<PushManager*>(user_data);
@@ -221,7 +221,7 @@ static void push_notify_cb(push_notification_h noti, void *user_data)
 
         MultiCallbackUserDataPtr callback = thisPushManager->m_notificationCallback;
         if (!callback) {
-            LogWarning("notification callback is not set. ignored.");
+            LoggerW("notification callback is not set. ignored.");
             return;
         }
 
@@ -243,7 +243,7 @@ static void push_notify_cb(push_notification_h noti, void *user_data)
 
         ret = push_get_notification_time(noti, &date);
         if (ret != PUSH_ERROR_NONE) {
-            LogError("Platform error while getting notification date/time. " << _get_internal_error(ret));
+            LoggerE("Platform error while getting notification date/time. " << _get_internal_error(ret));
         }
 
         PushMessage *pushMessage = new PushMessage();
@@ -264,7 +264,7 @@ static void push_notify_cb(push_notification_h noti, void *user_data)
 
         callback->invokeCallback("onsuccess", pushMessageObj);
     } catch (const BasePlatformException &err) {
-        LogError(err.getMessage());
+        LoggerE(err.getMessage());
     }
 }
 
@@ -273,7 +273,7 @@ static void push_registration_result_cb(push_result_e result, const char *msg, v
     int ret;
     char *tmp = NULL;
 
-    LogInfo("Push registration cb");
+    LoggerI("Push registration cb");
 
     try {
         PushManager *thisPushManager = static_cast<PushManager*>(user_data);
@@ -302,13 +302,13 @@ static void push_registration_result_cb(push_result_e result, const char *msg, v
             callback->invokeCallback("onerror", errorObj);
         }
     } catch (const BasePlatformException &err) {
-        LogError(err.getMessage());
+        LoggerE(err.getMessage());
     }
 }
 
 static void push_unregistration_result_cb(push_result_e result, const char *msg, void *user_data)
 {
-    LogInfo("Push unregistration cb");
+    LoggerI("Push unregistration cb");
 
     try {
         PushManager *thisPushManager = static_cast<PushManager*>(user_data);
@@ -329,7 +329,7 @@ static void push_unregistration_result_cb(push_result_e result, const char *msg,
             callback->invokeCallback("onerror", errorObj);
         }
     } catch (const BasePlatformException &err) {
-        LogError(err.getMessage());
+        LoggerE(err.getMessage());
     }
 }
 
@@ -339,28 +339,28 @@ PushManager::PushManager():
     m_connectionState(PUSH_STATE_UNREGISTERED),
     m_connectionHandle(NULL)
 {
-    LogInfo("Connecting to the push service...");
+    LoggerI("Connecting to the push service...");
     int ret;
 
     ret = get_current_app_id_and_pkg_id(&m_appId, &m_pkgId);
     if (APP_ERROR_NONE != ret) {
-        LogError("Error while getting app id: "<<ret);
+        LoggerE("Error while getting app id: "<<ret);
         return;
     }
 
-    LogInfo("Push App id: " << m_appId);
-    LogInfo("Push Package id: " << m_pkgId);
+    LoggerI("Push App id: " << m_appId);
+    LoggerI("Push Package id: " << m_pkgId);
 
     ret = push_connect(m_pkgId, push_connection_state_cb, push_notify_cb, this, &m_connectionHandle);
     if (PUSH_ERROR_NONE!=ret) {
-        LogError("Error while connecting to the push service: "<< ret);
+        LoggerE("Error while connecting to the push service: "<< ret);
         return;
     }
 }
 
 PushManager::~PushManager()
 {
-    LogInfo("Disconnecting to the push service...");
+    LoggerI("Disconnecting to the push service...");
 
     if(m_appId) {
         free(m_appId);
@@ -374,7 +374,7 @@ PushManager::~PushManager()
 }
 
 PushManager *PushManager::getInstance() {
-    LogInfo("Getting instance of PushManager...");
+    LoggerI("Getting instance of PushManager...");
     static PushManager instance;
     return &instance;
 }
@@ -401,14 +401,14 @@ void PushManager::registerService(ApplicationControlPtr appControl, MultiCallbac
     if (appControl->getUri().compare("") != 0) {
         ret = service_set_uri(service, appControl->getUri().c_str());
         if (ret != SERVICE_ERROR_NONE) {
-            LogWarning("Platform error while setting uri to appControl. " << _get_internal_error(ret));
+            LoggerW("Platform error while setting uri to appControl. " << _get_internal_error(ret));
         }
     }
 
     if (appControl->getMime().compare("") != 0) {
         ret = service_set_mime(service, appControl->getMime().c_str());
         if (ret != SERVICE_ERROR_NONE) {
-            LogWarning("Platform error while setting mime to appControl. " << _get_internal_error(ret));
+            LoggerW("Platform error while setting mime to appControl. " << _get_internal_error(ret));
         }
     }
 
@@ -425,7 +425,7 @@ void PushManager::registerService(ApplicationControlPtr appControl, MultiCallbac
         for (size_t i = 0; i < controlDataArray.size(); i++) {
             key = controlDataArray.at(i)->getKey();
             if (key.empty()) {
-                LogWarning("Invalid key for " << i << " in ApplicationControl's data array.");
+                LoggerW("Invalid key for " << i << " in ApplicationControl's data array.");
             } else {
                 std::vector<std::string> valueArray = controlDataArray.at(i)->getValue();
                 size_t size = valueArray.size();
@@ -442,12 +442,12 @@ void PushManager::registerService(ApplicationControlPtr appControl, MultiCallbac
                 if (size == 1) {
                     ret = service_add_extra_data(service, (const char*)key.c_str(), arr[0]);
                     if (ret != SERVICE_ERROR_NONE) {
-                        LogWarning("Platform error while adding extra data to appControl. " << _get_internal_error(ret));
+                        LoggerW("Platform error while adding extra data to appControl. " << _get_internal_error(ret));
                     }
                 } else {
                     ret = service_add_extra_data_array(service, (const char*)key.c_str(), arr, size);
                     if (ret != SERVICE_ERROR_NONE) {
-                        LogWarning("Platform error while adding extra data array to appControl. " << _get_internal_error(ret));
+                        LoggerW("Platform error while adding extra data array to appControl. " << _get_internal_error(ret));
                     }
                 }
 
@@ -503,7 +503,7 @@ std::string PushManager::getRegistrationId()
 
     ret = push_get_registration_id(m_connectionHandle, &regId);
     if (ret != PUSH_ERROR_NONE) {
-        LogWarning("Platform error while getting registration id. " << _get_internal_error(ret));
+        LoggerW("Platform error while getting registration id. " << _get_internal_error(ret));
     } else {
         if (regId) {
             str = regId;