2 * empathy-account-settings.c - Source for EmpathyAccountSettings
3 * Copyright (C) 2009 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <telepathy-glib/account-manager.h>
26 #include <telepathy-glib/util.h>
27 #include <telepathy-glib/interfaces.h>
28 #include <telepathy-glib/gtypes.h>
30 #include "empathy-account-settings.h"
31 #include "empathy-connection-managers.h"
32 #include "empathy-keyring.h"
33 #include "empathy-utils.h"
34 #include "empathy-presence-manager.h"
36 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
37 #include <libempathy/empathy-debug.h>
39 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountSettings)
41 G_DEFINE_TYPE(EmpathyAccountSettings
, empathy_account_settings
, G_TYPE_OBJECT
)
49 PROP_DISPLAY_NAME_OVERRIDDEN
,
54 PASSWORD_RETRIEVED
= 1,
58 static gulong signals
[LAST_SIGNAL
] = { 0, };
60 /* private structure */
61 typedef struct _EmpathyAccountSettingsPriv EmpathyAccountSettingsPriv
;
63 struct _EmpathyAccountSettingsPriv
65 gboolean dispose_has_run
;
66 EmpathyConnectionManagers
*managers
;
67 TpAccountManager
*account_manager
;
69 TpConnectionManager
*manager
;
70 TpProtocol
*protocol_obj
;
78 gboolean display_name_overridden
;
81 gboolean supports_sasl
;
82 gboolean password_changed
;
85 gchar
*password_original
;
87 gboolean password_retrieved
;
88 gboolean password_requested
;
90 /* Parameter name (gchar *) -> parameter value (GValue) */
91 GHashTable
*parameters
;
92 /* Keys are parameter names from the hash above (gchar *).
93 * Values are regular expresions that should match corresponding parameter
94 * values (GRegex *). Possible regexp patterns are defined in
95 * empathy-account-widget.c */
96 GHashTable
*param_regexps
;
97 GArray
*unset_parameters
;
98 GList
*required_params
;
100 gulong managers_ready_id
;
101 gboolean preparing_protocol
;
103 /* If TRUE, the account should have 'tel' in its
104 * Account.Interface.Addressing.URISchemes property. */
105 gboolean uri_scheme_tel
;
107 GSimpleAsyncResult
*apply_result
;
111 empathy_account_settings_init (EmpathyAccountSettings
*obj
)
113 EmpathyAccountSettingsPriv
*priv
= G_TYPE_INSTANCE_GET_PRIVATE ((obj
),
114 EMPATHY_TYPE_ACCOUNT_SETTINGS
, EmpathyAccountSettingsPriv
);
118 /* allocate any data required by the object here */
119 priv
->managers
= empathy_connection_managers_dup_singleton ();
120 priv
->account_manager
= tp_account_manager_dup ();
122 priv
->parameters
= g_hash_table_new_full (g_str_hash
, g_str_equal
,
123 g_free
, (GDestroyNotify
) tp_g_value_slice_free
);
125 priv
->param_regexps
= g_hash_table_new_full (g_str_hash
, g_str_equal
,
126 g_free
, (GDestroyNotify
) g_regex_unref
);
128 priv
->unset_parameters
= g_array_new (TRUE
, FALSE
, sizeof (gchar
*));
130 priv
->required_params
= NULL
;
133 static void empathy_account_settings_dispose (GObject
*object
);
134 static void empathy_account_settings_finalize (GObject
*object
);
135 static void empathy_account_settings_account_ready_cb (GObject
*source_object
,
136 GAsyncResult
*result
, gpointer user_data
);
137 static void empathy_account_settings_managers_ready_cb (GObject
*obj
,
138 GParamSpec
*pspec
, gpointer user_data
);
139 static void empathy_account_settings_check_readyness (
140 EmpathyAccountSettings
*self
);
143 empathy_account_settings_set_property (GObject
*object
,
148 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (object
);
149 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
154 priv
->account
= g_value_dup_object (value
);
157 priv
->cm_name
= g_value_dup_string (value
);
160 priv
->protocol
= g_value_dup_string (value
);
163 priv
->service
= g_value_dup_string (value
);
165 case PROP_DISPLAY_NAME
:
166 priv
->display_name
= g_value_dup_string (value
);
168 case PROP_DISPLAY_NAME_OVERRIDDEN
:
169 priv
->display_name_overridden
= g_value_get_boolean (value
);
172 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
178 empathy_account_settings_get_property (GObject
*object
,
183 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (object
);
184 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
189 g_value_set_object (value
, priv
->account
);
192 g_value_set_string (value
, priv
->cm_name
);
195 g_value_set_string (value
, priv
->protocol
);
198 g_value_set_string (value
, priv
->service
);
200 case PROP_DISPLAY_NAME
:
201 g_value_set_string (value
, priv
->display_name
);
203 case PROP_DISPLAY_NAME_OVERRIDDEN
:
204 g_value_set_boolean (value
, priv
->display_name_overridden
);
207 g_value_set_boolean (value
, priv
->ready
);
210 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
216 empathy_account_settings_constructed (GObject
*object
)
218 EmpathyAccountSettings
*self
= EMPATHY_ACCOUNT_SETTINGS (object
);
219 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
221 if (priv
->account
!= NULL
)
223 g_free (priv
->cm_name
);
224 g_free (priv
->protocol
);
225 g_free (priv
->service
);
228 g_strdup (tp_account_get_connection_manager (priv
->account
));
230 g_strdup (tp_account_get_protocol (priv
->account
));
232 g_strdup (tp_account_get_service (priv
->account
));
233 priv
->icon_name
= g_strdup
234 (tp_account_get_icon_name (priv
->account
));
238 priv
->icon_name
= empathy_protocol_icon_name (priv
->protocol
);
241 g_assert (priv
->cm_name
!= NULL
&& priv
->protocol
!= NULL
);
243 empathy_account_settings_check_readyness (self
);
247 GQuark features
[] = {
248 TP_ACCOUNT_FEATURE_CORE
,
249 TP_ACCOUNT_FEATURE_STORAGE
,
250 TP_ACCOUNT_FEATURE_ADDRESSING
,
253 if (priv
->account
!= NULL
)
255 tp_proxy_prepare_async (priv
->account
, features
,
256 empathy_account_settings_account_ready_cb
, self
);
259 tp_g_signal_connect_object (priv
->managers
, "notify::ready",
260 G_CALLBACK (empathy_account_settings_managers_ready_cb
), object
, 0);
264 empathy_account_settings_parent_class
)->constructed
!= NULL
)
266 empathy_account_settings_parent_class
)->constructed (object
);
271 empathy_account_settings_class_init (
272 EmpathyAccountSettingsClass
*empathy_account_settings_class
)
274 GObjectClass
*object_class
= G_OBJECT_CLASS (empathy_account_settings_class
);
276 g_type_class_add_private (empathy_account_settings_class
, sizeof
277 (EmpathyAccountSettingsPriv
));
279 object_class
->dispose
= empathy_account_settings_dispose
;
280 object_class
->finalize
= empathy_account_settings_finalize
;
281 object_class
->set_property
= empathy_account_settings_set_property
;
282 object_class
->get_property
= empathy_account_settings_get_property
;
283 object_class
->constructed
= empathy_account_settings_constructed
;
285 g_object_class_install_property (object_class
, PROP_ACCOUNT
,
286 g_param_spec_object ("account",
288 "The TpAccount backing these settings",
290 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
292 g_object_class_install_property (object_class
, PROP_CM_NAME
,
293 g_param_spec_string ("connection-manager",
294 "connection-manager",
295 "The name of the connection manager this account uses",
297 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
299 g_object_class_install_property (object_class
, PROP_PROTOCOL
,
300 g_param_spec_string ("protocol",
302 "The name of the protocol this account uses",
304 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
306 g_object_class_install_property (object_class
, PROP_SERVICE
,
307 g_param_spec_string ("service",
309 "The service of this account, or NULL",
311 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
313 g_object_class_install_property (object_class
, PROP_DISPLAY_NAME
,
314 g_param_spec_string ("display-name",
316 "The display name account these settings belong to",
318 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
));
320 g_object_class_install_property (object_class
, PROP_DISPLAY_NAME_OVERRIDDEN
,
321 g_param_spec_boolean ("display-name-overridden",
322 "display-name-overridden",
323 "Whether the display name for this account has been manually "
326 G_PARAM_STATIC_STRINGS
| G_PARAM_READWRITE
));
328 g_object_class_install_property (object_class
, PROP_READY
,
329 g_param_spec_boolean ("ready",
331 "Whether this account is ready to be used",
333 G_PARAM_STATIC_STRINGS
| G_PARAM_READABLE
));
335 signals
[PASSWORD_RETRIEVED
] =
336 g_signal_new ("password-retrieved",
337 G_TYPE_FROM_CLASS (empathy_account_settings_class
),
338 G_SIGNAL_RUN_LAST
, 0, NULL
, NULL
,
339 g_cclosure_marshal_VOID__VOID
,
344 empathy_account_settings_dispose (GObject
*object
)
346 EmpathyAccountSettings
*self
= EMPATHY_ACCOUNT_SETTINGS (object
);
347 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
349 if (priv
->dispose_has_run
)
352 priv
->dispose_has_run
= TRUE
;
354 if (priv
->managers_ready_id
!= 0)
355 g_signal_handler_disconnect (priv
->managers
, priv
->managers_ready_id
);
356 priv
->managers_ready_id
= 0;
358 tp_clear_object (&priv
->managers
);
359 tp_clear_object (&priv
->manager
);
360 tp_clear_object (&priv
->account_manager
);
361 tp_clear_object (&priv
->account
);
362 tp_clear_object (&priv
->protocol_obj
);
364 /* release any references held by the object here */
365 if (G_OBJECT_CLASS (empathy_account_settings_parent_class
)->dispose
)
366 G_OBJECT_CLASS (empathy_account_settings_parent_class
)->dispose (object
);
370 empathy_account_settings_free_unset_parameters (
371 EmpathyAccountSettings
*settings
)
373 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
376 for (i
= 0 ; i
< priv
->unset_parameters
->len
; i
++)
377 g_free (g_array_index (priv
->unset_parameters
, gchar
*, i
));
379 g_array_set_size (priv
->unset_parameters
, 0);
383 empathy_account_settings_finalize (GObject
*object
)
385 EmpathyAccountSettings
*self
= EMPATHY_ACCOUNT_SETTINGS (object
);
386 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
389 /* free any data held directly by the object here */
390 g_free (priv
->cm_name
);
391 g_free (priv
->protocol
);
392 g_free (priv
->service
);
393 g_free (priv
->display_name
);
394 g_free (priv
->icon_name
);
395 g_free (priv
->password
);
396 g_free (priv
->password_original
);
398 if (priv
->required_params
!= NULL
)
400 for (l
= priv
->required_params
; l
; l
= l
->next
)
402 g_list_free (priv
->required_params
);
405 g_hash_table_destroy (priv
->parameters
);
406 g_hash_table_destroy (priv
->param_regexps
);
408 empathy_account_settings_free_unset_parameters (self
);
409 g_array_free (priv
->unset_parameters
, TRUE
);
411 G_OBJECT_CLASS (empathy_account_settings_parent_class
)->finalize (object
);
415 empathy_account_settings_protocol_obj_prepared_cb (GObject
*source
,
416 GAsyncResult
*result
,
419 EmpathyAccountSettings
*self
= user_data
;
420 GError
*error
= NULL
;
422 if (!tp_proxy_prepare_finish (source
, result
, &error
))
424 DEBUG ("Failed to prepare protocol object: %s", error
->message
);
425 g_clear_error (&error
);
429 empathy_account_settings_check_readyness (self
);
433 empathy_account_settings_get_password_cb (GObject
*source
,
434 GAsyncResult
*result
,
437 EmpathyAccountSettings
*self
= user_data
;
438 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
439 const gchar
*password
;
440 GError
*error
= NULL
;
442 password
= empathy_keyring_get_account_password_finish (TP_ACCOUNT (source
),
447 DEBUG ("Failed to get password: %s", error
->message
);
448 g_clear_error (&error
);
451 /* It doesn't really matter if getting the password failed; that
452 * just means that it's not there, or let's act like that at
455 g_assert (priv
->password
== NULL
);
457 priv
->password
= g_strdup (password
);
458 priv
->password_original
= g_strdup (password
);
460 g_signal_emit (self
, signals
[PASSWORD_RETRIEVED
], 0);
464 empathy_account_settings_migrate_password_cb (GObject
*source
,
465 GAsyncResult
*result
,
468 TpAccount
*account
= TP_ACCOUNT (source
);
469 GError
*error
= NULL
;
470 EmpathyAccountSettings
*self
= user_data
;
471 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
473 const gchar
*unset
[] = { "password", NULL
};
475 if (!empathy_keyring_set_account_password_finish (account
, result
, &error
))
477 DEBUG ("Failed to set password: %s", error
->message
);
478 g_clear_error (&error
);
482 /* Now clear the password MC has stored. */
483 empty
= tp_asv_new (NULL
, NULL
);
484 tp_account_update_parameters_async (priv
->account
,
485 empty
, unset
, NULL
, NULL
);
487 g_hash_table_remove (priv
->parameters
, "password");
489 g_hash_table_unref (empty
);
493 empathy_account_settings_try_migrating_password (EmpathyAccountSettings
*self
)
495 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
497 const gchar
*password
;
499 if (!priv
->supports_sasl
|| empathy_account_settings_get (
500 self
, "password") == NULL
)
503 /* mission-control still has our password, although the CM
504 * supports SASL. Let's try migrating it. */
506 DEBUG ("Trying to migrate password parameter from MC to the "
507 "keyring ourselves for account %s",
508 tp_account_get_path_suffix (priv
->account
));
510 v
= empathy_account_settings_get (self
, "password");
512 /* I can't imagine why this would fail. */
513 if (!G_VALUE_HOLDS_STRING (v
))
516 password
= g_value_get_string (v
);
518 if (EMP_STR_EMPTY (password
))
521 empathy_keyring_set_account_password_async (priv
->account
, password
,
522 empathy_account_settings_migrate_password_cb
, self
);
524 /* We don't want to request the password again, we
525 * already know it. */
526 priv
->password_requested
= TRUE
;
528 priv
->password
= g_strdup (password
);
529 priv
->password_original
= g_strdup (password
);
533 empathy_account_settings_check_readyness (EmpathyAccountSettings
*self
)
535 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
536 const TpConnectionManagerProtocol
*tp_protocol
;
537 GQuark features
[] = { TP_PROTOCOL_FEATURE_CORE
, 0 };
542 if (priv
->account
!= NULL
543 && !tp_account_is_prepared (priv
->account
, TP_ACCOUNT_FEATURE_CORE
))
546 if (!empathy_connection_managers_is_ready (priv
->managers
))
549 if (priv
->manager
== NULL
)
551 priv
->manager
= empathy_connection_managers_get_cm (
552 priv
->managers
, priv
->cm_name
);
555 if (priv
->manager
== NULL
)
558 g_object_ref (priv
->manager
);
560 if (priv
->account
!= NULL
)
562 g_free (priv
->display_name
);
564 g_strdup (tp_account_get_display_name (priv
->account
));
566 g_free (priv
->icon_name
);
568 g_strdup (tp_account_get_icon_name (priv
->account
));
570 priv
->uri_scheme_tel
= empathy_account_has_uri_scheme_tel (priv
->account
);
573 tp_protocol
= tp_connection_manager_get_protocol (priv
->manager
,
576 if (tp_protocol
== NULL
)
578 tp_clear_object (&priv
->manager
);
582 if (priv
->required_params
== NULL
)
584 TpConnectionManagerParam
*cur
;
586 for (cur
= tp_protocol
->params
; cur
->name
!= NULL
; cur
++)
588 if (tp_connection_manager_param_is_required (cur
))
590 priv
->required_params
= g_list_append (priv
->required_params
,
591 g_strdup (cur
->name
));
596 if (priv
->protocol_obj
== NULL
)
598 priv
->protocol_obj
= g_object_ref (
599 tp_connection_manager_get_protocol_object (priv
->manager
,
603 if (!tp_proxy_is_prepared (priv
->protocol_obj
, TP_PROTOCOL_FEATURE_CORE
)
604 && !priv
->preparing_protocol
)
606 priv
->preparing_protocol
= TRUE
;
607 tp_proxy_prepare_async (priv
->protocol_obj
, features
,
608 empathy_account_settings_protocol_obj_prepared_cb
, self
);
613 if (tp_strv_contains (tp_protocol_get_authentication_types (
615 TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION
))
617 priv
->supports_sasl
= TRUE
;
621 /* NOTE: When removing MC migration code, remove this call, and the
622 * function it's calling. That's it. */
623 empathy_account_settings_try_migrating_password (self
);
625 /* priv->account won't be a proper account if it's the account
626 * assistant showing this widget. */
627 if (priv
->supports_sasl
&& !priv
->password_requested
628 && priv
->account
!= NULL
)
630 priv
->password_requested
= TRUE
;
632 /* Make this call but don't block on its readiness. We'll signal
633 * if it's updated later with ::password-retrieved. */
634 empathy_keyring_get_account_password_async (priv
->account
,
635 empathy_account_settings_get_password_cb
, self
);
639 g_object_notify (G_OBJECT (self
), "ready");
643 empathy_account_settings_account_ready_cb (GObject
*source_object
,
644 GAsyncResult
*result
,
647 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
648 TpAccount
*account
= TP_ACCOUNT (source_object
);
649 GError
*error
= NULL
;
651 if (!tp_proxy_prepare_finish (account
, result
, &error
))
653 DEBUG ("Failed to prepare account: %s", error
->message
);
654 g_error_free (error
);
658 empathy_account_settings_check_readyness (settings
);
662 empathy_account_settings_managers_ready_cb (GObject
*object
,
666 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
668 empathy_account_settings_check_readyness (settings
);
671 EmpathyAccountSettings
*
672 empathy_account_settings_new (const gchar
*connection_manager
,
673 const gchar
*protocol
,
674 const gchar
*service
,
675 const char *display_name
)
677 return g_object_new (EMPATHY_TYPE_ACCOUNT_SETTINGS
,
678 "connection-manager", connection_manager
,
679 "protocol", protocol
,
681 "display-name", display_name
,
685 EmpathyAccountSettings
*
686 empathy_account_settings_new_for_account (TpAccount
*account
)
688 return g_object_new (EMPATHY_TYPE_ACCOUNT_SETTINGS
,
693 TpConnectionManagerParam
*
694 empathy_account_settings_get_tp_params (EmpathyAccountSettings
*settings
)
696 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
697 const TpConnectionManagerProtocol
*tp_protocol
;
699 g_return_val_if_fail (priv
->manager
!= NULL
, NULL
);
700 g_return_val_if_fail (priv
->protocol
!= NULL
, NULL
);
702 tp_protocol
= tp_connection_manager_get_protocol (priv
->manager
,
704 if (tp_protocol
== NULL
)
706 DEBUG ("Can't retrieve TpConnectionManagerProtocol for protocol '%s'",
711 return tp_protocol
->params
;
715 empathy_account_settings_is_ready (EmpathyAccountSettings
*settings
)
717 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
723 empathy_account_settings_get_cm (EmpathyAccountSettings
*settings
)
725 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
727 return priv
->cm_name
;
731 empathy_account_settings_get_protocol (EmpathyAccountSettings
*settings
)
733 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
735 return priv
->protocol
;
739 empathy_account_settings_get_service (EmpathyAccountSettings
*settings
)
741 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
743 return priv
->service
;
747 empathy_account_settings_get_icon_name (EmpathyAccountSettings
*settings
)
749 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
751 return priv
->icon_name
;
755 empathy_account_settings_get_display_name (EmpathyAccountSettings
*settings
)
757 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
759 return priv
->display_name
;
763 empathy_account_settings_get_account (EmpathyAccountSettings
*settings
)
765 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
767 return priv
->account
;
771 empathy_account_settings_is_unset (EmpathyAccountSettings
*settings
,
774 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
778 a
= priv
->unset_parameters
;
780 for (i
= 0; i
< a
->len
; i
++)
782 if (!tp_strdiff (g_array_index (a
, gchar
*, i
), param
))
789 static TpConnectionManagerParam
*
790 empathy_account_settings_get_tp_param (EmpathyAccountSettings
*settings
,
793 TpConnectionManagerParam
*tp_params
=
794 empathy_account_settings_get_tp_params (settings
);
795 TpConnectionManagerParam
*p
;
797 for (p
= tp_params
; p
!= NULL
&& p
->name
!= NULL
; p
++)
799 if (tp_strdiff (p
->name
, param
))
809 empathy_account_settings_have_tp_param (EmpathyAccountSettings
*settings
,
812 return (empathy_account_settings_get_tp_param (settings
, param
) != NULL
);
816 account_settings_remove_from_unset (EmpathyAccountSettings
*settings
,
819 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
823 for (idx
= 0; idx
< priv
->unset_parameters
->len
; idx
++)
825 val
= g_array_index (priv
->unset_parameters
, gchar
*, idx
);
827 if (!tp_strdiff (val
, param
))
829 priv
->unset_parameters
=
830 g_array_remove_index (priv
->unset_parameters
, idx
);
839 empathy_account_settings_get_default (EmpathyAccountSettings
*settings
,
842 TpConnectionManagerParam
*p
;
844 p
= empathy_account_settings_get_tp_param (settings
, param
);
846 if (p
== NULL
|| !(p
->flags
& TP_CONN_MGR_PARAM_FLAG_HAS_DEFAULT
))
849 return &(p
->default_value
);
853 empathy_account_settings_get_dbus_signature (EmpathyAccountSettings
*settings
,
856 TpConnectionManagerParam
*p
;
858 p
= empathy_account_settings_get_tp_param (settings
, param
);
863 return p
->dbus_signature
;
867 empathy_account_settings_get (EmpathyAccountSettings
*settings
,
870 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
871 const GValue
*result
= NULL
;
873 /* Lookup the update parameters we set */
874 result
= tp_asv_lookup (priv
->parameters
, param
);
878 /* If the parameters isn't unset use the accounts setting if any */
879 if (priv
->account
!= NULL
880 && !empathy_account_settings_is_unset (settings
, param
))
882 const GHashTable
*parameters
;
884 parameters
= tp_account_get_parameters (priv
->account
);
885 result
= tp_asv_lookup (parameters
, param
);
891 /* fallback to the default */
892 return empathy_account_settings_get_default (settings
, param
);
896 empathy_account_settings_unset (EmpathyAccountSettings
*settings
,
899 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
901 if (empathy_account_settings_is_unset (settings
, param
))
904 if (priv
->supports_sasl
&& !tp_strdiff (param
, "password"))
906 g_free (priv
->password
);
907 priv
->password
= NULL
;
908 priv
->password_changed
= TRUE
;
912 v
= g_strdup (param
);
914 g_array_append_val (priv
->unset_parameters
, v
);
915 g_hash_table_remove (priv
->parameters
, param
);
919 empathy_account_settings_discard_changes (EmpathyAccountSettings
*settings
)
921 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
923 g_hash_table_remove_all (priv
->parameters
);
924 empathy_account_settings_free_unset_parameters (settings
);
926 priv
->password_changed
= FALSE
;
927 g_free (priv
->password
);
928 priv
->password
= g_strdup (priv
->password_original
);
930 if (priv
->account
!= NULL
)
931 priv
->uri_scheme_tel
= empathy_account_has_uri_scheme_tel (priv
->account
);
933 priv
->uri_scheme_tel
= FALSE
;
937 empathy_account_settings_get_string (EmpathyAccountSettings
*settings
,
940 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
943 if (!tp_strdiff (param
, "password") && priv
->supports_sasl
)
945 return priv
->password
;
948 v
= empathy_account_settings_get (settings
, param
);
950 if (v
== NULL
|| !G_VALUE_HOLDS_STRING (v
))
953 return g_value_get_string (v
);
956 const gchar
* const *
957 empathy_account_settings_get_strv (EmpathyAccountSettings
*settings
,
962 v
= empathy_account_settings_get (settings
, param
);
964 if (v
== NULL
|| !G_VALUE_HOLDS (v
, G_TYPE_STRV
))
967 return g_value_get_boxed (v
);
971 empathy_account_settings_get_int32 (EmpathyAccountSettings
*settings
,
977 v
= empathy_account_settings_get (settings
, param
);
982 switch G_VALUE_TYPE (v
)
985 ret
= g_value_get_uchar (v
);
988 ret
= g_value_get_int (v
);
991 ret
= CLAMP (g_value_get_uint (v
), (guint
) G_MININT32
,
995 ret
= CLAMP (g_value_get_int64 (v
), G_MININT32
, G_MAXINT32
);
998 ret
= CLAMP (g_value_get_uint64 (v
), (guint64
) G_MININT32
,
1010 empathy_account_settings_get_int64 (EmpathyAccountSettings
*settings
,
1016 v
= empathy_account_settings_get (settings
, param
);
1020 switch G_VALUE_TYPE (v
)
1023 ret
= g_value_get_uchar (v
);
1026 ret
= g_value_get_int (v
);
1029 ret
= g_value_get_uint (v
);
1032 ret
= g_value_get_int64 (v
);
1035 ret
= CLAMP (g_value_get_uint64 (v
), (guint64
) G_MININT64
, G_MAXINT64
);
1046 empathy_account_settings_get_uint32 (EmpathyAccountSettings
*settings
,
1052 v
= empathy_account_settings_get (settings
, param
);
1056 switch G_VALUE_TYPE (v
)
1059 ret
= g_value_get_uchar (v
);
1062 ret
= MAX (0, g_value_get_int (v
));
1065 ret
= g_value_get_uint (v
);
1068 ret
= CLAMP (g_value_get_int64 (v
), 0, G_MAXUINT32
);
1071 ret
= MIN (g_value_get_uint64 (v
), G_MAXUINT32
);
1082 empathy_account_settings_get_uint64 (EmpathyAccountSettings
*settings
,
1088 v
= empathy_account_settings_get (settings
, param
);
1090 if (v
== NULL
|| !G_VALUE_HOLDS_INT (v
))
1093 switch G_VALUE_TYPE (v
)
1096 ret
= g_value_get_uchar (v
);
1099 ret
= MAX (0, g_value_get_int (v
));
1102 ret
= g_value_get_uint (v
);
1105 ret
= MAX (0, g_value_get_int64 (v
));
1108 ret
= g_value_get_uint64 (v
);
1119 empathy_account_settings_get_boolean (EmpathyAccountSettings
*settings
,
1124 v
= empathy_account_settings_get (settings
, param
);
1126 if (v
== NULL
|| !G_VALUE_HOLDS_BOOLEAN (v
))
1129 return g_value_get_boolean (v
);
1133 empathy_account_settings_set_string (EmpathyAccountSettings
*settings
,
1137 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1139 g_return_if_fail (param
!= NULL
);
1140 g_return_if_fail (value
!= NULL
);
1142 if (!tp_strdiff (param
, "password") && priv
->supports_sasl
)
1144 g_free (priv
->password
);
1145 priv
->password
= g_strdup (value
);
1146 priv
->password_changed
= TRUE
;
1150 tp_asv_set_string (priv
->parameters
, g_strdup (param
), value
);
1153 account_settings_remove_from_unset (settings
, param
);
1157 empathy_account_settings_set_strv (EmpathyAccountSettings
*settings
,
1161 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1163 g_return_if_fail (param
!= NULL
);
1164 g_return_if_fail (value
!= NULL
);
1166 tp_asv_set_strv (priv
->parameters
, g_strdup (param
), value
);
1168 account_settings_remove_from_unset (settings
, param
);
1172 empathy_account_settings_set_int32 (EmpathyAccountSettings
*settings
,
1176 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1178 g_return_if_fail (param
!= NULL
);
1180 tp_asv_set_int32 (priv
->parameters
, g_strdup (param
), value
);
1182 account_settings_remove_from_unset (settings
, param
);
1186 empathy_account_settings_set_int64 (EmpathyAccountSettings
*settings
,
1190 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1192 g_return_if_fail (param
!= NULL
);
1194 tp_asv_set_int64 (priv
->parameters
, g_strdup (param
), value
);
1196 account_settings_remove_from_unset (settings
, param
);
1200 empathy_account_settings_set_uint32 (EmpathyAccountSettings
*settings
,
1204 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1206 g_return_if_fail (param
!= NULL
);
1208 tp_asv_set_uint32 (priv
->parameters
, g_strdup (param
), value
);
1210 account_settings_remove_from_unset (settings
, param
);
1214 empathy_account_settings_set_uint64 (EmpathyAccountSettings
*settings
,
1218 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1220 g_return_if_fail (param
!= NULL
);
1222 tp_asv_set_uint64 (priv
->parameters
, g_strdup (param
), value
);
1224 account_settings_remove_from_unset (settings
, param
);
1228 empathy_account_settings_set_boolean (EmpathyAccountSettings
*settings
,
1232 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1234 g_return_if_fail (param
!= NULL
);
1236 tp_asv_set_boolean (priv
->parameters
, g_strdup (param
), value
);
1238 account_settings_remove_from_unset (settings
, param
);
1242 account_settings_display_name_set_cb (GObject
*src
,
1246 GError
*error
= NULL
;
1247 TpAccount
*account
= TP_ACCOUNT (src
);
1248 GSimpleAsyncResult
*set_result
= user_data
;
1250 tp_account_set_display_name_finish (account
, res
, &error
);
1254 g_simple_async_result_set_from_error (set_result
, error
);
1255 g_error_free (error
);
1258 g_simple_async_result_complete (set_result
);
1259 g_object_unref (set_result
);
1263 empathy_account_settings_set_display_name_async (
1264 EmpathyAccountSettings
*settings
,
1266 GAsyncReadyCallback callback
,
1269 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1270 GSimpleAsyncResult
*result
;
1272 g_return_if_fail (name
!= NULL
);
1274 result
= g_simple_async_result_new (G_OBJECT (settings
),
1275 callback
, user_data
, empathy_account_settings_set_display_name_finish
);
1277 if (!tp_strdiff (name
, priv
->display_name
))
1280 g_simple_async_result_complete_in_idle (result
);
1284 if (priv
->account
== NULL
)
1286 if (priv
->display_name
!= NULL
)
1287 g_free (priv
->display_name
);
1289 priv
->display_name
= g_strdup (name
);
1291 g_simple_async_result_complete_in_idle (result
);
1296 tp_account_set_display_name_async (priv
->account
, name
,
1297 account_settings_display_name_set_cb
, result
);
1301 empathy_account_settings_set_display_name_finish (
1302 EmpathyAccountSettings
*settings
,
1303 GAsyncResult
*result
,
1306 if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result
),
1310 g_return_val_if_fail (g_simple_async_result_is_valid (result
,
1311 G_OBJECT (settings
), empathy_account_settings_set_display_name_finish
),
1318 account_settings_icon_name_set_cb (GObject
*src
,
1322 GError
*error
= NULL
;
1323 TpAccount
*account
= TP_ACCOUNT (src
);
1324 GSimpleAsyncResult
*set_result
= user_data
;
1326 tp_account_set_icon_name_finish (account
, res
, &error
);
1330 g_simple_async_result_set_from_error (set_result
, error
);
1331 g_error_free (error
);
1334 g_simple_async_result_complete (set_result
);
1335 g_object_unref (set_result
);
1339 empathy_account_settings_set_icon_name_async (
1340 EmpathyAccountSettings
*settings
,
1342 GAsyncReadyCallback callback
,
1345 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1346 GSimpleAsyncResult
*result
;
1348 g_return_if_fail (name
!= NULL
);
1350 result
= g_simple_async_result_new (G_OBJECT (settings
),
1351 callback
, user_data
, empathy_account_settings_set_icon_name_finish
);
1353 if (priv
->account
== NULL
)
1355 if (priv
->icon_name
!= NULL
)
1356 g_free (priv
->icon_name
);
1358 priv
->icon_name
= g_strdup (name
);
1360 g_simple_async_result_complete_in_idle (result
);
1365 tp_account_set_icon_name_async (priv
->account
, name
,
1366 account_settings_icon_name_set_cb
, result
);
1370 empathy_account_settings_set_icon_name_finish (
1371 EmpathyAccountSettings
*settings
,
1372 GAsyncResult
*result
,
1375 if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result
),
1379 g_return_val_if_fail (g_simple_async_result_is_valid (result
,
1380 G_OBJECT (settings
), empathy_account_settings_set_icon_name_finish
),
1387 empathy_account_settings_processed_password (GObject
*source
,
1388 GAsyncResult
*result
,
1390 gpointer finish_func
)
1392 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
1393 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1394 GSimpleAsyncResult
*r
;
1395 GError
*error
= NULL
;
1396 gboolean (*func
) (TpAccount
*source
, GAsyncResult
*result
, GError
**error
) =
1399 g_free (priv
->password_original
);
1400 priv
->password_original
= g_strdup (priv
->password
);
1402 if (!func (TP_ACCOUNT (source
), result
, &error
))
1404 g_simple_async_result_set_from_error (priv
->apply_result
, error
);
1405 g_error_free (error
);
1408 empathy_account_settings_discard_changes (settings
);
1410 r
= priv
->apply_result
;
1411 priv
->apply_result
= NULL
;
1413 g_simple_async_result_complete (r
);
1418 empathy_account_settings_set_password_cb (GObject
*source
,
1419 GAsyncResult
*result
,
1422 empathy_account_settings_processed_password (source
, result
, user_data
,
1423 empathy_keyring_set_account_password_finish
);
1427 empathy_account_settings_delete_password_cb (GObject
*source
,
1428 GAsyncResult
*result
,
1431 empathy_account_settings_processed_password (source
, result
, user_data
,
1432 empathy_keyring_delete_account_password_finish
);
1436 update_account_uri_schemes (EmpathyAccountSettings
*self
)
1438 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1440 if (priv
->uri_scheme_tel
== empathy_account_has_uri_scheme_tel (
1444 tp_account_set_uri_scheme_association_async (priv
->account
, "tel",
1445 priv
->uri_scheme_tel
, NULL
, NULL
);
1449 empathy_account_settings_account_updated (GObject
*source
,
1450 GAsyncResult
*result
,
1453 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
1454 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1455 GSimpleAsyncResult
*r
;
1456 GError
*error
= NULL
;
1457 GStrv reconnect_required
= NULL
;
1459 if (!tp_account_update_parameters_finish (TP_ACCOUNT (source
),
1460 result
, &reconnect_required
, &error
))
1462 g_simple_async_result_set_from_error (priv
->apply_result
, error
);
1463 g_error_free (error
);
1467 /* Only set the password in the keyring if the CM supports SASL and
1469 if (priv
->supports_sasl
&& priv
->password_changed
)
1471 if (priv
->password
!= NULL
)
1473 /* FIXME: we shouldn't save the password if we
1474 * can't (MaySaveResponse=False) but we don't have API to check that
1475 * at this point (fdo #35382). */
1476 empathy_keyring_set_account_password_async (priv
->account
, priv
->password
,
1477 empathy_account_settings_set_password_cb
, settings
);
1481 empathy_keyring_delete_account_password_async (priv
->account
,
1482 empathy_account_settings_delete_password_cb
, settings
);
1488 update_account_uri_schemes (settings
);
1490 g_simple_async_result_set_op_res_gboolean (priv
->apply_result
,
1491 g_strv_length (reconnect_required
) > 0);
1494 empathy_account_settings_discard_changes (settings
);
1496 r
= priv
->apply_result
;
1497 priv
->apply_result
= NULL
;
1499 g_simple_async_result_complete (r
);
1501 g_strfreev (reconnect_required
);
1505 empathy_account_settings_created_cb (GObject
*source
,
1506 GAsyncResult
*result
,
1509 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
1510 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1512 GError
*error
= NULL
;
1513 GSimpleAsyncResult
*r
;
1515 account
= tp_account_manager_create_account_finish (
1516 TP_ACCOUNT_MANAGER (source
), result
, &error
);
1518 if (account
== NULL
)
1520 g_simple_async_result_set_from_error (priv
->apply_result
, error
);
1524 priv
->account
= g_object_ref (account
);
1526 if (priv
->supports_sasl
&& priv
->password
!= NULL
)
1528 /* Save the password before connecting */
1529 /* FIXME: we shouldn't save the password if we
1530 * can't (MaySaveResponse=False) but we don't have API to check that
1531 * at this point (fdo #35382). */
1532 empathy_keyring_set_account_password_async (priv
->account
,
1533 priv
->password
, empathy_account_settings_set_password_cb
,
1538 update_account_uri_schemes (settings
);
1540 empathy_account_settings_discard_changes (settings
);
1543 r
= priv
->apply_result
;
1544 priv
->apply_result
= NULL
;
1546 g_simple_async_result_complete (r
);
1552 empathy_account_settings_do_create_account (EmpathyAccountSettings
*settings
)
1554 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1555 GHashTable
*properties
;
1556 TpConnectionPresenceType type
;
1559 EmpathyPresenceManager
*presence_mgr
;
1561 properties
= tp_asv_new (NULL
, NULL
);
1563 presence_mgr
= empathy_presence_manager_dup_singleton ();
1564 type
= empathy_presence_manager_get_requested_presence (presence_mgr
, &status
,
1566 g_object_unref (presence_mgr
);
1568 if (type
!= TP_CONNECTION_PRESENCE_TYPE_UNSET
)
1570 /* Create the account with the requested presence the same as the current
1571 * global requested presence, but don't enable it */
1572 GValueArray
*presence
;
1573 GValue vtype
= { 0, };
1574 GValue vstatus
= { 0, };
1575 GValue vmessage
= { 0, };
1577 presence
= g_value_array_new (3);
1579 g_value_init (&vtype
, G_TYPE_UINT
);
1580 g_value_set_uint (&vtype
, type
);
1581 g_value_array_append (presence
, &vtype
);
1583 g_value_init (&vstatus
, G_TYPE_STRING
);
1584 g_value_take_string (&vstatus
, status
);
1585 g_value_array_append (presence
, &vstatus
);
1587 g_value_init (&vmessage
, G_TYPE_STRING
);
1588 g_value_take_string (&vmessage
, message
);
1589 g_value_array_append (presence
, &vmessage
);
1591 tp_asv_take_boxed (properties
, TP_IFACE_ACCOUNT
".RequestedPresence",
1592 TP_STRUCT_TYPE_SIMPLE_PRESENCE
, presence
);
1595 tp_asv_set_string (properties
, TP_IFACE_ACCOUNT
".Icon",
1598 if (priv
->service
!= NULL
)
1599 tp_asv_set_string (properties
, TP_PROP_ACCOUNT_SERVICE
, priv
->service
);
1601 tp_account_manager_create_account_async (priv
->account_manager
,
1602 priv
->cm_name
, priv
->protocol
, priv
->display_name
,
1603 priv
->parameters
, properties
,
1604 empathy_account_settings_created_cb
,
1607 g_hash_table_unref (properties
);
1611 empathy_account_settings_manager_ready_cb (GObject
*source_object
,
1612 GAsyncResult
*result
,
1615 EmpathyAccountSettings
*settings
= EMPATHY_ACCOUNT_SETTINGS (user_data
);
1616 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1617 TpAccountManager
*account_manager
= TP_ACCOUNT_MANAGER (source_object
);
1618 GError
*error
= NULL
;
1620 if (!tp_account_manager_prepare_finish (account_manager
, result
, &error
))
1622 DEBUG ("Failed to prepare account manager: %s", error
->message
);
1623 g_error_free (error
);
1627 g_assert (priv
->apply_result
!= NULL
&& priv
->account
== NULL
);
1628 empathy_account_settings_do_create_account (settings
);
1632 empathy_account_settings_apply_async (EmpathyAccountSettings
*settings
,
1633 GAsyncReadyCallback callback
,
1636 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1638 if (priv
->apply_result
!= NULL
)
1640 g_simple_async_report_error_in_idle (G_OBJECT (settings
),
1641 callback
, user_data
,
1642 G_IO_ERROR
, G_IO_ERROR_PENDING
, "Applying already in progress");
1646 priv
->apply_result
= g_simple_async_result_new (G_OBJECT (settings
),
1647 callback
, user_data
, empathy_account_settings_apply_finish
);
1649 /* We'll have to reconnect only if we change none DBus_Property on an
1650 * existing account. */
1651 g_simple_async_result_set_op_res_gboolean (priv
->apply_result
, FALSE
);
1653 if (priv
->account
== NULL
)
1655 tp_account_manager_prepare_async (priv
->account_manager
, NULL
,
1656 empathy_account_settings_manager_ready_cb
, settings
);
1660 tp_account_update_parameters_async (priv
->account
,
1661 priv
->parameters
, (const gchar
**)priv
->unset_parameters
->data
,
1662 empathy_account_settings_account_updated
, settings
);
1667 empathy_account_settings_apply_finish (EmpathyAccountSettings
*settings
,
1668 GAsyncResult
*result
,
1669 gboolean
*reconnect_required
,
1672 if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result
),
1676 g_return_val_if_fail (g_simple_async_result_is_valid (result
,
1677 G_OBJECT (settings
), empathy_account_settings_apply_finish
), FALSE
);
1679 if (reconnect_required
!= NULL
)
1680 *reconnect_required
= g_simple_async_result_get_op_res_gboolean (
1681 G_SIMPLE_ASYNC_RESULT (result
));
1687 empathy_account_settings_has_account (EmpathyAccountSettings
*settings
,
1690 EmpathyAccountSettingsPriv
*priv
;
1691 const gchar
*account_path
;
1692 const gchar
*priv_account_path
;
1694 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings
), FALSE
);
1695 g_return_val_if_fail (TP_IS_ACCOUNT (account
), FALSE
);
1697 priv
= GET_PRIV (settings
);
1699 if (priv
->account
== NULL
)
1702 account_path
= tp_proxy_get_object_path (TP_PROXY (account
));
1703 priv_account_path
= tp_proxy_get_object_path (TP_PROXY (priv
->account
));
1705 return (!tp_strdiff (account_path
, priv_account_path
));
1709 empathy_account_settings_set_regex (EmpathyAccountSettings
*settings
,
1711 const gchar
*pattern
)
1713 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (settings
);
1715 GError
*error
= NULL
;
1717 regex
= g_regex_new (pattern
, 0, 0, &error
);
1720 g_warning ("Failed to create reg exp: %s", error
->message
);
1721 g_error_free (error
);
1725 g_hash_table_insert (priv
->param_regexps
, g_strdup (param
), regex
);
1729 empathy_account_settings_parameter_is_valid (
1730 EmpathyAccountSettings
*settings
,
1733 EmpathyAccountSettingsPriv
*priv
;
1734 const GRegex
*regex
;
1737 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings
), FALSE
);
1739 priv
= GET_PRIV (settings
);
1741 if (g_list_find_custom (priv
->required_params
, param
, (GCompareFunc
) strcmp
))
1743 /* first, look if it's set in our own parameters */
1744 if (tp_asv_lookup (priv
->parameters
, param
))
1747 /* if we did not unset the parameter, look if it's in the account */
1748 if (priv
->account
!= NULL
&&
1749 !empathy_account_settings_is_unset (settings
, param
))
1751 const GHashTable
*account_params
;
1753 account_params
= tp_account_get_parameters (priv
->account
);
1754 if (tp_asv_lookup (account_params
, param
))
1762 /* test whether parameter value matches its regex */
1763 regex
= g_hash_table_lookup (priv
->param_regexps
, param
);
1766 value
= empathy_account_settings_get_string (settings
, param
);
1767 if (value
!= NULL
&& !g_regex_match (regex
, value
, 0, NULL
))
1775 empathy_account_settings_is_valid (EmpathyAccountSettings
*settings
)
1777 EmpathyAccountSettingsPriv
*priv
;
1779 GHashTableIter iter
;
1782 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings
), FALSE
);
1784 priv
= GET_PRIV (settings
);
1786 for (l
= priv
->required_params
; l
; l
= l
->next
)
1788 if (!empathy_account_settings_parameter_is_valid (settings
, l
->data
))
1792 g_hash_table_iter_init (&iter
, priv
->param_regexps
);
1793 while (g_hash_table_iter_next (&iter
, (gpointer
*) ¶m
, NULL
))
1795 if (!empathy_account_settings_parameter_is_valid (settings
, param
))
1802 const TpConnectionManagerProtocol
*
1803 empathy_account_settings_get_tp_protocol (EmpathyAccountSettings
*self
)
1805 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1807 return tp_connection_manager_get_protocol (priv
->manager
, priv
->protocol
);
1811 empathy_account_settings_supports_sasl (EmpathyAccountSettings
*self
)
1813 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1815 return priv
->supports_sasl
;
1819 empathy_account_settings_param_is_supported (EmpathyAccountSettings
*self
,
1822 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1824 return tp_protocol_has_param (priv
->protocol_obj
, param
);
1828 empathy_account_settings_set_uri_scheme_tel (EmpathyAccountSettings
*self
,
1831 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1833 priv
->uri_scheme_tel
= associate
;
1837 empathy_account_settings_has_uri_scheme_tel (
1838 EmpathyAccountSettings
*self
)
1840 EmpathyAccountSettingsPriv
*priv
= GET_PRIV (self
);
1842 return priv
->uri_scheme_tel
;