[Pkg-telepathy-commits] [telepathy-mission-control-6] 272/280: Merge commit '553acd80fac93fb21c28cb51f00c9c51045c9921' into next

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit 404f67814a6bbf71fba965211becbf8cbd9a64af
Merge: 2e69031 553acd8
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Mar 19 18:35:21 2014 +0000

    Merge commit '553acd80fac93fb21c28cb51f00c9c51045c9921' into next
    
    Conflicts:
    	configure.ac
    	src/mcd-account-connection.c
    	src/mcd-account-manager.c
    	src/mcd-account.c
    	src/mcd-account.h
    	tools/glib-client-gen.py
    	tools/glib-client-marshaller-gen.py
    	tools/glib-ginterface-gen.py
    	tools/glib-gtypes-generator.py
    	tools/libglibcodegen.py
    	tools/libtpcodegen.py
    	xml/all.xml
    	xml/telepathy-types.xml

 .gitignore                                         |    1 -
 Makefile.am                                        |    1 -
 NEWS                                               |    8 +-
 configure.ac                                       |    1 -
 doc/Makefile.am                                    |   13 -
 mission-control-plugins/account-storage.c          |  193 ++-
 mission-control-plugins/account-storage.h          |   34 +
 src/Makefile.am                                    |  120 +-
 src/gtypes.c                                       |   10 -
 src/mcd-account-addressing.c                       |    1 -
 src/mcd-account-connection.c                       |  153 ---
 src/mcd-account-manager-default.c                  |   65 +
 src/mcd-account-manager.c                          |   53 +-
 src/mcd-account-priv.h                             |   18 -
 src/mcd-account.c                                  |  798 +++++-------
 src/mcd-account.h                                  |   16 +-
 src/mcd-channel.c                                  |    2 -
 src/mcd-connection.c                               |    2 -
 src/mcd-misc.c                                     |    3 -
 src/mcd-storage.c                                  |  223 ++++
 src/mcd-storage.h                                  |    7 +
 src/mcd.xml                                        |   11 -
 src/request.c                                      |    1 -
 tests/twisted/account-storage/load-keyfiles.py     |   31 +-
 tests/twisted/account-storage/storage_helper.py    |    8 +-
 tests/twisted/dbus-account-plugin.c                |   67 +-
 tests/twisted/mcp-account-diversion.c              |   44 +
 tests/twisted/mctest.py                            |   11 +-
 tools/Makefile.am                                  |   31 -
 tools/c-constants-generator.xsl                    |  299 -----
 tools/c-interfaces-generator.xsl                   |   84 --
 tools/doc-generator.xsl                            | 1199 -----------------
 tools/glib-blocking-client-gen.py                  | 1014 ---------------
 tools/glib-client-gen.py                           | 1363 --------------------
 tools/glib-client-marshaller-gen.py                |   60 -
 tools/glib-ginterface-gen.py                       |  849 ------------
 tools/glib-gtypes-generator.py                     |  304 -----
 tools/glib-interfaces-body-generator.xsl           |   47 -
 tools/glib-interfaces-generator.xsl                |   55 -
 tools/glib-signals-marshal-gen.py                  |   55 -
 tools/gquark-gen.py                                |  135 --
 tools/identity.xsl                                 |    7 -
 tools/libglibcodegen.py                            |  172 ---
 tools/libtpcodegen.py                              |  247 ----
 tools/spec-to-introspect.xsl                       |   26 -
 ...Account_Interface_External_Password_Storage.xml |   58 -
 ...onnection_Manager_Interface_Account_Storage.xml |  120 --
 xml/Makefile.am                                    |   30 -
 xml/all.xml                                        |   35 -
 xml/generic-types.xml                              |  214 ---
 xml/nmc5.xml                                       |   11 -
 xml/telepathy-types.xml                            |   96 --
 52 files changed, 997 insertions(+), 7409 deletions(-)

diff --cc mission-control-plugins/account-storage.c
index 8f56880,b04e3bd..efae5c9
--- a/mission-control-plugins/account-storage.c
+++ b/mission-control-plugins/account-storage.c
@@@ -54,8 -54,9 +54,9 @@@
   *   iface->priority = 0;
   *   iface->name = "foo";
   *   iface->desc = "The FOO storage backend";
 - *   iface->provider = "org.freedesktop.Telepathy.MissionControl5.FooStorage";
 + *   iface->provider = "im.telepathy.v1.MissionControl6.FooStorage";
   *
+  *   iface->get_flags = foo_plugin_get_flags;
   *   iface->delete_async = foo_plugin_delete_async;
   *   iface->delete_finish = foo_plugin_delete_finish;
   *   iface->commit = foo_plugin_commit;
