From 524c5a6e0cf654e092e54870470656bdeba3c408 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 May 2012 16:59:39 +0100 Subject: [PATCH] Remove support for the non-standard Query interface --- src/Makefile.am | 3 - src/mcd-account-manager-priv.h | 6 - src/mcd-account-manager-query.c | 368 -------------------- src/mcd-account-manager.c | 3 - src/mcd.xml | 1 - tests/twisted/account-manager/account-basics.py | 3 - .../account-manager/create-with-properties.py | 3 - tests/twisted/constants.py | 1 - tests/twisted/mctest.py | 3 - xml/Account_Manager_Interface_Query.xml | 75 ---- xml/Makefile.am | 1 - xml/nmc5.xml | 1 - 12 files changed, 468 deletions(-) delete mode 100644 src/mcd-account-manager-query.c delete mode 100644 xml/Account_Manager_Interface_Query.xml diff --git a/src/Makefile.am b/src/Makefile.am index 62aeb51..9042cdb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,7 +63,6 @@ mc_gen_headers = \ _gen/svc-Account_Interface_External_Password_Storage.h \ _gen/svc-Account_Interface_Hidden.h \ _gen/svc-Account_Manager_Interface_Hidden.h \ - _gen/svc-Account_Manager_Interface_Query.h \ _gen/svc-dispatcher.h nodist_libmcd_convenience_la_SOURCES = \ @@ -78,7 +77,6 @@ nodist_libmcd_convenience_la_SOURCES = \ _gen/svc-Account_Interface_Conditions.c \ _gen/svc-Account_Interface_External_Password_Storage.c \ _gen/svc-Account_Interface_Hidden.c \ - _gen/svc-Account_Manager_Interface_Query.c \ _gen/svc-Account_Manager_Interface_Hidden.c \ _gen/svc-dispatcher.c \ mcd-enum-types.c \ @@ -161,7 +159,6 @@ libmcd_convenience_la_SOURCES = \ mcd-account-addressing.c \ mcd-account-manager.c \ mcd-account-manager-priv.h \ - mcd-account-manager-query.c \ mcd-account-manager-default.c \ mcd-account-priv.h \ mcd-client.c \ diff --git a/src/mcd-account-manager-priv.h b/src/mcd-account-manager-priv.h index 839fafc..170953e 100644 --- a/src/mcd-account-manager-priv.h +++ b/src/mcd-account-manager-priv.h @@ -30,7 +30,6 @@ /* auto-generated stubs */ #include "_gen/svc-Account_Manager_Interface_Hidden.h" -#include "_gen/svc-Account_Manager_Interface_Query.h" G_BEGIN_DECLS @@ -55,11 +54,6 @@ G_GNUC_INTERNAL void _mcd_account_manager_store_account_connections (McdAccountManager *manager); -extern const McdDBusProp account_manager_query_properties[]; - -void account_manager_query_iface_init (McSvcAccountManagerInterfaceQueryClass *iface, - gpointer iface_data); - G_END_DECLS #endif diff --git a/src/mcd-account-manager-query.c b/src/mcd-account-manager-query.c deleted file mode 100644 index 8e11779..0000000 --- a/src/mcd-account-manager-query.c +++ /dev/null @@ -1,368 +0,0 @@ -/* vi: set et sw=4 ts=8 cino=t0,(0: */ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/* - * This file is part of mission-control - * - * Copyright (C) 2008-2009 Nokia Corporation. - * Copyright (C) 2009 Collabora Ltd. - * - * Contact: Alberto Mardegan - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * 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 "config.h" - -#include -#include -#include - -#include -#include -#include -#include "mcd-account.h" -#include "mcd-account-manager.h" -#include "mcd-account-manager-priv.h" -#include "mcd-account-priv.h" - -typedef struct -{ - const gchar *name; - const GValue *value; -} McdFindParam; - -typedef struct -{ - gchar *iface; - const gchar *name; - const GValue *value; -} McdIfaceProperty; - -typedef struct -{ - const gchar *manager; - const gchar *protocol; - guint requested_presence; - const gchar *requested_status; - guint current_presence; - const gchar *current_status; - GArray *params; - GArray *properties; - gint n_accounts; - GPtrArray *accounts; - GError *error; -} McdFindData; - -static const gchar *supported_keywords[] = { - "Manager", "Protocol", - "RequestedPresence", "RequestedStatus", - "CurrentPresence", "CurrentStatus", - NULL -}; - -static void -get_keywords (TpSvcDBusProperties *self, const gchar *name, - GValue *value) -{ - g_value_init (value, G_TYPE_STRV); - g_value_set_static_boxed (value, supported_keywords); -} - - -const McdDBusProp account_manager_query_properties[] = { - { "Keywords", NULL, get_keywords }, - { 0 }, -}; - - -static gboolean -match_account_parameter (McdAccount *account, const gchar *name, - const GValue *value) -{ - gboolean match = FALSE; - McdStorage *storage = _mcd_account_get_storage (account); - const gchar *account_name = mcd_account_get_unique_name (account); - GType vtype = G_VALUE_TYPE (value); - - if (mcd_storage_has_value (storage, account_name, name)) - { - GValue *conf = NULL; - - switch (vtype) - { - case G_TYPE_STRING: - case G_TYPE_UINT: - case G_TYPE_BOOLEAN: - conf = mcd_storage_dup_value (storage, account_name, name, vtype, - NULL); - break; - default: - g_warning ("Unexpected type %s", G_VALUE_TYPE_NAME (value)); - } - - if (conf != NULL) - { - if (G_VALUE_TYPE (conf) == vtype) - { - switch (vtype) - { - case G_TYPE_STRING: - match = g_strcmp0 (g_value_get_string (value), - g_value_get_string (conf)) == 0; - break; - - case G_TYPE_UINT: - match = g_value_get_uint (value) == g_value_get_uint (conf); - break; - - case G_TYPE_BOOLEAN: - match = - g_value_get_boolean (value) == g_value_get_boolean (conf); - break; - - default: - break; - } - } - - tp_g_value_slice_free (conf); - } - } - - return match; -} - -static gboolean -match_account_property (McdAccount *account, McdIfaceProperty *prop) -{ - const gchar *unique_name; - gboolean match = FALSE; - GValue value = { 0 }; - GError *error = NULL; - - DEBUG ("prop %s, value type %s", prop->name, G_VALUE_TYPE_NAME (prop->value)); - unique_name = mcd_account_get_unique_name (account); - mcd_dbusprop_get_property (TP_SVC_DBUS_PROPERTIES (account), - prop->iface, prop->name, &value, - &error); - if (error) - { - g_warning ("%s on %s: %s", G_STRFUNC, unique_name, error->message); - g_error_free (error); - return FALSE; - } - - if (G_VALUE_TYPE (&value) == G_VALUE_TYPE (prop->value)) - { - switch (G_VALUE_TYPE (&value)) - { - case G_TYPE_CHAR: - case G_TYPE_UCHAR: - case G_TYPE_BOOLEAN: - case G_TYPE_INT: - case G_TYPE_UINT: - case G_TYPE_LONG: - case G_TYPE_ULONG: - case G_TYPE_INT64: - case G_TYPE_UINT64: - case G_TYPE_FLOAT: - case G_TYPE_DOUBLE: - case G_TYPE_POINTER: - /* this assumes the GValue was previously initialized to 0, which - * should always be the case */ - match = (value.data[0].v_uint64 == prop->value->data[0].v_uint64); - break; - case G_TYPE_STRING: - match = !tp_strdiff (g_value_get_string (&value), - g_value_get_string (prop->value)); - break; - default: - g_warning ("%s: unsupported value type: %s", - G_STRFUNC, G_VALUE_TYPE_NAME (&value)); - } - } - g_value_unset (&value); - return match; -} - -static void -find_accounts (gpointer key, gpointer value, gpointer userdata) -{ - McdAccount *account = MCD_ACCOUNT (value); - McdFindData *fd = userdata; - TpConnectionPresenceType presence; - const gchar *object_path, *string, *status, *message; - guint i; - - DEBUG ("%s", (gchar *)key); - if (fd->manager) - { - string = mcd_account_get_manager_name (account); - if (!string || strcmp (fd->manager, string) != 0) return; - } - if (fd->protocol) - { - string = mcd_account_get_protocol_name (account); - if (!string || strcmp (fd->protocol, string) != 0) return; - } - if (fd->requested_presence > 0) - { - mcd_account_get_requested_presence (account, &presence, - &status, &message); - if (fd->requested_presence != presence) return; - } - if (fd->requested_status) - { - mcd_account_get_requested_presence (account, &presence, - &status, &message); - if (!status || strcmp (fd->requested_status, status) != 0) return; - } - if (fd->current_presence > 0) - { - mcd_account_get_current_presence (account, &presence, - &status, &message); - if (fd->current_presence != presence) return; - } - if (fd->current_status) - { - mcd_account_get_current_presence (account, &presence, - &status, &message); - if (!status || strcmp (fd->current_status, status) != 0) return; - } - - DEBUG ("checking parameters"); - for (i = 0; i < fd->params->len; i++) - { - McdFindParam *param; - param = &g_array_index (fd->params, McdFindParam, i); - if (!match_account_parameter (account, param->name, param->value)) - return; - } - - DEBUG ("checking properties"); - for (i = 0; i < fd->properties->len; i++) - { - McdIfaceProperty *prop; - prop = &g_array_index (fd->properties, McdIfaceProperty, i); - if (!match_account_property (account, prop)) - return; - } - object_path = mcd_account_get_object_path (account); - DEBUG ("%s", object_path); - g_ptr_array_add (fd->accounts, (gpointer)object_path); -} - -static void -parse_query (gpointer key, gpointer val, gpointer userdata) -{ - McdFindData *fd = userdata; - gchar *name = key, *dot; - GValue *value = val; - - if (fd->error) return; - - if (strcmp (name, "Manager") == 0) - fd->manager = g_value_get_string (value); - else if (strcmp (name, "Protocol") == 0) - fd->protocol = g_value_get_string (value); - else if (strcmp (name, "RequestedPresence") == 0) - fd->requested_presence = g_value_get_uint (value); - else if (strcmp (name, "RequestedStatus") == 0) - fd->requested_status = g_value_get_string (value); - else if (strcmp (name, "CurrentPresence") == 0) - fd->current_presence = g_value_get_uint (value); - else if (strcmp (name, "CurrentStatus") == 0) - fd->current_status = g_value_get_string (value); - else if (strncmp (name, "param-", 6) == 0) - { - McdFindParam param; - - param.name = name; - param.value = value; - g_array_append_val (fd->params, param); - } - else if ((dot = strrchr (name, '.')) != NULL) - { - McdIfaceProperty prop; - - prop.iface = g_strndup (name, dot - name); - prop.name = dot + 1; - prop.value = value; - g_array_append_val (fd->properties, prop); - } - else - { - g_set_error (&fd->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "Unrecognized query parameter: %s", name); - } -} - -static void -account_manager_find_accounts (McSvcAccountManagerInterfaceQuery *self, - GHashTable *query, - DBusGMethodInvocation *context) -{ - McdAccountManager *account_manager = MCD_ACCOUNT_MANAGER (self); - McdFindData fd; - guint i; - - DEBUG ("called"); - memset (&fd, 0, sizeof (fd)); - fd.params = g_array_new (FALSE, FALSE, sizeof (McdFindParam)); - fd.properties = g_array_new (FALSE, FALSE, sizeof (McdIfaceProperty)); - - /* break the hash table into the McdFindData struct, to avoid having to - * iterate over it for every account */ - g_hash_table_foreach (query, parse_query, &fd); - if (!fd.error) - { - GHashTable *accounts; - - fd.accounts = g_ptr_array_sized_new (16); - accounts = _mcd_account_manager_get_accounts (account_manager); - g_hash_table_foreach (accounts, find_accounts, &fd); - } - g_array_unref (fd.params); - for (i = 0; i < fd.properties->len; i++) - { - McdIfaceProperty *prop; - prop = &g_array_index (fd.properties, McdIfaceProperty, i); - g_free (prop->iface); - } - g_array_unref (fd.properties); - - if (fd.error) - { - dbus_g_method_return_error (context, fd.error); - g_error_free (fd.error); - return; - } - - mc_svc_account_manager_interface_query_return_from_find_accounts (context, - fd.accounts); - g_ptr_array_unref (fd.accounts); -} - - -void -account_manager_query_iface_init (McSvcAccountManagerInterfaceQueryClass *iface, - gpointer iface_data) -{ -#define IMPLEMENT(x) mc_svc_account_manager_interface_query_implement_##x (\ - iface, account_manager_##x) - IMPLEMENT(find_accounts); -#undef IMPLEMENT -} - diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index 1533d6f..77c9cea 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -80,9 +80,6 @@ static const McdInterfaceData account_manager_interfaces[] = { MCD_IMPLEMENT_IFACE (tp_svc_account_manager_get_type, account_manager, TP_IFACE_ACCOUNT_MANAGER), - MCD_IMPLEMENT_IFACE (mc_svc_account_manager_interface_query_get_type, - account_manager_query, - MC_IFACE_ACCOUNT_MANAGER_INTERFACE_QUERY), MCD_IMPLEMENT_IFACE (mc_svc_account_manager_interface_hidden_get_type, account_manager_hidden, MC_IFACE_ACCOUNT_MANAGER_INTERFACE_HIDDEN), diff --git a/src/mcd.xml b/src/mcd.xml index 244f750..b0b626a 100644 --- a/src/mcd.xml +++ b/src/mcd.xml @@ -11,7 +11,6 @@ - diff --git a/tests/twisted/account-manager/account-basics.py b/tests/twisted/account-manager/account-basics.py index b2ccc46..ec21a51 100644 --- a/tests/twisted/account-manager/account-basics.py +++ b/tests/twisted/account-manager/account-basics.py @@ -44,9 +44,6 @@ def test(q, bus, mc): properties.get('InvalidAccounts') interfaces = properties.get('Interfaces') - # assert that current functionality exists - assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces - params = dbus.Dictionary({"account": "someguy@example.com", "password": "secrecy"}, signature='sv') (cm_name_ref, account) = create_fakecm_account(q, bus, mc, params) diff --git a/tests/twisted/account-manager/create-with-properties.py b/tests/twisted/account-manager/create-with-properties.py index 6b1b352..f4a6982 100644 --- a/tests/twisted/account-manager/create-with-properties.py +++ b/tests/twisted/account-manager/create-with-properties.py @@ -39,9 +39,6 @@ def test(q, bus, mc): interfaces = properties.get('Interfaces') supported = properties.get('SupportedAccountProperties') - # assert that current functionality exists - assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces - assert (cs.ACCOUNT + '.AutomaticPresence') in supported assert (cs.ACCOUNT + '.Enabled') in supported assert (cs.ACCOUNT + '.Icon') in supported diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index e23e2bf..c3de47c 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -176,7 +176,6 @@ ACCOUNT_PATH_PREFIX = tp_path_prefix + '/Account/' AM = tp_name_prefix + '.AccountManager' AM_IFACE_HIDDEN = AM + '.Interface.Hidden.DRAFT1' -AM_IFACE_NOKIA_QUERY = 'com.nokia.AccountManager.Interface.Query' AM_PATH = tp_path_prefix + '/AccountManager' CR = tp_name_prefix + '.ChannelRequest' diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index 88f0a14..044cad5 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -1100,9 +1100,6 @@ def connect_to_mc(q, bus, mc): assert properties is not None interfaces = properties.get('Interfaces') - # assert that current functionality exists - assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces - return account_manager, properties, interfaces def tell_mc_to_die(q, bus): diff --git a/xml/Account_Manager_Interface_Query.xml b/xml/Account_Manager_Interface_Query.xml deleted file mode 100644 index e66e127..0000000 --- a/xml/Account_Manager_Interface_Query.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - Copyright (C) 2008 Nokia Corporation - -

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 Street, Fifth Floor, Boston, MA 02110-1301, USA.

