[gnome-contacts/wip/nielsdg/setup-add-accounts] WIP: allow to add online accounts when setting up.



commit 37ac24de25a3ccd99f3d288359852df05c4f2a91
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Dec 28 15:42:58 2017 +0100

    WIP: allow to add online accounts when setting up.

 meson.build               |    3 +++
 src/contacts-esd-setup.c  |    1 -
 src/contacts-window.vala  |   15 +++++++++++++++
 src/meson.build           |    1 +
 vapi/goa-backend-1.0.deps |    1 +
 vapi/goa-backend-1.0.vapi |   36 ++++++++++++++++++++++++++++++++++++
 6 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/meson.build b/meson.build
index 151a2ad..ee13ac3 100644
--- a/meson.build
+++ b/meson.build
@@ -37,6 +37,7 @@ glib = dependency('glib-2.0', version: '>=' + min_glib_version)
 gmodule_export = dependency('gmodule-export-2.0', version: '>=' + min_glib_version)
 gnome_desktop = dependency('gnome-desktop-3.0')
 goa = dependency('goa-1.0')
+goa_backend = dependency('goa-backend-1.0')
 gtk = dependency('gtk+-3.0', version: '>= 3.22.0')
 libebook = dependency('libebook-1.2', version: '>=' + min_eds_version)
 libedataserver = dependency('libedataserver-1.2', version: '>=' + min_eds_version)
@@ -68,6 +69,8 @@ conf.set_quoted('PACKAGE_VERSION', meson.project_version())
 conf.set_quoted('PKGDATADIR', pkgdatadir)
 conf.set_quoted('PKGLIBDIR', pkglibdir)
 conf.set_quoted('VERSION', meson.project_version())
+conf.set('GOA_API_IS_SUBJECT_TO_CHANGE', true)
+conf.set('GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE', true)
 configure_file(output: 'config.h', configuration: conf)
 
 # Post-install scripts
diff --git a/src/contacts-esd-setup.c b/src/contacts-esd-setup.c
index 936be16..7a7f872 100644
--- a/src/contacts-esd-setup.c
+++ b/src/contacts-esd-setup.c
@@ -21,7 +21,6 @@
 #include <libedataserverui/libedataserverui.h>
 #include <glib/gi18n-lib.h>
 
-#define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
 #include <gtk/gtk.h>
 
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 5c1899b..a8b7f98 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -160,6 +160,21 @@ public class Contacts.Window : Gtk.ApplicationWindow {
           setup_accounts_list.disconnect (id2);
         });
 
+      // TODO make this a clickbable listbox
+      // TODO if accountslist is empty: don't show accountslist 
+      GLib.List<Goa.Provider>? providers = null;
+      Goa.Provider.get_all ( (obj, res) => {
+          try {
+            Goa.Provider.get_all_finish (out providers, res);
+          } catch (Error e) {
+            warning ("Couldn't get list of providers!");
+          }
+
+          foreach (var provider in providers)
+            if (Goa.ProviderFeatures.CONTACTS in provider.get_provider_features ())
+              warning ("Found contacts provider \"%s\"", provider.get_provider_name ());
+        });
+
       view_switcher.visible_child_name = "setup-view";
       set_titlebar (setup_header_bar);
 
diff --git a/src/meson.build b/src/meson.build
index c95aca3..45e1bf1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -64,6 +64,7 @@ contacts_deps = [
   glib,
   gnome_desktop,
   goa,
+  goa_backend,
   gtk,
   libebook,
   libedataserver,
diff --git a/vapi/goa-backend-1.0.deps b/vapi/goa-backend-1.0.deps
new file mode 100644
index 0000000..fb7e14c
--- /dev/null
+++ b/vapi/goa-backend-1.0.deps
@@ -0,0 +1 @@
+goa-1.0
diff --git a/vapi/goa-backend-1.0.vapi b/vapi/goa-backend-1.0.vapi
new file mode 100644
index 0000000..af53759
--- /dev/null
+++ b/vapi/goa-backend-1.0.vapi
@@ -0,0 +1,36 @@
+[CCode (cheader_filename = "goabackend/goabackend.h")]
+namespace Goa {
+  public class Provider : GLib.Object {
+    // FIXME: we would ofc like this to be an async method, but it seems that _finish is not helping us
+    // by not having AsyncResult as its first argument
+    public static void get_all (GLib.AsyncReadyCallback cb);
+    public static bool get_all_finish (out GLib.List<Provider> providers, GLib.AsyncResult res) throws 
GLib.Error;
+
+    public string get_provider_name (Goa.Object? object = null);
+    public GLib.Icon get_provider_icon (Goa.Object? object = null);
+    public unowned string get_provider_type ();
+    public ProviderFeatures get_provider_features ();
+
+    public void add_account (Goa.Client client, Gtk.Dialog dialog, Gtk.Box vbox) throws GLib.Error;
+  }
+
+  [Flags]
+  [CCode (cprefix = "GOA_PROVIDER_FEATURE_")]
+  public enum ProviderFeatures {
+    BRANDED,
+    MAIL,
+    CALENDAR,
+    CONTACTS,
+    CHAT,
+    DOCUMENTS,
+    PHOTOS,
+    FILES,
+    TICKETING,
+    READ_LATER,
+    PRINTERS,
+    MAPS,
+    MUSIC,
+    TODO,
+    INVALID;
+  }
+}


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