diff --cc src/mcd-account-addressing.c
index eadc4ea,e1a0fb7..7d2355b
--- a/src/mcd-account-addressing.c
+++ b/src/mcd-account-addressing.c
@@@ -30,10 -30,9 +30,9 @@@
  
  #include "mcd-account.h"
  #include "mcd-account-priv.h"
- #include "_gen/interfaces.h"
  
  static void
 -addressing_set_uri_scheme_association (TpSvcAccountInterfaceAddressing *iface,
 +addressing_set_uri_scheme_association (TpSvcAccountInterfaceAddressing1 *iface,
      const gchar *uri_scheme,
      gboolean association,
      DBusGMethodInvocation *context)
diff --cc src/mcd-account-connection.c
index 88ccc5c,a532f35..0000000
deleted file mode 100644,100644
--- a/src/mcd-account-connection.c
+++ /dev/null
@@@ -1,153 -1,38 +1,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  <alberto.mardegan at 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
-- * 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 <stdio.h>
--#include <string.h>
--#include <glib/gstdio.h>
--
--#include "mcd-master.h"
--#include "mcd-master-priv.h"
--#include "mcd-account.h"
--#include "mcd-account-priv.h"
--#include "mcd-account-manager.h"
--#include "mcd-connection-priv.h"
- 
- struct _McdAccountConnectionContext {
-     GHashTable *params;
-     gboolean user_initiated;
- };
- 
- void
- _mcd_account_connection_context_free (McdAccountConnectionContext *c)
- {
-     g_hash_table_unref (c->params);
-     g_free (c);
- }
- 
- void
- _mcd_account_connection_begin (McdAccount *account,
-                                gboolean user_initiated)
- {
-     McdAccountConnectionContext *ctx;
- 
-     /* check whether a connection process is already ongoing */
-     if (_mcd_account_get_connection_context (account) != NULL)
-     {
-         DEBUG ("already trying to connect");
-         return;
-     }
- 
-     /* get account params */
-     /* create dynamic params HT */
-     /* run the handlers */
-     ctx = g_malloc (sizeof (McdAccountConnectionContext));
-     ctx->user_initiated = user_initiated;
- 
-     /* If we get this far, the account should be usable, so getting the
-      * parameters should succeed.
-      */
-     ctx->params = _mcd_account_dup_parameters (account);
-     g_assert (ctx->params != NULL);
- 
-     _mcd_account_set_connection_status (account,
-                                         TP_CONNECTION_STATUS_CONNECTING,
-                                         TP_CONNECTION_STATUS_REASON_REQUESTED,
-                                         NULL, NULL, NULL);
-     _mcd_account_set_connection_context (account, ctx);
-     mcd_account_connection_proceed (account, TRUE);
- }
- 
- void
- mcd_account_connection_proceed_with_reason (McdAccount *account,
-                                             gboolean success,
-                                             TpConnectionStatusReason reason)
- {
-     McdAccountConnectionContext *ctx;
-     gboolean delayed;
- 
-     /* call next handler, or terminate the chain (emitting proper signal).
-      * if everything is fine, call mcd_manager_create_connection() and
-      * _mcd_connection_connect () with the dynamic parameters. Remove that call
-      * from mcd_manager_create_connection() */
-     ctx = _mcd_account_get_connection_context (account);
-     g_return_if_fail (ctx != NULL);
-     g_return_if_fail (ctx->params != NULL);
- 
-     if (success)
-     {
-         if (mcd_connectivity_monitor_is_online (
-               mcd_account_get_connectivity_monitor (account)))
-         {
-             DEBUG ("%s wants to connect and we're online - go for it",
-                 mcd_account_get_unique_name (account));
-             delayed = FALSE;
-         }
-         else if (!mcd_account_get_waiting_for_connectivity (account))
-         {
-             DEBUG ("%s wants to connect, but we're offline; queuing it up",
-                 mcd_account_get_unique_name (account));
-             delayed = TRUE;
-             mcd_account_set_waiting_for_connectivity (account, TRUE);
-         }
-         else
-         {
-             DEBUG ("%s wants to connect, but is already waiting for "
-                 "connectivity?", mcd_account_get_unique_name (account));
-             delayed = TRUE;
-         }
-     }
-     else
-     {
-         DEBUG ("%s failed to connect: reason code %d",
-             mcd_account_get_unique_name (account), reason);
-         delayed = FALSE;
-     }
- 
-     if (!delayed)
-     {
- 	/* end of the chain */
- 	if (success)
- 	{
- 	    _mcd_account_connect (account, ctx->params);
- 	}
-         else
-         {
-             _mcd_account_set_connection_status
-                 (account, TP_CONNECTION_STATUS_DISCONNECTED, reason, NULL,
-                  TP_ERROR_STR_DISCONNECTED, NULL);
-         }
-         _mcd_account_set_connection_context (account, NULL);
-     }
- }
- 
- void
- mcd_account_connection_proceed (McdAccount *account, gboolean success)
- {
-     mcd_account_connection_proceed_with_reason
-         (account, success, TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED);
- }
diff --cc src/mcd-account-manager.c
index 5b6bb7a,5703925..c3f4485
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@@ -269,9 -254,15 +254,15 @@@ async_created_manager_cb (McdManager *c
  
      /* this triggers the final parameter check which results in dbus signals *
       * being fired and (potentially) the account going online automatically  */
-     mcd_account_check_usability (account, async_created_usability_cb, NULL);
 -    ok = mcd_account_check_validity (account, NULL);
 -    DEBUG ("asynchronously created account %s is %svalid",
++    ok = mcd_account_check_usability (account, NULL);
++    DEBUG ("asynchronously created account %s is %susable",
+            mcd_account_get_unique_name (account),
 -           ok ? "" : "in");
++           ok ? "" : "un");
  
      g_object_unref (cm);
+ 
+     /* safely cached in the accounts hash by now */
+     g_object_unref (account);
  }
  
  /* account created by an McpAccountStorage plugin after the initial setup   *
@@@ -841,13 -814,12 +815,12 @@@ complete_account_creation_set_cb (McdAc
      if (cad->ok)
      {
          add_account (account_manager, account, G_STRFUNC);
-         mcd_account_check_usability (account,
-             complete_account_creation_check_usability_cb, cad);
-     }
-     else
-     {
-         complete_account_creation_finish (account, cad);
+ 
 -        if (!mcd_account_check_validity (account, &cad->error))
++        if (!mcd_account_check_usability (account, &cad->error))
+             cad->ok = FALSE;
      }
+ 
+     complete_account_creation_finish (account, cad);
  }
  
  static void
diff --cc src/mcd-account.c
index 9d89c8b,0cfcdab..437b1af
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@@ -57,14 -52,11 +52,11 @@@ static void account_iface_init (TpSvcAc
  			       	gpointer iface_data);
  static void properties_iface_init (TpSvcDBusPropertiesClass *iface,
  				   gpointer iface_data);
 -static void account_avatar_iface_init (TpSvcAccountInterfaceAvatarClass *iface,
 +static void account_avatar_iface_init (TpSvcAccountInterfaceAvatar1Class *iface,
  				       gpointer iface_data);
  static void account_storage_iface_init (
 -    TpSvcAccountInterfaceStorageClass *iface,
 +    TpSvcAccountInterfaceStorage1Class *iface,
      gpointer iface_data);
- static void account_external_password_storage_iface_init (
-     McSvcAccountInterfaceExternalPasswordStorageClass *iface,
-     gpointer iface_data);
  
  static const McdDBusProp account_properties[];
  static const McdDBusProp account_avatar_properties[];
@@@ -72,20 -64,15 +64,15 @@@ static const McdDBusProp account_storag
  
  static const McdInterfaceData account_interfaces[] = {
      MCD_IMPLEMENT_IFACE (tp_svc_account_get_type, account, TP_IFACE_ACCOUNT),
 -    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_avatar_get_type,
 +    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_avatar1_get_type,
  			 account_avatar,
 -			 TP_IFACE_ACCOUNT_INTERFACE_AVATAR),
 -    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_storage_get_type,
 +			 TP_IFACE_ACCOUNT_INTERFACE_AVATAR1),
 +    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_storage1_get_type,
                           account_storage,
 -                         TP_IFACE_ACCOUNT_INTERFACE_STORAGE),
 -    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_addressing_get_type,
 +                         TP_IFACE_ACCOUNT_INTERFACE_STORAGE1),
 +    MCD_IMPLEMENT_IFACE (tp_svc_account_interface_addressing1_get_type,
          account_addressing,
 -        TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING),
 +        TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING1),
-     MCD_IMPLEMENT_OPTIONAL_IFACE (
-         mc_svc_account_interface_external_password_storage_get_type,
-         account_external_password_storage,
-         MC_IFACE_ACCOUNT_INTERFACE_EXTERNAL_PASSWORD_STORAGE),
  
      { G_TYPE_INVALID, }
  };
@@@ -461,169 -461,63 +461,63 @@@ mcd_account_get_parameter_of_known_typ
      return FALSE;
  }
  
- typedef void (*CheckParametersCb) (
-     McdAccount *account,
-     const GError *unusable_reason,
-     gpointer user_data);
- static void mcd_account_check_parameters (McdAccount *account,
-     CheckParametersCb callback, gpointer user_data);
- 
- static void
- manager_ready_check_params_cb (McdAccount *account,
-     const GError *unusable_reason,
-     gpointer user_data)
- {
-     McdAccountPrivate *priv = account->priv;
- 
-     g_clear_error (&priv->unusable_reason);
-     if (unusable_reason != NULL)
-     {
-         priv->unusable_reason = g_error_copy (unusable_reason);
-     }
- 
-     mcd_account_loaded (account);
- }
- 
- static void
- account_external_password_storage_get_accounts_cb (TpProxy *cm,
-     const GValue *value,
-     const GError *in_error,
-     gpointer user_data,
-     GObject *self)
- {
-   McdAccount *account = MCD_ACCOUNT (self);
-   const char *account_id = user_data;
-   GHashTable *map, *props;
- 
-   if (in_error != NULL)
-     {
-       DEBUG ("Failed to get Account property: %s", in_error->message);
-       return;
-     }
- 
-   g_return_if_fail (G_VALUE_HOLDS (value, MC_HASH_TYPE_ACCOUNT_FLAGS_MAP));
- 
-   map = g_value_get_boxed (value);
- 
-   account->priv->password_saved =
-     GPOINTER_TO_UINT (g_hash_table_lookup (map, account_id)) &
-       MC_ACCOUNT_FLAG_CREDENTIALS_STORED;
- 
-   DEBUG ("PasswordSaved = %u", account->priv->password_saved);
- 
-   /* emit the changed signal */
-   props = tp_asv_new (
-       "PasswordSaved", G_TYPE_BOOLEAN, account->priv->password_saved,
-       NULL);
- 
-   tp_svc_dbus_properties_emit_properties_changed (account,
-       MC_IFACE_ACCOUNT_INTERFACE_EXTERNAL_PASSWORD_STORAGE,
-       props,
-       NULL);
- 
-   g_hash_table_unref (props);
- }
- 
- static void
- account_setup_identify_account_cb (TpProxy *protocol,
-     const char *account_id,
-     const GError *in_error,
-     gpointer user_data,
-     GObject *self)
- {
-   McdAccount *account = MCD_ACCOUNT (self);
-   TpConnectionManager *cm = mcd_account_get_cm (account);
- 
-   if (in_error != NULL)
-     {
-       DEBUG ("Error identifying account: %s", in_error->message);
-       return;
-     }
- 
-   DEBUG ("Identified account as %s", account_id);
- 
-   /* look up the current value of the CM.I.AS.Accounts property
-    * and monitor future changes */
-   tp_cli_dbus_properties_call_get (cm, -1,
-       MC_IFACE_CONNECTION_MANAGER_INTERFACE_ACCOUNT_STORAGE,
-       "Accounts",
-       account_external_password_storage_get_accounts_cb,
-       g_strdup (account_id), g_free, G_OBJECT (account));
- }
- 
- static void
- account_external_password_storage_properties_changed_cb (TpProxy *cm,
-     const char *iface,
-     GHashTable *changed_properties,
-     const char **invalidated_properties,
-     gpointer user_data,
-     GObject *self)
- {
-   McdAccount *account = MCD_ACCOUNT (self);
-   TpProtocol *protocol = tp_connection_manager_get_protocol (
-       TP_CONNECTION_MANAGER (cm), account->priv->protocol_name);
-   GHashTable *params;
- 
-   if (tp_strdiff (iface,
-         MC_IFACE_CONNECTION_MANAGER_INTERFACE_ACCOUNT_STORAGE))
-     return;
- 
-   /* look up account identity so we can look up our value in
-    * the Accounts map */
-   params = _mcd_account_dup_parameters (account);
-   tp_cli_protocol_call_identify_account (protocol, -1, params,
-       account_setup_identify_account_cb,
-       NULL, NULL, G_OBJECT (account));
- 
-   g_hash_table_unref (params);
- }
+ static gboolean mcd_account_check_parameters (McdAccount *account,
 -    GError **invalid_reason);
