pidgin/plugins/gevolution/gevo-util.c

branch
release-2.x.y
changeset 40849
a2a16969a8fa
parent 38258
9a6551eba09c
--- a/pidgin/plugins/gevolution/gevo-util.c	Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/gevo-util.c	Fri Apr 09 23:53:13 2021 -0500
@@ -120,26 +120,51 @@
 }
 
 gboolean
-gevo_load_addressbook(const gchar* uri, EBook **book, GError **error)
-{
+gevo_load_addressbook(const gchar* uid, EBook **book, GError **error) {
 	gboolean result = FALSE;
+	ESourceRegistry *registry;
+	ESource *source;
 
 	g_return_val_if_fail(book != NULL, FALSE);
 
-	if (uri == NULL)
-		*book = e_book_new_system_addressbook(error);
-	else
-		*book = e_book_new_from_uri(uri, error);
+	registry = e_source_registry_new_sync(NULL, error);
+
+	if(!registry) {
+	    return FALSE;
+	}
+
+	if(uid == NULL) {
+		source = e_source_registry_ref_default_address_book(registry);
+	} else {
+		source = e_source_registry_ref_source(registry, uid);
+	}
+
+	g_object_unref(registry);
+
+	result = gevo_load_addressbook_from_source(source, book, error);
 
-	if (*book == NULL)
+	g_object_unref(source);
+
+	return result;
+}
+
+gboolean
+gevo_load_addressbook_from_source(ESource *source, EBook **book,
+                                  GError **error)
+{
+	gboolean result = FALSE;
+
+	*book = e_book_new(source, error);
+
+	if(*book == NULL) {
 		return FALSE;
+	}
 
 	*error = NULL;
 
 	result = e_book_open(*book, FALSE, error);
 
-	if (!result && *book != NULL)
-	{
+	if(!result && *book != NULL) {
 		g_object_unref(*book);
 		*book = NULL;
 	}

mercurial