[gnome-online-accounts] client: Add goa_client_lookup_by_id
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] client: Add goa_client_lookup_by_id
- Date: Sat, 11 Aug 2012 10:09:04 +0000 (UTC)
commit 72839e02dab7bd7818c37e2709a90c1027aee6de
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Aug 11 12:05:07 2012 +0200
client: Add goa_client_lookup_by_id
Users have been reimplementing this again and again. Makes sense to
include it to make their lives easier.
src/goa/goaclient.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
src/goa/goaclient.h | 4 +++-
2 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/src/goa/goaclient.c b/src/goa/goaclient.c
index fa7232e..3ab4f48 100644
--- a/src/goa/goaclient.c
+++ b/src/goa/goaclient.c
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011, 2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -481,6 +481,50 @@ goa_client_get_accounts (GoaClient *client)
return ret;
}
+/**
+ * goa_client_lookup_by_id:
+ * @client: A #GoaClient.
+ * @id: The ID to look for.
+ *
+ * Finds and returns the #GoaObject instance whose
+ * <link
+ * linkend="gdbus-property-org-gnome-OnlineAccounts-Account.Id">"Id"</link>
+ * D-Bus property matches @id.
+ *
+ * Returns: (transfer full): A #GoaObject. Free the returned
+ * object with g_object_unref().
+ */
+GoaObject *
+goa_client_lookup_by_id (GoaClient *client,
+ const gchar *id)
+{
+ GList *accounts;
+ GList *l;
+ GoaObject *ret;
+
+ ret = NULL;
+
+ accounts = goa_client_get_accounts (client);
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ GoaAccount *account;
+ GoaObject *object = GOA_OBJECT (l->data);
+
+ account = goa_object_peek_account (object);
+ if (account == NULL)
+ continue;
+
+ if (g_strcmp0 (goa_account_get_id (account), id) == 0)
+ {
+ ret = g_object_ref (object);
+ break;
+ }
+ }
+
+ g_list_free_full (accounts, g_object_unref);
+ return ret;
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static void
diff --git a/src/goa/goaclient.h b/src/goa/goaclient.h
index cab58f0..cda0bea 100644
--- a/src/goa/goaclient.h
+++ b/src/goa/goaclient.h
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011, 2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -47,6 +47,8 @@ GoaClient *goa_client_new_sync (GCancellable *cancella
GDBusObjectManager *goa_client_get_object_manager (GoaClient *client);
GoaManager *goa_client_get_manager (GoaClient *client);
GList *goa_client_get_accounts (GoaClient *client);
+GoaObject *goa_client_lookup_by_id (GoaClient *client,
+ const gchar *id);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]