++    GError **unusable_reason);
  
  static void on_manager_ready (McdManager *manager, const GError *error,
                                gpointer user_data)
  {
      McdAccount *account = MCD_ACCOUNT (user_data);
 -    GError *invalid_reason = NULL;
++    GError *unusable_reason = NULL;
+     TpProtocol *protocol;
  
      if (error)
      {
          DEBUG ("got error: %s", error->message);
-         mcd_account_loaded (account);
+     }
 -    else if (!mcd_account_check_parameters (account, &invalid_reason))
++    else if (!mcd_account_check_parameters (account, &unusable_reason))
+     {
 -        g_clear_error (&account->priv->invalid_reason);
 -        account->priv->invalid_reason = invalid_reason;
++        g_clear_error (&account->priv->unusable_reason);
++        account->priv->unusable_reason = unusable_reason;
      }
      else
      {
-         TpConnectionManager *cm = mcd_manager_get_tp_proxy (manager);
 -        g_clear_error (&account->priv->invalid_reason);
++        g_clear_error (&account->priv->unusable_reason);
+     }
  
-         mcd_account_check_parameters (account, manager_ready_check_params_cb,
-                                       NULL);
+     protocol = _mcd_manager_dup_protocol (account->priv->manager,
+             account->priv->protocol_name);
  
-         /* determine if we support Acct.I.ExternalPasswordStorage */
-         if (tp_proxy_has_interface_by_id (cm,
-                 MC_IFACE_QUARK_CONNECTION_MANAGER_INTERFACE_ACCOUNT_STORAGE))
+     if (protocol != NULL)
+     {
+         if (mcd_storage_maybe_migrate_parameters (
+                 account->priv->storage,
+                 account->priv->unique_name,
+                 protocol))
          {
-             TpProtocol *protocol = tp_connection_manager_get_protocol (
-                 cm, account->priv->protocol_name);
-             GHashTable *params;
- 
-             DEBUG ("CM %s has CM.I.AccountStorage iface",
-                    mcd_manager_get_name (manager));
+             GHashTable *params = _mcd_account_dup_parameters (account);
  
-             mcd_dbus_activate_optional_interface (
-                 TP_SVC_DBUS_PROPERTIES (account),
-                 MC_TYPE_SVC_ACCOUNT_INTERFACE_EXTERNAL_PASSWORD_STORAGE);
+             if (params != NULL)
+             {
+                 GValue value = G_VALUE_INIT;
  
-             /* look up account identity so we can look up our value in
-              * the Accounts map */
-             params = _mcd_account_dup_parameters (account);
-             tp_cli_protocol_call_identify_account (protocol, -1, params,
-                 account_setup_identify_account_cb,
-                 NULL, NULL, G_OBJECT (account));
+                 g_value_init (&value, TP_HASH_TYPE_STRING_VARIANT_MAP);
+                 g_value_take_boxed (&value, params);
+                 mcd_account_changed_property (account, "Parameters", &value);
+                 g_value_unset (&value);
+             }
+             else
+             {
+                 WARNING ("somehow managed to migrate parameters without "
+                     "being able to emit change notification");
+             }
+         }
  
-             tp_cli_dbus_properties_connect_to_properties_changed (cm,
-                 account_external_password_storage_properties_changed_cb,
-                 NULL, NULL, G_OBJECT (account), NULL);
  
-             g_hash_table_unref (params);
-         }
+         g_object_unref (protocol);
      }
