diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2008-06-12 06:51:20 +0000 |
---|---|---|
committer | Alberto Mardegan <mardy@users.sourceforge.net> | 2008-06-12 06:51:20 +0000 |
commit | 44063001f756e8ee8247f4887ff653b129ee675c (patch) | |
tree | 9c2265dc11254bfeff227aff269232c44f6552b8 /libmcclient | |
parent | 72e3be147953ea8b2b0b6a06950051753fee1753 (diff) |
Add Conditions interface.
git-svn-id: https://mission-control.svn.sourceforge.net/svnroot/mission-control/trunk@428 d91c8aed-3f2b-0410-a83d-924a1c20a0ba
Diffstat (limited to 'libmcclient')
-rw-r--r-- | libmcclient/Makefile.am | 1 | ||||
-rw-r--r-- | libmcclient/mc-account-conditions.c | 90 | ||||
-rw-r--r-- | libmcclient/mc-account-priv.h | 4 | ||||
-rw-r--r-- | libmcclient/mc-account.c | 3 | ||||
-rw-r--r-- | libmcclient/mc-account.h | 7 |
5 files changed, 105 insertions, 0 deletions
diff --git a/libmcclient/Makefile.am b/libmcclient/Makefile.am index d12831b8..56dfad58 100644 --- a/libmcclient/Makefile.am +++ b/libmcclient/Makefile.am @@ -22,6 +22,7 @@ libmcclient_la_SOURCES = \ mc-account.c \ mc-account-avatar.c \ mc-account-compat.c \ + mc-account-conditions.c \ mc-account-manager.c \ mc-errors.c \ mc-profile.c \ diff --git a/libmcclient/mc-account-conditions.c b/libmcclient/mc-account-conditions.c new file mode 100644 index 00000000..d633f74b --- /dev/null +++ b/libmcclient/mc-account-conditions.c @@ -0,0 +1,90 @@ +/* + * mc-account-conditions.c - Telepathy Account D-Bus interface (client side) + * + * Copyright (C) 2008 Nokia Corporation + * + * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <string.h> +#include "mc-account.h" +#include "mc-account-priv.h" +#include "dbus-api.h" + +struct _McAccountConditionsProps { + GHashTable *conditions; +}; + + +void +_mc_account_conditions_props_free (McAccountConditionsProps *props) +{ + if (props->conditions) + g_hash_table_destroy (props->conditions); + g_free (props); +} + +static void +update_property (gpointer key, gpointer ht_value, gpointer user_data) +{ + McAccount *account = user_data; + McAccountConditionsProps *props = account->priv->conditions_props; + GValue *value = ht_value; + const gchar *name = key; + + if (strcmp (name, "Condition") == 0) + { + if (props->conditions) + g_hash_table_destroy (props->conditions); + props->conditions = g_value_get_boxed (value); + _mc_gvalue_stolen (value); + } +} + +static void +create_props (McAccount *account, GHashTable *props) +{ + McAccountPrivate *priv = account->priv; + + priv->conditions_props = g_malloc0 (sizeof (McAccountConditionsProps)); + g_hash_table_foreach (props, update_property, account); +} + +void +mc_account_conditions_call_when_ready (McAccount *account, + McAccountWhenReadyCb callback, + gpointer user_data) +{ + McAccountIfaceData iface_data; + + iface_data.name = MC_IFACE_ACCOUNT_INTERFACE_CONDITIONS; + iface_data.props_data_ptr = (gpointer *)&account->priv->conditions_props; + iface_data.create_props = create_props; + + _mc_account_call_when_ready_int (account, callback, user_data, &iface_data); +} + +const GHashTable * +mc_account_conditions_get (McAccount *account) +{ + g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); + + if (G_UNLIKELY (!account->priv->conditions_props)) return NULL; + return account->priv->conditions_props->conditions; +} + diff --git a/libmcclient/mc-account-priv.h b/libmcclient/mc-account-priv.h index 718793af..5051fa33 100644 --- a/libmcclient/mc-account-priv.h +++ b/libmcclient/mc-account-priv.h @@ -30,11 +30,13 @@ G_BEGIN_DECLS typedef struct _McAccountProps McAccountProps; typedef struct _McAccountAvatarProps McAccountAvatarProps; typedef struct _McAccountCompatProps McAccountCompatProps; +typedef struct _McAccountConditionsProps McAccountConditionsProps; struct _McAccountPrivate { McAccountProps *props; McAccountAvatarProps *avatar_props; McAccountCompatProps *compat_props; + McAccountConditionsProps *conditions_props; }; typedef struct _CallWhenReadyContext CallWhenReadyContext; @@ -63,6 +65,8 @@ void _mc_account_avatar_props_free (McAccountAvatarProps *props); void _mc_account_compat_props_free (McAccountCompatProps *props); +void _mc_account_conditions_props_free (McAccountConditionsProps *props); + G_END_DECLS #endif diff --git a/libmcclient/mc-account.c b/libmcclient/mc-account.c index a66f2c0e..aa6d084e 100644 --- a/libmcclient/mc-account.c +++ b/libmcclient/mc-account.c @@ -182,6 +182,9 @@ finalize (GObject *object) if (account->priv->compat_props) _mc_account_compat_props_free (account->priv->compat_props); + if (account->priv->conditions_props) + _mc_account_conditions_props_free (account->priv->conditions_props); + g_free (account->manager_name); g_free (account->protocol_name); diff --git a/libmcclient/mc-account.h b/libmcclient/mc-account.h index 38d53b3f..91ad53a9 100644 --- a/libmcclient/mc-account.h +++ b/libmcclient/mc-account.h @@ -109,6 +109,13 @@ const gchar *mc_account_compat_get_profile (McAccount *account); const gchar *mc_account_compat_get_avatar_file (McAccount *account); const gchar * const *mc_account_compat_get_secondary_vcard_fields (McAccount *account); + +void mc_account_conditions_call_when_ready (McAccount *account, + McAccountWhenReadyCb callback, + gpointer user_data); + +const GHashTable *mc_account_conditions_get (McAccount *account); + G_END_DECLS /* auto-generated stubs */ |