Fix left over use of old ev.ModemAdded event object structure
[profile/ivi/sockdrawer.git] / Tizen.Device.js
index 493eb0d..dce5707 100644 (file)
@@ -45,15 +45,15 @@ var __callmanager = function () {
            services = tmp;
        }
     }
-    tizen.account.addAccountListener(listener);
+    tizen.__account.addAccountListener(listener);
 
     socket.onmessage = function(msg) {
         var ev = JSON.parse(msg.data);
 
        if (ev.type == "ModemAdded") {
-           tizen.account.addAccount(new tizen.Account(ev.ModemAdded, ev));
+           tizen.__account.addAccount(new tizen.Account(ev.ModemAdded, ev));
        } else if (ev.type == "ModemRemoved") {
-           tizen.account.deleteAccount(ev.ModemRemoved);
+           tizen.__account.deleteAccount(ev.id);
        } else if (ev.type == "CallAdded") {
            calls.push(new __call(this, socket, ev));
        } else if (ev.type == "CallRemoved") {
@@ -326,13 +326,6 @@ var __tizen = function() {
         return application;
     });
 
-    var call = null;
-    this.__defineGetter__("call", function() {
-        if (call == null)
-            call = new __callmanager();
-        return call;
-    });
-
     this.Account = function (accountId, accountProperties) {
        var id = accountId;
        var properties = accountProperties;
@@ -345,13 +338,33 @@ var __tizen = function() {
            });
        }
     }
+
+    var call = null;
+    this.__defineGetter__("call", function() {
+        if (call == null) {
+            // ensure the account object is created first
+            tizen.account;
+
+            call = new __callmanager();
+        }
+        return call;
+    });
     var account = null;
     this.__defineGetter__("account", function() {
        if (account == null)
            account = new __accountmanager();
+
+        // ensure the call object is always the first listener
+        // for new accounts, which means we need a backdoor to
+        // access the acount object before the getter has finished
+        // executing for the first time
+        this.__defineGetter__("__account", function() {
+            return account;
+        });
+        if (call == null)
+            call = new __callmanager();        
        return account;
     });
 }
 
 var tizen = new __tizen();
-