+ 
+     mcd_account_loaded (account);
  }
  
  static gboolean
@@@ -665,34 -558,7 +559,8 @@@ get_old_account_data_path (McdAccountPr
      else
  	return g_build_filename (base, priv->unique_name, NULL);
  }
 +#endif
  
- static void
- account_delete_identify_account_cb (TpProxy *protocol,
-     const char *account_id,
-     const GError *in_error,
-     gpointer user_data,
-     GObject *self)
- {
-   McdAccount *account = MCD_ACCOUNT (self);
-   TpConnectionManager *cm = mcd_account_get_cm (account);
- 
-   if (in_error != NULL)
-     {
-       DEBUG ("Error identifying account: %s", in_error->message);
-     }
-   else
-     {
-       DEBUG ("Identified account as %s", account_id);
- 
-       mc_cli_connection_manager_interface_account_storage_call_remove_account (
-           cm, -1, account_id,
-           NULL, NULL, NULL, NULL);
-     }
- 
-   g_object_unref (account);
- }
- 
  static TpStorageRestrictionFlags mcd_account_get_storage_restrictions (
      McdAccount *account);
  
@@@ -703,12 -569,9 +571,11 @@@ mcd_account_delete_async (McdAccount *a
      gpointer user_data)
  {
      McdAccountPrivate *priv = account->priv;
 +#if 0
      gchar *data_dir_str;
 +#endif
      GError *error = NULL;
      const gchar *name = mcd_account_get_unique_name (account);
-     TpConnectionManager *cm = mcd_account_get_cm (account);
      GTask *task;
  
      task = g_task_new (account, NULL, callback, user_data);
@@@ -2674,8 -2392,11 +2401,11 @@@ apply_parameter_updates (McdAccount *ac
          }
      }
  
