[gnome-online-accounts] exchange: Prevent duplicate accounts from being added



commit 1df47ab0b13d6529f1f88e3d7187f4697da48fb8
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Apr 19 15:17:07 2012 +0200

    exchange: Prevent duplicate accounts from being added

 src/goabackend/goaexchangeprovider.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index 3d2befd..2eb2a00 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -28,6 +28,7 @@
 #include "goaprovider.h"
 #include "goaexchangeprovider.h"
 #include "goaeditablelabel.h"
+#include "goautils.h"
 
 /**
  * GoaExchangeProvider:
@@ -521,6 +522,7 @@ add_account (GoaProvider    *provider,
   const gchar *server;
   const gchar *password;
   const gchar *username;
+  const gchar *provider_type;
   gint response;
 
   ews_client = NULL;
@@ -552,6 +554,17 @@ add_account (GoaProvider    *provider,
   username = gtk_entry_get_text (GTK_ENTRY (data.username));
   server = gtk_entry_get_text (GTK_ENTRY (data.server));
 
+  /* See if there's already an account of this type with the
+   * given identity
+   */
+  provider_type = goa_provider_get_provider_type (provider);
+  if (!goa_utils_check_duplicate (client,
+                                  username,
+                                  provider_type,
+                                  (GoaPeekInterfaceFunc) goa_object_peek_password_based,
+                                  &data.error))
+    goto out;
+
   local_error = NULL;
   if (!goa_ews_client_autodiscover_sync (ews_client,
                                          email_address,



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