diff options
223 files changed, 3492 insertions, 1009 deletions
diff --git a/.gitignore b/.gitignore index d748bd11f..67d7c7ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ FIXME.out INSTALL aclocal.m4 autom4te.cache +/build-aux config.guess config.h config.h.in diff --git a/Makefile.am b/Makefile.am index 47487a27e..ed1c2410d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ check-valgrind: maintainer-upload-release: _maintainer-upload-release-local _maintainer-upload-release-local: _maintainer-upload-release-check rsync -rvzPp --chmod=Dg+s,ug+rwX,o=rX $(builddir)/docs/reference/html/ \ - telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/doc/telepathy-glib-0.22.x/ + telepathy.freedesktop.org:/srv/telepathy.freedesktop.org/www/doc/telepathy-glib/ BRANCH = $(shell sh tools/git-which-branch.sh misc | tr -d '\n' | tr -C "[:alnum:]" _) UPLOAD_BRANCH_TO = people.freedesktop.org:public_html/telepathy-glib @@ -1,23 +1,102 @@ -telepathy-glib 0.22.2 (UNRELEASED) +telepathy-glib 0.23.3 (UNRELEASED) ================================== -... +Fixes: + +• fix a memory leak when cleaning up TpProxy "prepare" requests + (fd.o #76000, Simon) + +• fix a memory leak for paths to contacts' avatar data (fd.o #76000, Simon) -telepathy-glib 0.22.1 (2014-01-29) +telepathy-glib 0.23.2 (2014-02-26) ================================== -The “tiny tyrannosaur” release. +Enhancements: + +• TpBaseConnection now has an "account-path-suffix" property + (fd.o #74030, Xavier) + +• New high level TpAccountChannelRequest API, including tubes, Conference and + SMSChannel. (fd.o #75450, Guillaume) + +• 'TargetHandleType: None' is now automatically added when requesting a + channel with TpAccountChannelRequest if no handle type has been defined. + (fd.o #75450, Guillaume) + +telepathy-glib 0.23.1 (2014-02-04) +================================== + +The “undead space elves” release. + +Dependencies: + +• GLib 2.36 or later is required + +Deprecations: + +• TpPresenceMixin: optional arguments are deprecated, apart from a + string named "message". This matches our current D-Bus API. + +Enhancements: + +• tp_protocol_normalize_contact_async(), + tp_protocol_identify_account_async(), and high-level API for + the Protocol Addressing and Presence interfaces (fd.o #71048, Simon) + +• More accessors for TpPresenceStatusSpec, which is now a boxed type + (fd.o #71048, Simon) + +• tp_connection_manager_param_dup_variant_type() (fd.o #71093, Simon) + +• Better debug output (fd.o #68390, #71048; Simon) Fixes: • In the examples, specifically ask for "TelepathyGlib-0.12" (this API version), not Telepathy 1.0 (fd.o #49737, Simon) +• Improve tests' isolation from the real session bus (Xavier) + • Fix a critical warning for each new connection under GLib 2.39 (fd.o #72303, Xavier) +• Fix some possible crashes in file transfer channels, particularly + under GLib 2.39 (fd.o #72319, Xavier) + +• Correct tp_account_request_set_avatar documentation (Xavier) + • Fix a TpConnection reference-leak in TpBaseClient (Guillaume) +telepathy-glib 0.23.0 (2013-10-28) +================================== + +We no longer guarantee compatible upgrades within a development (odd) branch, +see README for details. + +Dependencies: + +• GLib 2.34 or later is required. + +Enhancements: + +• Spec 0.27.3 + · added Conn.I.Sidecars1 + · added Conn.I.Renaming + · added CD.I.Messages1 + +• TpAccount::avatar-changed signal (fd.o #52938, Guillaume) + +• tp_value_array_free: equivalent of g_value_array_free but does not provoke + deprecation warnings from GLib (fd.o #69849, Simon) + +• tp_account_is_prepared and tp_account_manager_is_prepared are now deprecated + (Guillaume) + +Fixes: + +• tp_contact_set_attributes: don't warn on genuinely absent interfaces + (fd.o #68149, Simon) + • channel-group: don't crash if no message has been provided (Guillaume) telepathy-glib 0.22.0 (2013-10-02) @@ -60,24 +60,24 @@ branches have y odd. In a stable (even) branch, we will not make incompatible API or ABI changes between one release tarball and the next. -In a development (odd) branch, if we make incompatible ABI changes -between one release tarball and the next, we will change the SONAME of the -library; we will attempt to avoid incompatible API or ABI changes. - -The GObject-Introspection and Vala bindings are not currently considered to -be stable, so they have no API/ABI guarantees yet. +In a development (odd) branch, we will attempt to avoid incompatible API +or ABI changes. If we break ABI relative to the previous stable (even) +release, we will increase the library SONAME to avoid breaking existing +code. If we break ABI relative to a previous development (odd) release, +we will not necessarily increase the library SONAME: in other words, +API/ABI added by a development release is not guaranteed until it appears +in a stable release. (This is basically the same policy as GLib - in +versions 0.22 and earlier, we had a more restrictive policy.) + +The GObject-Introspection and Vala bindings are more or less stable, +but might break compatibility between one development branch and the next. Unreleased builds straight from git identify themselves as version -"x.y.z.1". We DO NOT make any API guarantees about unreleased builds: -any binary relying on new functionality from an unreleased build is not -guaranteed to work with any subsequent release or unreleased build, and on -platforms with versioned symbols (mainly Linux) it definitely won't work with -subsequent releases (you'll have to at least relink the binary). -We do not increment SONAMEs on the basis of unreleased changes. +"x.y.z.1". We DO NOT make any API guarantees about unreleased builds. Unreleased builds are compiled with -Werror, so they might stop working if your gcc version issues more warnings than ours. If this is a problem -for you, use a release tarball. +for you, use a release tarball or configure with --disable-fatal-warnings. Contact info ============ diff --git a/configure.ac b/configure.ac index c566410d4..19e835b9e 100644 --- a/configure.ac +++ b/configure.ac @@ -10,8 +10,8 @@ AC_PREREQ([2.60]) # set nano_version to 1 m4_define([tp_glib_major_version], [0]) -m4_define([tp_glib_minor_version], [22]) -m4_define([tp_glib_micro_version], [1]) +m4_define([tp_glib_minor_version], [23]) +m4_define([tp_glib_micro_version], [2]) m4_define([tp_glib_nano_version], [1]) # If library source has changed since last release, increment revision @@ -26,9 +26,9 @@ m4_define([tp_glib_nano_version], [1]) # (we don't guarantee that we won't add ABI then remove it again, if it was # never seen in a release). -m4_define([tp_glib_lt_current], [80]) -m4_define([tp_glib_lt_revision], [1]) -m4_define([tp_glib_lt_age], [80]) +m4_define([tp_glib_lt_current], [83]) +m4_define([tp_glib_lt_revision], [0]) +m4_define([tp_glib_lt_age], [83]) # Some magic m4_define([tp_glib_base_version], @@ -41,8 +41,9 @@ AC_INIT([Telepathy-GLib], [tp_glib_version], [https://bugs.freedesktop.org/enter_bug.cgi?product=Telepathy&component=tp-glib]) AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([1.11 -Wno-portability]) +AM_INIT_AUTOMAKE([1.11 -Wno-portability subdir-objects]) AC_CONFIG_HEADERS(config.h) AM_SILENT_RULES @@ -116,8 +117,7 @@ TP_COMPILER_WARNINGS([ERROR_CFLAGS], [test "x$enable_fatal_warnings" = xyes], format-security \ init-self], [missing-field-initializers \ - unused-parameter \ - deprecated-declarations]) + unused-parameter]) AC_SUBST([ERROR_CFLAGS]) # these aren't really error flags but they serve a similar purpose for us - @@ -199,11 +199,10 @@ AC_SUBST(tpglibtestsdir) dnl Check for Glib PKG_CHECK_MODULES(GLIB, - [glib-2.0 >= 2.32.0, gobject-2.0 >= 2.32.0, gio-2.0 >= 2.32.0]) + [glib-2.0 >= 2.36, gobject-2.0 >= 2.36, gio-2.0 >= 2.36]) -dnl MIN_REQUIRED must stay to 2.30 because of GValueArray -AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_30], [Ignore post 2.32 deprecations]) -AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post 2.32 APIs]) +AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_36], [Ignore post 2.36 deprecations]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_36], [Prevent post 2.36 APIs]) dnl Check for GIO-Unix PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], @@ -297,7 +296,7 @@ CXXFLAGS="$GLIB_CFLAGS" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <gio/gio.h>]], - [[g_type_init (); g_object_unref (g_file_new_for_path ("/"));]]) + [[g_object_unref (g_file_new_for_path ("/"));]]) ], [tp_cxx_works=yes], [tp_cxx_works=no]) diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 16ede12d0..982359646 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -142,6 +142,14 @@ check-local: echo "$$file missing from telepathy-glib-docs.sgml"; \ err=1; \ fi; \ - done + done; \ + case $(enable_fatal_warnings)/$$err in \ + (yes/1) \ + echo "Documentation check failed" >&2; \ + exit $$err; \ + ;; \ + (*) \ + exit 0; \ + ;; \ + esac endif -# ... but don't fail on incomplete documentation, this is a stable branch diff --git a/docs/reference/telepathy-glib-docs.sgml b/docs/reference/telepathy-glib-docs.sgml index eb3139ac8..8037ab9a2 100644 --- a/docs/reference/telepathy-glib-docs.sgml +++ b/docs/reference/telepathy-glib-docs.sgml @@ -10,8 +10,6 @@ This manual documents telepathy-glib version &tpglibversion;. The latest development version of this documentation can be found here: <ulink role="online-location" url="http://telepathy.freedesktop.org/doc/telepathy-glib/">online copy of the telepathy-glib API Reference Manual</ulink>. - The latest version in this stable branch can be found here: - <ulink role="online-location" url="http://telepathy.freedesktop.org/doc/telepathy-glib-0.22.x/">online copy of the telepathy-glib 0.22.x API Reference Manual</ulink>. </releaseinfo> </bookinfo> @@ -59,6 +57,8 @@ <xi:include href="xml/connection-mail.xml"/> <xi:include href="xml/connection-powersaving.xml"/> <xi:include href="xml/connection-addressing.xml"/> + <xi:include href="xml/connection-renaming.xml"/> + <xi:include href="xml/connection-sidecars.xml"/> <xi:include href="xml/contact-search.xml"/> <xi:include href="xml/contact-search-result.xml"/> <xi:include href="xml/channel.xml"/> diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 9a0003bd1..7c0489a33 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -45,6 +45,7 @@ TP_VERSION_0_16 TP_VERSION_0_18 TP_VERSION_0_20 TP_VERSION_0_22 +TP_VERSION_0_24 TP_VERSION_MIN_REQUIRED TP_VERSION_MAX_ALLOWED <SUBSECTION Private> @@ -85,6 +86,7 @@ TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED tp_base_connection_register_with_contacts_mixin tp_base_connection_add_possible_client_interest tp_base_connection_add_client_interest +tp_base_connection_get_account_path_suffix <SUBSECTION> TpChannelManagerIter tp_base_connection_channel_manager_iter_init @@ -1599,6 +1601,31 @@ TP_SVC_CONNECTION_INTERFACE_ADDRESSING TP_SVC_CONNECTION_INTERFACE_ADDRESSING_GET_CLASS TP_TYPE_SVC_CONNECTION_INTERFACE_ADDRESSING tp_svc_connection_interface_addressing_get_type +<SUBSECTION> +TpSvcConnectionInterfaceRenaming +TpSvcConnectionInterfaceRenamingClass +tp_svc_connection_interface_renaming_emit_renamed +tp_svc_connection_interface_renaming_implement_request_rename +tp_svc_connection_interface_renaming_request_rename_impl +tp_svc_connection_interface_renaming_return_from_request_rename +<SUBSECTION Standard> +TP_IS_SVC_CONNECTION_INTERFACE_RENAMING +TP_SVC_CONNECTION_INTERFACE_RENAMING +TP_SVC_CONNECTION_INTERFACE_RENAMING_GET_CLASS +TP_TYPE_SVC_CONNECTION_INTERFACE_RENAMING +tp_svc_connection_interface_renaming_get_type +<SUBSECTION> +TpSvcConnectionInterfaceSidecars1 +TpSvcConnectionInterfaceSidecars1Class +tp_svc_connection_interface_sidecars1_ensure_sidecar_impl +tp_svc_connection_interface_sidecars1_implement_ensure_sidecar +tp_svc_connection_interface_sidecars1_return_from_ensure_sidecar +<SUBSECTION Standard> +TP_IS_SVC_CONNECTION_INTERFACE_SIDECARS1 +TP_SVC_CONNECTION_INTERFACE_SIDECARS1 +TP_SVC_CONNECTION_INTERFACE_SIDECARS1_GET_CLASS +TP_TYPE_SVC_CONNECTION_INTERFACE_SIDECARS1 +tp_svc_connection_interface_sidecars1_get_type </SECTION> <SECTION> @@ -1754,6 +1781,7 @@ tp_g_key_file_get_uint64 tp_g_signal_connect_object tp_value_array_build tp_value_array_unpack +tp_value_array_free TpWeakRef tp_weak_ref_new tp_weak_ref_dup_object @@ -2274,6 +2302,13 @@ TP_CONTACTS_MIXIN <FILE>presence-mixin</FILE> TpPresenceStatusOptionalArgumentSpec TpPresenceStatusSpec +tp_presence_status_spec_can_set_on_self +tp_presence_status_spec_get_name +tp_presence_status_spec_get_presence_type +tp_presence_status_spec_has_message +tp_presence_status_spec_new +tp_presence_status_spec_copy +tp_presence_status_spec_free TpPresenceMixinStatusAvailableFunc TpPresenceMixinGetContactStatusesFunc TpPresenceMixinSetOwnStatusFunc @@ -2302,9 +2337,11 @@ tp_presence_mixin_class_get_offset_quark tp_presence_mixin_get_offset_quark TpPresenceMixinPrivate TpPresenceMixinClassPrivate +TpPresenceStatusSpecPrivate <SUBSECTION Standard> TP_PRESENCE_MIXIN_CLASS TP_PRESENCE_MIXIN +tp_presence_status_spec_get_type </SECTION> <SECTION> @@ -3101,8 +3138,12 @@ TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_LIST TP_IFACE_CONNECTION_INTERFACE_CONTACTS TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACTS +TP_IFACE_CONNECTION_INTERFACE_RENAMING +TP_IFACE_QUARK_CONNECTION_INTERFACE_RENAMING TP_IFACE_CONNECTION_INTERFACE_REQUESTS TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS +TP_IFACE_CONNECTION_INTERFACE_SIDECARS1 +TP_IFACE_QUARK_CONNECTION_INTERFACE_SIDECARS1 TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE TP_IFACE_QUARK_CONNECTION_INTERFACE_SIMPLE_PRESENCE TP_IFACE_CONNECTION_INTERFACE_PRESENCE @@ -3183,6 +3224,8 @@ TP_IFACE_CHANNEL_INTERFACE_SERVICE_POINT TP_IFACE_QUARK_CHANNEL_INTERFACE_SERVICE_POINT TP_IFACE_CHANNEL_DISPATCHER TP_IFACE_QUARK_CHANNEL_DISPATCHER +TP_IFACE_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1 +TP_IFACE_QUARK_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1 TP_IFACE_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST TP_IFACE_QUARK_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST TP_IFACE_CHANNEL_DISPATCH_OPERATION @@ -3445,7 +3488,9 @@ TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DESCRIPTION +TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILE_COLLECTION TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME +TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILE_COLLECTION TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_INITIAL_OFFSET TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_STATE @@ -3612,6 +3657,7 @@ tp_iface_quark_channel_type_dbus_tube tp_iface_quark_channel_type_server_authentication tp_iface_quark_channel_type_stream_tube tp_iface_quark_channel_dispatcher +tp_iface_quark_channel_dispatcher_interface_messages1 tp_iface_quark_channel_dispatcher_interface_operation_list tp_iface_quark_channel_dispatch_operation tp_iface_quark_channel_request @@ -3634,8 +3680,10 @@ tp_iface_quark_connection_interface_contact_info tp_iface_quark_connection_interface_contact_list tp_iface_quark_connection_interface_capabilities tp_iface_quark_connection_interface_mail_notification +tp_iface_quark_connection_interface_renaming tp_iface_quark_connection_interface_requests tp_iface_quark_connection_interface_power_saving +tp_iface_quark_connection_interface_sidecars1 tp_iface_quark_connection_interface_simple_presence tp_iface_quark_connection_interface_presence tp_iface_quark_connection_interface_location @@ -4441,6 +4489,24 @@ tp_cli_connection_interface_aliasing_signal_callback_aliases_changed </SECTION> <SECTION> +<FILE>connection-renaming</FILE> +<TITLE>connection-renaming</TITLE> +<INCLUDE>telepathy-glib/telepathy-glib-dbus.h</INCLUDE> +tp_cli_connection_interface_renaming_call_request_rename +tp_cli_connection_interface_renaming_callback_for_request_rename +tp_cli_connection_interface_renaming_connect_to_renamed +tp_cli_connection_interface_renaming_signal_callback_renamed +</SECTION> + +<SECTION> +<FILE>connection-sidecars</FILE> +<TITLE>connection-sidecars</TITLE> +<INCLUDE>telepathy-glib/telepathy-glib-dbus.h</INCLUDE> +tp_cli_connection_interface_sidecars1_call_ensure_sidecar +tp_cli_connection_interface_sidecars1_callback_for_ensure_sidecar +</SECTION> + +<SECTION> <FILE>connection-avatars</FILE> <TITLE>connection-avatars</TITLE> <INCLUDE>telepathy-glib/telepathy-glib-dbus.h</INCLUDE> @@ -4784,6 +4850,7 @@ tp_connection_manager_protocol_get_param TpConnectionManagerParam tp_connection_manager_param_get_name tp_connection_manager_param_get_dbus_signature +tp_connection_manager_param_dup_variant_type tp_connection_manager_param_is_required tp_connection_manager_param_is_required_for_registration tp_connection_manager_param_is_secret @@ -5410,6 +5477,9 @@ tp_cli_channel_dispatcher_call_present_channel tp_cli_channel_dispatcher_callback_for_delegate_channels tp_cli_channel_dispatcher_callback_for_present_channel <SUBSECTION> +tp_cli_channel_dispatcher_interface_messages1_call_send_message +tp_cli_channel_dispatcher_interface_messages1_callback_for_send_message +<SUBSECTION> tp_cli_channel_dispatcher_interface_operation_list_signal_callback_dispatch_operation_finished tp_cli_channel_dispatcher_interface_operation_list_connect_to_dispatch_operation_finished tp_cli_channel_dispatcher_interface_operation_list_signal_callback_new_dispatch_operation @@ -5455,16 +5525,27 @@ TpSvcChannelDispatcherInterfaceOperationList TpSvcChannelDispatcherInterfaceOperationListClass tp_svc_channel_dispatcher_interface_operation_list_emit_new_dispatch_operation tp_svc_channel_dispatcher_interface_operation_list_emit_dispatch_operation_finished +<SUBSECTION> +TpSvcChannelDispatcherInterfaceMessages1 +TpSvcChannelDispatcherInterfaceMessages1Class +tp_svc_channel_dispatcher_interface_messages1_implement_send_message +tp_svc_channel_dispatcher_interface_messages1_return_from_send_message +tp_svc_channel_dispatcher_interface_messages1_send_message_impl <SUBSECTION Standard> TP_SVC_CHANNEL_DISPATCHER +TP_SVC_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1 TP_SVC_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST TP_IS_SVC_CHANNEL_DISPATCHER +TP_IS_SVC_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1 TP_IS_SVC_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST TP_TYPE_SVC_CHANNEL_DISPATCHER +TP_TYPE_SVC_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1 TP_TYPE_SVC_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST tp_svc_channel_dispatcher_get_type +tp_svc_channel_dispatcher_interface_messages1_get_type tp_svc_channel_dispatcher_interface_operation_list_get_type TP_SVC_CHANNEL_DISPATCHER_GET_CLASS +TP_SVC_CHANNEL_DISPATCHER_INTERFACE_MESSAGES1_GET_CLASS TP_SVC_CHANNEL_DISPATCHER_INTERFACE_OPERATION_LIST_GET_CLASS </SECTION> @@ -6084,6 +6165,7 @@ TP_TYPE_SVC_PROTOCOL_INTERFACE_AVATARS TpProtocol TpProtocolClass tp_protocol_new +tp_protocol_new_vardict tp_protocol_get_name tp_protocol_get_cm_name tp_protocol_init_known_interfaces @@ -6096,6 +6178,7 @@ tp_protocol_get_param tp_protocol_dup_param tp_protocol_has_param tp_protocol_can_register +tp_protocol_dup_immutable_properties <SUBSECTION> TP_PROTOCOL_FEATURE_CORE tp_protocol_get_capabilities @@ -6103,8 +6186,22 @@ tp_protocol_get_english_name tp_protocol_get_icon_name tp_protocol_get_vcard_field tp_protocol_get_authentication_types +tp_protocol_identify_account_async +tp_protocol_identify_account_finish +tp_protocol_normalize_contact_async +tp_protocol_normalize_contact_finish +<SUBSECTION> tp_protocol_get_avatar_requirements <SUBSECTION> +tp_protocol_dup_presence_statuses +<SUBSECTION> +tp_protocol_get_addressable_uri_schemes +tp_protocol_get_addressable_vcard_fields +tp_protocol_normalize_contact_uri_async +tp_protocol_normalize_contact_uri_finish +tp_protocol_normalize_vcard_address_async +tp_protocol_normalize_vcard_address_finish +<SUBSECTION> tp_cli_protocol_call_identify_account tp_cli_protocol_call_normalize_contact tp_cli_protocol_callback_for_identify_account @@ -6187,6 +6284,10 @@ tp_account_channel_request_set_target_contact tp_account_channel_request_set_target_id tp_account_channel_request_set_request_property tp_account_channel_request_new_text +tp_account_channel_request_set_sms_channel +tp_account_channel_request_set_conference_initial_channels +tp_account_channel_request_set_initial_invitee_ids +tp_account_channel_request_set_initial_invitees tp_account_channel_request_new_audio_call tp_account_channel_request_new_audio_video_call tp_account_channel_request_new_file_transfer @@ -6194,6 +6295,9 @@ tp_account_channel_request_set_file_transfer_description tp_account_channel_request_set_file_transfer_initial_offset tp_account_channel_request_set_file_transfer_timestamp tp_account_channel_request_set_file_transfer_uri +tp_account_channel_request_set_file_transfer_hash +tp_account_channel_request_new_stream_tube +tp_account_channel_request_new_dbus_tube tp_account_channel_request_create_and_handle_channel_async tp_account_channel_request_create_and_handle_channel_finish tp_account_channel_request_ensure_and_handle_channel_async diff --git a/examples/client/approver.c b/examples/client/approver.c index 800f19788..3cc6f88c0 100644 --- a/examples/client/approver.c +++ b/examples/client/approver.c @@ -143,7 +143,6 @@ main (int argc, GError *error = NULL; TpBaseClient *approver; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); manager = tp_account_manager_dup (); diff --git a/examples/client/contact-list.c b/examples/client/contact-list.c index 5ed82a4af..7506d473f 100644 --- a/examples/client/contact-list.c +++ b/examples/client/contact-list.c @@ -74,7 +74,6 @@ main (int argc, TpSimpleClientFactory *factory; GMainLoop *loop; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); loop = g_main_loop_new (NULL, FALSE); diff --git a/examples/client/dbus-tubes/accepter.c b/examples/client/dbus-tubes/accepter.c index 2f2dae5ca..1219e6e1a 100644 --- a/examples/client/dbus-tubes/accepter.c +++ b/examples/client/dbus-tubes/accepter.c @@ -185,8 +185,6 @@ main (int argc, TpBaseClient *handler; GError *error = NULL; - g_type_init (); - manager = tp_account_manager_dup (); handler = tp_simple_handler_new_with_am (manager, FALSE, FALSE, "ExampleServiceHandler", FALSE, handle_channels, NULL, NULL); diff --git a/examples/client/dbus-tubes/offerer.c b/examples/client/dbus-tubes/offerer.c index 2e4807bfc..48221a08d 100644 --- a/examples/client/dbus-tubes/offerer.c +++ b/examples/client/dbus-tubes/offerer.c @@ -188,8 +188,6 @@ main (int argc, TpAccountChannelRequest *req; GHashTable *request; - g_type_init (); - if (argc != 3) { g_printerr ("Usage: offerer gabble/jabber/ladygaga t-pain@example.com\n"); diff --git a/examples/client/extended-client.c b/examples/client/extended-client.c index 55e3086e2..a2af57115 100644 --- a/examples/client/extended-client.c +++ b/examples/client/extended-client.c @@ -71,14 +71,15 @@ got_hats_cb (TpConnection *conn, for (i = 0; i < hats->len; i++) { GValueArray *vals = g_ptr_array_index (hats, i); + guint handle; + const gchar *color; + guint style; + GHashTable *details; + tp_value_array_unpack (vals, 4, + &handle, &color, &style, &details); g_message ("Contact #%u has hat style %u, color \"%s\", with %u " - "properties", - g_value_get_uint (g_value_array_get_nth (vals, 0)), - g_value_get_uint (g_value_array_get_nth (vals, 2)), - g_value_get_string (g_value_array_get_nth (vals, 1)), - g_hash_table_size (g_value_get_boxed (g_value_array_get_nth (vals, - 3)))); + "properties", handle, style, color, g_hash_table_size (details)); } tp_cli_connection_call_disconnect (conn, -1, disconnect_cb, @@ -283,7 +284,6 @@ main (int argc, GError *error = NULL; TpDBusDaemon *dbus = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); example_cli_init (); diff --git a/examples/client/inspect-channel.c b/examples/client/inspect-channel.c index 969a4f831..ef8c89270 100644 --- a/examples/client/inspect-channel.c +++ b/examples/client/inspect-channel.c @@ -136,7 +136,6 @@ main (int argc, TpConnection *connection = NULL; GError *error = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); if (argc < 3) diff --git a/examples/client/inspect-cm.c b/examples/client/inspect-cm.c index 68fefedbe..c2a1532be 100644 --- a/examples/client/inspect-cm.c +++ b/examples/client/inspect-cm.c @@ -233,7 +233,6 @@ main (int argc, TpDBusDaemon *dbus = NULL; int ret = 1; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); if (g_getenv ("EXAMPLE_TIMING") != NULL) diff --git a/examples/client/inspect-connection.c b/examples/client/inspect-connection.c index 6b6fa81a1..460887a71 100644 --- a/examples/client/inspect-connection.c +++ b/examples/client/inspect-connection.c @@ -86,7 +86,6 @@ main (int argc, TpSimpleClientFactory *factory; GError *error = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); if (argc < 2) diff --git a/examples/client/inspect-contact.c b/examples/client/inspect-contact.c index 5c967c528..f960e0850 100644 --- a/examples/client/inspect-contact.c +++ b/examples/client/inspect-contact.c @@ -157,7 +157,6 @@ main (int argc, TpSimpleClientFactory *factory; GError *error = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); if (argc < 2) diff --git a/examples/client/list-connections.c b/examples/client/list-connections.c index 1b3211f04..3df69ee1e 100644 --- a/examples/client/list-connections.c +++ b/examples/client/list-connections.c @@ -62,7 +62,6 @@ main (int argc, TpDBusDaemon *bus_daemon; GError *error = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); bus_daemon = tp_dbus_daemon_dup (&error); diff --git a/examples/client/list-managers.c b/examples/client/list-managers.c index bffd19b23..87109e597 100644 --- a/examples/client/list-managers.c +++ b/examples/client/list-managers.c @@ -60,7 +60,6 @@ main (int argc, TpDBusDaemon *bus_daemon; GError *error = NULL; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); bus_daemon = tp_dbus_daemon_dup (&error); diff --git a/examples/client/media-observer.c b/examples/client/media-observer.c index 0d9a6940d..ef0aa8960 100644 --- a/examples/client/media-observer.c +++ b/examples/client/media-observer.c @@ -76,7 +76,6 @@ main (int argc, GError *error = NULL; TpBaseClient *observer; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); manager = tp_account_manager_dup (); diff --git a/examples/client/python/inspect-cm.py b/examples/client/python/inspect-cm.py index de02742aa..cf3b83800 100644 --- a/examples/client/python/inspect-cm.py +++ b/examples/client/python/inspect-cm.py @@ -30,9 +30,11 @@ def describe(cm): print("\t\tNo default") def manager_prepared_cb(cm, result, loop): - cm.prepare_finish(result) - describe(cm) - loop.quit() + try: + cm.prepare_finish(result) + describe(cm) + finally: + loop.quit() def inspect(name): cm = Tp.ConnectionManager( @@ -43,13 +45,14 @@ def inspect(name): cm.prepare_async(None, cm, loop) def cms_cb(source, result, loop): - cms = Tp.list_connection_managers_finish(result) - - for cm in cms: - describe(cm) - print("") + try: + cms = Tp.list_connection_managers_finish(result) - loop.quit() + for cm in cms: + describe(cm) + print("") + finally: + loop.quit() if __name__ == '__main__': loop = GObject.MainLoop() diff --git a/examples/client/stream-tubes/accepter.c b/examples/client/stream-tubes/accepter.c index 574173abb..ed820562d 100644 --- a/examples/client/stream-tubes/accepter.c +++ b/examples/client/stream-tubes/accepter.c @@ -135,8 +135,6 @@ main (int argc, TpBaseClient *handler; GError *error = NULL; - g_type_init (); - manager = tp_account_manager_dup (); handler = tp_simple_handler_new_with_am (manager, FALSE, FALSE, "ExampleServiceHandler", FALSE, _handle_channels, NULL, NULL); diff --git a/examples/client/stream-tubes/offerer.c b/examples/client/stream-tubes/offerer.c index 8d62da38d..16bb9279a 100644 --- a/examples/client/stream-tubes/offerer.c +++ b/examples/client/stream-tubes/offerer.c @@ -146,8 +146,6 @@ main (int argc, return 2; } - g_type_init (); - factory = TP_SIMPLE_CLIENT_FACTORY (tp_automatic_client_factory_new (NULL)); account_path = g_strconcat (TP_ACCOUNT_OBJECT_PATH_BASE, argv[1], NULL); diff --git a/examples/client/text-handler.c b/examples/client/text-handler.c index 4eb94f565..6a079c878 100644 --- a/examples/client/text-handler.c +++ b/examples/client/text-handler.c @@ -124,7 +124,6 @@ main (int argc, GError *error = NULL; TpBaseClient *handler; - g_type_init (); tp_debug_set_flags (g_getenv ("EXAMPLE_DEBUG")); manager = tp_account_manager_dup (); diff --git a/examples/cm/call/main.c b/examples/cm/call/main.c index aee9f17bc..1c5c966d2 100644 --- a/examples/cm/call/main.c +++ b/examples/cm/call/main.c @@ -50,10 +50,6 @@ main (int argc, tp_debug_set_persistent (TRUE); #endif - /* strictly speaking, this is only necessary for client code, but it's - * harmless here */ - g_type_init (); - return tp_run_connection_manager ("telepathy-example-cm-call", VERSION, construct_cm, argc, argv); } diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c index a28ae8547..3c48f3a9f 100644 --- a/examples/cm/contactlist/conn.c +++ b/examples/cm/contactlist/conn.c @@ -163,14 +163,10 @@ alias_updated_cb (ExampleContactList *contact_list, GPtrArray *aliases; GValueArray *pair; - pair = g_value_array_new (2); - g_value_array_append (pair, NULL); - g_value_array_append (pair, NULL); - g_value_init (pair->values + 0, G_TYPE_UINT); - g_value_init (pair->values + 1, G_TYPE_STRING); - g_value_set_uint (pair->values + 0, contact); - g_value_set_string (pair->values + 1, - example_contact_list_get_alias (contact_list, contact)); + pair = tp_value_array_build (2, + G_TYPE_UINT, contact, + G_TYPE_STRING, example_contact_list_get_alias (contact_list, contact), + G_TYPE_INVALID); aliases = g_ptr_array_sized_new (1); g_ptr_array_add (aliases, pair); @@ -178,7 +174,7 @@ alias_updated_cb (ExampleContactList *contact_list, tp_svc_connection_interface_aliasing_emit_aliases_changed (self, aliases); g_ptr_array_unref (aliases); - g_value_array_free (pair); + tp_value_array_free (pair); } static void diff --git a/examples/cm/echo-message-parts/protocol.c b/examples/cm/echo-message-parts/protocol.c index 4512216b9..7917ba000 100644 --- a/examples/cm/echo-message-parts/protocol.c +++ b/examples/cm/echo-message-parts/protocol.c @@ -115,7 +115,7 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED, const gchar *account = tp_asv_get_string (asv, "account"); if (account != NULL) - return g_strdup (account); + return g_utf8_strdown (account, -1); g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "'account' parameter not given"); @@ -226,6 +226,72 @@ dup_supported_vcard_fields (TpBaseProtocol *self) return g_strdupv ((GStrv) addressing_vcard_fields); } +static gchar * +normalize_vcard_address (TpBaseProtocol *self, + const gchar *vcard_field, + const gchar *vcard_address, + GError **error) +{ + if (g_ascii_strcasecmp (vcard_field, "x-jabber") == 0) + { + /* This is not really how you normalize a JID but it's good enough + * for an example. In real life you'd do syntax-checking beyond + * "is it empty?", stringprep, and so on. Here, we just assume + * non-empty means valid, and lower-case means normalized. */ + + if (tp_str_empty (vcard_address)) + { + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + "The empty string is not a valid JID"); + return NULL; + } + + return g_utf8_strdown (vcard_address, -1); + } + else + { + g_set_error (error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, + "Don't know how to normalize vCard field: %s", vcard_field); + return NULL; + } +} + +static gchar * +normalize_contact_uri (TpBaseProtocol *self, + const gchar *uri, + GError **error) +{ + gchar *scheme = g_uri_parse_scheme (uri); + + if (g_ascii_strcasecmp (scheme, "xmpp") == 0) + { + gchar *ret = NULL; + gchar *id; + + id = normalize_vcard_address (self, "x-jabber", uri + 5, error); + + if (id != NULL) + ret = g_strdup_printf ("%s:%s", scheme, id); + + g_free (scheme); + g_free (id); + return ret; + } + else if (scheme == NULL) + { + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + "Not a valid URI: %s", uri); + return NULL; + } + else + { + g_set_error (error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, + "Don't know how to normalize URIs of that scheme: %s", scheme); + g_free (scheme); + return NULL; + } +} + static void example_echo_2_protocol_class_init ( ExampleEcho2ProtocolClass *klass) @@ -248,4 +314,6 @@ addressing_iface_init (TpProtocolAddressingInterface *iface) { iface->dup_supported_vcard_fields = dup_supported_vcard_fields; iface->dup_supported_uri_schemes = dup_supported_uri_schemes; + iface->normalize_vcard_address = normalize_vcard_address; + iface->normalize_contact_uri = normalize_contact_uri; } diff --git a/examples/cm/extended/conn.c b/examples/cm/extended/conn.c index 873fcf2b0..c92076f4e 100644 --- a/examples/cm/extended/conn.c +++ b/examples/cm/extended/conn.c @@ -274,40 +274,30 @@ my_get_hats (ExampleSvcConnectionInterfaceHats *iface, for (i = 0; i < contacts->len; i++) { TpHandle handle = g_array_index (contacts, guint, i); - GValueArray *vals = g_value_array_new (4); - - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 0), G_TYPE_UINT); - g_value_set_uint (g_value_array_get_nth (vals, 0), handle); - - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 1), G_TYPE_STRING); - - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 2), G_TYPE_UINT); - - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 3), - TP_HASH_TYPE_STRING_VARIANT_MAP); + GValueArray *vals; /* for the sake of a simple example, let's assume nobody except me * has any hats */ if (handle == tp_base_connection_get_self_handle (base)) { - g_value_set_string (g_value_array_get_nth (vals, 1), - self->priv->hat_color); - g_value_set_uint (g_value_array_get_nth (vals, 2), - self->priv->hat_style); - g_value_set_boxed (g_value_array_get_nth (vals, 3), - self->priv->hat_properties); + vals = tp_value_array_build (4, + G_TYPE_UINT, handle, + G_TYPE_STRING, self->priv->hat_color, + G_TYPE_UINT, self->priv->hat_style, + TP_HASH_TYPE_STRING_VARIANT_MAP, self->priv->hat_properties, + G_TYPE_INVALID); } else { - g_value_set_static_string (g_value_array_get_nth (vals, 1), ""); - g_value_set_uint (g_value_array_get_nth (vals, 2), - EXAMPLE_HAT_STYLE_NONE); - g_value_take_boxed (g_value_array_get_nth (vals, 3), - g_hash_table_new (NULL, NULL)); + GHashTable *empty = g_hash_table_new (g_str_hash, g_str_equal); + + vals = tp_value_array_build (4, + G_TYPE_UINT, handle, + G_TYPE_STRING, "", + G_TYPE_UINT, EXAMPLE_HAT_STYLE_NONE, + TP_HASH_TYPE_STRING_VARIANT_MAP, empty, + G_TYPE_INVALID); + g_hash_table_unref (empty); } g_ptr_array_add (ret, vals); diff --git a/spec/Channel_Dispatcher_Interface_Messages1.xml b/spec/Channel_Dispatcher_Interface_Messages1.xml new file mode 100644 index 000000000..e768b5549 --- /dev/null +++ b/spec/Channel_Dispatcher_Interface_Messages1.xml @@ -0,0 +1,175 @@ +<?xml version="1.0" ?> +<node name="/Channel_Dispatcher_Interface_Messages1" + xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + + <tp:copyright>Copyright (C) 2011-2013 Collabora Ltd.</tp:copyright> + <tp:copyright>Copyright (C) 2011 Nokia Corporation</tp:copyright> + <tp:license xmlns="http://www.w3.org/1999/xhtml"> + <p>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.</p> + + <p>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.</p> + + <p>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.</p> + </tp:license> + + <interface + name="org.freedesktop.Telepathy.ChannelDispatcher.Interface.Messages1"> + <tp:requires interface="org.freedesktop.Telepathy.ChannelDispatcher"/> + + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p> + This interface allows DBus clients to use the ChannelDispatcher to + send one-off text messages to a contact, identified by account and + target ID, without requiring the caller to handle channels or be + the primary message UI. + </p> + + <tp:rationale> + <p> + This enables entities other than the main UI to send messages + to contacts. + </p> + </tp:rationale> + </tp:docstring> + + <method name="SendMessage" tp:name-for-bindings="Send_Message"> + <arg direction="in" name="Account" type="o"> + <tp:docstring> + The <tp:dbus-ref namespace="ofdT">Account</tp:dbus-ref> + through which to communicate. + </tp:docstring> + </arg> + <arg direction="in" name="Target_ID" type="s"> + <tp:docstring> + The contact to send the message to. + </tp:docstring> + </arg> + <arg direction="in" name="Message" type="aa{sv}" + tp:type="Message_Part[]"> + <tp:docstring> + The parts of the message, the same as for <tp:dbus-ref + namespace="ofdT.Channel.Interface">Messages.SendMessage</tp:dbus-ref>. + </tp:docstring> + </arg> + <arg direction="in" name="Flags" type="u"> + <tp:docstring> + Flags influencing how to send the message, the same as for <tp:dbus-ref + namespace="ofdT.Channel.Interface">Messages.SendMessage</tp:dbus-ref>. + </tp:docstring> + </arg> + <arg direction="out" name="Token" type="s"> + <tp:docstring> + An opaque token equivalent to the one returned by <tp:dbus-ref + namespace="ofdT.Channel.Interface">Messages.SendMessage</tp:dbus-ref>. + </tp:docstring> + </arg> + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p>Submit a message to the server for sending, like the + <tp:dbus-ref namespace="ofdT.Channel.Interface">Messages.SendMessage</tp:dbus-ref> + method.</p> + + <p>If the <var>Account</var> is connected and a Text channel to the + <var>Target_ID</var> already exists, this method is equivalent to + sending the same message via that channel.</p> + + <p>Otherwise, this method creates a channel (connecting the + Account if appropriate), sends the desired message, and + closes the channel as if via <tp:dbus-ref + namespace="ofdT">Channel.Close</tp:dbus-ref>, without + acknowledging any messages received on that channel + during that time.</p> + + <p>If any messages are received on that channel before it is + closed, a correct connection manager implementation will reopen + the channel when it is closed, resulting in those "rescued" messages + being processed by the system's normal <tp:dbus-ref + namespace="ofdT.Client">Handler</tp:dbus-ref> for text + channels. In particular, this deals with the situation where + a successful or failed delivery report is received + before the channel is closed.</p> + + <tp:rationale> + <p>Expecting a trivial client (perhaps a send-only IRC bot, + or a simple SMS-sending API) to go through all those steps to + send a message seems somewhat unreasonable. Having this as a + method in the ChannelDispatcher lets it take some short-cuts if + required, and centralizes the implementation to reduce the risk of + mistakes that cause message loss.</p> + </tp:rationale> + + <p>The ChannelDispatcher SHOULD support this method for any + connection manager that would accept channel requests of this + form:</p> + + <pre> { + …<tp:dbus-ref namespace="ofdT">Channel.ChannelType</tp:dbus-ref>: + …<tp:dbus-ref namespace="ofdT">Channel.Type.Text</tp:dbus-ref>, + …<tp:dbus-ref namespace="ofdT">Channel.TargetHandleType</tp:dbus-ref>: + <tp:value-ref type="Handle_Type">Contact</tp:value-ref>, + …<tp:dbus-ref namespace="ofdT">Channel.TargetID</tp:dbus-ref>: + <var>Target_ID</var> + }</pre> + + <p>However, if the connection manager provides additional APIs + (such as a way to open "send-only" channels), the + ChannelDispatcher MAY use those: it is not required to use + those exact request parameters.</p> + + <p>This method may raise any error that would be raised by the + <tp:dbus-ref + namespace="ofdT.Connection.Interface">Requests.EnsureChannel</tp:dbus-ref> + or <tp:dbus-ref + namespace="ofdT.Channel.Interface">Messages.SendMessage</tp:dbus-ref> + methods, or signalled by the <tp:dbus-ref + namespace="ofdT.ChannelRequest">Failed</tp:dbus-ref> + signal.</p> + </tp:docstring> + + <tp:possible-errors> + <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> + <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/> + <tp:error name="org.freedesktop.Telepathy.Error.NotImplemented"> + <tp:docstring> + The connection manager does not implement Text channels + that communicate with a named contact. + </tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.Telepathy.Error.InvalidHandle"> + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + The <var>Target_ID</var> was not syntactically valid for the + <var>Account</var>'s protocol. + </tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.Telepathy.Error.InvalidHandle"> + <tp:docstring> + The requested message is malformed and cannot be sent. + </tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.Telepathy.Error.Offline"> + <tp:docstring> + The requested channel cannot be created because the target is + offline. + </tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.Telepathy.Error.NotAvailable"> + <tp:docstring> + The requested channel cannot be created, but in + principle, a similar request might succeed in future. + </tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.Telepathy.Error.PermissionDenied"/> + </tp:possible-errors> + </method> + + </interface> +</node> + diff --git a/spec/Channel_Type_File_Transfer.xml b/spec/Channel_Type_File_Transfer.xml index f50b96344..493ac54f4 100644 --- a/spec/Channel_Type_File_Transfer.xml +++ b/spec/Channel_Type_File_Transfer.xml @@ -579,6 +579,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ </arg> </signal> + <property name="FileCollection" tp:name-for-bindings="File_Collection" + type="s" access="read"> + <tp:added version="0.27.3"/> + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p>The collection of files to which this channel belongs, + or the empty string if this channel does not belong to + a collection of files.</p> + + <p>A channel's FileCollection property can never change.</p> + + <p>At least on GTalk and apparently also on iChat the user can + send a set of files to a contact and that contact can then + pick and choose which files to actually receive.</p> + + <p> The CM should emit all new FT channels belonging to one collection + at the same time. UIs supporting this feature can then + bundle all these channels together in some way, and show a + nice UI. UIs not supporting it will treat them as separate + transfers, which is not great but a reasonable fallback.</p> + + <p>No mechanism is currently defined to indicate whether the UI + should expect any more files in the same collection. UIs + SHOULD assume that more file transfers may be added to a + collection. It is possible that a "no more channels in this + collection" indication will be added in a future version of + this specification.</p> + </tp:docstring> + </property> + </interface> </node> diff --git a/spec/Connection_Interface_IRC_Command1.xml b/spec/Connection_Interface_IRC_Command1.xml new file mode 100644 index 000000000..864f1fa8e --- /dev/null +++ b/spec/Connection_Interface_IRC_Command1.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" ?> +<node name="/Connection_Interface_IRC_Command1" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <tp:copyright> Copyright (C) 2013 Collabora Limited </tp:copyright> + <tp:license xmlns="http://www.w3.org/1999/xhtml"> + <p>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.</p> + +<p>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.</p> + +<p>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.</p> + </tp:license> + <interface name="org.freedesktop.Telepathy.Connection.Interface.IRCCommand1" + tp:causes-havoc='not well-tested'> + <tp:requires interface="org.freedesktop.Telepathy.Connection"/> + <tp:added version="0.27.3"/> + + <method name="Send" tp:name-for-bindings="Send"> + <arg direction="in" name="Command" type="s"> + <tp:docstring> + The command followed by its arguments. + </tp:docstring> + </arg> + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p>Send an arbitrary IRC command to the server.</p> + <p>For example, an IRC client receiving <code>/bip blreset</code> from + the user might call this method with <code>BIP blreset</code> as + argument which will send <code>BIP blreset</code> to the server.</p> + <p>The command is supplied in UTF-8 (because strings on D-Bus are + always UTF-8). It is transcoded into the connection's configured + character set, if different, before sending to the server.</p> + </tp:docstring> + <tp:possible-errors> + <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> + <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/> + <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"> + <tp:docstring> + The connection manager MAY raise this error for commands that + have a more appropriate D-Bus API. + </tp:docstring> + </tp:error> + </tp:possible-errors> + </method> + <tp:docstring> + An interface to send arbitrary IRC commands to the server. + </tp:docstring> + </interface> +</node> +<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/spec/Connection_Interface_Renaming.xml b/spec/Connection_Interface_Renaming.xml index d08b748d9..200611850 100644 --- a/spec/Connection_Interface_Renaming.xml +++ b/spec/Connection_Interface_Renaming.xml @@ -18,8 +18,8 @@ Lesser General Public License for more details.</p> License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> </tp:license> - <interface name="org.freedesktop.Telepathy.Connection.Interface.Renaming" - tp:causes-havoc='not well-tested'> + <interface name="org.freedesktop.Telepathy.Connection.Interface.Renaming"> + <tp:added version="0.27.3">(as stable API)</tp:added> <tp:requires interface="org.freedesktop.Telepathy.Connection"/> <signal name="Renamed" tp:name-for-bindings="Renamed"> <arg name="Original" type="u" tp:type="Contact_Handle"> diff --git a/spec/Connection_Interface_Sidecars1.xml b/spec/Connection_Interface_Sidecars1.xml new file mode 100644 index 000000000..c303fcbe8 --- /dev/null +++ b/spec/Connection_Interface_Sidecars1.xml @@ -0,0 +1,110 @@ +<?xml version="1.0" ?> +<node name="/Connection_Interface_Sidecars1" + xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" + > + <tp:copyright>Copyright © 2009-2013 Collabora Limited</tp:copyright> + <tp:copyright>Copyright © 2009 Nokia Corporation</tp:copyright> + <tp:license xmlns="http://www.w3.org/1999/xhtml"> +<p>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.</p> + +<p>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.</p> + +<p>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.</p> + </tp:license> + <interface name="org.freedesktop.Telepathy.Connection.Interface.Sidecars1"> + <tp:requires interface="org.freedesktop.Telepathy.Connection"/> + <tp:added version="0.27.3"/> + + <method name="EnsureSidecar" tp:name-for-bindings="Ensure_Sidecar"> + <tp:added version="0.27.3">(as stable API)</tp:added> + + <arg direction="in" name="Main_Interface" type="s" + tp:type="DBus_Interface"> + <tp:docstring> + The "primary" interface implemented by an object attached + to a connection. For example, a Gabble plugin implementing + fine-grained control of XEP-0016 privacy lists might expose an object + implementing <tt>com.example.PrivacyLists</tt>. + </tp:docstring> + </arg> + + <arg direction="out" name="Path" type="o"> + <tp:docstring>The object path of the sidecar, exported by the same bus + name as the Connection to which it is attached.</tp:docstring> + </arg> + <arg direction="out" name="Properties" type="a{sv}" + tp:type="Qualified_Property_Value_Map"> + <tp:docstring>Immutable properties of the sidecar.</tp:docstring> + </arg> + + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p>Request an object with a particular interface providing additional + connection-specific functionality, together with its immutable + properties. These will often be implemented by plug-ins to the + connection managers; for example, support for an XMPP XEP for which + no generic Telepathy interface exists might be implemented by a + Gabble plugin exposing a sidecar with a particular interface.</p> + + <p>This method may be called at any point during the lifetime of a + connection, even before its <tp:type>Connection_Status</tp:type> + changes to Connected. It MAY take a long time to + return—perhaps it needs to wait for a connection to be established + and for all the services supported by the server to be discovered + before determining whether necessary server-side support is + available—so callers SHOULD override the default method timeout (25 + seconds) with a much higher value (perhaps even MAX_INT32, meaning + “no timeout” in recent versions of libdbus).</p> + + <tp:rationale> + <p>There is an implicit assumption that any connection + manager plugin will only want to export one “primary” object per + feature it implements, since there is a one-to-one mapping between + interface and object. This is reasonable since Sidecars are + (intended to be) analogous to extra interfaces on the connection, + providing once-per-connection shared functionality; it also makes + client code straightforward (look up the interface you care about + in a dictionary, build a proxy object from the value). More + “plural” plugins are likely to want to implement new types of + <tp:dbus-ref + namespace="org.freedesktop.Telepathy">Channel</tp:dbus-ref> + instead.</p> + </tp:rationale> + </tp:docstring> + + <tp:error name="org.freedesktop.Telepathy.Error.NotImplemented"> + <tp:docstring> + The requested sidecar is not implemented by this connection manager, + or a necessary server-side component does not exist. (FIXME: split + these two errors out? Then again, once we list the guaranteed and + possible sidecars on a Protocol object, clients can tell the + difference themselves, because they shouldn't be calling this in the + first case.) + </tp:docstring> + </tp:error> + + <tp:error name="org.freedesktop.Telepathy.Error.ServiceBusy"> + <tp:docstring> + A server-side component needed by the requested sidecar reported it + is currently too busy, or did not respond for some + implementation-defined time. The caller may wish to try again later. + </tp:docstring> + </tp:error> + + <tp:error name="org.freedesktop.Telepathy.Error.Cancelled"> + <tp:docstring> + The connection was disconnected while the sidecar was being set up. + </tp:docstring> + </tp:error> + </method> + + </interface> +</node> diff --git a/spec/Makefile.am b/spec/Makefile.am index ea7899a07..711c07bb8 100644 --- a/spec/Makefile.am +++ b/spec/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = \ Channel.xml \ Channel_Dispatch_Operation.xml \ Channel_Dispatcher.xml \ + Channel_Dispatcher_Interface_Messages1.xml \ Channel_Dispatcher_Interface_Operation_List.xml \ Channel_Future.xml \ Channel_Handler.xml \ @@ -92,6 +93,7 @@ EXTRA_DIST = \ Connection_Interface_Contact_List.xml \ Connection_Interface_Contacts.xml \ Connection_Interface_Forwarding.xml \ + Connection_Interface_IRC_Command1.xml \ Connection_Interface_Keepalive.xml \ Connection_Interface_Location.xml \ Connection_Interface_Mail_Notification.xml \ @@ -102,6 +104,7 @@ EXTRA_DIST = \ Connection_Interface_Requests.xml \ Connection_Interface_Resources.xml \ Connection_Interface_Service_Point.xml \ + Connection_Interface_Sidecars1.xml \ Connection_Interface_Simple_Presence.xml \ Connection_Manager.xml \ Connection_Manager_Interface_Account_Storage.xml \ diff --git a/spec/all.xml b/spec/all.xml index e1c8647eb..e94eb0677 100644 --- a/spec/all.xml +++ b/spec/all.xml @@ -3,7 +3,7 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> <tp:title>Telepathy D-Bus Interface Specification</tp:title> -<tp:version>0.27.2</tp:version> +<tp:version>0.27.3</tp:version> <tp:copyright>Copyright © 2005-2012 Collabora Limited</tp:copyright> <tp:copyright>Copyright © 2005-2011 Nokia Corporation</tp:copyright> @@ -48,7 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ </p> </tp:docstring> <xi:include href="Connection.xml"/> - <xi:include href="Connection_Future.xml"/> <xi:include href="Connection_Interface_Contacts.xml"/> <xi:include href="Connection_Interface_Requests.xml"/> @@ -108,6 +107,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ <xi:include href="Connection_Interface_Mail_Notification.xml"/> <xi:include href="Connection_Interface_Power_Saving.xml"/> <xi:include href="Connection_Interface_Service_Point.xml"/> + <xi:include href="Connection_Interface_Sidecars1.xml"/> + <xi:include href="Connection_Interface_IRC_Command1.xml"/> </tp:section> </tp:section> @@ -300,6 +301,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</ </p> </tp:docstring> <xi:include href="Channel_Dispatcher.xml"/> + <xi:include href="Channel_Dispatcher_Interface_Messages1.xml"/> <xi:include href="Channel_Dispatcher_Interface_Operation_List.xml"/> <xi:include href="Channel_Dispatch_Operation.xml"/> <xi:include href="Channel_Request.xml"/> diff --git a/telepathy-glib/abi.am b/telepathy-glib/abi.am index c0ae10f40..a503f5615 100644 --- a/telepathy-glib/abi.am +++ b/telepathy-glib/abi.am @@ -96,6 +96,9 @@ ABI_LISTS = \ versions/0.19.9.abi \ versions/0.19.10.abi \ versions/0.21.2.abi \ + versions/0.23.0.abi \ + versions/0.23.1.abi \ + versions/0.23.2.abi \ $(NULL) # The quoting here is unnecessary but harmless, and has the useful side-effect diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c index 5269a39f6..e32d64704 100644 --- a/telepathy-glib/account-channel-request.c +++ b/telepathy-glib/account-channel-request.c @@ -1000,34 +1000,59 @@ delegated_channels_cb (TpBaseClient *client, self->priv->delegated_channel_data); } -static void -request_and_handle_channel_async (TpAccountChannelRequest *self, +static gboolean +going_to_request (TpAccountChannelRequest *self, + ActionType action_type, + gboolean ensure, GCancellable *cancellable, GAsyncReadyCallback callback, - gpointer user_data, - gboolean ensure) + gpointer user_data) { - GError *error = NULL; - TpChannelDispatcher *cd; - - g_return_if_fail (!self->priv->requested); + g_return_val_if_fail (!self->priv->requested, FALSE); self->priv->requested = TRUE; - self->priv->action_type = ACTION_TYPE_HANDLE; + self->priv->action_type = action_type; if (g_cancellable_is_cancelled (cancellable)) { g_simple_async_report_error_in_idle (G_OBJECT (self), callback, user_data, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Operation has been cancelled"); - - return; + return FALSE; } if (cancellable != NULL) self->priv->cancellable = g_object_ref (cancellable); + self->priv->ensure = ensure; + /* Set TargetHandleType: TP_HANDLE_TYPE_NONE if no TargetHandleType has been + * defined. */ + if (g_hash_table_lookup (self->priv->request, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE) == NULL) + { + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_TARGET_HANDLE_TYPE), + tp_g_value_slice_new_uint (TP_HANDLE_TYPE_NONE)); + } + + return TRUE; +} + +static void +request_and_handle_channel_async (TpAccountChannelRequest *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data, + gboolean ensure) +{ + GError *error = NULL; + TpChannelDispatcher *cd; + + if (!going_to_request (self, ACTION_TYPE_HANDLE, ensure, cancellable, + callback, user_data)) + return; + /* Create a temp handler */ self->priv->handler = tp_simple_handler_new_with_factory ( tp_proxy_get_factory (self->priv->account), TRUE, FALSE, @@ -1293,23 +1318,9 @@ request_channel_async (TpAccountChannelRequest *self, { TpChannelDispatcher *cd; - g_return_if_fail (!self->priv->requested); - self->priv->requested = TRUE; - - self->priv->action_type = ACTION_TYPE_FORGET; - - if (g_cancellable_is_cancelled (cancellable)) - { - g_simple_async_report_error_in_idle (G_OBJECT (self), callback, - user_data, G_IO_ERROR, G_IO_ERROR_CANCELLED, - "Operation has been cancelled"); - - return; - } - - if (cancellable != NULL) - self->priv->cancellable = g_object_ref (cancellable); - self->priv->ensure = ensure; + if (!going_to_request (self, ACTION_TYPE_FORGET, ensure, cancellable, + callback, user_data)) + return; cd = tp_channel_dispatcher_new (self->priv->dbus); @@ -1560,23 +1571,9 @@ request_and_observe_channel_async (TpAccountChannelRequest *self, { TpChannelDispatcher *cd; - g_return_if_fail (!self->priv->requested); - self->priv->requested = TRUE; - - self->priv->action_type = ACTION_TYPE_OBSERVE; - - if (g_cancellable_is_cancelled (cancellable)) - { - g_simple_async_report_error_in_idle (G_OBJECT (self), callback, - user_data, G_IO_ERROR, G_IO_ERROR_CANCELLED, - "Operation has been cancelled"); - - return; - } - - if (cancellable != NULL) - self->priv->cancellable = g_object_ref (cancellable); - self->priv->ensure = ensure; + if (!going_to_request (self, ACTION_TYPE_OBSERVE, ensure, cancellable, + callback, user_data)) + return; cd = tp_channel_dispatcher_new (self->priv->dbus); @@ -2390,3 +2387,265 @@ tp_account_channel_request_set_file_transfer_initial_offset ( tp_g_value_slice_new_uint64 (offset)); } } + +/** + * tp_account_channel_request_set_file_transfer_hash: + * @self: a #TpAccountChannelRequest + * @hash_type: a type of @hash + * @hash: hash of the contents of the file transfer + * + * Configure this channel request to accompany the file transfer with + * the hash of the file. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: 0.23.2 + */ +void +tp_account_channel_request_set_file_transfer_hash ( + TpAccountChannelRequest *self, + TpFileHashType hash_type, + const gchar *hash) +{ + g_return_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self)); + g_return_if_fail (!self->priv->requested); + g_return_if_fail (hash_type < TP_NUM_FILE_HASH_TYPES); + + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE), + tp_g_value_slice_new_uint (hash_type)); + + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH), + tp_g_value_slice_new_string (hash)); +} + +/** + * tp_account_channel_request_new_stream_tube: + * @account: a #TpAccount + * @service: the service name that will be used over the tube. It should be a + * well-known TCP service name as defined by + * http://www.iana.org/assignments/port-numbers or + * http://www.dns-sd.org/ServiceTypes.html, for instance "rsync" or "daap". + * @user_action_time: the time of the user action that caused this request, + * or one of the special values %TP_USER_ACTION_TIME_NOT_USER_ACTION or + * %TP_USER_ACTION_TIME_CURRENT_TIME (see + * #TpAccountChannelRequest:user-action-time) + * + * Convenience function to create a new #TpAccountChannelRequest object, + * which will yield a StreamTube channel. + * + * After creating the request, you will also need to set the "target" + * of the channel by calling one of the following functions: + * + * - tp_account_channel_request_set_target_contact() + * - tp_account_channel_request_set_target_id() + * + * Returns: a new #TpAccountChannelRequest object + * + * Since: 0.23.2 + */ +TpAccountChannelRequest * +tp_account_channel_request_new_stream_tube (TpAccount *account, + const gchar *service, + gint64 user_action_time) +{ + TpAccountChannelRequest *self; + GHashTable *request; + + g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); + g_return_val_if_fail (!tp_str_empty (service), NULL); + + request = tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, + TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, service, + NULL); + + self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST, + "account", account, + "request", request, + "user-action-time", user_action_time, + NULL); + + g_hash_table_unref (request); + return self; +} + +/** + * tp_account_channel_request_new_dbus_tube: + * @account: a #TpAccount + * @service_name: the service name that will be used over the tube. It should be + * @user_action_time: the time of the user action that caused this request, + * or one of the special values %TP_USER_ACTION_TIME_NOT_USER_ACTION or + * %TP_USER_ACTION_TIME_CURRENT_TIME (see + * #TpAccountChannelRequest:user-action-time) + * + * Convenience function to create a new #TpAccountChannelRequest object, + * which will yield a DBusTube channel. + * + * After creating the request, you will also need to set the "target" + * of the channel by calling one of the following functions: + * + * - tp_account_channel_request_set_target_contact() + * - tp_account_channel_request_set_target_id() + * + * Returns: a new #TpAccountChannelRequest object + * + * Since: 0.23.2 + */ +TpAccountChannelRequest * +tp_account_channel_request_new_dbus_tube (TpAccount *account, + const gchar *service_name, + gint64 user_action_time) +{ + TpAccountChannelRequest *self; + GHashTable *request; + + g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); + g_return_val_if_fail (!tp_str_empty (service_name), NULL); + + request = tp_asv_new ( + TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, + TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, service_name, + NULL); + + self = g_object_new (TP_TYPE_ACCOUNT_CHANNEL_REQUEST, + "account", account, + "request", request, + "user-action-time", user_action_time, + NULL); + + g_hash_table_unref (request); + return self; +} + +/** + * tp_account_channel_request_set_sms_channel: + * @self: a #TpAccountChannelRequest + * @is_sms_channel: #TRUE if the channel should use SMS + * + * If @is_sms_channel is set to #TRUE, messages sent and received on the + * requested channel will be transmitted via SMS. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: 0.23.2 + */ +void +tp_account_channel_request_set_sms_channel (TpAccountChannelRequest *self, + gboolean is_sms_channel) +{ + g_return_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self)); + g_return_if_fail (!self->priv->requested); + + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL), + tp_g_value_slice_new_boolean (is_sms_channel)); +} + +/** + * tp_account_channel_request_set_conference_initial_channels: + * @self: a #TpAccountChannelRequest + * @channels: a #NULL-terminated array of channel paths + * + * Indicate that the channel which is going to be requested using @self + * is an upgrade of the channels whose object paths is listed in @channels. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: 0.23.2 + */ +void +tp_account_channel_request_set_conference_initial_channels ( + TpAccountChannelRequest *self, + const gchar * const * channels) +{ + GPtrArray *chans; + guint i; + + g_return_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self)); + g_return_if_fail (!self->priv->requested); + + chans = g_ptr_array_new (); + for (i = 0; channels != NULL && channels[i] != NULL; i++) + g_ptr_array_add (chans, (gpointer) channels[i]); + + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_CHANNELS), + tp_g_value_slice_new_boxed (TP_ARRAY_TYPE_OBJECT_PATH_LIST, chans)); + + g_ptr_array_unref (chans); +} + +/** + * tp_account_channel_request_set_initial_invitee_ids: + * @self: a #TpAccountChannelRequest + * @ids: a #NULL-terminated array of contact ids + * + * Indicate that the contacts listed in @ids have to be invited to the + * conference represented by the channel which is going to be requested + * using @self. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: 0.23.2 + */ +void +tp_account_channel_request_set_initial_invitee_ids ( + TpAccountChannelRequest *self, + const gchar * const * ids) +{ + g_return_if_fail (TP_IS_ACCOUNT_CHANNEL_REQUEST (self)); + g_return_if_fail (!self->priv->requested); + + g_hash_table_insert (self->priv->request, + g_strdup (TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS), + tp_g_value_slice_new_boxed (G_TYPE_STRV, ids)); +} + +/** + * tp_account_channel_request_set_initial_invitees: + * @self: a #TpAccountChannelRequest + * @contacts: (element-type TelepathyGLib.Contact): a #GPtrArray of #TpContact + * + * Indicate that the contacts listed in @contacts have to be invited to the + * conference represented by the channel which is going to be requested + * using @self. + * + * This function can't be called once @self has been used to request a + * channel. + * + * Since: 0.23.2 + */ +void +tp_account_channel_request_set_initial_invitees ( + TpAccountChannelRequest *self, + GPtrArray *contacts) +{ + guint i; + GPtrArray *ids; + + g_return_if_fail (contacts != NULL); + + ids = g_ptr_array_new (); + + for (i = 0; i < contacts->len; i++) + { + TpContact *contact = g_ptr_array_index (contacts, i); + + g_ptr_array_add (ids, (gchar *) tp_contact_get_identifier (contact)); + } + + g_ptr_array_add (ids, NULL); + + tp_account_channel_request_set_initial_invitee_ids (self, + (const gchar * const *) ids->pdata); + + g_ptr_array_unref (ids); +} diff --git a/telepathy-glib/account-channel-request.h b/telepathy-glib/account-channel-request.h index f05571417..45eea63bc 100644 --- a/telepathy-glib/account-channel-request.h +++ b/telepathy-glib/account-channel-request.h @@ -114,6 +114,10 @@ TpAccountChannelRequest *tp_account_channel_request_new_text ( TpAccount *account, gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT; +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_sms_channel (TpAccountChannelRequest *self, + gboolean is_sms_channel); + /* Calls */ _TP_AVAILABLE_IN_0_20 @@ -152,6 +156,43 @@ void tp_account_channel_request_set_file_transfer_initial_offset ( TpAccountChannelRequest *self, guint64 offset); +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_file_transfer_hash ( + TpAccountChannelRequest *self, + TpFileHashType hash_type, + const gchar *hash); + +/* Tube */ + +_TP_AVAILABLE_IN_0_24 +TpAccountChannelRequest *tp_account_channel_request_new_stream_tube ( + TpAccount *account, + const gchar *service, + gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT; + +_TP_AVAILABLE_IN_0_24 +TpAccountChannelRequest *tp_account_channel_request_new_dbus_tube ( + TpAccount *account, + const gchar *service_name, + gint64 user_action_time) G_GNUC_WARN_UNUSED_RESULT; + +/* Conference */ + +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_conference_initial_channels ( + TpAccountChannelRequest *self, + const gchar * const * channels); + +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_initial_invitee_ids ( + TpAccountChannelRequest *self, + const gchar * const * ids); + +_TP_AVAILABLE_IN_0_24 +void tp_account_channel_request_set_initial_invitees ( + TpAccountChannelRequest *self, + GPtrArray *contacts); + /* Channel target (shared between all channel types) */ _TP_AVAILABLE_IN_0_20 diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c index 8a121a42b..b77e827d9 100644 --- a/telepathy-glib/account-manager.c +++ b/telepathy-glib/account-manager.c @@ -1221,7 +1221,7 @@ tp_account_manager_set_all_requested_presences (TpAccountManager *manager, { TpAccount *account = TP_ACCOUNT (value); - if (tp_account_is_prepared (account, TP_ACCOUNT_FEATURE_CORE)) + if (tp_proxy_is_prepared (account, TP_ACCOUNT_FEATURE_CORE)) tp_account_request_presence_async (account, type, status, message, NULL, NULL); } @@ -1463,6 +1463,7 @@ tp_account_manager_create_account_finish (TpAccountManager *manager, * Returns: the same thing as tp_proxy_is_prepared() * * Since: 0.9.0 + * Deprecated: since 0.23.0, use tp_proxy_is_prepared() instead. */ gboolean tp_account_manager_is_prepared (TpAccountManager *manager, diff --git a/telepathy-glib/account-manager.h b/telepathy-glib/account-manager.h index 8c52f10ed..6b324c786 100644 --- a/telepathy-glib/account-manager.h +++ b/telepathy-glib/account-manager.h @@ -121,10 +121,11 @@ TpAccount * tp_account_manager_create_account_finish ( TpAccountManager *manager, GAsyncResult *result, GError **error) G_GNUC_WARN_UNUSED_RESULT; +#ifndef TP_DISABLE_DEPRECATED +_TP_DEPRECATED_IN_0_24_FOR(tp_proxy_is_prepared) gboolean tp_account_manager_is_prepared (TpAccountManager *manager, GQuark feature); -#ifndef TP_DISABLE_DEPRECATED _TP_DEPRECATED_IN_0_16_FOR (tp_proxy_prepare_async) void tp_account_manager_prepare_async (TpAccountManager *manager, const GQuark *features, diff --git a/telepathy-glib/account-request.c b/telepathy-glib/account-request.c index 474883908..e1afdc922 100644 --- a/telepathy-glib/account-request.c +++ b/telepathy-glib/account-request.c @@ -1057,7 +1057,7 @@ tp_account_request_add_supersedes (TpAccountRequest *self, /** * tp_account_request_set_avatar: * @self: a #TpAccountRequest - * @avatar: (allow-none) (array length=len) a new avatar to set; can + * @avatar: (allow-none) (array length=len): a new avatar to set; can * be %NULL only if %len equals 0 * @len: the length of the new avatar * @mime_type: (allow-none): the MIME type of the new avatar; can be %NULL diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index 24dbd001a..07a2af026 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -149,6 +149,7 @@ G_DEFINE_TYPE (TpAccount, tp_account, TP_TYPE_PROXY) enum { STATUS_CHANGED, PRESENCE_CHANGED, + AVATAR_CHANGED, LAST_SIGNAL }; @@ -631,6 +632,8 @@ _tp_account_update (TpAccount *account, TpConnectionStatus old_s = priv->connection_status; gboolean status_changed = FALSE; gboolean presence_changed = FALSE; + const gchar *status; + const gchar *message; tp_proxy_add_interfaces (proxy, tp_asv_get_strv (properties, "Interfaces")); @@ -721,29 +724,30 @@ _tp_account_update (TpAccount *account, presence_changed = TRUE; arr = tp_asv_get_boxed (properties, "CurrentPresence", TP_STRUCT_TYPE_SIMPLE_PRESENCE); - priv->cur_presence = g_value_get_uint (g_value_array_get_nth (arr, 0)); + tp_value_array_unpack (arr, 3, + &priv->cur_presence, + &status, + &message); g_free (priv->cur_status); - priv->cur_status = g_value_dup_string (g_value_array_get_nth (arr, 1)); - + priv->cur_status = g_strdup (status); g_free (priv->cur_message); - priv->cur_message = g_value_dup_string (g_value_array_get_nth (arr, 2)); + priv->cur_message = g_strdup (message); } if (g_hash_table_lookup (properties, "RequestedPresence") != NULL) { arr = tp_asv_get_boxed (properties, "RequestedPresence", TP_STRUCT_TYPE_SIMPLE_PRESENCE); - priv->requested_presence = - g_value_get_uint (g_value_array_get_nth (arr, 0)); + tp_value_array_unpack (arr, 3, + &priv->requested_presence, + &status, + &message); g_free (priv->requested_status); - priv->requested_status = - g_value_dup_string (g_value_array_get_nth (arr, 1)); - + priv->requested_status = g_strdup (status); g_free (priv->requested_message); - priv->requested_message = - g_value_dup_string (g_value_array_get_nth (arr, 2)); + priv->requested_message = g_strdup (message); g_object_notify (G_OBJECT (account), "requested-presence-type"); g_object_notify (G_OBJECT (account), "requested-status"); @@ -754,16 +758,15 @@ _tp_account_update (TpAccount *account, { arr = tp_asv_get_boxed (properties, "AutomaticPresence", TP_STRUCT_TYPE_SIMPLE_PRESENCE); - priv->auto_presence = - g_value_get_uint (g_value_array_get_nth (arr, 0)); + tp_value_array_unpack (arr, 3, + &priv->auto_presence, + &status, + &message); g_free (priv->auto_status); - priv->auto_status = - g_value_dup_string (g_value_array_get_nth (arr, 1)); - + priv->auto_status = g_strdup (status); g_free (priv->auto_message); - priv->auto_message = - g_value_dup_string (g_value_array_get_nth (arr, 2)); + priv->auto_message = g_strdup (message); g_object_notify (G_OBJECT (account), "automatic-presence-type"); g_object_notify (G_OBJECT (account), "automatic-status"); @@ -1005,6 +1008,14 @@ _tp_account_properties_changed (TpAccount *proxy, } static void +avatar_changed_cb (TpAccount *self, + gpointer user_data, + GObject *weak_object) +{ + g_signal_emit (self, signals[AVATAR_CHANGED], 0); +} + +static void _tp_account_got_all_cb (TpProxy *proxy, GHashTable *properties, const GError *error, @@ -1025,6 +1036,11 @@ _tp_account_got_all_cb (TpProxy *proxy, } _tp_account_update (self, properties); + + /* We can't try connecting this signal earlier as tp_proxy_add_interfaces() + * has to be called first if we support the Avatar interface. */ + tp_cli_account_interface_avatar_connect_to_avatar_changed (self, + avatar_changed_cb, NULL, NULL, G_OBJECT (self), NULL); } static void @@ -2148,6 +2164,22 @@ tp_account_class_init (TpAccountClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); + /** + * TpAccount::avatar-changed: + * @self: a #TpAccount + * + * Emitted when the avatar changes. Call tp_account_get_avatar_async() + * to get the new avatar data. + * + * Since: 0.23.0 + */ + signals[AVATAR_CHANGED] = g_signal_new ("avatar-changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, + 0); + proxy_class->interface = TP_IFACE_QUARK_ACCOUNT; proxy_class->list_features = _tp_account_list_features; tp_account_init_known_interfaces (); @@ -3551,8 +3583,6 @@ _tp_account_got_avatar_cb (TpProxy *proxy, GObject *weak_object) { GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); - GValueArray *avatar; - GArray *res; if (error != NULL) { @@ -3567,8 +3597,18 @@ _tp_account_got_avatar_cb (TpProxy *proxy, } else { + GValueArray *avatar; + GArray *res; + const GArray *tmp; + const gchar *mime_type; + avatar = g_value_get_boxed (out_Value); - res = g_value_dup_boxed (g_value_array_get_nth (avatar, 0)); + tp_value_array_unpack (avatar, 2, + &tmp, + &mime_type); + + res = g_array_sized_new (FALSE, FALSE, 1, tmp->len); + g_array_append_vals (res, tmp->data, tmp->len); g_simple_async_result_set_op_res_gpointer (result, res, (GDestroyNotify) g_array_unref); } @@ -3641,6 +3681,7 @@ tp_account_get_avatar_finish (TpAccount *account, * Returns: the same thing as tp_proxy_is_prepared() * * Since: 0.9.0 + * Deprecated: since 0.23.0, use tp_proxy_is_prepared() instead. */ gboolean tp_account_is_prepared (TpAccount *account, diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h index faf2492a2..253eaba45 100644 --- a/telepathy-glib/account.h +++ b/telepathy-glib/account.h @@ -250,7 +250,10 @@ void tp_account_get_avatar_async (TpAccount *account, const GArray *tp_account_get_avatar_finish (TpAccount *account, GAsyncResult *result, GError **error); +#ifndef TP_DISABLE_DEPRECATED +_TP_DEPRECATED_IN_0_24_FOR(tp_proxy_is_prepared) gboolean tp_account_is_prepared (TpAccount *account, GQuark feature); +#endif #ifndef TP_DISABLE_DEPRECATED _TP_DEPRECATED_IN_0_16_FOR (tp_proxy_prepare_async) diff --git a/telepathy-glib/base-call-channel.c b/telepathy-glib/base-call-channel.c index 045a2b3df..b9d053caf 100644 --- a/telepathy-glib/base-call-channel.c +++ b/telepathy-glib/base-call-channel.c @@ -287,7 +287,7 @@ tp_base_call_channel_finalize (GObject *object) TpBaseCallChannel *self = TP_BASE_CALL_CHANNEL (object); g_hash_table_unref (self->priv->details); - g_value_array_free (self->priv->reason); + tp_value_array_free (self->priv->reason); g_free (self->priv->initial_audio_name); g_free (self->priv->initial_video_name); g_free (self->priv->initial_tones); @@ -761,7 +761,7 @@ tp_base_call_channel_flags_changed (TpBaseCallChannel *self, const gchar *dbus_reason, const gchar *message) { - g_value_array_free (self->priv->reason); + tp_value_array_free (self->priv->reason); self->priv->reason = _tp_base_call_state_reason_new (actor_handle, reason, dbus_reason, message); @@ -806,7 +806,7 @@ tp_base_call_channel_set_state (TpBaseCallChannel *self, old_state = self->priv->state; self->priv->state = state; - g_value_array_free (self->priv->reason); + tp_value_array_free (self->priv->reason); self->priv->reason = _tp_base_call_state_reason_new (actor_handle, reason, dbus_reason, message); @@ -1021,7 +1021,7 @@ tp_base_call_channel_remove_content (TpBaseCallChannel *self, _tp_base_call_channel_remove_content_internal (self, content, reason_array); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); } /** @@ -1151,7 +1151,7 @@ tp_base_call_channel_update_member_flags (TpBaseCallChannel *self, g_hash_table_unref (updates); g_hash_table_unref (identifiers); g_array_unref (empty_array); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); } /** @@ -1203,7 +1203,7 @@ tp_base_call_channel_remove_member (TpBaseCallChannel *self, g_hash_table_unref (empty_table); g_array_unref (removed); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); } /** diff --git a/telepathy-glib/base-call-content.c b/telepathy-glib/base-call-content.c index 2f572c5f7..89e263bf2 100644 --- a/telepathy-glib/base-call-content.c +++ b/telepathy-glib/base-call-content.c @@ -751,7 +751,7 @@ tp_base_call_content_remove_stream (TpBaseCallContent *self, _tp_base_call_content_remove_stream_internal (self, stream, reason_array); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); } static void diff --git a/telepathy-glib/base-call-stream.c b/telepathy-glib/base-call-stream.c index f4d72dbdf..415e0ef88 100644 --- a/telepathy-glib/base-call-stream.c +++ b/telepathy-glib/base-call-stream.c @@ -573,7 +573,7 @@ tp_base_call_stream_update_local_sending_state (TpBaseCallStream *self, tp_svc_call_stream_emit_local_sending_state_changed ( TP_SVC_CALL_STREAM (self), new_state, reason_array); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); return TRUE; } @@ -677,7 +677,7 @@ tp_base_call_stream_update_remote_sending_state (TpBaseCallStream *self, removed_empty, reason_array); g_array_unref (removed_empty); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); g_hash_table_unref (updates); g_hash_table_unref (identifiers); @@ -732,7 +732,7 @@ tp_base_call_stream_remove_member (TpBaseCallStream *self, tp_svc_call_stream_emit_remote_members_changed (self, empty_table, empty_table, removed_array, reason_array); - g_value_array_free (reason_array); + tp_value_array_free (reason_array); g_hash_table_unref (empty_table); g_array_unref (removed_array); diff --git a/telepathy-glib/base-connection-manager.c b/telepathy-glib/base-connection-manager.c index 662db9962..a533bb2bc 100644 --- a/telepathy-glib/base-connection-manager.c +++ b/telepathy-glib/base-connection-manager.c @@ -956,7 +956,7 @@ tp_base_connection_manager_get_parameters (TpSvcConnectionManager *iface, for (i = 0; i < ret->len; i++) { - g_value_array_free (g_ptr_array_index (ret, i)); + tp_value_array_free (g_ptr_array_index (ret, i)); } g_ptr_array_unref (ret); diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index 20a79b8c0..483e4cc61 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -291,6 +291,7 @@ enum PROP_DBUS_STATUS, PROP_DBUS_DAEMON, PROP_HAS_IMMORTAL_HANDLES, + PROP_ACCOUNT_PATH_SUFFIX, N_PROPS }; @@ -441,6 +442,8 @@ struct _TpBaseConnectionPrivate /* GQuark iface => GHashTable { * unique name borrowed from interested_clients => gsize count } */ GHashTable *client_interests; + + gchar *account_path_suffix; }; static const gchar * const *tp_base_connection_get_interfaces ( @@ -500,6 +503,10 @@ tp_base_connection_get_property (GObject *object, g_value_set_boolean (value, TRUE); break; + case PROP_ACCOUNT_PATH_SUFFIX: + g_value_set_string (value, self->priv->account_path_suffix); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -537,6 +544,11 @@ tp_base_connection_set_property (GObject *object, } break; + case PROP_ACCOUNT_PATH_SUFFIX: + g_assert (self->priv->account_path_suffix == NULL); /* construct-only */ + self->priv->account_path_suffix = g_value_dup_string (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -637,6 +649,7 @@ tp_base_connection_finalize (GObject *object) g_free (self->object_path); g_hash_table_unref (priv->client_interests); g_hash_table_unref (priv->interested_clients); + g_free (priv->account_path_suffix); G_OBJECT_CLASS (tp_base_connection_parent_class)->finalize (object); } @@ -728,7 +741,7 @@ exportable_channel_get_old_info (TpExportableChannel *channel, static GValueArray * get_channel_details (GObject *obj) { - GValueArray *structure = g_value_array_new (2); + GValueArray *structure; GHashTable *table; GValue *value; gchar *object_path; @@ -737,12 +750,6 @@ get_channel_details (GObject *obj) "object-path", &object_path, NULL); - g_value_array_append (structure, NULL); - value = g_value_array_get_nth (structure, 0); - g_value_init (value, DBUS_TYPE_G_OBJECT_PATH); - g_value_take_boxed (value, object_path); - object_path = NULL; - g_assert (TP_IS_EXPORTABLE_CHANNEL (obj) || TP_IS_CHANNEL_IFACE (obj)); if (TP_IS_EXPORTABLE_CHANNEL (obj)) @@ -769,10 +776,13 @@ get_channel_details (GObject *obj) g_hash_table_insert (table, TP_PROP_CHANNEL_CHANNEL_TYPE, value); } - g_value_array_append (structure, NULL); - value = g_value_array_get_nth (structure, 1); - g_value_init (value, TP_HASH_TYPE_QUALIFIED_PROPERTY_VALUE_MAP); - g_value_take_boxed (value, table); + structure = tp_value_array_build (2, + DBUS_TYPE_G_OBJECT_PATH, object_path, + TP_HASH_TYPE_QUALIFIED_PROPERTY_VALUE_MAP, table, + G_TYPE_INVALID); + + g_free (object_path); + g_hash_table_unref (table); return structure; } @@ -941,7 +951,7 @@ factory_satisfy_requests (TpBaseConnection *conn, g_ptr_array_add (array, get_channel_details (G_OBJECT (chan))); tp_svc_connection_interface_requests_emit_new_channels (conn, array); - g_value_array_free (g_ptr_array_index (array, 0)); + tp_value_array_free (g_ptr_array_index (array, 0)); g_ptr_array_unref (array); tp_svc_connection_emit_new_channel (conn, object_path, channel_type, @@ -1176,7 +1186,7 @@ manager_new_channels_cb (TpChannelManager *manager, tp_svc_connection_interface_requests_emit_new_channels (self, array); - g_ptr_array_foreach (array, (GFunc) g_value_array_free, NULL); + g_ptr_array_foreach (array, (GFunc) tp_value_array_free, NULL); g_ptr_array_unref (array); /* Emit NewChannel */ @@ -1458,20 +1468,11 @@ get_requestables_foreach (TpChannelManager *manager, gpointer user_data) { GPtrArray *details = user_data; - GValueArray *requestable = g_value_array_new (2); - GValue *value; - - g_value_array_append (requestable, NULL); - value = g_value_array_get_nth (requestable, 0); - g_value_init (value, TP_HASH_TYPE_CHANNEL_CLASS); - g_value_set_boxed (value, fixed_properties); - g_value_array_append (requestable, NULL); - value = g_value_array_get_nth (requestable, 1); - g_value_init (value, G_TYPE_STRV); - g_value_set_boxed (value, allowed_properties); - - g_ptr_array_add (details, requestable); + g_ptr_array_add (details, tp_value_array_build (2, + TP_HASH_TYPE_CHANNEL_CLASS, fixed_properties, + G_TYPE_STRV, allowed_properties, + G_TYPE_INVALID)); } @@ -1680,6 +1681,27 @@ tp_base_connection_class_init (TpBaseConnectionClass *klass) g_object_class_install_property (object_class, PROP_HAS_IMMORTAL_HANDLES, param_spec); + /** + * TpBaseConnection:account-path-suffix: + * + * The suffix of the account object path such as + * "gabble/jabber/chris_40example_2ecom0" for the account whose object path is + * %TP_ACCOUNT_OBJECT_PATH_BASE + "gabble/jabber/chris_40example_2ecom0". + * The same as returned by tp_account_get_path_suffix(). + * + * It is given by the AccountManager in the connection parameters. Or %NULL if + * the ConnectionManager or the AccountManager are too old. + * + * Since: 0.23.2 + */ + param_spec = g_param_spec_string ("account-path-suffix", + "Account path suffix", + "The suffix of the account path", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_ACCOUNT_PATH_SUFFIX, + param_spec); + /* signal definitions */ /** @@ -4106,3 +4128,21 @@ tp_base_connection_get_object_path (TpBaseConnection *self) return self->object_path; } + +/** + * tp_base_connection_get_account_path_suffix: + * @self: the connection + * + * <!-- --> + * + * Returns: the same value has the #TpBaseConnection:account-path-suffix + * property. + * Since: 0.23.2 + */ +const gchar * +tp_base_connection_get_account_path_suffix (TpBaseConnection *self) +{ + g_return_val_if_fail (TP_IS_BASE_CONNECTION (self), NULL); + + return self->priv->account_path_suffix; +} diff --git a/telepathy-glib/base-connection.h b/telepathy-glib/base-connection.h index 264f64213..f4c16eaf1 100644 --- a/telepathy-glib/base-connection.h +++ b/telepathy-glib/base-connection.h @@ -241,6 +241,10 @@ void tp_base_connection_add_client_interest (TpBaseConnection *self, void tp_base_connection_add_possible_client_interest (TpBaseConnection *self, GQuark token); +_TP_AVAILABLE_IN_0_24 +const gchar *tp_base_connection_get_account_path_suffix ( + TpBaseConnection *self); + G_END_DECLS #endif /* #ifndef __TP_BASE_CONNECTION_H__*/ diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c index d24e5ce2d..d66717b2c 100644 --- a/telepathy-glib/base-contact-list.c +++ b/telepathy-glib/base-contact-list.c @@ -2129,7 +2129,7 @@ tp_base_contact_list_contacts_changed_internal (TpBaseContactList *self, store = tp_intset_new (); changes = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); change_ids = g_hash_table_new (NULL, NULL); if (changed != NULL) diff --git a/telepathy-glib/base-media-call-stream.c b/telepathy-glib/base-media-call-stream.c index b0cf3667d..94b11992f 100644 --- a/telepathy-glib/base-media-call-stream.c +++ b/telepathy-glib/base-media-call-stream.c @@ -235,7 +235,7 @@ tp_base_media_call_stream_init (TpBaseMediaCallStream *self) TP_TYPE_BASE_MEDIA_CALL_STREAM, TpBaseMediaCallStreamPrivate); self->priv->local_candidates = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); self->priv->username = g_strdup (""); self->priv->password = g_strdup (""); self->priv->receiving_requests = tp_intset_new (); @@ -1392,7 +1392,7 @@ tp_base_media_call_stream_set_credentials (TpSvcCallStreamInterfaceMedia *iface, tp_clear_pointer (&self->priv->local_candidates, g_ptr_array_unref); self->priv->local_candidates = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); g_object_notify (G_OBJECT (self), "local-candidates"); g_object_notify (G_OBJECT (self), "local-credentials"); @@ -1439,8 +1439,10 @@ tp_base_media_call_stream_add_candidates (TpSvcCallStreamInterfaceMedia *iface, { GValueArray *c = g_ptr_array_index (accepted_candidates, i); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_ptr_array_add (self->priv->local_candidates, g_value_array_copy (c)); + G_GNUC_END_IGNORE_DEPRECATIONS } tp_svc_call_stream_interface_media_emit_local_candidates_added (self, diff --git a/telepathy-glib/base-protocol.c b/telepathy-glib/base-protocol.c index 926cdcdb9..3f16449f0 100644 --- a/telepathy-glib/base-protocol.c +++ b/telepathy-glib/base-protocol.c @@ -964,7 +964,7 @@ protocol_prop_presence_getter (GObject *object, tp_base_protocol_get_statuses (self); GHashTable *ret = g_hash_table_new_full ( g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_value_array_free); + g_free, (GDestroyNotify) tp_value_array_free); for (; status->name != NULL; status++) { diff --git a/telepathy-glib/call-content-media-description.c b/telepathy-glib/call-content-media-description.c index bc8339c85..bd6b20557 100644 --- a/telepathy-glib/call-content-media-description.c +++ b/telepathy-glib/call-content-media-description.c @@ -157,12 +157,12 @@ tp_call_content_media_description_init (TpCallContentMediaDescription *self) self->priv->ssrcs = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_array_unref); self->priv->codecs = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); self->priv->header_extensions = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); self->priv->feedback_messages = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); } static void @@ -922,7 +922,7 @@ ensure_rtcp_feedback_properties (TpCallContentMediaDescription *self, if (properties == NULL) { messages_array = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); properties = tp_value_array_build (2, G_TYPE_UINT, G_MAXUINT, G_TYPE_PTR_ARRAY, messages_array, @@ -975,7 +975,9 @@ tp_call_content_media_description_add_rtcp_feedback_message ( g_return_if_fail (TP_IS_CALL_CONTENT_MEDIA_DESCRIPTION (self)); properties = ensure_rtcp_feedback_properties (self, codec_identifier); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (properties, 1); + G_GNUC_END_IGNORE_DEPRECATIONS messages_array = g_value_get_boxed (value); g_ptr_array_add (messages_array, tp_value_array_build (3, @@ -1022,7 +1024,9 @@ tp_call_content_media_description_set_rtcp_feedback_minimum_interval ( g_return_if_fail (TP_IS_CALL_CONTENT_MEDIA_DESCRIPTION (self)); properties = ensure_rtcp_feedback_properties (self, codec_identifier); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (properties, 0); + G_GNUC_END_IGNORE_DEPRECATIONS g_value_set_uint (value, rtcp_minimum_interval); tp_call_content_media_description_add_rtcp_feedback_interface (self); diff --git a/telepathy-glib/call-stream-endpoint.c b/telepathy-glib/call-stream-endpoint.c index 2f87d2d3f..b62460197 100644 --- a/telepathy-glib/call-stream-endpoint.c +++ b/telepathy-glib/call-stream-endpoint.c @@ -134,9 +134,9 @@ tp_call_stream_endpoint_init (TpCallStreamEndpoint *self) self->priv->username = g_strdup (""); self->priv->password = g_strdup (""); self->priv->remote_candidates = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); self->priv->selected_candidate_pairs = g_ptr_array_new_with_free_func ( - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); self->priv->endpoint_state = g_hash_table_new (NULL, NULL); } @@ -583,8 +583,10 @@ tp_call_stream_endpoint_add_new_candidates (TpCallStreamEndpoint *self, { GValueArray *c = g_ptr_array_index (candidates, i); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_ptr_array_add (self->priv->remote_candidates, g_value_array_copy (c)); + G_GNUC_END_IGNORE_DEPRECATIONS } tp_svc_call_stream_endpoint_emit_remote_candidates_added (self, @@ -681,7 +683,10 @@ validate_candidate (const GValueArray *candidate, return FALSE; } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth ((GValueArray *) candidate, 0); + G_GNUC_END_IGNORE_DEPRECATIONS + if (g_value_get_uint (value) >= TP_NUM_STREAM_COMPONENTS) { g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, @@ -689,7 +694,10 @@ validate_candidate (const GValueArray *candidate, return FALSE; } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth ((GValueArray *) candidate, 1); + G_GNUC_END_IGNORE_DEPRECATIONS + if (tp_str_empty (g_value_get_string (value))) { g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, @@ -697,7 +705,10 @@ validate_candidate (const GValueArray *candidate, return FALSE; } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth ((GValueArray *) candidate, 2); + G_GNUC_END_IGNORE_DEPRECATIONS + if (g_value_get_uint (value) > 65535) { g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, @@ -713,7 +724,9 @@ get_candidate_component (const GValueArray *candidate) { GValue *component_value; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS component_value = g_value_array_get_nth ((GValueArray *) candidate, 0); + G_GNUC_END_IGNORE_DEPRECATIONS return g_value_get_uint (component_value); } @@ -778,8 +791,10 @@ call_stream_endpoint_set_selected_candidate_pair (TpSvcCallStreamEndpoint *iface TpStreamComponent this_component; this_pair = g_ptr_array_index (self->priv->selected_candidate_pairs, i); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS this_component = get_candidate_component ( g_value_get_boxed (g_value_array_get_nth (this_pair, 0))); + G_GNUC_END_IGNORE_DEPRECATIONS if (this_component == component) { diff --git a/telepathy-glib/capabilities.c b/telepathy-glib/capabilities.c index 4ddf368f3..d4557b44a 100644 --- a/telepathy-glib/capabilities.c +++ b/telepathy-glib/capabilities.c @@ -322,11 +322,14 @@ supports_simple_channel (TpCapabilities *self, { GValueArray *arr = g_ptr_array_index (self->priv->classes, i); GHashTable *fixed; + const gchar * const *allowed; const gchar *chan_type; TpHandleType handle_type; gboolean valid; - fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); + tp_value_array_unpack (arr, 2, + &fixed, + &allowed); if (g_hash_table_size (fixed) != 2) continue; @@ -439,8 +442,9 @@ tp_capabilities_supports_sms (TpCapabilities *self) gboolean valid; guint nb_fixed_props; - fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); - allowed = g_value_get_boxed (g_value_array_get_nth (arr, 1)); + tp_value_array_unpack (arr, 2, + &fixed, + &allowed); handle_type = tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid); @@ -809,12 +813,15 @@ tp_capabilities_supports_tubes_common (TpCapabilities *self, { GValueArray *arr = g_ptr_array_index (self->priv->classes, i); GHashTable *fixed; + const gchar * const *allowed; const gchar *chan_type; TpHandleType handle_type; gboolean valid; guint nb_fixed_props = 2; - fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); + tp_value_array_unpack (arr, 2, + &fixed, + &allowed); chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE); if (tp_strdiff (chan_type, expected_channel_type)) diff --git a/telepathy-glib/channel-dispatcher.xml b/telepathy-glib/channel-dispatcher.xml index 82d6d63f6..265c1c799 100644 --- a/telepathy-glib/channel-dispatcher.xml +++ b/telepathy-glib/channel-dispatcher.xml @@ -5,6 +5,7 @@ <tp:title>Channel Dispatcher interfaces</tp:title> <xi:include href="../spec/Channel_Dispatcher.xml"/> +<xi:include href="../spec/Channel_Dispatcher_Interface_Messages1.xml"/> <xi:include href="../spec/Channel_Dispatcher_Interface_Operation_List.xml"/> </tp:spec> diff --git a/telepathy-glib/connection-contact-info.c b/telepathy-glib/connection-contact-info.c index b2008df00..0f2d6951c 100644 --- a/telepathy-glib/connection-contact-info.c +++ b/telepathy-glib/connection-contact-info.c @@ -581,7 +581,7 @@ tp_connection_set_contact_info_async (TpConnection *self, tp_cli_connection_interface_contact_info_call_set_contact_info (self, -1, contact_info, set_info_cb, result, g_object_unref, NULL); - g_ptr_array_foreach (contact_info, (GFunc) g_value_array_free, NULL); + g_ptr_array_foreach (contact_info, (GFunc) tp_value_array_free, NULL); g_ptr_array_unref (contact_info); } diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c index 2dd1c4ec8..8d77617c8 100644 --- a/telepathy-glib/connection-manager.c +++ b/telepathy-glib/connection-manager.c @@ -1789,20 +1789,36 @@ list_context_unref (_ListContext *list_context) } static void -tp_list_connection_managers_cm_prepared (GObject *source G_GNUC_UNUSED, - GAsyncResult *result G_GNUC_UNUSED, +tp_list_connection_managers_cm_prepared (GObject *source, + GAsyncResult *result, gpointer user_data) { _ListContext *list_context = user_data; + GError *error = NULL; + TpConnectionManager *cm = TP_CONNECTION_MANAGER (source); + + if (tp_proxy_prepare_finish (source, result, &error)) + { + DEBUG ("%s: prepared", cm->name); + } + else + { + DEBUG ("%s: failed to prepare, continuing: %s #%d: %s", cm->name, + g_quark_to_string (error->domain), error->code, error->message); + g_clear_error (&error); + /* other than that, ignore it - all we guarantee is that + * the CM is ready *if possible* */ + } - /* ignore the result here - all we guarantee is that the CM is ready - * *if possible* */ + list_context->cms_to_ready--; - if ((--list_context->cms_to_ready) == 0) + if (list_context->cms_to_ready == 0) { TpConnectionManager **cms; guint n_cms = list_context->arr->len; + DEBUG ("We've prepared as many as possible of %u CMs", n_cms); + g_assert (list_context->callback != NULL); g_ptr_array_add (list_context->arr, NULL); @@ -1819,6 +1835,11 @@ tp_list_connection_managers_cm_prepared (GObject *source G_GNUC_UNUSED, list_context->callback = NULL; } + else + { + DEBUG ("We still need to prepare %" G_GSIZE_FORMAT " CM(s)", + list_context->cms_to_ready); + } list_context_unref (list_context); } @@ -1832,17 +1853,27 @@ tp_list_connection_managers_got_names (TpDBusDaemon *bus_daemon, { _ListContext *list_context = user_data; const gchar * const *name_iter; + const gchar *method; + + if (list_context->getting_names) + method = "ListNames"; + else + method = "ListActivatableNames"; /* The TpProxy APIs we use guarantee this */ g_assert (weak_object != NULL || !list_context->had_weak_object); if (error != NULL) { + DEBUG ("%s failed: %s #%d: %s", method, + g_quark_to_string (error->domain), error->code, error->message); list_context->callback (NULL, 0, error, list_context->user_data, weak_object); return; } + DEBUG ("%s succeeded", method); + for (name_iter = names; name_iter != NULL && *name_iter != NULL; name_iter++) { const gchar *name; @@ -1853,6 +1884,7 @@ tp_list_connection_managers_got_names (TpDBusDaemon *bus_daemon, continue; name = *name_iter + list_context->base_len; + DEBUG (" found CM: %s", name); if (g_hash_table_lookup (list_context->table, name) == NULL) { @@ -1877,16 +1909,21 @@ tp_list_connection_managers_got_names (TpDBusDaemon *bus_daemon, list_context->cms_to_ready = list_context->arr->len; list_context->refcount += list_context->cms_to_ready; + DEBUG ("Total of %" G_GSIZE_FORMAT " CMs to be prepared", + list_context->cms_to_ready); + for (i = 0; i < list_context->cms_to_ready; i++) { TpConnectionManager *cm = g_ptr_array_index (list_context->arr, i); + DEBUG (" preparing %s", cm->name); tp_proxy_prepare_async (cm, NULL, tp_list_connection_managers_cm_prepared, list_context); } } else { + DEBUG ("Calling ListNames"); list_context->getting_names = TRUE; list_context->refcount++; tp_dbus_daemon_list_names (bus_daemon, 2000, @@ -1947,6 +1984,7 @@ tp_list_connection_managers (TpDBusDaemon *bus_daemon, g_object_add_weak_pointer (weak_object, &list_context->weak_object); } + DEBUG ("Calling ListActivatableNames"); tp_dbus_daemon_list_activatable_names (bus_daemon, 2000, tp_list_connection_managers_got_names, list_context, (GDestroyNotify) list_context_unref, weak_object); @@ -2563,6 +2601,28 @@ tp_connection_manager_param_get_dbus_signature ( } /** + * tp_connection_manager_param_dup_variant_type: + * @param: a parameter supported by a #TpConnectionManager + * + * <!-- --> + * + * Returns: (transfer full): the #GVariantType of the parameter + * Since: 0.23.1 + */ +GVariantType * +tp_connection_manager_param_dup_variant_type ( + const TpConnectionManagerParam *param) +{ + g_return_val_if_fail (param != NULL, NULL); + + /* this should have been checked when we created it */ + g_return_val_if_fail (g_variant_type_string_is_valid (param->dbus_signature), + NULL); + + return g_variant_type_new (param->dbus_signature); +} + +/** * tp_connection_manager_param_is_required: * @param: a parameter supported by a #TpConnectionManager * diff --git a/telepathy-glib/connection-manager.h b/telepathy-glib/connection-manager.h index ac89341c3..c472c24c3 100644 --- a/telepathy-glib/connection-manager.h +++ b/telepathy-glib/connection-manager.h @@ -204,6 +204,9 @@ gboolean tp_connection_manager_param_get_default ( _TP_AVAILABLE_IN_0_20 GVariant *tp_connection_manager_param_dup_default_variant ( const TpConnectionManagerParam *param); +_TP_AVAILABLE_IN_0_24 +GVariantType *tp_connection_manager_param_dup_variant_type ( + const TpConnectionManagerParam *param); void tp_connection_manager_init_known_interfaces (void); diff --git a/telepathy-glib/connection.xml b/telepathy-glib/connection.xml index c72fcb8af..95fceea43 100644 --- a/telepathy-glib/connection.xml +++ b/telepathy-glib/connection.xml @@ -19,6 +19,8 @@ <xi:include href="../spec/Connection_Interface_Contact_Groups.xml"/> <xi:include href="../spec/Connection_Interface_Contact_Info.xml"/> <xi:include href="../spec/Connection_Interface_Contact_List.xml"/> +<xi:include href="../spec/Connection_Interface_Renaming.xml"/> +<xi:include href="../spec/Connection_Interface_Sidecars1.xml"/> <xi:include href="../spec/Connection_Interface_Simple_Presence.xml"/> <xi:include href="../spec/Connection_Interface_Presence.xml"/> <xi:include href="../spec/Connection_Interface_Contacts.xml"/> diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index af81bf4fa..20f4bf681 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -1633,6 +1633,22 @@ typedef struct _ContactsContext ContactsContext; typedef void (*ContactsProc) (ContactsContext *self); typedef enum { CB_BY_HANDLE, CB_BY_ID, CB_UPGRADE } ContactsSignature; +static const gchar * +contacts_signature_to_string (ContactsSignature sig) +{ + switch (sig) + { + case CB_BY_HANDLE: + return "by handle"; + case CB_BY_ID: + return "by ID"; + case CB_UPGRADE: + return "upgrade"; + default: + return "???"; + } +} + struct _ContactsContext { gsize refcount; @@ -1653,9 +1669,13 @@ struct _ContactsContext { /* ID => GError, NULL unless we started from IDs */ GHashTable *request_errors; - /* features we need before this request can finish */ + /* features we need to get, if possible, before this request can finish */ ContactFeatureFlags wanted; + /* features we can expect to get from GetContactAttributes + * (subset of wanted) */ + ContactFeatureFlags getting; + /* callback for when we've finished, plus the usual misc */ ContactsSignature signature; union { @@ -1711,6 +1731,32 @@ contacts_context_new (TpConnection *connection, { ContactsContext *c = g_slice_new0 (ContactsContext); + DEBUG ("%p, for %u contacts, %s", c, n_contacts, + contacts_signature_to_string (signature)); + + DEBUG ("want alias: %s", + (want_features & CONTACT_FEATURE_FLAG_ALIAS) ? "yes" : "no"); + DEBUG ("want avatar token: %s", + (want_features & CONTACT_FEATURE_FLAG_AVATAR_TOKEN) ? "yes" : "no"); + DEBUG ("want presence: %s", + (want_features & CONTACT_FEATURE_FLAG_PRESENCE) ? "yes" : "no"); + DEBUG ("want location: %s", + (want_features & CONTACT_FEATURE_FLAG_LOCATION) ? "yes" : "no"); + DEBUG ("want caps: %s", + (want_features & CONTACT_FEATURE_FLAG_CAPABILITIES) ? "yes" : "no"); + DEBUG ("want avatar data: %s", + (want_features & CONTACT_FEATURE_FLAG_AVATAR_DATA) ? "yes" : "no"); + DEBUG ("want contact info: %s", + (want_features & CONTACT_FEATURE_FLAG_CONTACT_INFO) ? "yes" : "no"); + DEBUG ("want client types: %s", + (want_features & CONTACT_FEATURE_FLAG_CLIENT_TYPES) ? "yes" : "no"); + DEBUG ("want states: %s", + (want_features & CONTACT_FEATURE_FLAG_STATES) ? "yes" : "no"); + DEBUG ("want contact groups: %s", + (want_features & CONTACT_FEATURE_FLAG_CONTACT_GROUPS) ? "yes" : "no"); + DEBUG ("want contact blocking: %s", + (want_features & CONTACT_FEATURE_FLAG_CONTACT_BLOCKING) ? "yes" : "no"); + c->refcount = 1; c->connection = g_object_ref (connection); c->contacts = g_ptr_array_sized_new (n_contacts); @@ -1740,6 +1786,8 @@ contacts_context_unref (gpointer p) if ((--c->refcount) > 0) return; + DEBUG ("last-unref (%p)", c); + g_assert (c->connection != NULL); tp_clear_object (&c->connection); @@ -1938,7 +1986,10 @@ static void contacts_context_continue (ContactsContext *c) { if (c->no_purpose_in_life) - return; + { + DEBUG ("%p: no purpose in life", c); + return; + } if (g_queue_is_empty (&c->todo)) { @@ -1946,6 +1997,8 @@ contacts_context_continue (ContactsContext *c) * library user */ guint i; + DEBUG ("%p: nothing more to do", c); + g_assert (c->contacts != NULL); g_assert (c->invalid != NULL); @@ -1987,12 +2040,13 @@ contacts_context_continue (ContactsContext *c) if (G_UNLIKELY (tp_proxy_get_invalidated (c->connection) != NULL)) { - DEBUG ("failing due to connection having been invalidated: %s", - tp_proxy_get_invalidated (c->connection)->message); + DEBUG ("%p: failing due to connection having been invalidated: %s", + c, tp_proxy_get_invalidated (c->connection)->message); contacts_context_fail (c, tp_proxy_get_invalidated (c->connection)); } else { + DEBUG ("%p: on to the next thing", c); next (c); } } @@ -2160,12 +2214,16 @@ contacts_inspected (TpConnection *connection, { guint i; + DEBUG ("%p: inspected %u handles", c, c->contacts->len); + for (i = 0; i < c->contacts->len; i++) { TpContact *contact = g_ptr_array_index (c->contacts, i); g_assert (ids[i] != NULL); + DEBUG ("- #%u: \"%s\"", contact->priv->handle, ids[i]); + if (contact->priv->identifier == NULL) { contact->priv->identifier = g_strdup (ids[i]); @@ -2797,23 +2855,23 @@ mime_file_written (GObject *source_object, WriteAvatarData *avatar_data = user_data; GFile *file = G_FILE (source_object); TpContact *self; - gchar *path; + gchar *path = g_file_get_path (file); g_assert (file == avatar_data->mime_file); - path = g_file_get_path (file); if (!g_file_replace_contents_finish (file, res, NULL, &error)) { - DEBUG ("Failed to store MIME type in cache (%s): %s", - path, error->message); + DEBUG ("Failed to store MIME type in cache (%s): %s", path, + error->message); g_clear_error (&error); } else { - DEBUG ("Contact avatar MIME type stored in cache: %s", - path); + DEBUG ("Contact avatar MIME type stored in cache: %s", path); } + g_free (path); + self = g_weak_ref_get (&avatar_data->contact); if (self == NULL) @@ -2849,7 +2907,6 @@ mime_file_written (GObject *source_object, } write_avatar_data_free (avatar_data); - g_free (path); } static void @@ -2899,6 +2956,15 @@ contact_avatar_retrieved (TpConnection *connection, gchar *mime_filename; WriteAvatarData *avatar_data; + DEBUG ("token '%s', %u bytes, MIME type '%s'", + token, avatar->len, mime_type); + + if (self == NULL) + DEBUG ("handle #%u is not associated with any TpContact", handle); + else + DEBUG ("used by contact #%u '%s'", handle, + tp_contact_get_identifier (self)); + if (self != NULL) { /* Update the avatar token if a newer one is given @@ -2908,7 +2974,10 @@ contact_avatar_retrieved (TpConnection *connection, if (!build_avatar_filename (connection, token, TRUE, &filename, &mime_filename)) - return; + { + DEBUG ("failed to set up cache"); + return; + } /* Save avatar in cache, even if the contact is unknown, to avoid as much as * possible future avatar requests */ @@ -3822,6 +3891,7 @@ static gboolean tp_contact_set_attributes (TpContact *contact, GHashTable *asv, ContactFeatureFlags wanted, + ContactFeatureFlags getting, GError **error) { TpConnection *connection = tp_contact_get_connection (contact); @@ -3841,6 +3911,23 @@ tp_contact_set_attributes (TpContact *contact, return FALSE; } + DEBUG ("#%u: \"%s\"", contact->priv->handle, s); + + { + GHashTableIter iter; + gpointer k, v; + + g_hash_table_iter_init (&iter, asv); + + while (g_hash_table_iter_next (&iter, &k, &v)) + { + gchar *str = g_strdup_value_contents (v); + + DEBUG ("- %s => %s", (const gchar *) k, str); + g_free (str); + } + } + if (contact->priv->identifier == NULL) { contact->priv->identifier = g_strdup (s); @@ -3864,9 +3951,12 @@ tp_contact_set_attributes (TpContact *contact, if (s == NULL) { - WARNING ("%s supposedly implements Contacts and Aliasing, but " - "omitted " TP_TOKEN_CONNECTION_INTERFACE_ALIASING_ALIAS, - tp_proxy_get_object_path (connection)); + if (getting & CONTACT_FEATURE_FLAG_ALIAS) + { + WARNING ("%s supposedly implements Contacts and Aliasing, but " + "omitted " TP_TOKEN_CONNECTION_INTERFACE_ALIASING_ALIAS, + tp_proxy_get_object_path (connection)); + } } else { @@ -3900,13 +3990,20 @@ tp_contact_set_attributes (TpContact *contact, TP_STRUCT_TYPE_SIMPLE_PRESENCE); if (boxed == NULL) - WARNING ("%s supposedly implements Contacts and SimplePresence, " - "but omitted the mandatory " - TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE - " attribute", - tp_proxy_get_object_path (connection)); + { + if (getting & CONTACT_FEATURE_FLAG_PRESENCE) + { + WARNING ("%s supposedly implements Contacts and SimplePresence, " + "but omitted the mandatory " + TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE + " attribute", + tp_proxy_get_object_path (connection)); + } + } else - contact_maybe_set_simple_presence (contact, boxed); + { + contact_maybe_set_simple_presence (contact, boxed); + } } /* Location */ @@ -4009,7 +4106,8 @@ _tp_contact_set_attributes (TpContact *contact, if (!get_feature_flags (n_features, features, &feature_flags)) return FALSE; - return tp_contact_set_attributes (contact, asv, feature_flags, error); + return tp_contact_set_attributes (contact, asv, feature_flags, + 0 /* can't know what we expected to get */, error); } static void @@ -4022,6 +4120,9 @@ contacts_got_attributes (TpConnection *connection, ContactsContext *c = user_data; guint i; + DEBUG ("%p: reply from GetContactAttributes: %s", + c, (error == NULL ? "OK" : error->message)); + if (error != NULL) { contacts_context_fail (c, error); @@ -4072,7 +4173,7 @@ contacts_got_attributes (TpConnection *connection, else { /* set up the contact with its attributes */ - tp_contact_set_attributes (contact, asv, c->wanted, &e); + tp_contact_set_attributes (contact, asv, c->wanted, c->getting, &e); } if (e != NULL) @@ -4088,7 +4189,8 @@ contacts_got_attributes (TpConnection *connection, static const gchar ** contacts_bind_to_signals (TpConnection *connection, - ContactFeatureFlags wanted) + ContactFeatureFlags wanted, + ContactFeatureFlags *getting) { GArray *contact_attribute_interfaces = connection->priv->contact_attribute_interfaces; @@ -4096,6 +4198,9 @@ contacts_bind_to_signals (TpConnection *connection, guint i; guint len = 0; + if (getting != NULL) + *getting = 0; + if (contact_attribute_interfaces != NULL) len = contact_attribute_interfaces->len; @@ -4115,6 +4220,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_ALIASING); contacts_bind_to_aliases_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_ALIAS; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS) @@ -4124,6 +4232,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_AVATARS); contacts_bind_to_avatar_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_AVATAR_TOKEN; } if ((wanted & CONTACT_FEATURE_FLAG_AVATAR_DATA) != 0) @@ -4138,6 +4249,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE); contacts_bind_to_presences_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_PRESENCE; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION) @@ -4147,6 +4261,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_LOCATION); contacts_bind_to_location_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_LOCATION; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_CAPABILITIES) @@ -4156,6 +4273,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES); contacts_bind_to_capabilities_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CAPABILITIES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO) @@ -4165,6 +4285,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO); contacts_bind_to_contact_info_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_INFO; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CLIENT_TYPES) @@ -4174,6 +4297,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES); contacts_bind_to_client_types_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CLIENT_TYPES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_LIST) @@ -4183,6 +4309,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST); contacts_bind_to_contacts_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_STATES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_GROUPS) @@ -4192,6 +4321,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS); contacts_bind_to_contact_groups_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_GROUPS; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING) @@ -4212,6 +4344,9 @@ contacts_bind_to_signals (TpConnection *connection, { tp_proxy_prepare_async (connection, features, NULL, NULL); } + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_BLOCKING; } } } @@ -4233,13 +4368,14 @@ _tp_contacts_bind_to_signals (TpConnection *connection, if (!get_feature_flags (n_features, features, &feature_flags)) return NULL; - return contacts_bind_to_signals (connection, feature_flags); + return contacts_bind_to_signals (connection, feature_flags, NULL); } static void contacts_get_attributes (ContactsContext *context) { const gchar **supported_interfaces; + guint i; /* tp_connection_get_contact_attributes insists that you have at least one * handle; skip it if we don't (can only happen if we started from IDs) */ @@ -4250,7 +4386,7 @@ contacts_get_attributes (ContactsContext *context) } supported_interfaces = contacts_bind_to_signals (context->connection, - context->wanted); + context->wanted, &context->getting); if (supported_interfaces[0] == NULL && !(context->signature == CB_BY_HANDLE && context->contacts->len == 0) && @@ -4267,6 +4403,11 @@ contacts_get_attributes (ContactsContext *context) /* The Hold parameter is only true if we started from handles, and we don't * already have all the contacts we need. */ context->refcount++; + DEBUG ("calling GetContactAttributes"); + + for (i = 0; supported_interfaces[i] != NULL; i++) + DEBUG ("- %s", supported_interfaces[i]); + tp_cli_connection_interface_contacts_call_get_contact_attributes ( context->connection, -1, context->handles, supported_interfaces, (context->signature == CB_BY_HANDLE && context->contacts->len == 0), @@ -4458,6 +4599,7 @@ tp_connection_get_contacts_by_handle (TpConnection *self, } /* if we haven't already returned, we're on the slow path */ + DEBUG ("slow path"); /* Before we return anything we'll want to inspect the handles */ g_queue_push_head (&context->todo, contacts_inspect); diff --git a/telepathy-glib/defs.h b/telepathy-glib/defs.h index 80d24c113..7531caf24 100644 --- a/telepathy-glib/defs.h +++ b/telepathy-glib/defs.h @@ -160,6 +160,7 @@ G_BEGIN_DECLS #define TP_VERSION_0_18 (_TP_ENCODE_VERSION (0, 18)) #define TP_VERSION_0_20 (_TP_ENCODE_VERSION (0, 20)) #define TP_VERSION_0_22 (_TP_ENCODE_VERSION (0, 22)) +#define TP_VERSION_0_24 (_TP_ENCODE_VERSION (0, 24)) #define TP_VERSION_1_0 (_TP_ENCODE_VERSION (1, 0)) #if (TP_MINOR_VERSION == 99) @@ -229,6 +230,14 @@ G_BEGIN_DECLS # define _TP_DEPRECATED_IN_0_22_FOR(f) /* nothing */ #endif +#if TP_VERSION_MIN_REQUIRED >= TP_VERSION_0_24 +# define _TP_DEPRECATED_IN_0_24 _TP_DEPRECATED +# define _TP_DEPRECATED_IN_0_24_FOR(f) _TP_DEPRECATED_FOR(f) +#else +# define _TP_DEPRECATED_IN_0_24 /* nothing */ +# define _TP_DEPRECATED_IN_0_24_FOR(f) /* nothing */ +#endif + #if TP_VERSION_MIN_REQUIRED >= TP_VERSION_1_0 # define _TP_DEPRECATED_IN_1_0 _TP_DEPRECATED # define _TP_DEPRECATED_IN_1_0_FOR(f) _TP_DEPRECATED_FOR(f) @@ -269,6 +278,12 @@ G_BEGIN_DECLS # define _TP_AVAILABLE_IN_0_22 /* nothing */ #endif +#if TP_VERSION_MAX_ALLOWED < TP_VERSION_0_24 +# define _TP_AVAILABLE_IN_0_24 _TP_UNAVAILABLE(0, 24) +#else +# define _TP_AVAILABLE_IN_0_24 /* nothing */ +#endif + #if TP_VERSION_MAX_ALLOWED < TP_VERSION_1_0 # define _TP_AVAILABLE_IN_1_0 _TP_UNAVAILABLE(1, 0) #else diff --git a/telepathy-glib/errors.c b/telepathy-glib/errors.c index bc045b5be..358f3130d 100644 --- a/telepathy-glib/errors.c +++ b/telepathy-glib/errors.c @@ -335,7 +335,6 @@ tp_error_quark (void) * "tp-error-quark" */ GQuark domain = g_quark_from_static_string ("tp_errors"); - g_type_init (); dbus_g_error_domain_register (domain, TP_ERROR_PREFIX, TP_TYPE_ERROR); g_once_init_leave (&quark, domain); diff --git a/telepathy-glib/extra-gtkdoc.h b/telepathy-glib/extra-gtkdoc.h index 6731a95e5..47b94a94e 100644 --- a/telepathy-glib/extra-gtkdoc.h +++ b/telepathy-glib/extra-gtkdoc.h @@ -471,6 +471,13 @@ */ /** + * TP_VERSION_0_24: (skip) + * + * A constant representing the telepathy-glib 0.24 stable branch, + * and the 0.23 development branch that led to it. + */ + +/** * TP_VERSION_1_0: (skip) * * A constant representing the telepathy-glib 1.0 stable branch, @@ -1191,3 +1198,26 @@ * * Since: 0.17.5 */ + +/** + * SECTION:connection-renaming + * @title: Connection Renaming interface + * @short_description: client-side wrappers for the Renaming interface + * @see_also: #TpConnection + * + * In IRC, and perhaps other protocols, users' unique identifiers can change. + * The Renaming interface models this. + */ + +/** + * SECTION:connection-sidecars + * @title: Connection Sidecars interface + * @short_description: client-side wrappers for the Sidecars interface + * @see_also: #TpConnection + * + * Some Telepathy connection managers have a plugin API, with plugins + * providing plugin-specific channel types and other D-Bus APIs. It is + * technically difficult for plugins to add interfaces analogous to Aliasing, + * Avatars etc. to a Connection. The Sidecars1 interface provides an + * alternative, by attaching plugin-provided interfaces to a secondary object. + */ diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c index d3067da90..f74a297e4 100644 --- a/telepathy-glib/file-transfer-channel.c +++ b/telepathy-glib/file-transfer-channel.c @@ -184,6 +184,7 @@ static void operation_failed (TpFileTransferChannel *self, GError *error) { + g_assert (self->priv->result != NULL); g_simple_async_result_take_error (self->priv->result, error); g_simple_async_result_complete_in_idle (self->priv->result); tp_clear_object (&self->priv->result); @@ -202,12 +203,11 @@ stream_close_cb (GObject *source, { DEBUG ("Failed to close stream: %s\n", error->message); g_clear_error (&error); - /* Don't fail the accept/provide operation as this is just a - * close operation. */ } /* Now that this is closed in both ways, let's just remove it. */ g_clear_object (&self->priv->stream); + g_object_unref (self); } static void @@ -222,13 +222,13 @@ splice_stream_ready_cb (GObject *output, &error); if (error != NULL && !g_cancellable_is_cancelled (self->priv->cancellable)) - { - DEBUG ("splice operation failed: %s", error->message); - operation_failed (self, error); - } + DEBUG ("splice operation failed: %s", error->message); + g_clear_error (&error); g_io_stream_close_async (self->priv->stream, G_PRIORITY_DEFAULT, - NULL, stream_close_cb, self); + NULL, stream_close_cb, g_object_ref (self)); + + g_object_unref (self); } static void @@ -241,10 +241,7 @@ client_socket_connected (TpFileTransferChannel *self) self->priv->client_socket); if (conn == NULL) { - error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, - "Failed to create client connection"); - DEBUG ("%s", error->message); - operation_failed (self, error); + DEBUG ("Failed to create client connection"); return; } @@ -262,9 +259,8 @@ client_socket_connected (TpFileTransferChannel *self) conn, byte, NULL, &error)) { DEBUG ("Failed to send credentials: %s", error->message); - - operation_failed (self, error); g_object_unref (conn); + g_clear_error (&error); return; } } @@ -282,7 +278,7 @@ client_socket_connected (TpFileTransferChannel *self) G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, G_PRIORITY_DEFAULT, self->priv->cancellable, - splice_stream_ready_cb, self); + splice_stream_ready_cb, g_object_ref (self)); } else { @@ -294,7 +290,7 @@ client_socket_connected (TpFileTransferChannel *self) G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, G_PRIORITY_DEFAULT, self->priv->cancellable, - splice_stream_ready_cb, self); + splice_stream_ready_cb, g_object_ref (self)); } } @@ -308,8 +304,7 @@ client_socket_cb (GSocket *socket, if (!g_socket_check_connect_result (socket, &error)) { DEBUG ("Failed to connect to socket: %s", error->message); - - operation_failed (self, error); + g_clear_error (&error); return FALSE; } @@ -1122,8 +1117,8 @@ start_transfer (TpFileTransferChannel *self) NULL); g_source_attach (source, g_main_context_get_thread_default ()); - g_source_set_callback (source, (GSourceFunc) client_socket_cb, self, - NULL); + g_source_set_callback (source, (GSourceFunc) client_socket_cb, + g_object_ref (self), g_object_unref); g_error_free (error); g_source_unref (source); @@ -1131,8 +1126,7 @@ start_transfer (TpFileTransferChannel *self) else { DEBUG ("Failed to connect to socket: %s:", error->message); - - operation_failed (self, error); + g_clear_error (&error); } } @@ -1171,6 +1165,7 @@ accept_or_provide_file_cb (TpChannel *proxy, } g_simple_async_result_complete_in_idle (self->priv->result); + g_clear_object (&self->priv->result); } static gboolean diff --git a/telepathy-glib/gnio-util.c b/telepathy-glib/gnio-util.c index 1ce6cd588..9b49e08f7 100644 --- a/telepathy-glib/gnio-util.c +++ b/telepathy-glib/gnio-util.c @@ -148,8 +148,10 @@ tp_g_socket_address_from_variant (TpSocketAddressType type, else { GValueArray *array = g_value_get_boxed (variant); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS GValue *hostv = g_value_array_get_nth (array, 0); GValue *portv = g_value_array_get_nth (array, 1); + G_GNUC_END_IGNORE_DEPRECATIONS GInetAddress *address; const char *host; guint16 port; diff --git a/telepathy-glib/group-mixin.c b/telepathy-glib/group-mixin.c index 5907d74b7..0910cee1a 100644 --- a/telepathy-glib/group-mixin.c +++ b/telepathy-glib/group-mixin.c @@ -956,7 +956,7 @@ tp_group_mixin_get_local_pending_members_with_info_async ( tp_svc_channel_interface_group_return_from_get_local_pending_members_with_info ( context, ret); for (i = 0 ; i < ret->len; i++) { - g_value_array_free (g_ptr_array_index (ret,i)); + tp_value_array_free (g_ptr_array_index (ret,i)); } g_ptr_array_unref (ret); } diff --git a/telepathy-glib/message-mixin.c b/telepathy-glib/message-mixin.c index ac4683b37..10af0551b 100644 --- a/telepathy-glib/message-mixin.c +++ b/telepathy-glib/message-mixin.c @@ -735,7 +735,7 @@ tp_message_mixin_list_pending_messages_async (TpSvcChannelTypeText *iface, messages); for (i = 0; i < messages->len; i++) - g_value_array_free (g_ptr_array_index (messages, i)); + tp_value_array_free (g_ptr_array_index (messages, i)); g_ptr_array_unref (messages); } diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c index f3b3b8787..3d14e2d25 100644 --- a/telepathy-glib/presence-mixin.c +++ b/telepathy-glib/presence-mixin.c @@ -131,7 +131,10 @@ * @optional_arguments: An array of #TpPresenceStatusOptionalArgumentSpec * structures representing the optional arguments for this status, terminated * by a NULL name. If there are no optional arguments for a status, this can - * be NULL. + * be NULL. In modern Telepathy connection managers, the only optional + * argument should be a string (type "s") named "message" on statuses + * that have an optional human-readable message. All other optional arguments + * are deprecated. * * Structure specifying a supported presence status. * @@ -153,9 +156,13 @@ * In addition to the fields documented here, there are two gpointer fields * which must currently be %NULL. A meaning may be defined for these in a * future version of telepathy-glib. + * + * In modern Telepathy connection managers, the only optional + * argument should be a %G_TYPE_STRING named "message", on statuses + * that have an optional human-readable message. All other optional arguments + * are deprecated. */ - /** * TpPresenceMixinStatusAvailableFunc: * @obj: An instance of a #TpBaseConnection subclass implementing the presence @@ -333,6 +340,11 @@ deep_copy_hashtable (GHashTable *hash_table) * Construct a presence status structure. You should free the returned * structure with #tp_presence_status_free. * + * In modern Telepathy connection managers, the only optional + * argument should be a %G_TYPE_STRING named "message", on statuses + * that have an optional human-readable message. All other optional arguments + * are deprecated. + * * Returns: A pointer to the newly allocated presence status structure. */ TpPresenceStatus * @@ -541,17 +553,11 @@ construct_presence_hash_foreach ( g_hash_table_insert (contact_status, (gpointer) supported_statuses[status->index].name, parameters); - vals = g_value_array_new (2); - - /* last-activity sucks and will probably be removed soon */ - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 0), G_TYPE_UINT); - g_value_set_uint (g_value_array_get_nth (vals, 0), 0); - - g_value_array_append (vals, NULL); - g_value_init (g_value_array_get_nth (vals, 1), - TP_HASH_TYPE_MULTIPLE_STATUS_MAP); - g_value_take_boxed (g_value_array_get_nth (vals, 1), contact_status); + vals = tp_value_array_build (2, + G_TYPE_UINT, 0, + TP_HASH_TYPE_MULTIPLE_STATUS_MAP, contact_status, + G_TYPE_INVALID); + g_hash_table_unref (contact_status); g_hash_table_insert (presence_hash, GUINT_TO_POINTER (handle), vals); } @@ -562,7 +568,7 @@ construct_presence_hash (const TpPresenceStatusSpec *supported_statuses, GHashTable *contact_statuses) { GHashTable *presence_hash = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); GHashTableIter iter; gpointer key, value; @@ -846,38 +852,25 @@ tp_presence_mixin_get_statuses (TpSvcConnectionInterfacePresence *iface, TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (conn, context); ret = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, (GDestroyNotify) g_value_array_free); + NULL, (GDestroyNotify) tp_value_array_free); for (i=0; mixin_cls->statuses[i].name != NULL; i++) { + GHashTable *args; + /* the spec says we include statuses here even if they're not available * to set on yourself */ if (!check_status_available (obj, mixin_cls, i, NULL, FALSE)) continue; - status = g_value_array_new (5); - - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 0), G_TYPE_UINT); - g_value_set_uint (g_value_array_get_nth (status, 0), - mixin_cls->statuses[i].presence_type); - - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 1), G_TYPE_BOOLEAN); - g_value_set_boolean (g_value_array_get_nth (status, 1), - mixin_cls->statuses[i].self); - - /* everything is exclusive */ - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 2), G_TYPE_BOOLEAN); - g_value_set_boolean (g_value_array_get_nth (status, 2), - TRUE); - - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 3), - DBUS_TYPE_G_STRING_STRING_HASHTABLE); - g_value_take_boxed (g_value_array_get_nth (status, 3), - get_statuses_arguments (mixin_cls->statuses[i].optional_arguments)); + args = get_statuses_arguments (mixin_cls->statuses[i].optional_arguments); + status = tp_value_array_build (4, + G_TYPE_UINT, (guint) mixin_cls->statuses[i].presence_type, + G_TYPE_BOOLEAN, mixin_cls->statuses[i].self, + G_TYPE_BOOLEAN, TRUE, /* exclusive */ + DBUS_TYPE_G_STRING_STRING_HASHTABLE, args, + G_TYPE_INVALID); + g_hash_table_unref (args); g_hash_table_insert (ret, (gchar *) mixin_cls->statuses[i].name, status); @@ -1260,45 +1253,25 @@ tp_presence_mixin_get_simple_presence_dbus_property (GObject *object, g_return_if_fail (G_VALUE_HOLDS_BOXED (value)); ret = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, (GDestroyNotify) g_value_array_free); + NULL, (GDestroyNotify) tp_value_array_free); for (i=0; mixin_cls->statuses[i].name != NULL; i++) { - const TpPresenceStatusOptionalArgumentSpec *specs; - int j; - gboolean message = FALSE; + gboolean message; /* we include statuses here even if they're not available * to set on yourself */ if (!check_status_available (object, mixin_cls, i, NULL, FALSE)) continue; - specs = mixin_cls->statuses[i].optional_arguments; - - for (j = 0; specs != NULL && specs[j].name != NULL; j++) - { - if (!tp_strdiff (specs[j].name, "message")) - { - message = TRUE; - break; - } - } - - status = g_value_array_new (3); - - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 0), G_TYPE_UINT); - g_value_set_uint (g_value_array_get_nth (status, 0), - mixin_cls->statuses[i].presence_type); + message = tp_presence_status_spec_has_message ( + &mixin_cls->statuses[i]); - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 1), G_TYPE_BOOLEAN); - g_value_set_boolean (g_value_array_get_nth (status, 1), - mixin_cls->statuses[i].self); - - g_value_array_append (status, NULL); - g_value_init (g_value_array_get_nth (status, 2), G_TYPE_BOOLEAN); - g_value_set_boolean (g_value_array_get_nth (status, 2), message); + status = tp_value_array_build (3, + G_TYPE_UINT, (guint) mixin_cls->statuses[i].presence_type, + G_TYPE_BOOLEAN, mixin_cls->statuses[i].self, + G_TYPE_BOOLEAN, message, + G_TYPE_INVALID); g_hash_table_insert (ret, (gchar *) mixin_cls->statuses[i].name, status); @@ -1425,19 +1398,11 @@ construct_simple_presence_value_array (TpPresenceStatus *status, if (message == NULL) message = ""; - presence = g_value_array_new (3); - - g_value_array_append (presence, NULL); - g_value_init (g_value_array_get_nth (presence, 0), G_TYPE_UINT); - g_value_set_uint (g_value_array_get_nth (presence, 0), status_type); - - g_value_array_append (presence, NULL); - g_value_init (g_value_array_get_nth (presence, 1), G_TYPE_STRING); - g_value_set_string (g_value_array_get_nth (presence, 1), status_name); - - g_value_array_append (presence, NULL); - g_value_init (g_value_array_get_nth (presence, 2), G_TYPE_STRING); - g_value_set_string (g_value_array_get_nth (presence, 2), message); + presence = tp_value_array_build (3, + G_TYPE_UINT, status_type, + G_TYPE_STRING, status_name, + G_TYPE_STRING, message, + G_TYPE_INVALID); return presence; } @@ -1460,7 +1425,7 @@ construct_simple_presence_hash (const TpPresenceStatusSpec *supported_statuses, GHashTable *contact_statuses) { GHashTable *presence_hash = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) g_value_array_free); + (GDestroyNotify) tp_value_array_free); GHashTableIter iter; gpointer key, value; @@ -1578,6 +1543,9 @@ tp_presence_mixin_simple_presence_fill_contact_attributes (GObject *obj, { GHashTableIter iter; gpointer key, value; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + GType type = G_TYPE_VALUE_ARRAY; + G_GNUC_END_IGNORE_DEPRECATIONS g_hash_table_iter_init (&iter, contact_statuses); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -1589,7 +1557,7 @@ tp_presence_mixin_simple_presence_fill_contact_attributes (GObject *obj, tp_contacts_mixin_set_contact_attribute (attributes_hash, handle, TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE, - tp_g_value_slice_new_take_boxed (G_TYPE_VALUE_ARRAY, presence)); + tp_g_value_slice_new_take_boxed (type, presence)); } g_hash_table_unref (contact_statuses); @@ -1613,3 +1581,188 @@ tp_presence_mixin_simple_presence_register_with_contacts_mixin (GObject *obj) tp_presence_mixin_simple_presence_fill_contact_attributes); } +/* For now, self->priv is just self if heap-allocated, NULL if not. */ +static gboolean +_tp_presence_status_spec_is_heap_allocated (const TpPresenceStatusSpec *self) +{ + return (self->priv == (TpPresenceStatusSpecPrivate *) self); +} + +/** + * tp_presence_status_spec_get_presence_type: + * @self: a presence status specification + * + * Return the category into which this presence type falls. For instance, + * for XMPP's "" (do not disturb) status, this would return + * %TP_CONNECTION_PRESENCE_TYPE_BUSY. + * + * Returns: a #TpConnectionPresenceType + * Since: 0.23.1 + */ +TpConnectionPresenceType +tp_presence_status_spec_get_presence_type (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, TP_CONNECTION_PRESENCE_TYPE_UNSET); + + return self->presence_type; +} + +/** + * tp_presence_status_spec_get_name: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: (transfer none): the name of this presence status, + * such as "available" or "out-to-lunch". + * Since: 0.23.1 + */ +const gchar * +tp_presence_status_spec_get_name (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, NULL); + + return self->name; +} + +/** + * tp_presence_status_spec_can_set_on_self: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: %TRUE if the user can set this presence status on themselves (most + * statuses), or %FALSE if they cannot directly set it on + * themselves (typically used for %TP_CONNECTION_PRESENCE_TYPE_OFFLINE + * and %TP_CONNECTION_PRESENCE_TYPE_ERROR) + * Since: 0.23.1 + */ +gboolean +tp_presence_status_spec_can_set_on_self (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + + return self->self; +} + +/** + * tp_presence_status_spec_has_message: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: %TRUE if this presence status is accompanied by an optional + * human-readable message + * Since: 0.23.1 + */ +gboolean +tp_presence_status_spec_has_message (const TpPresenceStatusSpec *self) +{ + const TpPresenceStatusOptionalArgumentSpec *arg; + + g_return_val_if_fail (self != NULL, FALSE); + + if (self->optional_arguments == NULL) + return FALSE; + + for (arg = self->optional_arguments; arg->name != NULL; arg++) + { + if (!tp_strdiff (arg->name, "message") && !tp_strdiff (arg->dtype, "s")) + return TRUE; + } + + return FALSE; +} + +/** + * tp_presence_status_spec_new: + * @name: the name of the new presence status + * @type: the category into which this presence status falls + * @can_set_on_self: %TRUE if the user can set this presence status + * on themselves + * @has_message: %TRUE if this presence status is accompanied by an + * optional human-readable message + * + * <!-- --> + * + * Returns: (transfer full): a new #TpPresenceStatusSpec + * Since: 0.23.1 + */ +TpPresenceStatusSpec * +tp_presence_status_spec_new (const gchar *name, + TpConnectionPresenceType type, + gboolean can_set_on_self, + gboolean has_message) +{ + TpPresenceStatusSpec *ret; + static const TpPresenceStatusOptionalArgumentSpec yes_it_has_a_message[] = { + { "message", "s" }, + { NULL } + }; + + g_return_val_if_fail (!tp_str_empty (name), NULL); + g_return_val_if_fail (type >= 0 && type < TP_NUM_CONNECTION_PRESENCE_TYPES, + NULL); + + ret = g_slice_new0 (TpPresenceStatusSpec); + + ret->name = g_strdup (name); + ret->presence_type = type; + ret->self = can_set_on_self; + + if (has_message) + ret->optional_arguments = yes_it_has_a_message; + else + ret->optional_arguments = NULL; + + /* dummy marker for "this is on the heap" rather than a real struct */ + ret->priv = (TpPresenceStatusSpecPrivate *) ret; + + return ret; +} + +/** + * tp_presence_status_spec_copy: + * @self: a presence status specification + * + * Copy a presence status specification. + * + * If @self has optional arguments other than a string named "message", + * they are not copied. Optional arguments with other names or types + * are deprecated. + * + * Returns: (transfer full): a new #TpPresenceStatusSpec resembling @self + * Since: 0.23.1 + */ +TpPresenceStatusSpec * +tp_presence_status_spec_copy (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, NULL); + + return tp_presence_status_spec_new (self->name, self->presence_type, + self->self, tp_presence_status_spec_has_message (self)); +} + +/** + * tp_presence_status_spec_free: + * @self: (transfer full): a presence status specification + * + * Free a presence status specification produced by + * tp_presence_status_spec_new() or tp_presence_status_spec_copy(). + * + * Since: 0.23.1 + */ +void +tp_presence_status_spec_free (TpPresenceStatusSpec *self) +{ + g_return_if_fail (_tp_presence_status_spec_is_heap_allocated (self)); + + /* This struct was designed to always be on the stack, so freeing this + * needs a non-const-correct cast */ + g_free ((gchar *) self->name); + + g_slice_free (TpPresenceStatusSpec, self); +} + +G_DEFINE_BOXED_TYPE (TpPresenceStatusSpec, tp_presence_status_spec, + tp_presence_status_spec_copy, tp_presence_status_spec_free) diff --git a/telepathy-glib/presence-mixin.h b/telepathy-glib/presence-mixin.h index 63d2c7e38..64a11f0d3 100644 --- a/telepathy-glib/presence-mixin.h +++ b/telepathy-glib/presence-mixin.h @@ -35,6 +35,7 @@ G_BEGIN_DECLS typedef struct _TpPresenceStatusOptionalArgumentSpec TpPresenceStatusOptionalArgumentSpec; typedef struct _TpPresenceStatusSpec TpPresenceStatusSpec; +typedef struct _TpPresenceStatusSpecPrivate TpPresenceStatusSpecPrivate; struct _TpPresenceStatusOptionalArgumentSpec { const gchar *name; @@ -53,9 +54,41 @@ struct _TpPresenceStatusSpec { /*<private>*/ gpointer _future1; - gpointer _future2; + TpPresenceStatusSpecPrivate *priv; }; +_TP_AVAILABLE_IN_0_24 +TpConnectionPresenceType tp_presence_status_spec_get_presence_type ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_0_24 +const gchar *tp_presence_status_spec_get_name ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_0_24 +gboolean tp_presence_status_spec_can_set_on_self ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_0_24 +gboolean tp_presence_status_spec_has_message ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_0_24 +GType tp_presence_status_spec_get_type (void); + +_TP_AVAILABLE_IN_0_24 +TpPresenceStatusSpec *tp_presence_status_spec_new (const gchar *name, + TpConnectionPresenceType type, + gboolean can_set_on_self, + gboolean has_message); + +_TP_AVAILABLE_IN_0_24 +TpPresenceStatusSpec *tp_presence_status_spec_copy ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_0_24 +void tp_presence_status_spec_free (TpPresenceStatusSpec *self); + typedef struct _TpPresenceStatus TpPresenceStatus; struct _TpPresenceStatus { diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c index b2935c042..c238d49d4 100644 --- a/telepathy-glib/protocol.c +++ b/telepathy-glib/protocol.c @@ -44,6 +44,8 @@ #include "telepathy-glib/capabilities-internal.h" #include "telepathy-glib/debug-internal.h" #include "telepathy-glib/proxy-internal.h" +#include "telepathy-glib/util-internal.h" +#include "telepathy-glib/variant-util-internal.h" #include "telepathy-glib/_gen/tp-cli-protocol-body.h" @@ -144,12 +146,17 @@ struct _TpProtocolPrivate TpCapabilities *capabilities; TpAvatarRequirements *avatar_req; gchar *cm_name; + GStrv addressable_vcard_fields; + GStrv addressable_uri_schemes; + /* (transfer container) (element-type utf8 Simple_Status_Spec) */ + GHashTable *presence_statuses; }; enum { PROP_PROTOCOL_NAME = 1, PROP_PROTOCOL_PROPERTIES, + PROP_PROTOCOL_PROPERTIES_VARDICT, PROP_ENGLISH_NAME, PROP_VCARD_FIELD, PROP_ICON_NAME, @@ -158,6 +165,8 @@ enum PROP_AUTHENTICATION_TYPES, PROP_AVATAR_REQUIREMENTS, PROP_CM_NAME, + PROP_ADDRESSABLE_VCARD_FIELDS, + PROP_ADDRESSABLE_URI_SCHEMES, N_PROPS }; @@ -184,15 +193,15 @@ tp_protocol_params_from_param_specs (const GPtrArray *parameters, { GValue structure = { 0 }; GValue *tmp; - /* Points to the zeroed entry just after the end of the array - * - but we're about to extend the array to make it valid */ - TpConnectionManagerParam *param = &g_array_index (output, - TpConnectionManagerParam, output->len); + TpConnectionManagerParam *param; g_value_init (&structure, TP_STRUCT_TYPE_PARAM_SPEC); g_value_set_static_boxed (&structure, g_ptr_array_index (parameters, i)); g_array_set_size (output, output->len + 1); + /* point to the new last item */ + param = &g_array_index (output, TpConnectionManagerParam, + output->len - 1); if (!dbus_g_type_struct_get (&structure, 0, ¶m->name, @@ -207,6 +216,15 @@ tp_protocol_params_from_param_specs (const GPtrArray *parameters, continue; } + if (!g_variant_type_string_is_valid (param->dbus_signature)) + { + DEBUG ("Parameter #%d for %s has type '%s' which is not a " + "single complete type, ignoring", i, protocol, + param->dbus_signature); + g_array_set_size (output, output->len - 1); + continue; + } + g_value_init (¶m->default_value, G_VALUE_TYPE (tmp)); g_value_copy (tmp, ¶m->default_value); @@ -260,6 +278,11 @@ tp_protocol_get_property (GObject *object, g_value_set_boxed (value, self->priv->protocol_properties); break; + case PROP_PROTOCOL_PROPERTIES_VARDICT: + g_value_take_variant (value, + tp_protocol_dup_immutable_properties (self)); + break; + case PROP_ENGLISH_NAME: g_value_set_string (value, tp_protocol_get_english_name (self)); break; @@ -292,6 +315,15 @@ tp_protocol_get_property (GObject *object, g_value_set_string (value, tp_protocol_get_cm_name (self)); break; + case PROP_ADDRESSABLE_VCARD_FIELDS: + g_value_set_boxed (value, tp_protocol_get_addressable_vcard_fields ( + self)); + break; + + case PROP_ADDRESSABLE_URI_SCHEMES: + g_value_set_boxed (value, tp_protocol_get_addressable_uri_schemes (self)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -393,6 +425,11 @@ tp_protocol_finalize (GObject *object) g_free (self->priv->english_name); g_free (self->priv->icon_name); g_free (self->priv->cm_name); + g_strfreev (self->priv->addressable_vcard_fields); + g_strfreev (self->priv->addressable_uri_schemes); + + if (self->priv->presence_statuses != NULL) + g_hash_table_unref (self->priv->presence_statuses); if (self->priv->protocol_properties != NULL) g_hash_table_unref (self->priv->protocol_properties); @@ -453,6 +490,19 @@ title_case (const gchar *s) return g_strdup_printf ("%s%s", buf, g_utf8_next_char (s)); } +static GStrv +asv_strdupv_or_empty (const GHashTable *asv, + const gchar *key) +{ + const gchar * const *strings = tp_asv_get_boxed (asv, key, G_TYPE_STRV); + static const gchar * const no_strings[] = { NULL }; + + if (strings != NULL) + return g_strdupv ((GStrv) strings); + else + return g_strdupv ((GStrv) no_strings); +} + static void tp_protocol_constructed (GObject *object) { @@ -463,7 +513,6 @@ tp_protocol_constructed (GObject *object) const gchar *s; const GPtrArray *rccs; gboolean had_immutables = TRUE; - const gchar * const *auth_types = NULL; const gchar * const *interfaces; if (chain_up != NULL) @@ -483,7 +532,21 @@ tp_protocol_constructed (GObject *object) } else { + GHashTableIter iter; + gpointer k, v; + DEBUG ("immutable properties already supplied"); + + g_hash_table_iter_init (&iter, self->priv->protocol_properties); + + while (g_hash_table_iter_next (&iter, &k, &v)) + { + gchar *printed; + + printed = g_strdup_value_contents (v); + DEBUG ("%s = %s", (const gchar *) k, printed); + g_free (printed); + } } self->priv->protocol_struct.params = tp_protocol_params_from_param_specs ( @@ -525,19 +588,9 @@ tp_protocol_constructed (GObject *object) if (rccs != NULL) self->priv->capabilities = _tp_capabilities_new (rccs, FALSE); - auth_types = tp_asv_get_boxed ( + self->priv->authentication_types = asv_strdupv_or_empty ( self->priv->protocol_properties, - TP_PROP_PROTOCOL_AUTHENTICATION_TYPES, G_TYPE_STRV); - - if (auth_types != NULL) - { - self->priv->authentication_types = g_strdupv ((GStrv) auth_types); - } - else - { - gchar *tmp[] = { NULL }; - self->priv->authentication_types = g_strdupv (tmp); - } + TP_PROP_PROTOCOL_AUTHENTICATION_TYPES); interfaces = tp_asv_get_strv (self->priv->protocol_properties, TP_PROP_PROTOCOL_INTERFACES); @@ -547,6 +600,9 @@ tp_protocol_constructed (GObject *object) if (tp_proxy_has_interface_by_id (self, TP_IFACE_QUARK_PROTOCOL_INTERFACE_AVATARS)) { + DEBUG ("%s/%s implements Avatars", self->priv->cm_name, + self->priv->protocol_struct.name); + self->priv->avatar_req = tp_avatar_requirements_new ( (GStrv) tp_asv_get_strv (self->priv->protocol_properties, TP_PROP_PROTOCOL_INTERFACE_AVATARS_SUPPORTED_AVATAR_MIME_TYPES), @@ -566,6 +622,58 @@ tp_protocol_constructed (GObject *object) TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_BYTES, NULL)); } + if (tp_proxy_has_interface_by_id (self, + TP_IFACE_QUARK_PROTOCOL_INTERFACE_ADDRESSING)) + { + DEBUG ("%s/%s implements Addressing", self->priv->cm_name, + self->priv->protocol_struct.name); + + self->priv->addressable_vcard_fields = asv_strdupv_or_empty ( + self->priv->protocol_properties, + TP_PROP_PROTOCOL_INTERFACE_ADDRESSING_ADDRESSABLE_VCARD_FIELDS); + self->priv->addressable_uri_schemes = asv_strdupv_or_empty ( + self->priv->protocol_properties, + TP_PROP_PROTOCOL_INTERFACE_ADDRESSING_ADDRESSABLE_URI_SCHEMES); + } + + if (tp_proxy_has_interface_by_id (self, + TP_IFACE_QUARK_PROTOCOL_INTERFACE_PRESENCE)) + { + DEBUG ("%s/%s implements Presence", self->priv->cm_name, + self->priv->protocol_struct.name); + + self->priv->presence_statuses = tp_asv_get_boxed ( + self->priv->protocol_properties, + TP_PROP_PROTOCOL_INTERFACE_PRESENCE_STATUSES, + TP_HASH_TYPE_SIMPLE_STATUS_SPEC_MAP); + + if (self->priv->presence_statuses != NULL) + { + GHashTableIter iter; + gpointer k, v; + + g_hash_table_ref (self->priv->presence_statuses); + + DEBUG ("%s/%s presence statuses:", self->priv->cm_name, + self->priv->protocol_struct.name); + g_hash_table_iter_init (&iter, self->priv->presence_statuses); + + while (g_hash_table_iter_next (&iter, &k, &v)) + { + guint type; + gboolean on_self, message; + + tp_value_array_unpack (v, 3, + &type, + &on_self, + &message); + DEBUG ("\tstatus '%s': type %u%s%s", + (const gchar *) k, type, on_self ? ", can set on self" : "", + message ? ", has message" : ""); + } + } + } + /* become ready immediately */ _tp_proxy_set_feature_prepared (proxy, TP_PROTOCOL_FEATURE_PARAMETERS, had_immutables); @@ -650,6 +758,28 @@ tp_protocol_class_init (TpProtocolClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** + * TpProtocol:protocol-properties-vardict: + * + * The immutable properties of this Protocol, as provided at construction + * time. This is a #G_VARIANT_TYPE_VARDICT #GVariant, + * which must not be modified. + * + * If the immutable properties were not provided at construction time, + * the %TP_PROTOCOL_FEATURE_PARAMETERS and %TP_PROTOCOL_FEATURE_CORE features + * will both be unavailable, and this #TpProtocol object will only be useful + * as a way to access lower-level D-Bus calls. + * + * Since: UNRELEASED + */ + g_object_class_install_property (object_class, + PROP_PROTOCOL_PROPERTIES_VARDICT, + g_param_spec_variant ("protocol-properties-vardict", + "Protocol properties", + "The immutable properties of this Protocol", + G_VARIANT_TYPE_VARDICT, NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** * TpProtocol:english-name: * * The name of the protocol in a form suitable for display to users, @@ -778,6 +908,45 @@ tp_protocol_class_init (TpProtocolClass *klass) NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * TpProtocol:addressable-vcard-fields: + * + * A non-%NULL #GStrv of vCard fields supported by this protocol. + * If this protocol does not support addressing contacts by a vCard field, + * the list is empty. + * + * For instance, a SIP connection manager that supports calling contacts + * by SIP URI (vCard field SIP) or telephone number (vCard field TEL) + * might have { "sip", "tel", NULL }. + * + * Since: 0.23.1 + */ + g_object_class_install_property (object_class, PROP_ADDRESSABLE_VCARD_FIELDS, + g_param_spec_boxed ("addressable-vcard-fields", + "AddressableVCardFields", + "A list of vCard fields", + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** + * TpProtocol:addressable-uri-schemes: + * + * A non-%NULL #GStrv of URI schemes supported by this protocol. + * If this protocol does not support addressing contacts by URI, + * the list is empty. + * + * For instance, a SIP connection manager that supports calling contacts + * by SIP URI (sip:alice@example.com, sips:bob@example.com) + * or telephone number (tel:+1-555-0123) might have + * { "sip", "sips", "tel", NULL }. + * + * Since: 0.23.1 + */ + g_object_class_install_property (object_class, PROP_ADDRESSABLE_URI_SCHEMES, + g_param_spec_boxed ("addressable-uri-schemes", + "AddressableURISchemes", + "A list of URI schemes", + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + proxy_class->list_features = tp_protocol_list_features; proxy_class->must_have_unique_name = FALSE; proxy_class->interface = TP_IFACE_QUARK_PROTOCOL; @@ -846,6 +1015,45 @@ finally: } /** + * tp_protocol_new_vardict: + * @dbus: proxy for the D-Bus daemon; may not be %NULL + * @cm_name: the connection manager name (such as "gabble") + * @protocol_name: the protocol name (such as "jabber") + * @immutable_properties: the immutable D-Bus properties for this protocol + * @error: used to indicate the error if %NULL is returned + * + * Create a new protocol proxy. + * + * If @immutable_properties is a floating reference, this function will + * take ownership of it, much like g_variant_ref_sink(). See documentation of + * that function for details. + * + * Returns: a new protocol proxy, or %NULL on invalid arguments + * + * Since: 0.UNRELEASED + */ +TpProtocol * +tp_protocol_new_vardict (TpDBusDaemon *dbus, + const gchar *cm_name, + const gchar *protocol_name, + GVariant *immutable_properties, + GError **error) +{ + GHashTable *hash; + TpProtocol *ret; + + g_return_val_if_fail (g_variant_is_of_type (immutable_properties, + G_VARIANT_TYPE_VARDICT), NULL); + + g_variant_ref_sink (immutable_properties); + hash = _tp_asv_from_vardict (immutable_properties); + ret = tp_protocol_new (dbus, cm_name, protocol_name, hash, error); + g_hash_table_unref (hash); + g_variant_unref (immutable_properties); + return ret; +} + +/** * tp_protocol_init_known_interfaces: * * Ensure that the known interfaces for TpProtocol have been set up. @@ -1221,7 +1429,7 @@ init_gvalue_from_dbus_sig (const gchar *sig, static gboolean parse_default_value (GValue *value, const gchar *sig, - gchar *string, + gchar *raw_value, GKeyFile *file, const gchar *group, const gchar *key) @@ -1244,31 +1452,28 @@ parse_default_value (GValue *value, * So, on error, let's fall back to more lenient parsing that explicitly * allows everything we historically allowed. */ g_error_free (error); - s = g_key_file_get_value (file, group, key, NULL); - if (s == NULL) + if (raw_value == NULL) return FALSE; - for (p = s; *p != '\0'; p++) + for (p = raw_value; *p != '\0'; p++) { *p = g_ascii_tolower (*p); } - if (!tp_strdiff (s, "1") || !tp_strdiff (s, "true")) + if (!tp_strdiff (raw_value, "1") || !tp_strdiff (raw_value, "true")) { g_value_set_boolean (value, TRUE); } - else if (!tp_strdiff (s, "0") || !tp_strdiff (s, "false")) + else if (!tp_strdiff (raw_value, "0") || !tp_strdiff (raw_value, "false")) { g_value_set_boolean (value, TRUE); } else { - g_free (s); return FALSE; } - g_free (s); return TRUE; case 's': @@ -1317,7 +1522,7 @@ parse_default_value (GValue *value, case 'n': case 'i': case 'x': - if (string[0] == '\0') + if (raw_value[0] == '\0') { return FALSE; } @@ -1464,20 +1669,34 @@ _tp_protocol_parse_channel_class (GKeyFile *file, const gchar *dbus_type; GValue *v = g_slice_new0 (GValue); - value = g_key_file_get_string (file, group, *key, NULL); + value = g_key_file_get_value (file, group, *key, NULL); /* keys without a space are reserved */ if (space == NULL) - goto cleanup; + { + DEBUG ("\t'%s' isn't a fixed property", *key); + goto cleanup; + } property = g_strndup (*key, space - *key); dbus_type = space + 1; if (!init_gvalue_from_dbus_sig (dbus_type, v)) - goto cleanup; + { + DEBUG ("\tunable to parse D-Bus type '%s' for '%s' in a " + ".manager file", dbus_type, property); + goto cleanup; + } if (!parse_default_value (v, dbus_type, value, file, group, *key)) - goto cleanup; + { + DEBUG ("\tunable to parse '%s' as a value of type '%s' for '%s'", + value, dbus_type, property); + goto cleanup; + } + + DEBUG ("\tfixed: '%s' of type '%s' = '%s'", + property, dbus_type, value); /* transfer ownership to @ret */ g_hash_table_insert (ret, property, v); @@ -1503,16 +1722,27 @@ cleanup: } static GValueArray * -_tp_protocol_parse_rcc (GKeyFile *file, +_tp_protocol_parse_rcc (const gchar *cm_debug_name, + const gchar *protocol_debug_name, + GKeyFile *file, const gchar *group) { GHashTable *fixed; GStrv allowed; GValueArray *ret; + guint i; + + DEBUG ("%s/%s: parsing requestable channel class '%s'", cm_debug_name, + protocol_debug_name, group); fixed = _tp_protocol_parse_channel_class (file, group); allowed = g_key_file_get_string_list (file, group, "allowed", NULL, NULL); + for (i = 0; allowed != NULL && allowed[i] != NULL; i++) + { + DEBUG ("\tallowed: '%s'", allowed[i]); + } + ret = tp_value_array_build (2, TP_HASH_TYPE_CHANNEL_CLASS, fixed, G_TYPE_STRV, allowed, @@ -1531,6 +1761,7 @@ _tp_protocol_parse_manager_file (GKeyFile *file, gchar **protocol_name) { GHashTable *immutables; + GHashTable *status_specs; GPtrArray *param_specs, *rccs; const gchar *name; gchar **rcc_groups, **rcc_group; @@ -1607,7 +1838,7 @@ _tp_protocol_parse_manager_file (GKeyFile *file, } def = g_strdup_printf ("default-%s", param.name); - value = g_key_file_get_string (file, group, def, NULL); + value = g_key_file_get_value (file, group, def, NULL); init_gvalue_from_dbus_sig (param.dbus_signature, ¶m.default_value); @@ -1651,8 +1882,6 @@ _tp_protocol_parse_manager_file (GKeyFile *file, } } - g_strfreev (keys); - immutables = tp_asv_new ( TP_PROP_PROTOCOL_PARAMETERS, TP_ARRAY_TYPE_PARAM_SPEC_LIST, param_specs, NULL); @@ -1712,11 +1941,89 @@ _tp_protocol_parse_manager_file (GKeyFile *file, if (rcc_groups != NULL) { for (rcc_group = rcc_groups; *rcc_group != NULL; rcc_group++) - g_ptr_array_add (rccs, _tp_protocol_parse_rcc (file, *rcc_group)); + g_ptr_array_add (rccs, + _tp_protocol_parse_rcc (cm_debug_name, name, file, *rcc_group)); } g_strfreev (rcc_groups); + /* Statuses */ + status_specs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, + (GDestroyNotify) tp_value_array_free); + + for (key = keys; key != NULL && *key != NULL; key++) + { + if (g_str_has_prefix (*key, "status-")) + { + GValueArray *ubb; + gint64 type; + gboolean on_self = FALSE, has_message = FALSE; + gchar *value, *endptr; + gchar **strv, **iter; + + if (!tp_strdiff (*key, "status-")) + { + DEBUG ("'status-' is not a valid status"); + continue; + } + + value = g_key_file_get_value (file, group, *key, NULL); + strv = g_strsplit (value, " ", 0); + g_free (value); + + type = g_ascii_strtoll (strv[0], &endptr, 10); + + if (endptr <= strv[0] || *endptr != '\0') + { + DEBUG ("invalid (non-numeric?) status type %s", strv[0]); + goto next_status; + } + + if (type == TP_CONNECTION_PRESENCE_TYPE_UNSET || + type < 0 || type >= TP_NUM_CONNECTION_PRESENCE_TYPES) + { + DEBUG ("presence type out of range: %" G_GINT64_FORMAT, + type); + goto next_status; + } + + for (iter = strv + 1; *iter != NULL; iter++) + { + if (!tp_strdiff (*iter, "settable")) + on_self = TRUE; + else if (!tp_strdiff (*iter, "message")) + has_message = TRUE; + else + DEBUG ("unknown status modifier '%s'", *iter); + } + + ubb = tp_value_array_build (3, + G_TYPE_UINT, (guint) type, + G_TYPE_BOOLEAN, on_self, + G_TYPE_BOOLEAN, has_message, + G_TYPE_INVALID); + + /* strlen ("status-") == 7 */ + g_hash_table_insert (status_specs, g_strdup (*key + 7), + ubb); + DEBUG ("Status '%s': type %u%s%s", *key + 7, (guint) type, + on_self ? ", can set on self" : "", + has_message ? ", has message" : ""); + +next_status: + g_strfreev (strv); + } + } + + if (g_hash_table_size (status_specs) > 0) + tp_asv_take_boxed (immutables, + TP_PROP_PROTOCOL_INTERFACE_PRESENCE_STATUSES, + TP_HASH_TYPE_SIMPLE_STATUS_SPEC_MAP, status_specs); + else + g_hash_table_unref (status_specs); + + g_strfreev (keys); + tp_asv_take_boxed (immutables, TP_PROP_PROTOCOL_REQUESTABLE_CHANNEL_CLASSES, TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, rccs); @@ -1761,3 +2068,364 @@ tp_protocol_get_cm_name (TpProtocol *self) return self->priv->cm_name; } + +/* + * Handle the result from a tp_cli_protocol_* function that + * returns one string. user_data is a #GTask. + */ +static void +tp_protocol_async_string_cb (TpProxy *proxy, + const gchar *normalized, + const GError *error, + gpointer user_data, + GObject *weak_object G_GNUC_UNUSED) +{ + if (error == NULL) + g_task_return_pointer (user_data, g_strdup (normalized), g_free); + else + g_task_return_error (user_data, g_error_copy (error)); +} + +/** + * tp_protocol_normalize_contact_async: + * @self: a protocol + * @contact: a contact identifier, possibly invalid + * @cancellable: (allow-none): may be used to cancel the async request + * @callback: (scope async): a callback to call when + * the request is satisfied + * @user_data: (closure) (allow-none): data to pass to @callback + * + * Perform best-effort offline contact normalization. This does syntactic + * normalization (e.g. transforming case-insensitive text to lower-case), + * but does not query servers or anything similar. + * + * Since: 0.23.1 + */ +void +tp_protocol_normalize_contact_async (TpProtocol *self, + const gchar *contact, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + + g_return_if_fail (TP_IS_PROTOCOL (self)); + g_return_if_fail (contact != NULL); + /* this makes no sense to call for its side-effects */ + g_return_if_fail (callback != NULL); + + task = g_task_new (self, cancellable, callback, user_data); + g_task_set_source_tag (task, tp_protocol_normalize_contact_async); + + tp_cli_protocol_call_normalize_contact (self, -1, contact, + tp_protocol_async_string_cb, task, g_object_unref, NULL); +} + +/** + * tp_protocol_normalize_contact_finish: + * @self: a protocol + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Interpret the result of tp_protocol_normalize_contact_async(). + * + * Returns: (transfer full): the normalized form of @contact, + * or %NULL on error + * Since: 0.23.1 + */ +gchar * +tp_protocol_normalize_contact_finish (TpProtocol *self, + GAsyncResult *result, + GError **error) +{ + g_return_val_if_fail (g_task_is_valid (result, self), NULL); + g_return_val_if_fail (g_async_result_is_tagged (result, + tp_protocol_normalize_contact_async), NULL); + + return g_task_propagate_pointer (G_TASK (result), error); +} + +/** + * tp_protocol_identify_account_async: + * @self: a protocol + * @vardict: the account parameters as a #GVariant of + * type %G_VARIANT_TYPE_VARDICT. If it is floating, ownership will + * be taken, as if via g_variant_ref_sink(). + * @cancellable: (allow-none): may be used to cancel the async request + * @callback: (scope async): a callback to call when + * the request is satisfied + * @user_data: (closure) (allow-none): data to pass to @callback + * + * Return a string that could identify the account with the given + * parameters. In most protocols that string is a normalized 'account' + * parameter, but some protocols have more complex requirements; + * for instance, on IRC, the 'account' (nickname) is insufficient, + * and must be combined with a server or network name. + * + * Since: 0.23.1 + */ +void +tp_protocol_identify_account_async (TpProtocol *self, + GVariant *vardict, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + GHashTable *asv; + + g_return_if_fail (TP_IS_PROTOCOL (self)); + g_return_if_fail (vardict != NULL); + g_return_if_fail (g_variant_is_of_type (vardict, G_VARIANT_TYPE_VARDICT)); + /* this makes no sense to call for its side-effects */ + g_return_if_fail (callback != NULL); + + task = g_task_new (self, cancellable, callback, user_data); + g_task_set_source_tag (task, tp_protocol_identify_account_async); + g_variant_ref_sink (vardict); + asv = _tp_asv_from_vardict (vardict); + tp_cli_protocol_call_identify_account (self, -1, asv, + tp_protocol_async_string_cb, task, g_object_unref, NULL); + g_hash_table_unref (asv); + g_variant_unref (vardict); +} + +/** + * tp_protocol_identify_account_finish: + * @self: a protocol + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Interpret the result of tp_protocol_identify_account_async(). + * + * Returns: (transfer full): a string identifying the account, + * or %NULL on error + * Since: 0.23.1 + */ +gchar * +tp_protocol_identify_account_finish (TpProtocol *self, + GAsyncResult *result, + GError **error) +{ + g_return_val_if_fail (g_task_is_valid (result, self), NULL); + g_return_val_if_fail (g_async_result_is_tagged (result, + tp_protocol_identify_account_async), NULL); + + return g_task_propagate_pointer (G_TASK (result), error); +} + +/** + * tp_protocol_normalize_contact_uri_async: + * @self: a protocol + * @uri: a contact URI, possibly invalid + * @cancellable: (allow-none): may be used to cancel the async request + * @callback: (scope async): a callback to call when the request is satisfied + * @user_data: (closure) (allow-none): data to pass to @callback + * + * Perform best-effort offline contact normalization, for a contact in + * the form of a URI. This method will fail if the URI is not in a + * scheme supported by this protocol or connection manager. + * + * Since: 0.23.1 + */ +void +tp_protocol_normalize_contact_uri_async (TpProtocol *self, + const gchar *uri, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + + g_return_if_fail (TP_IS_PROTOCOL (self)); + g_return_if_fail (uri != NULL); + /* this makes no sense to call for its side-effects */ + g_return_if_fail (callback != NULL); + + task = g_task_new (self, cancellable, callback, user_data); + g_task_set_source_tag (task, tp_protocol_normalize_contact_uri_async); + + tp_cli_protocol_interface_addressing_call_normalize_contact_uri (self, -1, + uri, tp_protocol_async_string_cb, task, g_object_unref, NULL); +} + +/** + * tp_protocol_normalize_contact_uri_finish: + * @self: a protocol + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Interpret the result of tp_protocol_normalize_contact_uri_async(). + * + * Returns: (transfer full): the normalized form of @uri, + * or %NULL on error + * Since: 0.23.1 + */ +gchar * +tp_protocol_normalize_contact_uri_finish (TpProtocol *self, + GAsyncResult *result, + GError **error) +{ + g_return_val_if_fail (g_task_is_valid (result, self), NULL); + g_return_val_if_fail (g_async_result_is_tagged (result, + tp_protocol_normalize_contact_uri_async), NULL); + + return g_task_propagate_pointer (G_TASK (result), error); +} + +/** + * tp_protocol_normalize_vcard_address_async: + * @self: a protocol + * @field: a vCard field + * @value: an address that is a value of @field + * @cancellable: (allow-none): may be used to cancel the async request + * @callback: (scope async): a callback to call when the request is satisfied + * @user_data: (closure) (allow-none): data to pass to @callback + * + * Perform best-effort offline contact normalization, for a contact in + * the form of a vCard field. This method will fail if the vCard field + * is not supported by this protocol or connection manager. + * + * Since: 0.23.1 + */ +void +tp_protocol_normalize_vcard_address_async (TpProtocol *self, + const gchar *field, + const gchar *value, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + + g_return_if_fail (TP_IS_PROTOCOL (self)); + g_return_if_fail (!tp_str_empty (field)); + g_return_if_fail (value != NULL); + /* this makes no sense to call for its side-effects */ + g_return_if_fail (callback != NULL); + + task = g_task_new (self, cancellable, callback, user_data); + g_task_set_source_tag (task, tp_protocol_normalize_vcard_address_async); + + tp_cli_protocol_interface_addressing_call_normalize_vcard_address (self, -1, + field, value, tp_protocol_async_string_cb, task, g_object_unref, NULL); +} + +/** + * tp_protocol_normalize_vcard_address_finish: + * @self: a protocol + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Interpret the result of tp_protocol_normalize_vcard_address_async(). + * + * Returns: (transfer full): the normalized form of @value, + * or %NULL on error + * Since: 0.23.1 + */ +gchar * +tp_protocol_normalize_vcard_address_finish (TpProtocol *self, + GAsyncResult *result, + GError **error) +{ + g_return_val_if_fail (g_task_is_valid (result, self), NULL); + g_return_val_if_fail (g_async_result_is_tagged (result, + tp_protocol_normalize_vcard_address_async), NULL); + + return g_task_propagate_pointer (G_TASK (result), error); +} + +/** + * tp_protocol_get_addressable_vcard_fields: + * @self: a protocol object + * + * <!-- --> + * + * Returns: (transfer none): the value of #TpProtocol:addressable-vcard-fields + * Since: 0.23.1 + */ +const gchar * const * +tp_protocol_get_addressable_vcard_fields (TpProtocol *self) +{ + g_return_val_if_fail (TP_IS_PROTOCOL (self), NULL); + return (const gchar * const *) self->priv->addressable_vcard_fields; +} + +/** + * tp_protocol_get_addressable_uri_schemes: + * @self: a protocol object + * + * <!-- --> + * + * Returns: (transfer none): the value of #TpProtocol:addressable-uri-schemes + * Since: 0.23.1 + */ +const gchar * const * +tp_protocol_get_addressable_uri_schemes (TpProtocol *self) +{ + g_return_val_if_fail (TP_IS_PROTOCOL (self), NULL); + return (const gchar * const *) self->priv->addressable_uri_schemes; +} + +/** + * tp_protocol_dup_presence_statuses: + * @self: a protocol object + * + * Return the presence statuses that might be supported by connections + * to this protocol. + * + * It is possible that some of these statuses will not actually be supported + * by a connection: for instance, an XMPP connection manager would + * include "hidden" in this list, even though not all XMPP servers allow + * users to be online-but-hidden. + * + * Returns: (transfer full) (element-type TelepathyGLib.PresenceStatusSpec): a + * list of statuses, or %NULL if unknown + */ +GList * +tp_protocol_dup_presence_statuses (TpProtocol *self) +{ + GHashTableIter iter; + gpointer k, v; + GList *l = NULL; + + g_return_val_if_fail (TP_IS_PROTOCOL (self), NULL); + + if (self->priv->presence_statuses == NULL) + return NULL; + + g_hash_table_iter_init (&iter, self->priv->presence_statuses); + + while (g_hash_table_iter_next (&iter, &k, &v)) + { + guint type; + gboolean on_self, message; + + tp_value_array_unpack (v, 3, + &type, + &on_self, + &message); + + l = g_list_prepend (l, tp_presence_status_spec_new (k, type, + on_self, message)); + } + + return g_list_reverse (l); +} + +/** + * tp_protocol_dup_immutable_properties: + * @self: a #TpProtocol object + * + * Return the #TpProtocol:protocol-properties-vardict property. + * + * Returns: (transfer full): the value of + * #TpProtocol:protocol-properties-vardict + * Since: UNRELEASED + */ +GVariant * +tp_protocol_dup_immutable_properties (TpProtocol *self) +{ + return _tp_asv_to_vardict (self->priv->protocol_properties); +} diff --git a/telepathy-glib/protocol.h b/telepathy-glib/protocol.h index bc36c5abc..22cf5ff9a 100644 --- a/telepathy-glib/protocol.h +++ b/telepathy-glib/protocol.h @@ -81,6 +81,12 @@ TpProtocol *tp_protocol_new (TpDBusDaemon *dbus, const gchar *cm_name, const gchar *protocol_name, const GHashTable *immutable_properties, GError **error); +TpProtocol * tp_protocol_new_vardict (TpDBusDaemon *dbus, + const gchar *cm_name, + const gchar *protocol_name, + GVariant *immutable_properties, + GError **error); + const gchar *tp_protocol_get_name (TpProtocol *self); _TP_AVAILABLE_IN_0_20 @@ -102,6 +108,8 @@ GStrv tp_protocol_dup_param_names (TpProtocol *self) G_GNUC_WARN_UNUSED_RESULT; _TP_AVAILABLE_IN_0_18 GList *tp_protocol_dup_params (TpProtocol *self) G_GNUC_WARN_UNUSED_RESULT; +GVariant * tp_protocol_dup_immutable_properties (TpProtocol *self); + #ifndef TP_DISABLE_DEPRECATED _TP_DEPRECATED_IN_0_20_FOR(tp_protocol_dup_params) _TP_AVAILABLE_IN_0_18 @@ -113,6 +121,20 @@ const gchar * const * /* gtk-doc sucks */ tp_protocol_get_authentication_types (TpProtocol *self); +_TP_AVAILABLE_IN_0_24 +const gchar * const * +/* ... */ +tp_protocol_get_addressable_vcard_fields (TpProtocol *self); + +_TP_AVAILABLE_IN_0_24 +const gchar * const * +/* ... */ +tp_protocol_get_addressable_uri_schemes (TpProtocol *self); + +_TP_AVAILABLE_IN_0_24 +GList *tp_protocol_dup_presence_statuses (TpProtocol *self) + G_GNUC_WARN_UNUSED_RESULT; + #define TP_PROTOCOL_FEATURE_CORE \ (tp_protocol_get_feature_quark_core ()) GQuark tp_protocol_get_feature_quark_core (void) G_GNUC_CONST; @@ -125,6 +147,55 @@ TpCapabilities *tp_protocol_get_capabilities (TpProtocol *self); _TP_AVAILABLE_IN_0_16 TpAvatarRequirements * tp_protocol_get_avatar_requirements (TpProtocol *self); +_TP_AVAILABLE_IN_0_24 +void tp_protocol_normalize_contact_async (TpProtocol *self, + const gchar *contact, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +_TP_AVAILABLE_IN_0_24 +gchar *tp_protocol_normalize_contact_finish (TpProtocol *self, + GAsyncResult *result, + GError **error); + +_TP_AVAILABLE_IN_0_24 +void tp_protocol_identify_account_async (TpProtocol *self, + GVariant *vardict, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +_TP_AVAILABLE_IN_0_24 +gchar *tp_protocol_identify_account_finish (TpProtocol *self, + GAsyncResult *result, + GError **error); + +_TP_AVAILABLE_IN_0_24 +void tp_protocol_normalize_contact_uri_async (TpProtocol *self, + const gchar *uri, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +_TP_AVAILABLE_IN_0_24 +gchar *tp_protocol_normalize_contact_uri_finish (TpProtocol *self, + GAsyncResult *result, + GError **error); + +_TP_AVAILABLE_IN_0_24 +void tp_protocol_normalize_vcard_address_async (TpProtocol *self, + const gchar *field, + const gchar *value, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +_TP_AVAILABLE_IN_0_24 +gchar *tp_protocol_normalize_vcard_address_finish (TpProtocol *self, + GAsyncResult *result, + GError **error); + G_END_DECLS #include <telepathy-glib/_gen/tp-cli-protocol.h> diff --git a/telepathy-glib/proxy-methods.c b/telepathy-glib/proxy-methods.c index a7472bd10..3e0609a42 100644 --- a/telepathy-glib/proxy-methods.c +++ b/telepathy-glib/proxy-methods.c @@ -24,6 +24,7 @@ #define DEBUG_FLAG TP_DEBUG_PROXY #include "telepathy-glib/debug-internal.h" +#include <telepathy-glib/util.h> #if 0 #define MORE_DEBUG DEBUG @@ -314,7 +315,7 @@ tp_proxy_pending_call_cancel (TpProxyPendingCall *pc) if (pc->args != NULL) { - g_value_array_free (pc->args); + tp_value_array_free (pc->args); pc->args = NULL; } } @@ -363,7 +364,7 @@ tp_proxy_pending_call_free (TpProxyPendingCall *pc) pc->error = NULL; if (pc->args != NULL) - g_value_array_free (pc->args); + tp_value_array_free (pc->args); pc->args = NULL; diff --git a/telepathy-glib/proxy-signals.c b/telepathy-glib/proxy-signals.c index 2af1e3854..b90bba2bf 100644 --- a/telepathy-glib/proxy-signals.c +++ b/telepathy-glib/proxy-signals.c @@ -23,6 +23,7 @@ #define DEBUG_FLAG TP_DEBUG_PROXY #include "telepathy-glib/debug-internal.h" +#include <telepathy-glib/util.h> #if 0 #define MORE_DEBUG DEBUG @@ -249,7 +250,7 @@ tp_proxy_signal_invocation_free (gpointer p) g_assert (invocation->proxy == NULL); if (invocation->args != NULL) - g_value_array_free (invocation->args); + tp_value_array_free (invocation->args); g_slice_free (TpProxySignalInvocation, invocation); } diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c index 8d6befbf4..f7a5a0efc 100644 --- a/telepathy-glib/proxy.c +++ b/telepathy-glib/proxy.c @@ -2208,7 +2208,7 @@ finish_all_requests (TpProxy *self, tp_proxy_prepare_request_finish (iter->data, error); } - g_queue_clear (tmp); + g_queue_free (tmp); } /* diff --git a/telepathy-glib/room-info.c b/telepathy-glib/room-info.c index 1843b1d0f..10942dcf6 100644 --- a/telepathy-glib/room-info.c +++ b/telepathy-glib/room-info.c @@ -25,6 +25,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/dbus.h> +#include <telepathy-glib/util.h> /** * SECTION: room-info @@ -97,7 +98,8 @@ TpRoomInfo * _tp_room_info_new (GValueArray *dbus_struct) { TpRoomInfo *room; - GValue *v; + const gchar *channel_type; + GHashTable *info; g_return_val_if_fail (dbus_struct != NULL, NULL); g_return_val_if_fail (dbus_struct->n_values == 3, NULL); @@ -107,14 +109,16 @@ _tp_room_info_new (GValueArray *dbus_struct) room = g_object_new (TP_TYPE_ROOM_INFO, NULL); - v = g_value_array_get_nth (dbus_struct, 0); - room->priv->handle = g_value_get_uint (v); - - v = g_value_array_get_nth (dbus_struct, 1); - room->priv->channel_type = g_value_dup_string (v); - - v = g_value_array_get_nth (dbus_struct, 2); - room->priv->info = g_value_dup_boxed (v); + tp_value_array_unpack (dbus_struct, 3, + &room->priv->handle, + &channel_type, + &info); + room->priv->channel_type = g_strdup (channel_type); + room->priv->info = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, (GDestroyNotify) tp_g_value_slice_free); + tp_g_hash_table_update (room->priv->info, info, + (GBoxedCopyFunc) g_strdup, + (GBoxedCopyFunc) tp_g_value_slice_dup); return room; } diff --git a/telepathy-glib/run.c b/telepathy-glib/run.c index c3df19037..1b3393caf 100644 --- a/telepathy-glib/run.c +++ b/telepathy-glib/run.c @@ -219,8 +219,6 @@ tp_run_connection_manager (const char *prog_name, add_signal_handlers (); - g_type_init (); - g_set_prgname (prog_name); #ifdef ENABLE_BACKTRACE diff --git a/telepathy-glib/simple-client-factory.c b/telepathy-glib/simple-client-factory.c index c096ea040..0060b9d0a 100644 --- a/telepathy-glib/simple-client-factory.c +++ b/telepathy-glib/simple-client-factory.c @@ -51,8 +51,6 @@ * TpSimpleClientFactory *factory; * TpAccountManager *manager; * - * g_type_init (); - * * factory = my_factory_new (); * manager = tp_account_manager_new_with_factory (factory); * tp_account_manager_set_default (manager); diff --git a/telepathy-glib/telepathy-glib.h b/telepathy-glib/telepathy-glib.h index 8fa3bef77..f3c01c072 100644 --- a/telepathy-glib/telepathy-glib.h +++ b/telepathy-glib/telepathy-glib.h @@ -110,6 +110,7 @@ #include <telepathy-glib/stream-tube-channel.h> #include <telepathy-glib/stream-tube-connection.h> #include <telepathy-glib/text-channel.h> +#include <telepathy-glib/text-mixin.h> #include <telepathy-glib/tls-certificate.h> #include <telepathy-glib/variant-util.h> diff --git a/telepathy-glib/text-mixin.c b/telepathy-glib/text-mixin.c index 7d6364f95..54b3fd71e 100644 --- a/telepathy-glib/text-mixin.c +++ b/telepathy-glib/text-mixin.c @@ -559,7 +559,7 @@ tp_text_mixin_list_pending_messages_async (TpSvcChannelTypeText *iface, context, ret); for (i = 0; i < ret->len; i++) - g_value_array_free (g_ptr_array_index (ret, i)); + tp_value_array_free (g_ptr_array_index (ret, i)); g_ptr_array_unref (ret); } diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c index e01dd2291..a91117c91 100644 --- a/telepathy-glib/util.c +++ b/telepathy-glib/util.c @@ -1097,7 +1097,7 @@ _tp_quark_array_copy (const GQuark *quarks) * </programlisting> * </example> * - * Returns: a newly created #GValueArray, free with g_value_array_free. + * Returns: a newly created #GValueArray, free with tp_value_array_free() * * Since: 0.9.2 */ @@ -1111,7 +1111,9 @@ tp_value_array_build (gsize length, va_list var_args; char *error = NULL; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS arr = g_value_array_new (length); + G_GNUC_END_IGNORE_DEPRECATIONS va_start (var_args, type); @@ -1119,7 +1121,9 @@ tp_value_array_build (gsize length, { GValue *v = arr->values + arr->n_values; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_value_array_append (arr, NULL); + G_GNUC_END_IGNORE_DEPRECATIONS g_value_init (v, t); @@ -1130,7 +1134,7 @@ tp_value_array_build (gsize length, CRITICAL ("%s", error); g_free (error); - g_value_array_free (arr); + tp_value_array_free (arr); va_end (var_args); return NULL; } @@ -1188,7 +1192,9 @@ tp_value_array_unpack (GValueArray *array, break; } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (array, i); + G_GNUC_END_IGNORE_DEPRECATIONS G_VALUE_LCOPY (value, var_args, G_VALUE_NOCOPY_CONTENTS, &error); if (error != NULL) @@ -2118,3 +2124,19 @@ _tp_g_list_copy_deep (GList *list, return ret; } + +/** + * tp_value_array_free: + * @va: a #GValueArray + * + * Free @va. This is exactly the same as g_value_array_free(), but does not + * provoke deprecation warnings from GLib when used in conjunction with + * tp_value_array_build() and tp_value_array_unpack(). + * + * Since: 0.23.0 + */ +void +(tp_value_array_free) (GValueArray *va) +{ + _tp_value_array_free_inline (va); +} diff --git a/telepathy-glib/util.h b/telepathy-glib/util.h index 5c5b9a036..af63a3a99 100644 --- a/telepathy-glib/util.h +++ b/telepathy-glib/util.h @@ -117,6 +117,22 @@ void tp_value_array_unpack (GValueArray *array, gsize len, ...); +/* Work around GLib having deprecated something that is part of our API. */ +_TP_AVAILABLE_IN_0_24 +void tp_value_array_free (GValueArray *va); +#if TP_VERSION_MAX_ALLOWED >= TP_VERSION_0_24 +#define tp_value_array_free(va) _tp_value_array_free_inline (va) +#ifndef __GTK_DOC_IGNORE__ /* gtk-doc can't parse this */ +static inline void +_tp_value_array_free_inline (GValueArray *va) +{ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_value_array_free (va); + G_GNUC_END_IGNORE_DEPRECATIONS +} +#endif +#endif + /* See https://bugzilla.gnome.org/show_bug.cgi?id=680813 for glib inclusion */ typedef struct _TpWeakRef TpWeakRef; TpWeakRef *tp_weak_ref_new (gpointer object, diff --git a/telepathy-glib/versions/0.23.0.abi b/telepathy-glib/versions/0.23.0.abi new file mode 100644 index 000000000..303206560 --- /dev/null +++ b/telepathy-glib/versions/0.23.0.abi @@ -0,0 +1,19 @@ +Version: TELEPATHY_GLIB_0.23.0 +Extends: TELEPATHY_GLIB_0.21.2 +Release: 0.23.0 + +tp_cli_channel_dispatcher_interface_messages1_call_send_message +tp_cli_connection_interface_renaming_call_request_rename +tp_cli_connection_interface_renaming_connect_to_renamed +tp_cli_connection_interface_sidecars1_call_ensure_sidecar +tp_iface_quark_channel_dispatcher_interface_messages1 +tp_iface_quark_connection_interface_renaming +tp_iface_quark_connection_interface_sidecars1 +tp_svc_channel_dispatcher_interface_messages1_get_type +tp_svc_channel_dispatcher_interface_messages1_implement_send_message +tp_svc_connection_interface_renaming_emit_renamed +tp_svc_connection_interface_renaming_get_type +tp_svc_connection_interface_renaming_implement_request_rename +tp_svc_connection_interface_sidecars1_get_type +tp_svc_connection_interface_sidecars1_implement_ensure_sidecar +tp_value_array_free diff --git a/telepathy-glib/versions/0.23.1.abi b/telepathy-glib/versions/0.23.1.abi new file mode 100644 index 000000000..0354a99e7 --- /dev/null +++ b/telepathy-glib/versions/0.23.1.abi @@ -0,0 +1,24 @@ +Version: TELEPATHY_GLIB_0.23.1 +Extends: TELEPATHY_GLIB_0.23.0 +Release: 0.23.1 + +tp_connection_manager_param_dup_variant_type +tp_presence_status_spec_can_set_on_self +tp_presence_status_spec_copy +tp_presence_status_spec_free +tp_presence_status_spec_get_name +tp_presence_status_spec_get_presence_type +tp_presence_status_spec_get_type +tp_presence_status_spec_has_message +tp_presence_status_spec_new +tp_protocol_dup_presence_statuses +tp_protocol_get_addressable_uri_schemes +tp_protocol_get_addressable_vcard_fields +tp_protocol_identify_account_async +tp_protocol_identify_account_finish +tp_protocol_normalize_contact_async +tp_protocol_normalize_contact_finish +tp_protocol_normalize_contact_uri_async +tp_protocol_normalize_contact_uri_finish +tp_protocol_normalize_vcard_address_async +tp_protocol_normalize_vcard_address_finish diff --git a/telepathy-glib/versions/0.23.2.abi b/telepathy-glib/versions/0.23.2.abi new file mode 100644 index 000000000..a379404ef --- /dev/null +++ b/telepathy-glib/versions/0.23.2.abi @@ -0,0 +1,12 @@ +Version: TELEPATHY_GLIB_0.23.2 +Extends: TELEPATHY_GLIB_0.23.1 +Release: 0.23.2 + +tp_account_channel_request_new_dbus_tube +tp_account_channel_request_new_stream_tube +tp_account_channel_request_set_conference_initial_channels +tp_account_channel_request_set_file_transfer_hash +tp_account_channel_request_set_initial_invitee_ids +tp_account_channel_request_set_initial_invitees +tp_account_channel_request_set_sms_channel +tp_base_connection_get_account_path_suffix diff --git a/tests/asv.c b/tests/asv.c index 80981ff18..390304f80 100644 --- a/tests/asv.c +++ b/tests/asv.c @@ -37,8 +37,6 @@ int main (int argc, char **argv) /* Setup */ - g_type_init (); - hash = tp_asv_new ( "d:123.2", G_TYPE_DOUBLE, 123.2, "s:test", G_TYPE_STRING, "test", diff --git a/tests/capabilities.c b/tests/capabilities.c index b7c87f36c..3427117c3 100644 --- a/tests/capabilities.c +++ b/tests/capabilities.c @@ -23,7 +23,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); } @@ -118,8 +117,10 @@ test_basics (Test *test, arr = g_ptr_array_index (classes, 0); g_assert_cmpuint (arr->n_values, ==, 2); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); allowed = g_value_get_boxed (g_value_array_get_nth (arr, 1)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_assert_cmpuint (g_hash_table_size (fixed), ==, 2); @@ -137,8 +138,10 @@ test_basics (Test *test, arr = g_ptr_array_index (classes, 1); g_assert_cmpuint (arr->n_values, ==, 2); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); allowed = g_value_get_boxed (g_value_array_get_nth (arr, 1)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_cmpuint (g_hash_table_size (fixed), ==, 2); diff --git a/tests/contact-search-result.c b/tests/contact-search-result.c index 63f914be5..185a31c1c 100644 --- a/tests/contact-search-result.c +++ b/tests/contact-search-result.c @@ -63,7 +63,6 @@ int main (int argc, char **argv) { - g_type_init (); tp_debug_set_flags ("all"); g_test_init (&argc, &argv, NULL); diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am index e446645e6..0476442c0 100644 --- a/tests/dbus/Makefile.am +++ b/tests/dbus/Makefile.am @@ -287,9 +287,11 @@ TESTS_ENVIRONMENT = \ G_SLICE=debug-blocks \ G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ G_MESSAGES_DEBUG=all \ + GIO_USE_VFS=local \ + GSETTINGS_BACKEND=memory \ + TP_TESTS_SERVICES_DIR=@abs_srcdir@/dbus-1/services \ + DBUS_SESSION_BUS_ADDRESS=this-is-clearly-not-valid \ $(top_srcdir)/tools/test-wrapper.sh \ - sh $(top_srcdir)/tools/with-session-bus.sh \ - --config-file=dbus-uninstalled/session.conf -- \ $(EXTRA_TESTS_ENVIRONMENT) EXTRA_TESTS_ENVIRONMENT = @@ -308,8 +310,6 @@ VALGRIND_TESTS_ENVIRONMENT = \ $(VALGRIND) --suppressions=$(top_srcdir)/tests/tests.supp $(VALGRIND_FLAGS) BUILT_SOURCES = \ - dbus-installed/session.conf \ - dbus-uninstalled/session.conf \ _gen/errors-check.h \ _gen/svc.h \ _gen/svc.c \ @@ -324,10 +324,7 @@ distclean-local: rm -rf _gen EXTRA_DIST = \ - dbus-installed/session.conf.in \ - dbus-installed/services/spurious.service \ - dbus-uninstalled/session.conf.in \ - dbus-uninstalled/services/spurious.service \ + dbus-1/services/spurious.service \ telepathy/managers/spurious.manager \ telepathy/managers/test_manager_file.manager \ telepathy/managers/test_manager_file_invalid.manager \ @@ -342,27 +339,11 @@ run-test.sh: run-test.sh.in $< > $@ @chmod +x $@ -dbus-uninstalled/%.conf: $(srcdir)/dbus-uninstalled/%.conf.in - $(AM_V_at)$(MKDIR_P) dbus-uninstalled - $(AM_V_GEN)sed \ - -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \ - -e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" \ - $< > $@ - -dbus-installed/%.conf: $(srcdir)/dbus-installed/%.conf.in - $(AM_V_at)$(MKDIR_P) dbus-installed - $(AM_V_GEN)sed -e "s|[@]tpglibtestsdir[@]|@tpglibtestsdir@|g" $< > $@ - -service_files = dbus-installed/services/spurious.service -conf_in_files = dbus-installed/session.conf.in -conf_files = $(conf_in_files:.conf.in=.conf) +service_files = services/dbus-1/spurious.service if ENABLE_INSTALLED_TESTS -dbusservicedir = @tpglibtestsdir@/dbus-installed/services +dbusservicedir = @tpglibtestsdir@/dbus-1/services dbusservice_DATA = $(service_files) - -dbusconfigdir = @tpglibtestsdir@/dbus-installed -dbusconfig_DATA = $(conf_files) endif _gen/svc.h: _gen/svc.c @@ -371,7 +352,7 @@ _gen/svc.h: _gen/svc.c _gen/svc.c: with-properties.xml \ $(top_srcdir)/tools/glib-ginterface-gen.py \ Makefile.am - $(AM_V_at)$(mkdir_p) _gen + $(AM_V_at)$(MKDIR_P) _gen $(AM_V_GEN)$(PYTHON) $(top_srcdir)/tools/glib-ginterface-gen.py \ --filename=_gen/svc \ --signal-marshal-prefix=NOT_NEEDED \ @@ -380,5 +361,5 @@ _gen/svc.c: with-properties.xml \ _gen/errors-check.h: $(top_srcdir)/spec/errors.xml \ $(top_srcdir)/tools/glib-errors-check-gen.py - $(AM_V_at)$(mkdir_p) _gen + $(AM_V_at)$(MKDIR_P) _gen $(AM_V_GEN)$(PYTHON) $(top_srcdir)/tools/glib-errors-check-gen.py $< > $@ diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c index 0de180b5c..49e5f9ba7 100644 --- a/tests/dbus/account-channel-request.c +++ b/tests/dbus/account-channel-request.c @@ -210,6 +210,8 @@ test_handle_create_success (Test *test, tp_account_channel_request_set_target_id (req, TP_HANDLE_TYPE_CONTACT, "alice"); + tp_account_channel_request_set_sms_channel (req, TRUE); + /* We didn't start requesting the channel yet, so there is no * ChannelRequest */ chan_req = tp_account_channel_request_get_channel_request (req); @@ -236,7 +238,9 @@ test_handle_create_success (Test *test, TP_PROP_CHANNEL_TARGET_ID), ==, "alice"); g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL), ==, TP_HANDLE_TYPE_CONTACT); - g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 3); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4); + g_assert (tp_asv_get_boolean (test->cd_service->last_request, + TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL)); } /* ChannelDispatcher.CreateChannel() call fails */ @@ -315,7 +319,7 @@ test_handle_proceed_fail (Test *test, TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, NULL), ==, TRUE); g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, "ProceedFail", NULL), ==, TRUE); - g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 5); } /* ChannelRequest fire the 'Failed' signal */ @@ -354,7 +358,7 @@ test_handle_cr_failed (Test *test, "application/x-rar"); g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, "FireFailed", NULL), ==, TRUE); - g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 5); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 6); g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); } @@ -374,6 +378,8 @@ test_ft_props (Test *test, 1111222233); tp_account_channel_request_set_file_transfer_uri (req, "file:///home/Downloads/warez.rar"); + tp_account_channel_request_set_file_transfer_hash (req, + TP_FILE_HASH_TYPE_SHA256, "This is not a hash"); /* Ask to the CR to fire the signal */ tp_account_channel_request_set_request_property (req, "FireFailed", @@ -411,9 +417,82 @@ test_ft_props (Test *test, g_assert_cmpuint (tp_asv_get_uint64 (test->cd_service->last_request, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE, NULL), ==, 1111222233); + g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE, NULL), ==, + TP_FILE_HASH_TYPE_SHA256); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH), ==, + "This is not a hash"); + g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, + "FireFailed", NULL), ==, TRUE); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 12); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); +} + +static void +test_stream_tube_props (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + + req = tp_account_channel_request_new_stream_tube (test->account, "daap", + 0); + + /* Ask to the CR to fire the signal */ + tp_account_channel_request_set_request_property (req, "FireFailed", + g_variant_new_boolean (TRUE)); + + tp_account_channel_request_create_and_handle_channel_async (req, + NULL, create_and_handle_cb, test); + + g_object_unref (req); + + g_main_loop_run (test->mainloop); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert (test->channel == NULL); + + /* The request had the properties we wanted */ + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE), ==, "daap"); g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, "FireFailed", NULL), ==, TRUE); - g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 9); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); +} + +static void +test_dbus_tube_props (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + + req = tp_account_channel_request_new_dbus_tube (test->account, + "com.example.ServiceName", 0); + + /* Ask to the CR to fire the signal */ + tp_account_channel_request_set_request_property (req, "FireFailed", + g_variant_new_boolean (TRUE)); + + tp_account_channel_request_create_and_handle_channel_async (req, + NULL, create_and_handle_cb, test); + + g_object_unref (req); + + g_main_loop_run (test->mainloop); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert (test->channel == NULL); + + /* The request had the properties we wanted */ + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME), ==, + "com.example.ServiceName"); + g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, + "FireFailed", NULL), ==, TRUE); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4); g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); } @@ -1231,6 +1310,124 @@ test_observe_no_channel (Test *test, g_assert_error (test->error, TP_ERROR, TP_ERROR_CONFUSED); } +/* Check if TargetHandleType: TP_HANDLE_TYPE_NONE is automatically added if no + * target has been specified by the user. */ +static void +test_no_handle_type (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + gboolean valid; + const gchar * const channels[] = { "/chan1", "/chan2", NULL }; + GPtrArray *chans; + const gchar * const invitees[] = { "badger@badger.com", + "snake@badger.com", NULL }; + const gchar * const *strv; + + req = tp_account_channel_request_new_text (test->account, 0); + + tp_account_channel_request_set_conference_initial_channels (req, channels); + + tp_account_channel_request_set_initial_invitee_ids (req, invitees); + + /* Ask to the CR to fire the signal */ + tp_account_channel_request_set_request_property (req, "FireFailed", + g_variant_new_boolean (TRUE)); + + tp_account_channel_request_create_and_handle_channel_async (req, + NULL, create_and_handle_cb, test); + + g_object_unref (req); + + g_main_loop_run (test->mainloop); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert (test->channel == NULL); + + /* The request had the properties we wanted */ + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_TEXT); + g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid), ==, TP_HANDLE_TYPE_NONE); + g_assert (valid); + g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, + "FireFailed", NULL), ==, TRUE); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 5); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); + + chans = tp_asv_get_boxed (test->cd_service->last_request, + TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_CHANNELS, + TP_ARRAY_TYPE_OBJECT_PATH_LIST); + g_assert (chans != NULL); + g_assert_cmpuint (chans->len, ==, 2); + g_assert_cmpstr (g_ptr_array_index (chans, 0), ==, "/chan1"); + g_assert_cmpstr (g_ptr_array_index (chans, 1), ==, "/chan2"); + + strv = tp_asv_get_boxed (test->cd_service->last_request, + TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS, + G_TYPE_STRV); + g_assert (strv != NULL); + g_assert_cmpuint (g_strv_length ((GStrv) strv), ==, 2); + g_assert (tp_strv_contains (strv, "badger@badger.com")); + g_assert (tp_strv_contains (strv, "snake@badger.com")); +} + +static void +test_initial_invitees (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + gboolean valid; + GPtrArray *invitees; + TpContact *contact; + const gchar * const *strv; + + req = tp_account_channel_request_new_text (test->account, 0); + + invitees = g_ptr_array_new_with_free_func (g_object_unref); + + contact = tp_tests_connection_run_until_contact_by_id (test->connection, + "badger@badger.com", 0, NULL); + g_ptr_array_add (invitees, contact); + contact = tp_tests_connection_run_until_contact_by_id (test->connection, + "snake@badger.com", 0, NULL); + g_ptr_array_add (invitees, contact); + + tp_account_channel_request_set_initial_invitees (req, invitees); + g_ptr_array_unref (invitees); + + /* Ask to the CR to fire the signal */ + tp_account_channel_request_set_request_property (req, "FireFailed", + g_variant_new_boolean (TRUE)); + + tp_account_channel_request_create_and_handle_channel_async (req, + NULL, create_and_handle_cb, test); + + g_object_unref (req); + + g_main_loop_run (test->mainloop); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert (test->channel == NULL); + + /* The request had the properties we wanted */ + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_TEXT); + g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid), ==, TP_HANDLE_TYPE_NONE); + g_assert (valid); + g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, + "FireFailed", NULL), ==, TRUE); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 4); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); + + strv = tp_asv_get_boxed (test->cd_service->last_request, + TP_PROP_CHANNEL_INTERFACE_CONFERENCE_INITIAL_INVITEE_IDS, + G_TYPE_STRV); + g_assert (strv != NULL); + g_assert_cmpuint (g_strv_length ((GStrv) strv), ==, 2); + g_assert (tp_strv_contains (strv, "badger@badger.com")); + g_assert (tp_strv_contains (strv, "snake@badger.com")); +} + int main (int argc, char **argv) @@ -1297,6 +1494,14 @@ main (int argc, /* Particular properties of the request */ g_test_add ("/account-channels/test-ft-props", Test, NULL, setup, test_ft_props, teardown); - - return g_test_run (); + g_test_add ("/account-channels/test-stream-tube-props", Test, NULL, + setup, test_stream_tube_props, teardown); + g_test_add ("/account-channels/test-dbus-tube-props", Test, NULL, + setup, test_dbus_tube_props, teardown); + g_test_add ("/account-channels/test-no-handle-type", Test, NULL, + setup, test_no_handle_type, teardown); + g_test_add ("/account-channels/test-initial-invitees", Test, NULL, + setup, test_initial_invitees, teardown); + + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c index 22de1c59d..0cf95e9d7 100644 --- a/tests/dbus/account-manager.c +++ b/tests/dbus/account-manager.c @@ -134,7 +134,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -276,7 +275,7 @@ finish_prepare_action (GObject *source_object, g_assert (test->am == am); test->prepared = tp_account_manager_prepare_finish (am, res, &test->error); - is_prepared_reply = tp_account_manager_is_prepared (test->am, + is_prepared_reply = tp_proxy_is_prepared (test->am, TP_ACCOUNT_MANAGER_FEATURE_CORE); g_assert_cmpint (is_prepared_reply, ==, test->prepared); script_continue (test); @@ -338,7 +337,7 @@ assert_core_not_ready_action (gpointer script_data, { Test *test = (Test *) script_data; - g_assert (!tp_account_manager_is_prepared (test->am, + g_assert (!tp_proxy_is_prepared (test->am, TP_ACCOUNT_MANAGER_FEATURE_CORE)); script_continue (script_data); @@ -350,7 +349,7 @@ assert_feature_not_ready_action (gpointer script_data, { Test *test = (Test *) script_data; - g_assert (!tp_account_manager_is_prepared (test->am, + g_assert (!tp_proxy_is_prepared (test->am, g_quark_from_string ((gchar *) user_data))); g_free (user_data); @@ -410,7 +409,7 @@ ensure_action (gpointer script_data, Test *test = (Test *) script_data; g_assert (test != NULL); g_assert (test->am != NULL); - g_assert (tp_account_manager_is_prepared (test->am, TP_ACCOUNT_MANAGER_FEATURE_CORE)); + g_assert (tp_proxy_is_prepared (test->am, TP_ACCOUNT_MANAGER_FEATURE_CORE)); test->account = tp_account_manager_ensure_account (test->am, path); @@ -437,7 +436,7 @@ finish_account_prepare_action (GObject *source_object, g_assert (test->account == account); test->prepared = tp_account_prepare_finish (account, res, &test->error); - g_assert (test->prepared == tp_account_is_prepared (account, TP_ACCOUNT_FEATURE_CORE)); + g_assert (test->prepared == tp_proxy_is_prepared (account, TP_ACCOUNT_FEATURE_CORE)); script_continue (test); } @@ -813,5 +812,5 @@ main (int argc, test_most_available_one_unset, teardown_service); g_test_add ("/am/most-available/two-unset", Test, NULL, setup_service, test_most_available_two_unset, teardown_service); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/account-request.c b/tests/dbus/account-request.c index bc3b7d2b6..aedc6b858 100644 --- a/tests/dbus/account-request.c +++ b/tests/dbus/account-request.c @@ -547,7 +547,6 @@ int main (int argc, char **argv) { - g_type_init (); tp_tests_abort_after (10); tp_debug_set_flags ("all"); @@ -566,5 +565,5 @@ main (int argc, g_test_add ("/account-request/create-fail", Test, NULL, setup, test_create_fail, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/account.c b/tests/dbus/account.c index b921f4068..1df043ab5 100644 --- a/tests/dbus/account.c +++ b/tests/dbus/account.c @@ -371,7 +371,7 @@ test_prepare_success (Test *test, g_main_loop_run (test->mainloop); /* the obvious accessors */ - g_assert (tp_account_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); + g_assert (tp_proxy_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); g_assert (tp_account_is_enabled (test->account)); assert_boolprop (test->account, "enabled", TRUE); g_assert (tp_account_is_valid (test->account)); @@ -690,6 +690,13 @@ test_addressing (Test *test, } static void +avatar_changed_cb (TpAccount *account, + Test *test) +{ + g_main_loop_quit (test->mainloop); +} + +static void test_avatar (Test *test, gconstpointer mode) { @@ -714,6 +721,27 @@ test_avatar (Test *test, g_assert_cmpstr (((char *) blob->data), ==, ":-)"); tp_clear_object (&test->result); + + /* change the avatar */ + g_signal_connect (test->account, "avatar-changed", + G_CALLBACK (avatar_changed_cb), test); + + tp_tests_simple_account_set_avatar (test->account_service, ":-("); + g_main_loop_run (test->mainloop); + + tp_account_get_avatar_async (test->account, + tp_tests_result_ready_cb, &test->result); + tp_tests_run_until_result (&test->result); + + blob = tp_account_get_avatar_finish ( + test->account, test->result, &error); + g_assert_no_error (error); + + g_assert (blob != NULL); + g_assert_cmpuint (blob->len, ==, 4); + g_assert_cmpstr (((char *) blob->data), ==, ":-("); + + tp_clear_object (&test->result); } static void @@ -738,7 +766,7 @@ test_connection (Test *test, account_prepare_cb, test); g_main_loop_run (test->mainloop); - g_assert (tp_account_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); + g_assert (tp_proxy_is_prepared (test->account, TP_ACCOUNT_FEATURE_CORE)); /* a connection turns up */ @@ -902,7 +930,6 @@ int main (int argc, char **argv) { - g_type_init (); tp_tests_abort_after (10); tp_debug_set_flags ("all"); @@ -975,5 +1002,5 @@ main (int argc, g_test_add ("/account/addressing", Test, "later", setup_service, test_addressing, teardown_service); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c index 843391510..a4de836e1 100644 --- a/tests/dbus/base-client.c +++ b/tests/dbus/base-client.c @@ -1605,5 +1605,5 @@ main (int argc, g_test_add ("/cd/delegate-to-preferred-handler/supported", Test, NULL, setup, test_delegate_to_preferred_handler_supported, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/call-cancellation.c b/tests/dbus/call-cancellation.c index d1f15f81c..95e790fbd 100644 --- a/tests/dbus/call-cancellation.c +++ b/tests/dbus/call-cancellation.c @@ -174,7 +174,6 @@ main (int argc, TpProxyPendingCall *pc; gpointer tmp_obj; - g_type_init (); tp_tests_abort_after (10); tp_debug_set_flags ("all"); diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c index 4e12a056e..12bafce78 100644 --- a/tests/dbus/call-channel.c +++ b/tests/dbus/call-channel.c @@ -71,7 +71,6 @@ setup (Test *test, guint not_a_media_type = 31337; GQuark conn_features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -1086,5 +1085,5 @@ main (int argc, g_test_add ("/call/dtmf", Test, NULL, setup, test_dtmf, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/channel-dispatch-operation.c b/tests/dbus/channel-dispatch-operation.c index 31410ca18..f5c39f28d 100644 --- a/tests/dbus/channel-dispatch-operation.c +++ b/tests/dbus/channel-dispatch-operation.c @@ -55,7 +55,6 @@ setup (Test *test, { DBusConnection *libdbus; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -945,5 +944,5 @@ main (int argc, g_test_add ("/cdo/destroy-channels", Test, NULL, setup_services, test_destroy_channels, teardown_services); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/channel-dispatcher.c b/tests/dbus/channel-dispatcher.c index 94bc68e3a..d3b466e03 100644 --- a/tests/dbus/channel-dispatcher.c +++ b/tests/dbus/channel-dispatcher.c @@ -27,7 +27,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -74,5 +73,5 @@ main (int argc, /* tp_channel_dispatcher_present_channel_async() is tested in * test-base-client */ - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/channel-introspect.c b/tests/dbus/channel-introspect.c index 072cf69e5..989dfde54 100644 --- a/tests/dbus/channel-introspect.c +++ b/tests/dbus/channel-introspect.c @@ -137,7 +137,6 @@ main (int argc, GQuark some_features[] = { TP_CHANNEL_FEATURE_CORE, TP_CHANNEL_FEATURE_CHAT_STATES, 0 }; - g_type_init (); tp_tests_abort_after (10); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/channel-manager-request-properties.c b/tests/dbus/channel-manager-request-properties.c index 5a5ecf342..71ce7701c 100644 --- a/tests/dbus/channel-manager-request-properties.c +++ b/tests/dbus/channel-manager-request-properties.c @@ -42,7 +42,6 @@ setup (Test *test, gboolean ok; gchar *name, *conn_path; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -221,5 +220,5 @@ main (int argc, g_test_add ("/channel-manager-request-properties/target-id", Test, NULL, setup, test_target_id, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c index c09d9390f..13920194d 100644 --- a/tests/dbus/channel-request.c +++ b/tests/dbus/channel-request.c @@ -75,7 +75,6 @@ setup (Test *test, { DBusConnection *libdbus; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -440,5 +439,5 @@ main (int argc, test_immutable_properties, teardown); g_test_add ("/cr/properties", Test, NULL, setup, test_properties, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/channel.c b/tests/dbus/channel.c index 0cec68374..593681ea8 100644 --- a/tests/dbus/channel.c +++ b/tests/dbus/channel.c @@ -707,5 +707,5 @@ main (int argc, g_test_add ("/channel/contacts", Test, NULL, setup, test_contacts, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c index 82a138dac..59c007c42 100644 --- a/tests/dbus/cli-group.c +++ b/tests/dbus/cli-group.c @@ -496,7 +496,6 @@ main (int argc, gchar *name; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/client-channel-factory.c b/tests/dbus/client-channel-factory.c index a3cbb26e0..92668ab6a 100644 --- a/tests/dbus/client-channel-factory.c +++ b/tests/dbus/client-channel-factory.c @@ -267,5 +267,5 @@ main (int argc, g_test_add ("/client-channel-factory/auto/dup", Test, NULL, setup, test_auto_dup, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/client.c b/tests/dbus/client.c index 2bde19c3e..3f442b8d9 100644 --- a/tests/dbus/client.c +++ b/tests/dbus/client.c @@ -27,7 +27,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -73,5 +72,5 @@ main (int argc, g_test_add ("/client/new", Test, NULL, setup, test_new, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/cm-message.c b/tests/dbus/cm-message.c index 5e504b3eb..3084d536c 100644 --- a/tests/dbus/cm-message.c +++ b/tests/dbus/cm-message.c @@ -22,7 +22,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); tp_tests_create_and_connect_conn (TP_TESTS_TYPE_SIMPLE_CONNECTION, @@ -341,5 +340,5 @@ main (int argc, g_test_add (TEST_PREFIX "take_message", Test, NULL, setup, test_take_message, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c index cd6248853..ad4285475 100644 --- a/tests/dbus/cm.c +++ b/tests/dbus/cm.c @@ -131,7 +131,6 @@ setup (Test *test, TpBaseConnectionManager *service_cm_as_base; gboolean ok; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -1191,5 +1190,5 @@ main (int argc, g_test_add ("/cm/list", Test, GINT_TO_POINTER (USE_OLD_LIST), setup, test_list, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/connection-aliasing.c b/tests/dbus/connection-aliasing.c index 3b5e6f89d..2572dc8fe 100644 --- a/tests/dbus/connection-aliasing.c +++ b/tests/dbus/connection-aliasing.c @@ -48,7 +48,6 @@ setup (Test *test, GError *error = NULL; GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; - g_type_init (); tp_debug_set_flags ("all"); test->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -153,13 +152,11 @@ int main (int argc, char **argv) { - g_type_init (); - tp_tests_abort_after (5); g_test_init (&argc, &argv, NULL); g_test_add ("/conn/aliasing/user-set", Test, NULL, setup, test_user_set, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/connection-balance.c b/tests/dbus/connection-balance.c index 4d022aba3..c80899661 100644 --- a/tests/dbus/connection-balance.c +++ b/tests/dbus/connection-balance.c @@ -202,7 +202,6 @@ setup (Test *test, GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; GType conn_type = GPOINTER_TO_SIZE (data); - g_type_init (); tp_debug_set_flags ("all"); test->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -383,8 +382,6 @@ int main (int argc, char **argv) { - g_type_init (); - tp_tests_abort_after (5); g_test_init (&argc, &argv, NULL); @@ -398,5 +395,5 @@ main (int argc, GSIZE_TO_POINTER (TP_TESTS_TYPE_SIMPLE_CONNECTION), setup, test_balance_unknown, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/connection-bug-18845.c b/tests/dbus/connection-bug-18845.c index 88a308114..e76e62616 100644 --- a/tests/dbus/connection-bug-18845.c +++ b/tests/dbus/connection-bug-18845.c @@ -46,7 +46,6 @@ main (int argc, DBusGProxy *proxy; tp_tests_abort_after (10); - g_type_init (); invalidated_for_test.domain = TP_ERROR; tp_debug_set_flags ("all"); diff --git a/tests/dbus/connection-error.c b/tests/dbus/connection-error.c index 1ade331a8..bf8ecaf8a 100644 --- a/tests/dbus/connection-error.c +++ b/tests/dbus/connection-error.c @@ -87,7 +87,6 @@ example_com_error_quark (void) g_assert (sizeof (GQuark) <= sizeof (gsize)); - g_type_init (); dbus_g_error_domain_register (domain, "com.example", example_com_error_get_type ()); g_once_init_leave (&quark, domain); @@ -116,7 +115,6 @@ global_setup (void) done = TRUE; - g_type_init (); tp_debug_set_flags ("all"); tp_proxy_subclass_add_error_mapping (TP_TYPE_CONNECTION, @@ -395,5 +393,5 @@ main (int argc, g_test_add ("/connection/detailed-error-vardict", Test, "variant", setup, test_detailed_error, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/connection-getinterfaces-failure.c b/tests/dbus/connection-getinterfaces-failure.c index 4d3494a07..693feefcd 100644 --- a/tests/dbus/connection-getinterfaces-failure.c +++ b/tests/dbus/connection-getinterfaces-failure.c @@ -94,7 +94,6 @@ main (int argc, gchar *conn_path; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); mainloop = g_main_loop_new (NULL, FALSE); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/connection-handles.c b/tests/dbus/connection-handles.c index bab685f14..23244657c 100644 --- a/tests/dbus/connection-handles.c +++ b/tests/dbus/connection-handles.c @@ -294,7 +294,6 @@ main (int argc, /* Setup */ tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/connection-inject-bug16307.c b/tests/dbus/connection-inject-bug16307.c index 87bd041d2..379653029 100644 --- a/tests/dbus/connection-inject-bug16307.c +++ b/tests/dbus/connection-inject-bug16307.c @@ -41,7 +41,6 @@ main (int argc, TpConnection *conn; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); mainloop = g_main_loop_new (NULL, FALSE); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/connection-interests.c b/tests/dbus/connection-interests.c index c850e555c..d5d703e43 100644 --- a/tests/dbus/connection-interests.c +++ b/tests/dbus/connection-interests.c @@ -148,7 +148,6 @@ setup (Test *test, GError *error = NULL; GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; - g_type_init (); tp_debug_set_flags ("all"); test->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -397,5 +396,5 @@ main (int argc, g_test_add ("/conn/interested-client", Test, NULL, setup, test_interested_client, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c index 0d2631133..8ed18f620 100644 --- a/tests/dbus/connection.c +++ b/tests/dbus/connection.c @@ -57,7 +57,6 @@ setup (Test *test, invalidated_for_test.domain = TP_ERROR; - g_type_init (); tp_debug_set_flags ("all"); test->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -446,5 +445,5 @@ main (int argc, g_test_add ("/conn/object_path", Test, NULL, setup, test_object_path, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/contact-list-client.c b/tests/dbus/contact-list-client.c index 943645c36..a3f878a16 100644 --- a/tests/dbus/contact-list-client.c +++ b/tests/dbus/contact-list-client.c @@ -580,5 +580,5 @@ main (int argc, g_test_add ("/contact-list-client/contact-list/properties", Test, GUINT_TO_POINTER (TRUE), setup, test_contact_list_properties, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/contact-lists.c b/tests/dbus/contact-lists.c index b97e69371..43ab26280 100644 --- a/tests/dbus/contact-lists.c +++ b/tests/dbus/contact-lists.c @@ -326,7 +326,6 @@ setup_pre_connect ( GError *error = NULL; const gchar *account; - g_type_init (); tp_debug_set_flags ("all"); test->dbus = tp_tests_dbus_daemon_dup_or_die (); test->main_loop = g_main_loop_new (NULL, FALSE); @@ -2740,7 +2739,6 @@ int main (int argc, char **argv) { - g_type_init (); tp_tests_abort_after (30); tp_debug_set_flags ("all"); @@ -2906,5 +2904,5 @@ main (int argc, g_test_add ("/contact-lists/download", Test, NULL, setup, test_download_contacts, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/contacts-bug-19101.c b/tests/dbus/contacts-bug-19101.c index 77474e15e..debc35b9e 100644 --- a/tests/dbus/contacts-bug-19101.c +++ b/tests/dbus/contacts-bug-19101.c @@ -146,7 +146,6 @@ main (int argc, /* Setup */ tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/contacts-mixin.c b/tests/dbus/contacts-mixin.c index 5e286c3df..c3146ed52 100644 --- a/tests/dbus/contacts-mixin.c +++ b/tests/dbus/contacts-mixin.c @@ -158,7 +158,6 @@ main (int argc, /* Setup */ tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/contacts-slow-path.c b/tests/dbus/contacts-slow-path.c index b7094c0e2..8c8b7491e 100644 --- a/tests/dbus/contacts-slow-path.c +++ b/tests/dbus/contacts-slow-path.c @@ -1297,5 +1297,5 @@ main (int argc, g_test_add ("/contacts-slow-path/one-by-id", Fixture, NULL, setup, test_one_by_id, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c index 9c070a732..0155cd221 100644 --- a/tests/dbus/contacts.c +++ b/tests/dbus/contacts.c @@ -326,7 +326,7 @@ test_contact_info (Fixture *f, GCancellable *cancellable; /* Create fake info fields */ - info = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free); + info = g_ptr_array_new_with_free_func ((GDestroyNotify) tp_value_array_free); g_ptr_array_add (info, tp_value_array_build (3, G_TYPE_STRING, "n", G_TYPE_STRV, NULL, @@ -3070,7 +3070,7 @@ main (int argc, g_test_add ("/contacts/self-contact", Fixture, NULL, setup_no_connect, test_self_contact, teardown); - ret = g_test_run (); + ret = tp_tests_run_with_bus (); g_assert (haze_remove_directory (dir)); g_free (dir); diff --git a/tests/dbus/dbus-installed/services/spurious.service b/tests/dbus/dbus-1/services/spurious.service index d0d70aa04..d0d70aa04 100644 --- a/tests/dbus/dbus-installed/services/spurious.service +++ b/tests/dbus/dbus-1/services/spurious.service diff --git a/tests/dbus/dbus-installed/session.conf.in b/tests/dbus/dbus-installed/session.conf.in deleted file mode 100644 index 313c653d1..000000000 --- a/tests/dbus/dbus-installed/session.conf.in +++ /dev/null @@ -1,29 +0,0 @@ -<!-- Copied from telepathy-gabble (which doubtless copied it from somewhere - else) and modified. - This configuration file controls the per-user-login-session message bus. - Add a session-local.conf and edit that rather than changing this - file directly. --> - -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - <!-- Our well-known bus type, don't change this --> - <type>session</type> - - <listen>unix:tmpdir=/tmp</listen> - - <servicedir>@tpglibtestsdir@/dbus-installed/services/</servicedir> - - <policy context="default"> - <!-- Allow everything to be sent --> - <allow send_destination="*" eavesdrop="true"/> - <!-- Allow everything to be received --> - <allow eavesdrop="true"/> - <!-- Allow anyone to own anything --> - <allow own="*"/> - </policy> - - <!-- This is included last so local configuration can override what's - in this standard file --> - -</busconfig> diff --git a/tests/dbus/dbus-tube.c b/tests/dbus/dbus-tube.c index ae9c83149..90e5e44df 100644 --- a/tests/dbus/dbus-tube.c +++ b/tests/dbus/dbus-tube.c @@ -514,5 +514,5 @@ main (int argc, g_test_add ("/dbus-tube/accept-invalidated-before-open", Test, NULL, setup, test_accept_invalidated_before_open, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/dbus-uninstalled/services/spurious.service b/tests/dbus/dbus-uninstalled/services/spurious.service deleted file mode 100644 index d0d70aa04..000000000 --- a/tests/dbus/dbus-uninstalled/services/spurious.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.freedesktop.Telepathy.ConnectionManager.spurious -Exec=/bin/false diff --git a/tests/dbus/dbus-uninstalled/session.conf.in b/tests/dbus/dbus-uninstalled/session.conf.in deleted file mode 100644 index 075ef7421..000000000 --- a/tests/dbus/dbus-uninstalled/session.conf.in +++ /dev/null @@ -1,29 +0,0 @@ -<!-- Copied from telepathy-gabble (which doubtless copied it from somewhere - else) and modified. - This configuration file controls the per-user-login-session message bus. - Add a session-local.conf and edit that rather than changing this - file directly. --> - -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - <!-- Our well-known bus type, don't change this --> - <type>session</type> - - <listen>unix:tmpdir=/tmp</listen> - - <servicedir>@abs_top_srcdir@/tests/dbus/dbus-uninstalled/services</servicedir> - - <policy context="default"> - <!-- Allow everything to be sent --> - <allow send_destination="*" eavesdrop="true"/> - <!-- Allow everything to be received --> - <allow eavesdrop="true"/> - <!-- Allow anyone to own anything --> - <allow own="*"/> - </policy> - - <!-- This is included last so local configuration can override what's - in this standard file --> - -</busconfig> diff --git a/tests/dbus/dbus.c b/tests/dbus/dbus.c index 3772856a0..3aec68f22 100644 --- a/tests/dbus/dbus.c +++ b/tests/dbus/dbus.c @@ -342,5 +342,5 @@ main (int argc, g_test_add_func ("/dbus-daemon/cancel-watch-during-dispatch", cancel_watch_during_dispatch); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/debug-client.c b/tests/dbus/debug-client.c index 50d07fae4..ab5ce5914 100644 --- a/tests/dbus/debug-client.c +++ b/tests/dbus/debug-client.c @@ -332,5 +332,5 @@ main (int argc, g_test_add ("/debug-client/get-messages-failed", Test, NULL, setup, test_get_messages_failed, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/disconnection.c b/tests/dbus/disconnection.c index bfa55cb2b..ef8ad11c8 100644 --- a/tests/dbus/disconnection.c +++ b/tests/dbus/disconnection.c @@ -164,7 +164,6 @@ main (int argc, gboolean freed = FALSE; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); freed_user_data = tp_intset_sized_new (N_DAEMONS); diff --git a/tests/dbus/error-enum.c b/tests/dbus/error-enum.c index ef4cd1d31..d5316a13c 100644 --- a/tests/dbus/error-enum.c +++ b/tests/dbus/error-enum.c @@ -2,6 +2,8 @@ #include <telepathy-glib/errors.h> +#include "tests/lib/util.h" + static void test_tp_errors (void) { @@ -16,5 +18,5 @@ main (int argc, g_test_add_func ("/test-error-enum/TP_ERROR", test_tp_errors); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/example-no-protocols.c b/tests/dbus/example-no-protocols.c index 4a076f5e6..2d22acd0f 100644 --- a/tests/dbus/example-no-protocols.c +++ b/tests/dbus/example-no-protocols.c @@ -97,7 +97,6 @@ main (int argc, gboolean saw_exited; tp_tests_abort_after (5); - g_type_init (); tp_debug_set_flags ("all"); diff --git a/tests/dbus/file-transfer-channel.c b/tests/dbus/file-transfer-channel.c index 3a167f763..be4c4ea29 100644 --- a/tests/dbus/file-transfer-channel.c +++ b/tests/dbus/file-transfer-channel.c @@ -585,7 +585,6 @@ main (int argc, char **argv) { tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); g_test_init (&argc, &argv, NULL); @@ -614,5 +613,5 @@ main (int argc, g_test_add ("/file-transfer-channel/provide/cancel", Test, NULL, setup, test_cancel_transfer, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/finalized-in-invalidated-handler.c b/tests/dbus/finalized-in-invalidated-handler.c index 03f7d6635..0eab5797c 100644 --- a/tests/dbus/finalized-in-invalidated-handler.c +++ b/tests/dbus/finalized-in-invalidated-handler.c @@ -84,7 +84,6 @@ main (int argc, TpHandle handle; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); mainloop = g_main_loop_new (NULL, FALSE); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/get-interface-after-invalidate.c b/tests/dbus/get-interface-after-invalidate.c index 08adf6b7c..73cab5f18 100644 --- a/tests/dbus/get-interface-after-invalidate.c +++ b/tests/dbus/get-interface-after-invalidate.c @@ -41,5 +41,5 @@ main (int argc, g_test_add_func ("/test-get-interface-after-invalidate", test_get_interface_after_invalidate); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c index 0b7a0a3a4..8943f4bef 100644 --- a/tests/dbus/group-mixin.c +++ b/tests/dbus/group-mixin.c @@ -526,7 +526,6 @@ main (int argc, gchar *chan_path; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/handle-repo.c b/tests/dbus/handle-repo.c index ec8002486..500826fd1 100644 --- a/tests/dbus/handle-repo.c +++ b/tests/dbus/handle-repo.c @@ -101,7 +101,6 @@ test_handles (void) int main (int argc, char **argv) { tp_tests_abort_after (10); - g_type_init (); test_handles (); diff --git a/tests/dbus/handle-set.c b/tests/dbus/handle-set.c index 4dc774b4e..4e9f9c007 100644 --- a/tests/dbus/handle-set.c +++ b/tests/dbus/handle-set.c @@ -27,7 +27,6 @@ main (int argc, TpHandle h1, h2, h3, h4; tp_tests_abort_after (10); - g_type_init (); repo = tp_tests_object_new_static_class (TP_TYPE_DYNAMIC_HANDLE_REPO, "handle-type", TP_HANDLE_TYPE_CONTACT, diff --git a/tests/dbus/invalidated-while-invoking-signals.c b/tests/dbus/invalidated-while-invoking-signals.c index 93606449d..01a5f3029 100644 --- a/tests/dbus/invalidated-while-invoking-signals.c +++ b/tests/dbus/invalidated-while-invoking-signals.c @@ -65,7 +65,6 @@ main (int argc, gchar *path; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); mainloop = g_main_loop_new (NULL, FALSE); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/long-connection-name.c b/tests/dbus/long-connection-name.c index bd34b1635..ac2b38b12 100644 --- a/tests/dbus/long-connection-name.c +++ b/tests/dbus/long-connection-name.c @@ -35,6 +35,7 @@ int main (int argc, char **argv) { + TpDBusDaemon *dbus; TpTestsEchoConnection *service_conn; TpBaseConnection *service_conn_as_base; GError *error = NULL; @@ -42,7 +43,7 @@ main (int argc, gchar *conn_path; tp_tests_abort_after (10); - g_type_init (); + dbus = tp_tests_dbus_daemon_dup_or_die (); MYASSERT (strlen (LONG_ACCOUNT_IS_LONG) == 256, ""); service_conn = TP_TESTS_ECHO_CONNECTION (tp_tests_object_new_static_class ( @@ -63,6 +64,7 @@ main (int argc, MYASSERT (strlen (name) == 255, ""); g_object_unref (service_conn); + g_object_unref (dbus); g_free (name); g_free (conn_path); return 0; diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c index 7f526ec19..8e46b41bb 100644 --- a/tests/dbus/message-mixin.c +++ b/tests/dbus/message-mixin.c @@ -219,7 +219,6 @@ main (int argc, GHashTable *parameters; tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/params-cm.c b/tests/dbus/params-cm.c index 9a4a6bb75..91f370253 100644 --- a/tests/dbus/params-cm.c +++ b/tests/dbus/params-cm.c @@ -59,7 +59,6 @@ setup (Test *test, TpBaseConnectionManager *service_cm_as_base; gboolean ok; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -362,5 +361,5 @@ main (int argc, g_test_add ("/params-cm/get-parameters-bad-proto", Test, NULL, setup, test_get_parameters_bad_proto, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/properties.c b/tests/dbus/properties.c index a458c7c3a..336ab0240 100644 --- a/tests/dbus/properties.c +++ b/tests/dbus/properties.c @@ -243,7 +243,7 @@ main (int argc, char **argv) g_test_add_data_func ("/properties/changed", &ctx, (GTestDataFunc) test_emit_changed); - g_test_run (); + tp_tests_run_with_bus (); g_object_unref (ctx.obj); g_object_unref (ctx.proxy); diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c index dcaea52f2..9dcdfd27a 100644 --- a/tests/dbus/protocol-objects.c +++ b/tests/dbus/protocol-objects.c @@ -11,6 +11,7 @@ #include <telepathy-glib/protocol.h> #include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/variant-util-internal.h> #include "tests/lib/echo-cm.h" @@ -46,7 +47,6 @@ setup (Test *test, TpBaseConnectionManager *service_cm_as_base; gboolean ok; - g_type_init (); tp_debug_set_flags ("all"); test->mainloop = g_main_loop_new (NULL, FALSE); @@ -388,74 +388,116 @@ check_avatar_requirements (TpAvatarRequirements *req) } static void -test_protocol_object (Test *test, - gconstpointer data G_GNUC_UNUSED) +check_tp_protocol (TpProtocol *protocol) { TpAvatarRequirements *req; GList *l; TpConnectionManagerParam *param; - g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, - "example_echo_2"); - tp_tests_proxy_run_until_prepared (test->cm, NULL); - test->protocol = g_object_ref ( - tp_connection_manager_get_protocol_object (test->cm, "example")); - - g_assert_cmpstr (tp_protocol_get_name (test->protocol), ==, "example"); + g_assert_cmpstr (tp_protocol_get_name (protocol), ==, "example"); - g_assert_cmpstr (tp_protocol_get_cm_name (test->protocol), + g_assert_cmpstr (tp_protocol_get_cm_name (protocol), ==, "example_echo_2"); - g_assert (tp_proxy_has_interface_by_id (test->protocol, + g_assert (tp_proxy_has_interface_by_id (protocol, TP_IFACE_QUARK_PROTOCOL)); - g_assert (tp_proxy_has_interface_by_id (test->protocol, + g_assert (tp_proxy_has_interface_by_id (protocol, TP_IFACE_QUARK_PROTOCOL_INTERFACE_AVATARS)); - g_assert (tp_proxy_is_prepared (test->protocol, + g_assert (tp_proxy_is_prepared (protocol, TP_PROTOCOL_FEATURE_PARAMETERS)); - g_assert (tp_protocol_has_param (test->protocol, "account")); - g_assert (!tp_protocol_has_param (test->protocol, "no-way")); + g_assert (tp_protocol_has_param (protocol, "account")); + g_assert (!tp_protocol_has_param (protocol, "no-way")); - g_assert (tp_proxy_is_prepared (test->protocol, TP_PROTOCOL_FEATURE_CORE)); + g_assert (tp_proxy_is_prepared (protocol, TP_PROTOCOL_FEATURE_CORE)); - g_assert_cmpstr (tp_protocol_get_icon_name (test->protocol), ==, + g_assert_cmpstr (tp_protocol_get_icon_name (protocol), ==, "im-icq"); - g_assert_cmpstr (tp_protocol_get_english_name (test->protocol), ==, + g_assert_cmpstr (tp_protocol_get_english_name (protocol), ==, "Echo II example"); - g_assert_cmpstr (tp_protocol_get_vcard_field (test->protocol), ==, + g_assert_cmpstr (tp_protocol_get_vcard_field (protocol), ==, "x-telepathy-example"); g_assert (TP_IS_CAPABILITIES (tp_protocol_get_capabilities ( - test->protocol))); + protocol))); - req = tp_protocol_get_avatar_requirements (test->protocol); + req = tp_protocol_get_avatar_requirements (protocol); check_avatar_requirements (req); - g_object_get (test->protocol, "avatar-requirements", &req, NULL); + g_object_get (protocol, "avatar-requirements", &req, NULL); check_avatar_requirements (req); - l = tp_protocol_dup_params (test->protocol); + l = tp_protocol_dup_params (protocol); g_assert_cmpuint (g_list_length (l), ==, 1); param = l->data; g_assert_cmpstr (param->name, ==, "account"); g_list_free_full (l, (GDestroyNotify) tp_connection_manager_param_free); - g_assert_cmpstr (tp_protocol_get_param (test->protocol, "account")->name, ==, + g_assert_cmpstr (tp_protocol_get_param (protocol, "account")->name, ==, "account"); - param = tp_protocol_dup_param (test->protocol, "account"); + param = tp_protocol_dup_param (protocol, "account"); /* it's a copy */ - g_assert (param != tp_protocol_get_param (test->protocol, "account")); + g_assert (param != tp_protocol_get_param (protocol, "account")); g_assert_cmpstr (param->name, ==, "account"); tp_connection_manager_param_free (param); - g_assert_cmpstr (tp_protocol_borrow_params (test->protocol)[0].name, ==, + g_assert_cmpstr (tp_protocol_borrow_params (protocol)[0].name, ==, "account"); - g_assert_cmpstr (tp_protocol_borrow_params (test->protocol)[1].name, ==, + g_assert_cmpstr (tp_protocol_borrow_params (protocol)[1].name, ==, NULL); } static void +test_protocol_object (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + GHashTable *props; + TpProtocol *protocol; + GVariant *vardict; + + g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, + "example_echo_2"); + tp_tests_proxy_run_until_prepared (test->cm, NULL); + test->protocol = g_object_ref ( + tp_connection_manager_get_protocol_object (test->cm, "example")); + + check_tp_protocol (test->protocol); + + /* Create a new TpProtocol for the same protocol but by passing it all its + * immutable properities */ + g_object_get (test->protocol, + "protocol-properties", &props, + NULL); + + protocol = tp_protocol_new (test->dbus, "example_echo_2", + "example", props, &test->error); + g_assert_no_error (test->error); + g_assert (TP_IS_PROTOCOL (protocol)); + + check_tp_protocol (protocol); + + vardict = tp_protocol_dup_immutable_properties (test->protocol); + g_assert (vardict != NULL); + g_assert (g_variant_is_of_type (vardict, G_VARIANT_TYPE_VARDICT)); + + g_object_unref (protocol); + + /* Same but using tp_protocol_new_vardict */ + protocol = tp_protocol_new_vardict (test->dbus, "example_echo_2", + "example", vardict, &test->error); + g_assert_no_error (test->error); + g_assert (TP_IS_PROTOCOL (protocol)); + + check_tp_protocol (protocol); + + g_object_unref (protocol); + + g_variant_unref (vardict); + g_hash_table_unref (props); +} + +static void test_protocol_object_old (Test *test, gconstpointer data G_GNUC_UNUSED) { @@ -535,6 +577,154 @@ test_protocol_object_from_file (Test *test, check_avatar_requirements (req); } +static void +test_normalize (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + GAsyncResult *result = NULL; + gchar *s; + + tp_tests_proxy_run_until_prepared (test->cm, NULL); + test->protocol = g_object_ref ( + tp_connection_manager_get_protocol_object (test->cm, "example")); + + tp_protocol_normalize_contact_async (test->protocol, + "MiXeDcAsE", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_contact_finish (test->protocol, result, + &test->error); + g_assert_no_error (test->error); + g_assert_cmpstr (s, ==, "mixedcase"); + g_clear_object (&result); + g_free (s); + + tp_protocol_normalize_contact_async (test->protocol, + "", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_contact_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_HANDLE); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_normalize_contact_uri_async (test->protocol, + "xmpp:MiXeDcAsE", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_contact_uri_finish (test->protocol, result, + &test->error); + g_assert_no_error (test->error); + g_assert_cmpstr (s, ==, "xmpp:mixedcase"); + g_clear_object (&result); + g_free (s); + + tp_protocol_normalize_contact_uri_async (test->protocol, + "xmpp:", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_contact_uri_finish (test->protocol, result, + &test->error); + g_assert_cmpstr (s, ==, NULL); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_normalize_contact_uri_async (test->protocol, + "http://example.com", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_contact_uri_finish (test->protocol, result, + &test->error); + g_assert_cmpstr (s, ==, NULL); + g_assert_error (test->error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_normalize_vcard_address_async (test->protocol, + "x-jabber", "MiXeDcAsE", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_vcard_address_finish (test->protocol, result, + &test->error); + g_assert_no_error (test->error); + g_assert_cmpstr (s, ==, "mixedcase"); + g_clear_object (&result); + g_free (s); + + tp_protocol_normalize_vcard_address_async (test->protocol, + "x-jabber", "", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_vcard_address_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_normalize_vcard_address_async (test->protocol, + "x-skype", "", NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_normalize_vcard_address_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); +} + +static void +test_id (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + GAsyncResult *result = NULL; + gchar *s; + + tp_tests_proxy_run_until_prepared (test->cm, NULL); + test->protocol = g_object_ref ( + tp_connection_manager_get_protocol_object (test->cm, "example")); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("{ 'account': <'Hello'> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_no_error (test->error); + g_assert_cmpstr (s, ==, "hello"); + g_clear_object (&result); + g_free (s); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("{ 'account': <'Hello'>, 'unknown-param': <42> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("@a{sv} {}"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("@a{sv} { 'account': <''> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); +} + int main (int argc, char **argv) @@ -558,6 +748,10 @@ main (int argc, test_protocol_object_old, teardown); g_test_add ("/protocol-objects/object-from-file", Test, NULL, setup, test_protocol_object_from_file, teardown); + g_test_add ("/protocol-objects/normalize", Test, NULL, setup, + test_normalize, teardown); + g_test_add ("/protocol-objects/id", Test, NULL, setup, + test_id, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c index 7d7638fd5..10e99d724 100644 --- a/tests/dbus/proxy-preparation.c +++ b/tests/dbus/proxy-preparation.c @@ -435,5 +435,5 @@ main (int argc, g_test_add ("/proxy-preparation/interface-later", Test, NULL, setup, test_interface_later, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/room-list.c b/tests/dbus/room-list.c index 0b1be2232..c1e3a874a 100644 --- a/tests/dbus/room-list.c +++ b/tests/dbus/room-list.c @@ -316,5 +316,5 @@ main (int argc, g_test_add ("/room-list-channel/invalidated", Test, NULL, setup, test_invalidated, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/run-test.sh.in b/tests/dbus/run-test.sh.in index 2e9648f0b..c9ecb6cb5 100644 --- a/tests/dbus/run-test.sh.in +++ b/tests/dbus/run-test.sh.in @@ -14,6 +14,14 @@ G_DEBUG=fatal_warnings,fatal_criticals export G_DEBUG libexec=@libexec@ export libexec +TP_TESTS_SERVICES_DIR=@tpglibtestsdir@/dbus-1/services +export TP_TESTS_SERVICES_DIR +GIO_USE_VFS=local +export GIO_USE_VFS +GSETTINGS_BACKEND=memory +export GSETTINGS_BACKEND +DBUS_SESSION_BUS_ADDRESS=this-is-clearly-not-valid +export DBUS_SESSION_BUS_ADDRESS if [ -n "$1" ] ; then list="$1" @@ -24,9 +32,6 @@ fi for i in $list ; do echo "Testing $i" - @tpglibtestsdir@/tools/test-wrapper.sh \ - sh @tpglibtestsdir@/tools/with-session-bus.sh \ - --config-file=@tpglibtestsdir@/dbus-installed/session.conf \ - -- @tpglibtestsdir@/$i + @tpglibtestsdir@/tools/test-wrapper.sh @tpglibtestsdir@/$i done diff --git a/tests/dbus/self-handle.c b/tests/dbus/self-handle.c index a5224b5c5..0a88be86b 100644 --- a/tests/dbus/self-handle.c +++ b/tests/dbus/self-handle.c @@ -379,5 +379,5 @@ main (int argc, g_test_add ("/self-handle/fails", Fixture, "archaic", setup, test_self_handle_fails, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/self-presence.c b/tests/dbus/self-presence.c index c9ed4730a..2efa5fd0f 100644 --- a/tests/dbus/self-presence.c +++ b/tests/dbus/self-presence.c @@ -236,7 +236,6 @@ main (int argc, /* Setup */ tp_tests_abort_after (10); - g_type_init (); tp_debug_set_flags ("all"); dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/simple-approver.c b/tests/dbus/simple-approver.c index 9995d9db6..cbbf5e5e9 100644 --- a/tests/dbus/simple-approver.c +++ b/tests/dbus/simple-approver.c @@ -497,5 +497,5 @@ main (int argc, g_test_add ("/simple-approver/fail", Test, NULL, setup, test_fail, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/simple-handler.c b/tests/dbus/simple-handler.c index 691a8d997..1465934c9 100644 --- a/tests/dbus/simple-handler.c +++ b/tests/dbus/simple-handler.c @@ -513,5 +513,5 @@ main (int argc, g_test_add ("/simple-handler/fail", Test, NULL, setup, test_fail, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c index 099efbc36..4d64a8438 100644 --- a/tests/dbus/simple-observer.c +++ b/tests/dbus/simple-observer.c @@ -479,5 +479,5 @@ main (int argc, g_test_add ("/simple-observer/fail", Test, NULL, setup, test_fail, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/stream-tube.c b/tests/dbus/stream-tube.c index 9b4946567..34179ae5b 100644 --- a/tests/dbus/stream-tube.c +++ b/tests/dbus/stream-tube.c @@ -1129,5 +1129,5 @@ main (int argc, g_test_add ("/stream-tube/offer/bad-connection/sig-first", Test, NULL, setup, test_offer_bad_connection_sig_first, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/text-channel.c b/tests/dbus/text-channel.c index dd4253ca1..4f38e3456 100644 --- a/tests/dbus/text-channel.c +++ b/tests/dbus/text-channel.c @@ -1082,5 +1082,5 @@ main (int argc, g_test_add ("/text-channel/chat-state", Test, NULL, setup, test_chat_state, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/text-mixin.c b/tests/dbus/text-mixin.c index b4f494e10..51bc6e1f6 100644 --- a/tests/dbus/text-mixin.c +++ b/tests/dbus/text-mixin.c @@ -94,7 +94,6 @@ main (int argc, TpHandle handle; tp_tests_abort_after (10); - g_type_init (); /* tp_debug_set_flags ("all"); */ dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/text-respawn.c b/tests/dbus/text-respawn.c index 46b99aa25..6de9f5b10 100644 --- a/tests/dbus/text-respawn.c +++ b/tests/dbus/text-respawn.c @@ -96,7 +96,6 @@ main (int argc, TpHandle handle; tp_tests_abort_after (10); - g_type_init (); /* tp_debug_set_flags ("all"); */ dbus = tp_tests_dbus_daemon_dup_or_die (); diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c index ee67ff23e..9aa2843f8 100644 --- a/tests/dbus/tls-certificate.c +++ b/tests/dbus/tls-certificate.c @@ -351,5 +351,5 @@ main (int argc, g_test_add ("/tls-certificate/invalidated", Test, NULL, setup, test_invalidated, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/dbus/unsupported-interface.c b/tests/dbus/unsupported-interface.c index e459e6206..43c8523a3 100644 --- a/tests/dbus/unsupported-interface.c +++ b/tests/dbus/unsupported-interface.c @@ -37,7 +37,6 @@ static void setup (Fixture *f, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); f->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -266,5 +265,5 @@ main (int argc, g_test_add ("/unsupported/signal", Fixture, NULL, setup, test_unsupported_signal, teardown); - return g_test_run (); + return tp_tests_run_with_bus (); } diff --git a/tests/debug-domain.c b/tests/debug-domain.c index 37ef41804..d4dfb29cb 100644 --- a/tests/debug-domain.c +++ b/tests/debug-domain.c @@ -54,8 +54,6 @@ int main (int argc, char **argv) #ifdef ENABLE_DEBUG TestItem i; - g_type_init (); - tp_debug_set_flags ("all"); g_log_set_default_handler (handler, NULL); diff --git a/tests/dtmf-player.c b/tests/dtmf-player.c index 33eb99c52..1f00f611d 100644 --- a/tests/dtmf-player.c +++ b/tests/dtmf-player.c @@ -96,8 +96,6 @@ static void setup (Fixture *f, gconstpointer nil G_GNUC_UNUSED) { - g_type_init (); - f->dtmf_player = tp_dtmf_player_new (); g_assert (f->dtmf_player != NULL); diff --git a/tests/enums.c b/tests/enums.c index 17ec4b46c..251050bbd 100644 --- a/tests/enums.c +++ b/tests/enums.c @@ -22,8 +22,6 @@ test_tp_contact_feature (void) { GEnumClass *klass; - g_type_init (); - klass = g_type_class_ref (TP_TYPE_CONTACT_FEATURE); g_assert (klass != NULL); @@ -40,8 +38,6 @@ test_tp_dbus_error (void) { GEnumClass *klass; - g_type_init (); - klass = g_type_class_ref (TP_TYPE_DBUS_ERROR); g_assert (klass != NULL); diff --git a/tests/gnio-util.c b/tests/gnio-util.c index 90de7a70c..1a5bd1dda 100644 --- a/tests/gnio-util.c +++ b/tests/gnio-util.c @@ -109,12 +109,16 @@ test_sockaddr_to_variant_ipv4 (void) g_assert (G_VALUE_HOLDS (variant, TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV4)); array = g_value_get_boxed (variant); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (array, 0); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert (G_VALUE_HOLDS_STRING (value)); g_assert_cmpstr (g_value_get_string (value), ==, IPV4_ADDR); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (array, 1); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert (G_VALUE_HOLDS_UINT (value)); g_assert_cmpuint (g_value_get_uint (value), ==, PORT); @@ -152,12 +156,16 @@ test_sockaddr_to_variant_ipv6 (void) g_assert (G_VALUE_HOLDS (variant, TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV6)); array = g_value_get_boxed (variant); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (array, 0); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert (G_VALUE_HOLDS_STRING (value)); g_assert_cmpstr (g_value_get_string (value), ==, IPV6_ADDR); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS value = g_value_array_get_nth (array, 1); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert (G_VALUE_HOLDS_UINT (value)); g_assert_cmpuint (g_value_get_uint (value), ==, PORT); @@ -294,7 +302,6 @@ test_sockaddr_to_variant_abstract_unix (void) int main (int argc, char **argv) { - g_type_init (); dbus_g_type_specialized_init (); test_variant_to_sockaddr_ipv4 (); diff --git a/tests/intset.c b/tests/intset.c index f92af36a0..16301389c 100644 --- a/tests/intset.c +++ b/tests/intset.c @@ -63,8 +63,6 @@ int main (int argc, char **argv) TpIntset *ab_symmdiff, *ab_expected_symmdiff; GValue *value; - g_type_init (); - g_assert (tp_intset_is_empty (set1)); g_assert_cmpuint (tp_intset_size (set1), ==, 0); diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 42c099b7b..33c1c6e67 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -83,7 +83,7 @@ include $(top_srcdir)/tools/check-coding-style.mk check-local: check-coding-style AM_CPPFLAGS = \ - -D_TP_COMPILATION \ + -DTP_DISABLE_SINGLE_INCLUDE \ $(NULL) AM_CFLAGS = \ diff --git a/tests/lib/broken-client-types-conn.c b/tests/lib/broken-client-types-conn.c index c73898c32..1c6f3aff1 100644 --- a/tests/lib/broken-client-types-conn.c +++ b/tests/lib/broken-client-types-conn.c @@ -13,7 +13,8 @@ #include "broken-client-types-conn.h" -#include <telepathy-glib/interfaces.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> G_DEFINE_TYPE_WITH_CODE (TpTestsBrokenClientTypesConnection, tp_tests_broken_client_types_connection, @@ -35,6 +36,9 @@ broken_fill_client_types ( GHashTable *attributes) { guint i; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + GType type = G_TYPE_VALUE_ARRAY; + G_GNUC_END_IGNORE_DEPRECATIONS for (i = 0; i < contacts->len; i++) { @@ -49,7 +53,7 @@ broken_fill_client_types ( tp_contacts_mixin_set_contact_attribute (attributes, handle, TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE, - tp_g_value_slice_new_take_boxed (G_TYPE_VALUE_ARRAY, presence)); + tp_g_value_slice_new_take_boxed (type, presence)); } } diff --git a/tests/lib/bug-19101-conn.c b/tests/lib/bug-19101-conn.c index bac600cf3..a591d9c5f 100644 --- a/tests/lib/bug-19101-conn.c +++ b/tests/lib/bug-19101-conn.c @@ -13,7 +13,8 @@ #include "bug-19101-conn.h" -#include <telepathy-glib/interfaces.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib.h> #include "debug.h" diff --git a/tests/lib/bug16307-conn.c b/tests/lib/bug16307-conn.c index 414d931a0..02323d14f 100644 --- a/tests/lib/bug16307-conn.c +++ b/tests/lib/bug16307-conn.c @@ -15,12 +15,8 @@ #include <dbus/dbus-glib.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/errors.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/handle-repo-dynamic.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> static void service_iface_init (gpointer, gpointer); diff --git a/tests/lib/bug16307-conn.h b/tests/lib/bug16307-conn.h index 678ba4582..58aa0ec1a 100644 --- a/tests/lib/bug16307-conn.h +++ b/tests/lib/bug16307-conn.h @@ -13,7 +13,7 @@ #define __TP_TESTS_BUG16307_CONN_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> #include "simple-conn.h" diff --git a/tests/lib/contact-list-manager.h b/tests/lib/contact-list-manager.h index 8be787c34..bc44863cb 100644 --- a/tests/lib/contact-list-manager.h +++ b/tests/lib/contact-list-manager.h @@ -12,7 +12,7 @@ #ifndef __TP_TESTS_CONTACT_LIST_MANAGER_H__ #define __TP_TESTS_CONTACT_LIST_MANAGER_H__ -#include <telepathy-glib/base-contact-list.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c index 5b0dcbba2..5b96b0c1a 100644 --- a/tests/lib/contacts-conn.c +++ b/tests/lib/contacts-conn.c @@ -15,12 +15,8 @@ #include <dbus/dbus-glib.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/errors.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/handle-repo-dynamic.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #include "debug.h" @@ -642,28 +638,22 @@ tp_tests_contacts_connection_change_aliases (TpTestsContactsConnection *self, for (i = 0; i < n; i++) { - GValueArray *pair = g_value_array_new (2); + GValueArray *pair = tp_value_array_build (2, + G_TYPE_UINT, handles[i], + G_TYPE_STRING, aliases[i], + G_TYPE_INVALID); DEBUG ("contact#%u -> %s", handles[i], aliases[i]); g_hash_table_insert (self->priv->aliases, GUINT_TO_POINTER (handles[i]), g_strdup (aliases[i])); - - g_value_array_append (pair, NULL); - g_value_init (pair->values + 0, G_TYPE_UINT); - g_value_set_uint (pair->values + 0, handles[i]); - - g_value_array_append (pair, NULL); - g_value_init (pair->values + 1, G_TYPE_STRING); - g_value_set_string (pair->values + 1, aliases[i]); - g_ptr_array_add (structs, pair); } tp_svc_connection_interface_aliasing_emit_aliases_changed (self, structs); - g_ptr_array_foreach (structs, (GFunc) g_value_array_free, NULL); + g_ptr_array_foreach (structs, (GFunc) tp_value_array_free, NULL); g_ptr_array_unref (structs); } @@ -1340,9 +1330,11 @@ my_set_contact_info (TpSvcConnectionInterfaceContactInfo *obj, TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); /* Deep copy info */ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS copy = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free); for (i = 0; i < info->len; i++) g_ptr_array_add (copy, g_value_array_copy (g_ptr_array_index (info, i))); + G_GNUC_END_IGNORE_DEPRECATIONS self_handle = tp_base_connection_get_self_handle (base); tp_tests_contacts_connection_change_contact_info (self, self_handle, copy); diff --git a/tests/lib/contacts-conn.h b/tests/lib/contacts-conn.h index 64056e039..c596e3e6c 100644 --- a/tests/lib/contacts-conn.h +++ b/tests/lib/contacts-conn.h @@ -13,9 +13,7 @@ #define __TP_TESTS_CONTACTS_CONN_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/contacts-mixin.h> -#include <telepathy-glib/presence-mixin.h> +#include <telepathy-glib/telepathy-glib.h> #include "simple-conn.h" #include "contact-list-manager.h" diff --git a/tests/lib/dbus-tube-chan.c b/tests/lib/dbus-tube-chan.c index d3e04eebf..2ca6673c9 100644 --- a/tests/lib/dbus-tube-chan.c +++ b/tests/lib/dbus-tube-chan.c @@ -13,9 +13,6 @@ #include "dbus-tube-chan.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/svc-channel.h> -#include <telepathy-glib/gnio-util.h> #include <glib/gstdio.h> #if defined(G_OS_UNIX) diff --git a/tests/lib/dbus-tube-chan.h b/tests/lib/dbus-tube-chan.h index 0a6b1a794..71800970d 100644 --- a/tests/lib/dbus-tube-chan.h +++ b/tests/lib/dbus-tube-chan.h @@ -12,8 +12,7 @@ #define __TP_DBUS_TUBE_CHAN_H__ #include <glib-object.h> -#include <telepathy-glib/base-channel.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/echo-chan.c b/tests/lib/echo-chan.c index 75f27d449..cf6d4f664 100644 --- a/tests/lib/echo-chan.c +++ b/tests/lib/echo-chan.c @@ -16,8 +16,7 @@ #include "echo-chan.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/svc-channel.h> +#include <telepathy-glib/telepathy-glib-dbus.h> /* This is for text-mixin unit tests, others should be using ExampleEcho2Channel * which uses newer TpMessageMixin */ diff --git a/tests/lib/echo-chan.h b/tests/lib/echo-chan.h index 7c4e11c8d..687f1e79e 100644 --- a/tests/lib/echo-chan.h +++ b/tests/lib/echo-chan.h @@ -13,9 +13,7 @@ #define __TP_TESTS_CHAN_H__ #include <glib-object.h> -#include <telepathy-glib/base-channel.h> -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/text-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/echo-cm.h b/tests/lib/echo-cm.h index 155f1e5ab..0832d6699 100644 --- a/tests/lib/echo-cm.h +++ b/tests/lib/echo-cm.h @@ -11,7 +11,7 @@ #define __TP_TESTS_ECHO_CONNECTION_MANAGER_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection-manager.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/echo-conn.c b/tests/lib/echo-conn.c index 2ce06a21e..dcadbb50b 100644 --- a/tests/lib/echo-conn.c +++ b/tests/lib/echo-conn.c @@ -16,7 +16,6 @@ #include <dbus/dbus-glib.h> #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/handle-repo-dynamic.h> #include "echo-im-manager.h" diff --git a/tests/lib/echo-conn.h b/tests/lib/echo-conn.h index 7bcad0749..2161481d6 100644 --- a/tests/lib/echo-conn.h +++ b/tests/lib/echo-conn.h @@ -13,7 +13,7 @@ #define __TP_TESTS_ECHO_CONN_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/file-transfer-chan.c b/tests/lib/file-transfer-chan.c index 2afea1dbb..a9706cc98 100644 --- a/tests/lib/file-transfer-chan.c +++ b/tests/lib/file-transfer-chan.c @@ -16,9 +16,6 @@ #include "debug.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/svc-channel.h> -#include <telepathy-glib/gnio-util.h> #include <glib/gstdio.h> diff --git a/tests/lib/file-transfer-chan.h b/tests/lib/file-transfer-chan.h index d64264753..19d6c98af 100644 --- a/tests/lib/file-transfer-chan.h +++ b/tests/lib/file-transfer-chan.h @@ -13,8 +13,7 @@ #define __TP_FILE_TRANSFER_CHAN_H__ #include <glib-object.h> -#include <telepathy-glib/base-channel.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c index 688ac14d7..0d7723c43 100644 --- a/tests/lib/my-conn-proxy.c +++ b/tests/lib/my-conn-proxy.c @@ -12,7 +12,7 @@ #include "my-conn-proxy.h" -#include <telepathy-glib/proxy-internal.h> +#include <telepathy-glib/telepathy-glib.h> G_DEFINE_TYPE (TpTestsMyConnProxy, tp_tests_my_conn_proxy, TP_TYPE_CONNECTION) diff --git a/tests/lib/myassert.h b/tests/lib/myassert.h index 4100c6035..1fd6fd3bf 100644 --- a/tests/lib/myassert.h +++ b/tests/lib/myassert.h @@ -2,7 +2,7 @@ #define TP_TESTS_MYASSERT_H #include <glib.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> #define MYASSERT(assertion, extra_format, ...)\ G_STMT_START {\ diff --git a/tests/lib/params-cm.c b/tests/lib/params-cm.c index 42b49b787..2714d6e66 100644 --- a/tests/lib/params-cm.c +++ b/tests/lib/params-cm.c @@ -25,8 +25,7 @@ #include <dbus/dbus-glib.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/errors.h> +#include <telepathy-glib/telepathy-glib.h> G_DEFINE_TYPE (TpTestsParamConnectionManager, tp_tests_param_connection_manager, diff --git a/tests/lib/params-cm.h b/tests/lib/params-cm.h index c54a2c975..eb3971cd3 100644 --- a/tests/lib/params-cm.h +++ b/tests/lib/params-cm.h @@ -23,7 +23,7 @@ #define __TP_TESTS_PARAM_CONNECTION_MANAGER_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection-manager.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/room-list-chan.c b/tests/lib/room-list-chan.c index 49ed291ab..cc5f15ff0 100644 --- a/tests/lib/room-list-chan.c +++ b/tests/lib/room-list-chan.c @@ -4,8 +4,6 @@ #include "room-list-chan.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/svc-channel.h> static void room_list_iface_init (gpointer iface, gpointer data); @@ -192,7 +190,7 @@ find_rooms (gpointer data) TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (data); GPtrArray *rooms; - rooms = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free); + rooms = g_ptr_array_new_with_free_func ((GDestroyNotify) tp_value_array_free); /* Find 2 rooms */ add_room (rooms); diff --git a/tests/lib/room-list-chan.h b/tests/lib/room-list-chan.h index b41be273b..52dbd2e8e 100644 --- a/tests/lib/room-list-chan.h +++ b/tests/lib/room-list-chan.h @@ -3,7 +3,7 @@ #define __TP_TESTS_ROOM_LIST_CHAN_H__ #include <glib-object.h> -#include <telepathy-glib/base-channel.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-account-manager.c b/tests/lib/simple-account-manager.c index e1fec6749..c38132ce5 100644 --- a/tests/lib/simple-account-manager.c +++ b/tests/lib/simple-account-manager.c @@ -13,12 +13,8 @@ #include "simple-account-manager.h" -#include <telepathy-glib/account.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/svc-generic.h> -#include <telepathy-glib/svc-account-manager.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> static void account_manager_iface_init (gpointer, gpointer); diff --git a/tests/lib/simple-account-manager.h b/tests/lib/simple-account-manager.h index d1608d518..94a60cddd 100644 --- a/tests/lib/simple-account-manager.h +++ b/tests/lib/simple-account-manager.h @@ -13,7 +13,7 @@ #define __TP_TESTS_SIMPLE_ACCOUNT_MANAGER_H__ #include <glib-object.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c index dc0912057..39b08bab0 100644 --- a/tests/lib/simple-account.c +++ b/tests/lib/simple-account.c @@ -10,16 +10,12 @@ #include "config.h" +#include <string.h> + #include "simple-account.h" -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/defs.h> -#include <telepathy-glib/enums.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/util.h> -#include <telepathy-glib/svc-generic.h> -#include <telepathy-glib/svc-account.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> static void account_iface_init (gpointer, gpointer); @@ -42,6 +38,7 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccount, static const char *ACCOUNT_INTERFACES[] = { TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING, TP_IFACE_ACCOUNT_INTERFACE_STORAGE, + TP_IFACE_ACCOUNT_INTERFACE_AVATAR, NULL }; enum @@ -81,6 +78,8 @@ struct _TpTestsSimpleAccountPrivate gchar *connection_path; gboolean enabled; GPtrArray *uri_schemes; + GHashTable *parameters; + GArray *avatar; }; static void @@ -143,6 +142,12 @@ tp_tests_simple_account_init (TpTestsSimpleAccount *self) self->priv->uri_schemes = g_ptr_array_new_with_free_func (g_free); for (i = 0; uri_schemes[i] != NULL; i++) g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_schemes[i])); + + self->priv->parameters = g_hash_table_new (NULL, NULL); + + self->priv->avatar = g_array_new (FALSE, FALSE, sizeof (char)); + + tp_tests_simple_account_set_avatar (self, ":-)"); } static void @@ -177,7 +182,7 @@ tp_tests_simple_account_get_property (GObject *object, g_value_set_string (value, "badger"); break; case PROP_PARAMETERS: - g_value_take_boxed (value, g_hash_table_new (NULL, NULL)); + g_value_set_boxed (value, self->priv->parameters); break; case PROP_AUTOMATIC_PRESENCE: g_value_take_boxed (value, tp_value_array_build (3, @@ -253,17 +258,11 @@ tp_tests_simple_account_get_property (GObject *object, break; case PROP_AVATAR: { - GArray *arr = g_array_new (FALSE, FALSE, sizeof (char)); - - /* includes NUL for simplicity */ - g_array_append_vals (arr, ":-)", 4); - g_value_take_boxed (value, tp_value_array_build (2, - TP_TYPE_UCHAR_ARRAY, arr, + TP_TYPE_UCHAR_ARRAY, self->priv->avatar, G_TYPE_STRING, "text/plain", G_TYPE_INVALID)); - g_array_unref (arr); } break; case PROP_SUPERSEDES: @@ -284,6 +283,26 @@ tp_tests_simple_account_get_property (GObject *object, } static void +tp_tests_simple_account_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *spec) +{ + TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object); + + switch (property_id) + { + case PROP_PARAMETERS: + self->priv->parameters = g_value_dup_boxed (value); + /* In principle we should be emitting AccountPropertyChanged here */ + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); + break; + } +} + +static void tp_tests_simple_account_finalize (GObject *object) { TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object); @@ -293,6 +312,8 @@ tp_tests_simple_account_finalize (GObject *object) g_free (self->priv->connection_path); g_ptr_array_unref (self->priv->uri_schemes); + g_hash_table_unref (self->priv->parameters); + g_array_unref (self->priv->avatar); G_OBJECT_CLASS (tp_tests_simple_account_parent_class)->finalize (object); } @@ -375,6 +396,7 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass) g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountPrivate)); object_class->get_property = tp_tests_simple_account_get_property; + object_class->set_property = tp_tests_simple_account_set_property; object_class->finalize = tp_tests_simple_account_finalize; param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces", @@ -416,7 +438,7 @@ tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass) param_spec = g_param_spec_boxed ("parameters", "parameters", "Parameters property", TP_HASH_TYPE_STRING_VARIANT_MAP, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_PARAMETERS, param_spec); param_spec = g_param_spec_boxed ("automatic-presence", "automatic presence", @@ -620,3 +642,16 @@ tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, g_strfreev (schemes); g_hash_table_unref (changed); } + +void +tp_tests_simple_account_set_avatar (TpTestsSimpleAccount *self, + const gchar *avatar) +{ + g_return_if_fail (avatar != NULL); + + g_array_set_size (self->priv->avatar, 0); + /* includes NULL for simplicity */ + g_array_append_vals (self->priv->avatar, avatar, strlen (avatar) +1); + + tp_svc_account_interface_avatar_emit_avatar_changed (self); +} diff --git a/tests/lib/simple-account.h b/tests/lib/simple-account.h index b8547bd75..bfe996108 100644 --- a/tests/lib/simple-account.h +++ b/tests/lib/simple-account.h @@ -13,8 +13,7 @@ #include <glib-object.h> -#include <telepathy-glib/connection.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS @@ -67,6 +66,9 @@ void tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self, void tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, const gchar * uri_scheme); +void tp_tests_simple_account_set_avatar (TpTestsSimpleAccount *self, + const gchar *avatar); + G_END_DECLS #endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ */ diff --git a/tests/lib/simple-channel-dispatch-operation.c b/tests/lib/simple-channel-dispatch-operation.c index 6a809f624..82b381972 100644 --- a/tests/lib/simple-channel-dispatch-operation.c +++ b/tests/lib/simple-channel-dispatch-operation.c @@ -13,15 +13,8 @@ #include "simple-channel-dispatch-operation.h" -#include <telepathy-glib/channel.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/defs.h> -#include <telepathy-glib/enums.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/util.h> -#include <telepathy-glib/svc-generic.h> -#include <telepathy-glib/svc-channel-dispatch-operation.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> static void channel_dispatch_operation_iface_init (gpointer, gpointer); diff --git a/tests/lib/simple-channel-dispatch-operation.h b/tests/lib/simple-channel-dispatch-operation.h index 84d8f0417..3e9ee9341 100644 --- a/tests/lib/simple-channel-dispatch-operation.h +++ b/tests/lib/simple-channel-dispatch-operation.h @@ -14,8 +14,7 @@ #include <glib-object.h> -#include <telepathy-glib/channel.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-channel-dispatcher.c b/tests/lib/simple-channel-dispatcher.c index 116df9a02..4be6e77e7 100644 --- a/tests/lib/simple-channel-dispatcher.c +++ b/tests/lib/simple-channel-dispatcher.c @@ -12,13 +12,8 @@ #include "simple-channel-dispatcher.h" -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/svc-generic.h> -#include <telepathy-glib/svc-channel-dispatcher.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #include "simple-channel-request.h" #include "simple-conn.h" diff --git a/tests/lib/simple-channel-dispatcher.h b/tests/lib/simple-channel-dispatcher.h index 4512e99d0..da2140617 100644 --- a/tests/lib/simple-channel-dispatcher.h +++ b/tests/lib/simple-channel-dispatcher.h @@ -12,7 +12,7 @@ #define __TP_TESTS_SIMPLE_CHANNEL_DISPATCHER_H__ #include <glib-object.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-channel-manager.c b/tests/lib/simple-channel-manager.c index 7d33f1be6..46523c673 100644 --- a/tests/lib/simple-channel-manager.c +++ b/tests/lib/simple-channel-manager.c @@ -10,7 +10,7 @@ #include "config.h" -#include <telepathy-glib/channel-manager.h> +#include <telepathy-glib/telepathy-glib.h> #include "simple-channel-manager.h" #include "util.h" diff --git a/tests/lib/simple-channel-manager.h b/tests/lib/simple-channel-manager.h index ee22ca3ff..ad711cd57 100644 --- a/tests/lib/simple-channel-manager.h +++ b/tests/lib/simple-channel-manager.h @@ -13,7 +13,7 @@ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> typedef struct _TpTestsSimpleChannelManager TpTestsSimpleChannelManager; typedef struct _TpTestsSimpleChannelManagerClass TpTestsSimpleChannelManagerClass; diff --git a/tests/lib/simple-channel-request.c b/tests/lib/simple-channel-request.c index c97253099..111f320ef 100644 --- a/tests/lib/simple-channel-request.c +++ b/tests/lib/simple-channel-request.c @@ -12,13 +12,9 @@ #include "simple-channel-request.h" -#include <telepathy-glib/client.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/proxy-subclass.h> -#include <telepathy-glib/svc-channel-request.h> -#include <telepathy-glib/svc-generic.h> #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib-dbus.h> +#include <telepathy-glib/proxy-subclass.h> #include "tests/lib/util.h" #include "tests/lib/textchan-null.h" diff --git a/tests/lib/simple-channel-request.h b/tests/lib/simple-channel-request.h index 85c12f80a..60ea3be64 100644 --- a/tests/lib/simple-channel-request.h +++ b/tests/lib/simple-channel-request.h @@ -13,8 +13,7 @@ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> #include "simple-conn.h" diff --git a/tests/lib/simple-client.c b/tests/lib/simple-client.c index 15da26bb1..227201049 100644 --- a/tests/lib/simple-client.c +++ b/tests/lib/simple-client.c @@ -16,12 +16,8 @@ #include <dbus/dbus-glib.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/errors.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/handle-repo-dynamic.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #include "tests/lib/util.h" diff --git a/tests/lib/simple-client.h b/tests/lib/simple-client.h index ec4fd31b8..f3f78694c 100644 --- a/tests/lib/simple-client.h +++ b/tests/lib/simple-client.h @@ -12,7 +12,7 @@ #define __TP_TESTS_SIMPLE_CLIENT_H__ #include <glib-object.h> -#include <telepathy-glib/base-client.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c index c78e1278a..6cdc6b019 100644 --- a/tests/lib/simple-conn.c +++ b/tests/lib/simple-conn.c @@ -17,13 +17,8 @@ #include <dbus/dbus-glib.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/dbus-properties-mixin.h> -#include <telepathy-glib/errors.h> -#include <telepathy-glib/gtypes.h> -#include <telepathy-glib/handle-repo-dynamic.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #include "textchan-null.h" #include "room-list-chan.h" diff --git a/tests/lib/simple-conn.h b/tests/lib/simple-conn.h index 837400bc3..14d227528 100644 --- a/tests/lib/simple-conn.h +++ b/tests/lib/simple-conn.h @@ -13,7 +13,7 @@ #define __TP_TESTS_SIMPLE_CONN_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/simple-manager.c b/tests/lib/simple-manager.c index a4296028d..da78210ea 100644 --- a/tests/lib/simple-manager.c +++ b/tests/lib/simple-manager.c @@ -16,8 +16,7 @@ #include <dbus/dbus-protocol.h> #include <dbus/dbus-glib.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/errors.h> +#include <telepathy-glib/telepathy-glib.h> #include "simple-conn.h" #include "tests/lib/util.h" diff --git a/tests/lib/simple-manager.h b/tests/lib/simple-manager.h index 426d7d0b1..232db926f 100644 --- a/tests/lib/simple-manager.h +++ b/tests/lib/simple-manager.h @@ -12,7 +12,7 @@ #define __TP_TESTS_SIMPLE_CONNECTION_MANAGER_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection-manager.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/stream-tube-chan.c b/tests/lib/stream-tube-chan.c index e2fd2e086..8da189ef3 100644 --- a/tests/lib/stream-tube-chan.c +++ b/tests/lib/stream-tube-chan.c @@ -16,9 +16,6 @@ #include "util.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/svc-channel.h> -#include <telepathy-glib/gnio-util.h> #ifdef HAVE_GIO_UNIX #include <gio/gunixsocketaddress.h> diff --git a/tests/lib/stream-tube-chan.h b/tests/lib/stream-tube-chan.h index b0c8fbde0..26729127a 100644 --- a/tests/lib/stream-tube-chan.h +++ b/tests/lib/stream-tube-chan.h @@ -12,8 +12,7 @@ #define __TP_STREAM_TUBE_CHAN_H__ #include <glib-object.h> -#include <telepathy-glib/base-channel.h> -#include <telepathy-glib/base-connection.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/textchan-group.c b/tests/lib/textchan-group.c index 8c33f53c0..6339e5d04 100644 --- a/tests/lib/textchan-group.c +++ b/tests/lib/textchan-group.c @@ -13,13 +13,8 @@ #include "textchan-group.h" -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/dbus-properties-mixin.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/svc-channel.h> -#include <telepathy-glib/svc-generic.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> /* This is for text-mixin unit tests, others should be using ExampleEcho2Channel * which uses newer TpMessageMixin */ diff --git a/tests/lib/textchan-group.h b/tests/lib/textchan-group.h index b33a5d35b..dfd922f16 100644 --- a/tests/lib/textchan-group.h +++ b/tests/lib/textchan-group.h @@ -13,10 +13,7 @@ #define __TEST_TEXT_CHANNEL_GROUP_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/base-channel.h> -#include <telepathy-glib/group-mixin.h> -#include <telepathy-glib/text-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/textchan-null.c b/tests/lib/textchan-null.c index bbeb0c719..c426acfac 100644 --- a/tests/lib/textchan-null.c +++ b/tests/lib/textchan-null.c @@ -13,13 +13,8 @@ #include "textchan-null.h" -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/channel-iface.h> -#include <telepathy-glib/dbus.h> -#include <telepathy-glib/dbus-properties-mixin.h> -#include <telepathy-glib/interfaces.h> -#include <telepathy-glib/svc-channel.h> -#include <telepathy-glib/svc-generic.h> +#include <telepathy-glib/telepathy-glib.h> +#include <telepathy-glib/telepathy-glib-dbus.h> /* This is for text-mixin unit tests, others should be using ExampleEcho2Channel * which uses newer TpMessageMixin */ diff --git a/tests/lib/textchan-null.h b/tests/lib/textchan-null.h index 583bec571..076defb40 100644 --- a/tests/lib/textchan-null.h +++ b/tests/lib/textchan-null.h @@ -13,9 +13,7 @@ #define __TP_TESTS_TEXT_CHANNEL_NULL_H__ #include <glib-object.h> -#include <telepathy-glib/base-connection.h> -#include <telepathy-glib/text-mixin.h> -#include <telepathy-glib/group-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/tls-certificate.c b/tests/lib/tls-certificate.c index 8a936e922..102c17cab 100644 --- a/tests/lib/tls-certificate.c +++ b/tests/lib/tls-certificate.c @@ -22,7 +22,7 @@ #include "tls-certificate.h" #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/svc-tls.h> +#include <telepathy-glib/telepathy-glib-dbus.h> #define DEBUG_FLAG TP_TESTS_DEBUG_TLS #include "debug.h" diff --git a/tests/lib/tls-certificate.h b/tests/lib/tls-certificate.h index 7ce0cf4aa..1de31927a 100644 --- a/tests/lib/tls-certificate.h +++ b/tests/lib/tls-certificate.h @@ -23,7 +23,7 @@ #include <glib-object.h> -#include <telepathy-glib/dbus-properties-mixin.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS diff --git a/tests/lib/util.c b/tests/lib/util.c index 022c56b30..d5751f4a3 100644 --- a/tests/lib/util.c +++ b/tests/lib/util.c @@ -12,7 +12,7 @@ #include "util.h" -#include <telepathy-glib/connection.h> +#include <telepathy-glib/telepathy-glib.h> #include <glib/gstdio.h> #include <string.h> @@ -77,10 +77,68 @@ tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy, return r; } +static GTestDBus *test_dbus = NULL; + +static void +start_dbus_session (void) +{ + g_assert (test_dbus == NULL); + + g_test_dbus_unset (); + + /* GLib 2.36 does not unset STARTER env variables but tp-glib are using them. + * See https://bugzilla.gnome.org/show_bug.cgi?id=697348 */ + g_unsetenv ("DBUS_STARTER_ADDRESS"); + g_unsetenv ("DBUS_STARTER_BUS_TYPE"); + + test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); + g_test_dbus_add_service_dir (test_dbus, g_getenv ("TP_TESTS_SERVICES_DIR")); + g_test_dbus_up (test_dbus); +} + +static void +stop_dbus_session (void) +{ + g_assert (test_dbus != NULL); + g_test_dbus_down (test_dbus); + g_clear_object (&test_dbus); +} + +gint +tp_tests_run_with_bus (void) +{ + gint ret; + + if (test_dbus != NULL) + return g_test_run (); + + start_dbus_session (); + ret = g_test_run (); + stop_dbus_session (); + + return ret; +} + TpDBusDaemon * tp_tests_dbus_daemon_dup_or_die (void) { - TpDBusDaemon *d = tp_dbus_daemon_dup (NULL); + TpDBusDaemon *d; + + if (test_dbus == NULL) + { + /* HACK: Some tests are not yet ported to GTest and thus are not using + * tp_tests_run_with_bus(). In that case we make sure to start the dbus + * session before aquiring the TpDBusDaemon and we stop the session when + * the daemon is disposed. In a perfect world this should not be needed. + */ + start_dbus_session (); + d = tp_dbus_daemon_dup (NULL); + g_object_weak_ref ((GObject *) d, (GWeakNotify) stop_dbus_session, NULL); + } + else + { + d = tp_dbus_daemon_dup (NULL); + } /* In a shared library, this would be very bad (see fd.o #18832), but in a * regression test that's going to be run under a temporary session bus, @@ -319,7 +377,6 @@ void tp_tests_init (int *argc, char ***argv) { - g_type_init (); tp_tests_abort_after (10); tp_debug_set_flags ("all"); diff --git a/tests/lib/util.h b/tests/lib/util.h index 18d868790..bc682ae17 100644 --- a/tests/lib/util.h +++ b/tests/lib/util.h @@ -12,7 +12,8 @@ #define __TP_TESTS_LIB_UTIL_H__ #include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/base-connection.h> + +gint tp_tests_run_with_bus (void); TpDBusDaemon *tp_tests_dbus_daemon_dup_or_die (void); diff --git a/tests/signal-connect-object.c b/tests/signal-connect-object.c index 90a867724..fa1c9e5da 100644 --- a/tests/signal-connect-object.c +++ b/tests/signal-connect-object.c @@ -60,7 +60,6 @@ static void setup (Test *test, gconstpointer data) { - g_type_init (); tp_debug_set_flags ("all"); test->caught = 0; diff --git a/tests/util-cxx.cpp b/tests/util-cxx.cpp index 3b2a6b577..b8b822e36 100644 --- a/tests/util-cxx.cpp +++ b/tests/util-cxx.cpp @@ -28,8 +28,6 @@ int main (int argc, char **argv) GObject *o; GHashTable *h; - g_type_init (); - o = (GObject *) g_file_new_for_path ("/"); tp_clear_object (&o); diff --git a/tests/util.c b/tests/util.c index dad995ca6..3b0b7c952 100644 --- a/tests/util.c +++ b/tests/util.c @@ -37,10 +37,12 @@ test_value_array_build (void) G_TYPE_UINT, port, G_TYPE_INVALID); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_assert_cmpstr (g_value_get_string (g_value_array_get_nth (arr, 0)), ==, host); g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (arr, 1)), ==, port); + G_GNUC_END_IGNORE_DEPRECATIONS tp_value_array_unpack (arr, 2, &host_out, @@ -49,7 +51,7 @@ test_value_array_build (void) g_assert_cmpstr (host_out, ==, host); g_assert_cmpuint (port_out, ==, port); - g_value_array_free (arr); + tp_value_array_free (arr); } static void @@ -295,8 +297,6 @@ int main (int argc, char **argv) GPtrArray *ptrarray; gchar *string; - g_type_init (); - g_assert (!tp_strdiff (NULL, NULL)); g_assert (tp_strdiff ("badger", NULL)); g_assert (tp_strdiff (NULL, "badger")); diff --git a/tools/Makefile.am b/tools/Makefile.am index 761ee03c3..0fd42f89c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -9,7 +9,6 @@ telepathy-glib-env: telepathy-glib-env.in Makefile if ENABLE_INSTALLED_TESTS toolsdir = @tpglibtestsdir@/tools tools_SCRIPTS = \ - with-session-bus.sh \ test-wrapper.sh \ libglibcodegen.py \ libtpcodegen.py \ @@ -44,7 +43,6 @@ EXTRA_DIST = \ telepathy-glib.supp \ telepathy-glib-env.in \ test-wrapper.sh \ - with-session-bus.sh \ xincludator.py CLEANFILES = libtpcodegen.pyc libtpcodegen.pyo libglibcodegen.pyc libglibcodegen.pyo $(noinst_SCRIPTS) diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py index e68e1a575..a0fecf083 100644 --- a/tools/glib-client-gen.py +++ b/tools/glib-client-gen.py @@ -28,8 +28,8 @@ import xml.dom.minidom from getopt import gnu_getopt from libtpcodegen import file_set_contents, key_by_name, u -from libglibcodegen import Signature, type_to_gtype, \ - get_docstring, xml_escape, get_deprecated +from libglibcodegen import (Signature, type_to_gtype, + get_docstring, xml_escape, get_deprecated, copy_into_gvalue) NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" @@ -186,6 +186,7 @@ class Generator(object): self.b(' TpProxySignalConnection *sc)') self.b('{') + self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS') self.b(' GValueArray *args = g_value_array_new (%d);' % len(args)) self.b(' GValue blank = { 0 };') self.b(' guint i;') @@ -194,6 +195,7 @@ class Generator(object): self.b('') self.b(' for (i = 0; i < %d; i++)' % len(args)) self.b(' g_value_array_append (args, &blank);') + self.b(' G_GNUC_END_IGNORE_DEPRECATIONS') self.b('') for i, arg in enumerate(args): @@ -203,36 +205,8 @@ class Generator(object): self.b(' g_value_unset (args->values + %d);' % i) self.b(' g_value_init (args->values + %d, %s);' % (i, gtype)) - if gtype == 'G_TYPE_STRING': - self.b(' g_value_set_string (args->values + %d, %s);' - % (i, name)) - elif marshaller == 'BOXED': - self.b(' g_value_set_boxed (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UCHAR': - self.b(' g_value_set_uchar (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_BOOLEAN': - self.b(' g_value_set_boolean (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_INT': - self.b(' g_value_set_int (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UINT': - self.b(' g_value_set_uint (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_INT64': - self.b(' g_value_set_int (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UINT64': - self.b(' g_value_set_uint64 (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_DOUBLE': - self.b(' g_value_set_double (args->values + %d, %s);' - % (i, name)) - else: - assert False, ("Don't know how to put %s in a GValue" - % gtype) + self.b(' ' + copy_into_gvalue('args->values + %d' % i, + gtype, marshaller, name)) self.b('') self.b(' tp_proxy_signal_connection_v0_take_results (sc, args);') @@ -282,12 +256,14 @@ class Generator(object): self.b(' weak_object);') self.b('') + self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS') if len(args) > 0: self.b(' g_value_array_free (args);') else: self.b(' if (args != NULL)') self.b(' g_value_array_free (args);') self.b('') + self.b(' G_GNUC_END_IGNORE_DEPRECATIONS') self.b(' g_object_unref (tpproxy);') self.b('}') @@ -553,11 +529,13 @@ class Generator(object): self.b(' return;') self.b(' }') self.b('') + self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS') self.b(' args = g_value_array_new (%d);' % len(out_args)) self.b(' g_value_init (&blank, G_TYPE_INT);') self.b('') self.b(' for (i = 0; i < %d; i++)' % len(out_args)) self.b(' g_value_array_append (args, &blank);') + self.b(' G_GNUC_END_IGNORE_DEPRECATIONS') for i, arg in enumerate(out_args): name, info, tp_type, elt = arg @@ -567,36 +545,8 @@ class Generator(object): self.b(' g_value_unset (args->values + %d);' % i) self.b(' g_value_init (args->values + %d, %s);' % (i, gtype)) - if gtype == 'G_TYPE_STRING': - self.b(' g_value_take_string (args->values + %d, %s);' - % (i, name)) - elif marshaller == 'BOXED': - self.b(' g_value_take_boxed (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UCHAR': - self.b(' g_value_set_uchar (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_BOOLEAN': - self.b(' g_value_set_boolean (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_INT': - self.b(' g_value_set_int (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UINT': - self.b(' g_value_set_uint (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_INT64': - self.b(' g_value_set_int (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_UINT64': - self.b(' g_value_set_uint (args->values + %d, %s);' - % (i, name)) - elif gtype == 'G_TYPE_DOUBLE': - self.b(' g_value_set_double (args->values + %d, %s);' - % (i, name)) - else: - assert False, ("Don't know how to put %s in a GValue" - % gtype) + self.b(' ' + copy_into_gvalue('args->values + %d' % i, + gtype, marshaller, name)) self.b(' tp_proxy_pending_call_v0_take_results (user_data, ' 'NULL, args);') @@ -665,11 +615,13 @@ class Generator(object): self.b(' error, user_data, weak_object);') self.b('') + self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS') if len(out_args) > 0: self.b(' g_value_array_free (args);') else: self.b(' if (args != NULL)') self.b(' g_value_array_free (args);') + self.b(' G_GNUC_END_IGNORE_DEPRECATIONS') self.b('}') self.b('') @@ -942,11 +894,13 @@ class Generator(object): self.b('') + self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS') if len(out_args) > 0: self.b(' g_value_array_free (args);') else: self.b(' if (args != NULL)') self.b(' g_value_array_free (args);') + self.b(' G_GNUC_END_IGNORE_DEPRECATIONS') self.b('}') self.b('') diff --git a/tools/glib-errors-check-gen.py b/tools/glib-errors-check-gen.py index fad261ece..3cc8a5afb 100644 --- a/tools/glib-errors-check-gen.py +++ b/tools/glib-errors-check-gen.py @@ -17,7 +17,6 @@ class Generator(object): print(' GEnumValue *value_by_name;') print(' GEnumValue *value_by_nick;') print('') - print(' g_type_init ();') print(' klass = g_type_class_ref (TP_TYPE_ERROR);') for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'): diff --git a/tools/libglibcodegen.py b/tools/libglibcodegen.py index 6cd1a6277..0b703a5a8 100644 --- a/tools/libglibcodegen.py +++ b/tools/libglibcodegen.py @@ -170,3 +170,26 @@ def type_to_gtype(s): # we just don't know .. raise Exception("don't know the GType for " + s) + + +def copy_into_gvalue(gvaluep, gtype, marshaller, name): + if gtype == 'G_TYPE_STRING': + return 'g_value_set_string (%s, %s);' % (gvaluep, name) + elif marshaller == 'BOXED': + return 'g_value_set_boxed (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_UCHAR': + return 'g_value_set_uchar (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_BOOLEAN': + return 'g_value_set_boolean (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_INT': + return 'g_value_set_int (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_UINT': + return 'g_value_set_uint (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_INT64': + return 'g_value_set_int (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_UINT64': + return 'g_value_set_uint64 (%s, %s);' % (gvaluep, name) + elif gtype == 'G_TYPE_DOUBLE': + return 'g_value_set_double (%s, %s);' % (gvaluep, name) + else: + raise AssertionError("Don't know how to put %s in a GValue" % gtype) diff --git a/tools/telepathy.am b/tools/telepathy.am index 20ff0be13..c919995dc 100644 --- a/tools/telepathy.am +++ b/tools/telepathy.am @@ -55,7 +55,7 @@ maintainer-prepare-release: $(MAKE) all $(MAKE) distcheck $(MAKE) release-mail - git tag -s @PACKAGE@-@VERSION@ -m @PACKAGE@' '@VERSION@ + cd $(srcdir) && git tag -s @PACKAGE@-@VERSION@ -m @PACKAGE@' '@VERSION@ gpg --detach-sign --armor @PACKAGE@-@VERSION@.tar.gz release-mail: NEWS diff --git a/tools/with-session-bus.sh b/tools/with-session-bus.sh deleted file mode 100755 index 0afa59321..000000000 --- a/tools/with-session-bus.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# with-session-bus.sh - run a program with a temporary D-Bus session daemon -# -# The canonical location of this program is the telepathy-glib tools/ -# directory, please synchronize any changes with that copy. -# -# Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/> -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. - -set -e - -me=with-session-bus - -dbus_daemon_args="--print-address=5 --print-pid=6 --fork" -sleep=0 - -usage () -{ - echo "usage: $me [options] -- program [program_options]" >&2 - echo "Requires write access to the current directory." >&2 - echo "" >&2 - echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2 - echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2 - echo "The output of dbus-monitor is saved in $me-<pid>.dbus-monitor-logs" >&2 - exit 2 -} - -while test "z$1" != "z--"; do - case "$1" in - --sleep=*) - sleep="$1" - sleep="${sleep#--sleep=}" - shift - ;; - --session) - dbus_daemon_args="$dbus_daemon_args --session" - shift - ;; - --config-file=*) - # FIXME: assumes config file doesn't contain any special characters - dbus_daemon_args="$dbus_daemon_args $1" - shift - ;; - *) - usage - ;; - esac -done -shift -if test "z$1" = "z"; then usage; fi - -exec 5> $me-$$.address -exec 6> $me-$$.pid - -cleanup () -{ - pid=`head -n1 $me-$$.pid` - if test -n "$pid" ; then - if [ -n "$VERBOSE_TESTS" ]; then - echo "Killing temporary bus daemon: $pid" >&2 - fi - kill -INT "$pid" - fi - rm -f $me-$$.address - rm -f $me-$$.pid -} - -trap cleanup INT HUP TERM -dbus-daemon $dbus_daemon_args - -if [ -n "$VERBOSE_TESTS" ]; then - { echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2 - { echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2 -fi - -e=0 - -# These might be non-null when run from e.g. gnome-terminal 3.8, which uses -# an activatable service for its windows; we don't want to inherit them either -unset DBUS_STARTER_ADDRESS -unset DBUS_STARTER_BUS_TYPE - -DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`" -export DBUS_SESSION_BUS_ADDRESS -DBUS_SESSION_BUS_PID="`cat $me-$$.pid`" -export DBUS_SESSION_BUS_PID - -if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then - echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2 - dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \ - > $me-$$.dbus-monitor-logs 2>&1 & -fi - -"$@" || e=$? - -if test $sleep != 0; then - sleep $sleep -fi - -trap - INT HUP TERM -cleanup - -exit $e |