From 5ef3db334f41ccf7660981c9dfb76c8eb291c019 Mon Sep 17 00:00:00 2001
From: Pawel Andruszkiewicz
Date: Fri, 13 Feb 2015 14:23:26 +0100
Subject: [PATCH] [Account] More fixes for listeners.
Change-Id: Ief0cb4c71980808c9583ae91df23de989d7a507d
---
src/account/account_api.js | 10 ++++++----
src/account/account_instance.cc | 10 +++++-----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/account/account_api.js b/src/account/account_api.js
index 3dab5def..009479df 100644
--- a/src/account/account_api.js
+++ b/src/account/account_api.js
@@ -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);
+ }
}
}
}
diff --git a/src/account/account_instance.cc b/src/account/account_instance.cc
index ede47e4e..07831e60 100644
--- a/src/account/account_instance.cc
+++ b/src/account/account_instance.cc
@@ -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(account_id));
instance->InvokeListener(result);
}
--
2.34.1