[Account] More fixes for listeners.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 13 Feb 2015 13:23:26 +0000 (14:23 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 13 Feb 2015 13:23:26 +0000 (14:23 +0100)
Change-Id: Ief0cb4c71980808c9583ae91df23de989d7a507d

src/account/account_api.js
src/account/account_instance.cc

index 3dab5def6ce7475bdcdf217fc59acb669d05e611..009479dfb5b4fb301f4f7720d0622a993ca3f22c 100644 (file)
@@ -336,10 +336,12 @@ function AccountListeners() {
             }
 
             var callback;
-            for ( var i = 0; i < that.instances.length; i++) {
-                callback = that.instances[i];
-                if (T_.isFunction(callback[event.action])) {
-                    callback[event.action](param);
+            for (var key in that.instances) {
+                if (that.instances.hasOwnProperty(key)) {
+                    callback = that.instances[key];
+                    if (T_.isFunction(callback[event.action])) {
+                        callback[event.action](param);
+                    }
                 }
             }
         }
index ede47e4e47cb16273d764395bdc6c489800501cd..07831e608366587ca62aafc3eaa8a3132fa3c697 100644 (file)
@@ -270,25 +270,25 @@ static bool AccountEventCb(const char *event_type, int account_id,
   }
 
   picojson::object result;
-  result["listenerId"] = picojson::value("accountChange");
+  result["listenerId"] = picojson::value("ACCOUNT_CHANGED");
   if (!strcmp(event_type, ACCOUNT_NOTI_NAME_INSERT)) {
     LoggerD("Added");
-    result["status"] = picojson::value("added");
+    result["action"] = picojson::value("onadded");
     picojson::object info;
     instance->GetAccountManager()->GetAccountInfo(account_id, info);
     result["result"] = picojson::value(info["result"]);
     instance->InvokeListener(result);
   } else if (!strcmp(event_type, ACCOUNT_NOTI_NAME_UPDATE)) {
     LoggerD("Updated");
-    result["status"] = picojson::value("updated");
+    result["action"] = picojson::value("onupdated");
     picojson::object info;
     instance->GetAccountManager()->GetAccountInfo(account_id, info);
     result["result"] = picojson::value(info["result"]);
     instance->InvokeListener(result);
   } else if (!strcmp(event_type, ACCOUNT_NOTI_NAME_DELETE)) {
     LoggerD("Deleted");
-    result["status"] = picojson::value("removed");
-    result["result"] = picojson::value("account_id");
+    result["action"] = picojson::value("onremoved");
+    result["result"] = picojson::value(static_cast<double>(account_id));
     instance->InvokeListener(result);
   }