-
- - - -

The Query interface provides a convienient way for clients to retrieve - a subset of the accounts satisfying certain conditions.

- - -

This is basically the same API proposed by Zdra

-
-
- - - -

Find all accounts which match the search query.

-

An empty parameter should return all accounts

-
- - - -

The search query data. The keys can be any Connection Manager - parameter (in which case they must be prepended with the string - "param-"), any readable Account property (in the form - Interface.PropertyName) or any of these special - keys:

-
    -
  • s: Manager
  • -
  • s: Protocol
  • -
  • u: RequestedPresence
  • -
  • s: RequestedStatus
  • -
  • u: CurrentPresence
  • -
  • s: CurrentStatus
  • -
-
-
- - - The array of account objects. - - -
- - - - A list of the special keywords recognized by the FindAccounts method. - -

It's likely that some new keywords will be added later, or that - different implementation of this interface will support a different - set of keywords; in such a scenario it seems proper to inform the - client about supported keywords.

-

But I'm not sure this is really needed.

-
-
-
-
-
- diff --git a/xml/Makefile.am b/xml/Makefile.am index a87966e..1b6c8ae 100644 --- a/xml/Makefile.am +++ b/xml/Makefile.am @@ -6,7 +6,6 @@ DROP_TPTYPE = sed -e 's@tp:type="[^"]*"@@g' SPECS = \ Account_Manager_Interface_Hidden.xml \ - Account_Manager_Interface_Query.xml \ Account_Interface_Addressing.xml \ Account_Interface_Conditions.xml \ Account_Interface_External_Password_Storage.xml \ diff --git a/xml/nmc5.xml b/xml/nmc5.xml index 9ecbcd0..9f17722 100644 --- a/xml/nmc5.xml +++ b/xml/nmc5.xml @@ -9,7 +9,6 @@ - -- 1.7.10