-     mcd_account_check_usability (account,
-                                  set_parameters_maybe_autoconnect_cb, NULL);
 -    mcd_account_check_validity (account, NULL);
++    mcd_account_check_usability (account, NULL);
+ 
+     /* Strictly speaking this doesn't need to be called if not valid,
+      * but calling it in all cases gives us clearer debug output */
+     _mcd_account_maybe_autoconnect (account);
  }
  
  static void
@@@ -2976,6 -2697,11 +2706,11 @@@ voi
  _mcd_account_reconnect (McdAccount *self,
      gboolean user_initiated)
  {
+     DEBUG ("%s", mcd_account_get_unique_name (self));
+ 
 -    /* If the account is disabled, invalid or has offline requested presence,
++    /* If the account is disabled, unusable or has offline requested presence,
+      * disconnecting should be a no-op, so we keep this before checking
+      * whether we want to. */
      /* FIXME: this isn't quite right. If we've just called RequestConnection
       * (possibly with out of date parameters) but we haven't got a Connection
       * back from the CM yet, the old parameters will still be used, I think
@@@ -2983,29 -2709,16 +2718,16 @@@
      if (self->priv->connection)
          mcd_connection_close (self->priv->connection, NULL);
  
-     _mcd_account_connection_begin (self, user_initiated);
- }
- 
- static void
- account_reconnect (TpSvcAccount *service,
-                    DBusGMethodInvocation *context)
- {
-     McdAccount *self = MCD_ACCOUNT (service);
-     McdAccountPrivate *priv = self->priv;
- 
-     DEBUG ("%s", mcd_account_get_unique_name (self));
- 
      /* if we can't, or don't want to, connect this method is a no-op */
-     if (!priv->enabled ||
+     if (!self->priv->enabled ||
 -        !mcd_account_is_valid (self) ||
 +        !mcd_account_is_usable (self) ||
-         priv->req_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
+         self->priv->req_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
      {
 -        DEBUG ("doing nothing (enabled=%c, valid=%c and "
 +        DEBUG ("doing nothing (enabled=%c, usable=%c and "
                 "combined presence=%i)",
                 self->priv->enabled ? 'T' : 'F',
 -               mcd_account_is_valid (self) ? 'T' : 'F',
 +               mcd_account_is_usable (self) ? 'T' : 'F',
                 self->priv->req_presence_type);
-         tp_svc_account_return_from_reconnect (context);
          return;
      }
  
@@@ -3833,15 -3542,48 +3555,48 @@@ mcd_account_get_storage_plugin (McdAcco
   * - Manager, protocol and TODO presets (if specified) must exist
   * - All required parameters for the protocol must be set
   *
 - * Returns: %TRUE if the account is valid, false otherwise.
 + * Returns: %TRUE if the account is usable, false otherwise.
   */
  gboolean
 -mcd_account_is_valid (McdAccount *account)
 +mcd_account_is_usable (McdAccount *account)
  {
      McdAccountPrivate *priv = MCD_ACCOUNT_PRIV (account);
 -    return priv->invalid_reason == NULL;
 +    return priv->unusable_reason == NULL;
  }
  
+ /*
+  * mcd_account_dup_protocol:
+  * @self: the account
+  *
+  * Returns: (transfer full): the account's connection manager's protocol,
+  *  possibly %NULL if "not valid"
+  */
+ static TpProtocol *
+ mcd_account_dup_protocol (McdAccount *self)
+ {
+   TpProtocol *protocol;
+ 
+   if (!self->priv->manager && !load_manager (self))
+     {
+       DEBUG ("unable to load manager for account %s",
+           self->priv->unique_name);
+       return NULL;
+     }
+ 
+   protocol = _mcd_manager_dup_protocol (self->priv->manager,
+       self->priv->protocol_name);
+ 
+   if (G_UNLIKELY (protocol == NULL))
+     {
+       DEBUG ("unable to get protocol for %s account %s",
+           self->priv->protocol_name,
+           self->priv->unique_name);
+       return NULL;
+     }
+ 
+   return protocol;
+ }
+ 
  /**
   * mcd_account_is_enabled:
   * @account: the #McdAccount.
@@@ -4617,69 -4383,54 +4396,54 @@@ mcd_account_get_connection (McdAccount 
      return priv->connection;
  }
  
- typedef struct
- {
-     McdAccountCheckUsabilityCb callback;
-     gpointer user_data;
- } CheckUsabilityData;
- 
- static void
- check_usability_check_parameters_cb (McdAccount *account,
-                                     const GError *unusable_reason,
-                                     gpointer user_data)
+ gboolean
 -mcd_account_check_validity (McdAccount *account,
++mcd_account_check_usability (McdAccount *account,
+     GError **error)
  {
-     CheckUsabilityData *data = (CheckUsabilityData *) user_data;
      McdAccountPrivate *priv = account->priv;
-     gboolean now_usable = (unusable_reason == NULL);
-     gboolean was_usable = (priv->unusable_reason == NULL);
 -    GError *invalid_reason = NULL;
 -    gboolean now_valid;
 -    gboolean was_valid;
++    GError *unusable_reason = NULL;
++    gboolean now_usable;
++    gboolean was_usable;
+ 
+     g_return_val_if_fail (MCD_IS_ACCOUNT (account), FALSE);
+ 
 -    was_valid = (priv->invalid_reason == NULL);
 -    now_valid = mcd_account_check_parameters (account, &invalid_reason);
++    was_usable = (priv->unusable_reason == NULL);
++    now_usable = mcd_account_check_parameters (account, &unusable_reason);
  
 -    g_clear_error (&priv->invalid_reason);
 +    g_clear_error (&priv->unusable_reason);
+ 
 -    if (invalid_reason != NULL)
 +    if (unusable_reason != NULL)
      {
 -        priv->invalid_reason = g_error_copy (invalid_reason);
 +        priv->unusable_reason = g_error_copy (unusable_reason);
      }
  
 -    if (was_valid != now_valid)
 +    if (was_usable != now_usable)
      {
          GValue value = G_VALUE_INIT;
 -        DEBUG ("Account validity changed (old: %d, new: %d)",
 -               was_valid, now_valid);
 -        g_signal_emit (account, _mcd_account_signals[VALIDITY_CHANGED], 0,
 -                       now_valid);
 +        DEBUG ("Account usability changed (old: %d, new: %d)",
 +               was_usable, now_usable);
 +        g_signal_emit (account, _mcd_account_signals[USABILITY_CHANGED], 0,
 +                       now_usable);
          g_value_init (&value, G_TYPE_BOOLEAN);
 -        g_value_set_boolean (&value, now_valid);
 -        mcd_account_changed_property (account, "Valid", &value);
 +        g_value_set_boolean (&value, now_usable);
 +        mcd_account_changed_property (account, "Usable", &value);
  
 -        if (now_valid)
 +        if (now_usable)
          {
 -            /* Newly valid - try setting requested presence again.
 +            /* Newly usable - try setting requested presence again.
               * This counts as user-initiated, because the user caused the
 -             * account to become valid somehow. */
 +             * account to become usable somehow. */
              mcd_account_rerequest_presence (account, TRUE);
          }
      }
  
-     if (data->callback != NULL)
-         data->callback (account, unusable_reason, data->user_data);
- 
-     g_slice_free (CheckUsabilityData, data);
- }
- 
- void
- mcd_account_check_usability (McdAccount *account,
-     McdAccountCheckUsabilityCb callback,
-     gpointer user_data)
- {
-     CheckUsabilityData *data;
- 
-     g_return_if_fail (MCD_IS_ACCOUNT (account));
- 
-     data = g_slice_new0 (CheckUsabilityData);
-     data->callback = callback;
-     data->user_data = user_data;
 -    if (invalid_reason != NULL)
++    if (unusable_reason != NULL)
+     {
 -        g_propagate_error (error, invalid_reason);
++        g_propagate_error (error, unusable_reason);
+         return FALSE;
+     }
  
-     mcd_account_check_parameters (account, check_usability_check_parameters_cb,
-                                   data);
+     return TRUE;
  }
  
  /*
@@@ -5279,3 -4995,107 +5021,107 @@@ mcd_account_set_waiting_for_connectivit
  {
    self->priv->waiting_for_connectivity = waiting;
  }
+ 
+ void
+ _mcd_account_connection_begin (McdAccount *account,
+                                gboolean user_initiated)
+ {
+     McdAccountConnectionContext *ctx;
+     TpProtocol *protocol;
+ 
+     /* check whether a connection process is already ongoing */
+     if (account->priv->connection_context != NULL)
+     {
+         DEBUG ("already trying to connect");
+         return;
+     }
+ 
+     /* get account params */
+     /* create dynamic params HT */
+     /* run the handlers */
+     ctx = g_malloc (sizeof (McdAccountConnectionContext));
+     ctx->user_initiated = user_initiated;
+ 
 -    /* If we get this far, the account should be valid, so getting the
++    /* If we get this far, the account should be usable, so getting the
+      * protocol should succeed.
+      */
+     protocol = mcd_account_dup_protocol (account);
+     g_assert (protocol != NULL);
+ 
+     ctx->params = mcd_account_coerce_parameters (account, protocol);
+     g_assert (ctx->params != NULL);
+     g_object_unref (protocol);
+ 
+     _mcd_account_set_connection_status (account,
+                                         TP_CONNECTION_STATUS_CONNECTING,
+                                         TP_CONNECTION_STATUS_REASON_REQUESTED,
+                                         NULL, NULL, NULL);
+     account->priv->connection_context = ctx;
+ 
+     mcd_account_connection_proceed_with_reason
+         (account, TRUE, TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED);
+ }
+ 
+ void
+ mcd_account_connection_proceed_with_reason (McdAccount *account,
+                                             gboolean success,
+                                             TpConnectionStatusReason reason)
+ {
+     McdAccountConnectionContext *ctx;
+     gboolean delayed;
+ 
+     /* call next handler, or terminate the chain (emitting proper signal).
+      * if everything is fine, call mcd_manager_create_connection() and
+      * _mcd_connection_connect () with the dynamic parameters. Remove that call
+      * from mcd_manager_create_connection() */
+     ctx = account->priv->connection_context;
+     g_return_if_fail (ctx != NULL);
+     g_return_if_fail (ctx->params != NULL);
+ 
+     if (success)
+     {
+         if (mcd_connectivity_monitor_is_online (
+               mcd_account_get_connectivity_monitor (account)))
+         {
+             DEBUG ("%s wants to connect and we're online - go for it",
+                 mcd_account_get_unique_name (account));
+             delayed = FALSE;
+         }
+         else if (!mcd_account_get_waiting_for_connectivity (account))
+         {
+             DEBUG ("%s wants to connect, but we're offline; queuing it up",
+                 mcd_account_get_unique_name (account));
+             delayed = TRUE;
+             mcd_account_set_waiting_for_connectivity (account, TRUE);
+         }
+         else
+         {
+             DEBUG ("%s wants to connect, but is already waiting for "
+                 "connectivity?", mcd_account_get_unique_name (account));
+             delayed = TRUE;
+         }
+     }
+     else
+     {
+         DEBUG ("%s failed to connect: reason code %d",
+             mcd_account_get_unique_name (account), reason);
+         delayed = FALSE;
+     }
+ 
+     if (!delayed)
+     {
+ 	/* end of the chain */
+ 	if (success)
+ 	{
+ 	    _mcd_account_connect (account, ctx->params);
+ 	}
+         else
+         {
+             _mcd_account_set_connection_status
+                 (account, TP_CONNECTION_STATUS_DISCONNECTED, reason, NULL,
+                  TP_ERROR_STR_DISCONNECTED, NULL);
+         }
+         tp_clear_pointer (&account->priv->connection_context,
+             _mcd_account_connection_context_free);
+     }
+ }
diff --cc src/mcd-account.h
index ff2eb22,85a56cc..e04cfeb
--- a/src/mcd-account.h
+++ b/src/mcd-account.h
@@@ -94,14 -94,10 +94,10 @@@ gboolean mcd_account_delete_finish (Mcd
  const gchar *mcd_account_get_unique_name (McdAccount *account);
  const gchar *mcd_account_get_object_path (McdAccount *account);
  
 -gboolean mcd_account_is_valid (McdAccount *account);
 +gboolean mcd_account_is_usable (McdAccount *account);
  
- typedef void (*McdAccountCheckUsabilityCb) (McdAccount *account,
-     const GError *unusable_reason,
-     gpointer user_data);
- void mcd_account_check_usability (McdAccount *account,
-     McdAccountCheckUsabilityCb callback,
-     gpointer user_data);
 -gboolean mcd_account_check_validity (McdAccount *account,
++gboolean mcd_account_check_usability (McdAccount *account,
+     GError **error);
  
  gboolean mcd_account_is_enabled (McdAccount *account);
  
diff --cc tests/twisted/account-storage/load-keyfiles.py
index 1769ff7,b6c9d2e..81954e0
--- a/tests/twisted/account-storage/load-keyfiles.py
+++ b/tests/twisted/account-storage/load-keyfiles.py
@@@ -246,14 -259,11 +260,12 @@@ def test(q, bus, mc)
      account_ifaces['migration'].UpdateParameters({'password': 'hello'}, [])
      q.expect('dbus-signal',
              path=account_paths['migration'],
 -            signal='AccountPropertyChanged',
 -            interface=cs.ACCOUNT,
 +            signal='PropertiesChanged',
 +            interface=cs.PROPERTIES_IFACE,
              predicate=(lambda e:
 -                'Parameters' in e.args[0]),
 +                e.args[0] == cs.ACCOUNT and
 +                'Parameters' in e.args[1]),
              )
-     # Check the account has copied (not moved! XDG_DATA_DIRS are,
-     # conceptually, read-only) 'migration' from the old to the new name
      assert not os.path.exists(old_key_file_name)
      assert not os.path.exists(newer_key_file_name)
      assert os.path.exists(low_prio_variant_file_names['migration'])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list