[gnome-maps/wip/contacts: 2/3] test contacts



commit 7d4a15fc400bd1b5cffdc2c1043866b12de6d1ae
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Thu Dec 4 03:10:35 2014 -0500

    test contacts

 src/application.js |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 9315d30..3bf5afd 100644
--- a/src/application.js
+++ b/src/application.js
@@ -34,6 +34,7 @@ const Format = imports.format;
 const Geoclue = imports.geoclue;
 const GeocodeService = imports.geocodeService;
 const MainWindow = imports.mainWindow;
+const MapsC = imports.gi.MapsC;
 const NotificationManager = imports.notificationManager;
 const Path = imports.path;
 const PlaceStore = imports.placeStore;
@@ -97,6 +98,28 @@ const Application = new Lang.Class({
         }).bind(this));
     },
 
+    _onShowContactActivate: function(action, parameter) {
+        this._createWindow();
+        this._checkNetwork();
+        this._mainWindow.window.present();
+
+        let contactId = parameter.deep_unpack();
+        log('lookup!');
+        this._contacts.lookup(contactId, function(contact) {
+            log('ID: ' + contact.id);
+            log('Name: ' + contact.name);
+            log('Icon: ' + contact.icon);
+            contact.get_addresses().forEach(function(address) {
+                log('Type: ' + address.type);
+                log('Street: ' + address.street);
+                log('Postal code: ' + address.postal_code);
+                log('Locality: ' + address.locality);
+                log('Region: ' + address.region);
+                log('Country: ' + address.country);
+            });
+        });
+    },
+
     _onQuitActivate: function() {
         this._mainWindow.window.destroy();
     },
@@ -105,6 +128,24 @@ const Application = new Lang.Class({
         placeStore = new PlaceStore.PlaceStore();
         try {
             placeStore.load();
+
+            this._contacts = new MapsC.Contacts();
+            this._contacts.load(function(contacts) {
+                contacts.get_list().forEach(function(contact) {
+                    log('ID: ' + contact.id);
+                    log('Name: ' + contact.name);
+                    log('Icon: ' + contact.icon);
+                    contact.get_addresses().forEach(function(address) {
+                        log('Type: ' + address.type);
+                        log('Street: ' + address.street);
+                        log('Postal code: ' + address.postal_code);
+                        log('Locality: ' + address.locality);
+                        log('Region: ' + address.region);
+                        log('Country: ' + address.country);
+                    });
+                    log('');
+                });
+            });
         } catch (e) {
             log('Failed to parse Maps places file, ' +
                 'subsequent writes will overwrite the file!');
@@ -131,7 +172,11 @@ const Application = new Lang.Class({
         this._initServices();
 
         Utils.addActions(this, {
-            'quit': { onActivate: this._onQuitActivate.bind(this) }
+            'quit': { onActivate: this._onQuitActivate.bind(this) },
+            'show-contact': {
+                paramType: 's',
+                onActivate: this._onShowContactActivate.bind(this)
+            }
         });
 
         this._initPlaceStore();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]