diff options
34 files changed, 319 insertions, 112 deletions
@@ -31,6 +31,7 @@ /doc/reference/mission-control-plugins/*.txt .libs .deps +Android.mk Makefile Makefile.in _gen/ diff --git a/Android.mk b/Android.mk new file mode 100644 index 00000000..e16fb6be --- /dev/null +++ b/Android.mk @@ -0,0 +1,40 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +TELEPATHY_MISSION_CONTROL_BUILT_SOURCES := \ + mission-control.pc \ + src/Android.mk \ + server/Android.mk \ + mission-control-plugins/Android.mk \ + util/Android.mk + +telepathy-mission-control-configure-real: + cd $(TELEPATHY_MISSION_CONTROL_TOP) ; \ + CC="$(CONFIGURE_CC)" \ + CFLAGS="$(CONFIGURE_CFLAGS)" \ + LD=$(TARGET_LD) \ + LDFLAGS="$(CONFIGURE_LDFLAGS)" \ + CPP=$(CONFIGURE_CPP) \ + CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \ + PKG_CONFIG_LIBDIR="$(CONFIGURE_PKG_CONFIG_LIBDIR)" \ + PKG_CONFIG_TOP_BUILD_DIR=$(PKG_CONFIG_TOP_BUILD_DIR) \ + $(TELEPATHY_MISSION_CONTROL_TOP)/$(CONFIGURE) --host=arm-linux-androideabi \ + --disable-gtk-doc && \ + for file in $(TELEPATHY_MISSION_CONTROL_BUILT_SOURCES); do \ + rm -f $$file && \ + make -C $$(dirname $$file) $$(basename $$file) ; \ + done + +telepathy-mission-control-configure: telepathy-mission-control-configure-real + +.PHONY: telepathy-mission-control-configure + +CONFIGURE_TARGETS += telepathy-mission-control-configure + +#include all the subdirs... +-include $(TELEPATHY_MISSION_CONTROL_TOP)/src/Android.mk +-include $(TELEPATHY_MISSION_CONTROL_TOP)/util/Android.mk +-include $(TELEPATHY_MISSION_CONTROL_TOP)/server/Android.mk +-include $(TELEPATHY_MISSION_CONTROL_TOP)/mission-control-plugins/Android.mk +-include $(TELEPATHY_MISSION_CONTROL_TOP)/utils/Android.mk diff --git a/configure.ac b/configure.ac index b2d01395..c5dc9b17 100644 --- a/configure.ac +++ b/configure.ac @@ -376,6 +376,16 @@ fi AM_CONDITIONAL(HAVE_NM, test "x$have_nm" = "xyes") AM_CONDITIONAL(HAVE_CONNMAN, test "x$have_connman" = "xyes") +AC_ARG_ENABLE([conn-setting], + [AS_HELP_STRING([--enable-conn-setting], + [use a GSetting to control automatic connectivity @<:@default=yes@:>@])], + [], + [enable_conn_setting=yes]) +if test x"$enable_conn_setting" = xyes; then + AC_DEFINE([ENABLE_CONN_SETTING], [1], [Define to use the "use-conn" GSetting]) +fi +AM_CONDITIONAL([ENABLE_CONN_SETTING], [test x"$enable_conn_setting" = xyes]) + # ----------------------------------------------------------- # Suspend/resume tracking goop # ----------------------------------------------------------- @@ -460,6 +470,7 @@ Configure summary: Gnome Keyring................: ${keyring_enabled} Network Manager integration..: ${have_nm} ConnMan integration..........: ${have_connman} + Connectivity GSetting........: ${enable_conn_setting} Suspend tracking with UPower.: ${have_upower} Aegis........................: ${aegis_enabled} libaccounts-glib backend.....: ${libaccounts_sso_enabled} diff --git a/data/Makefile.am b/data/Makefile.am index 3d293bd8..a83709e1 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,15 +1,22 @@ -gsettings_SCHEMAS = \ +mc_schemas = \ im.telepathy.MissionControl.FromEmpathy.gschema.xml \ $(NULL) -@GSETTINGS_RULES@ + +gsettings_SCHEMAS = + +if ENABLE_CONN_SETTING +gsettings_SCHEMAS += $(mc_schemas) # We build our own schema cache here for the benefit of the test suite noinst_DATA = gschemas.compiled gschemas.compiled: $(gsettings_SCHEMAS) $(AM_V_GEN)$(GLIB_COMPILE_SCHEMAS) --targetdir=$(builddir) $(srcdir) +endif + +@GSETTINGS_RULES@ EXTRA_DIST = \ - $(gsettings_SCHEMAS) \ + $(mc_schemas) \ $(NULL) CLEANFILES = $(noinst_DATA) diff --git a/mission-control-plugins/Makefile.am b/mission-control-plugins/Makefile.am index dfbb2cbf..76e68401 100644 --- a/mission-control-plugins/Makefile.am +++ b/mission-control-plugins/Makefile.am @@ -33,7 +33,7 @@ plugins_include_HEADERS = \ libmission_control_plugins_la_LDFLAGS = \ -export-symbols-regex "^(mcp_)" \ - -version-info "@MCP_LT_CURRENT@":"@MCP_LT_REVISION@":"@MCP_LT_AGE@" + -no-undefined -version-info "@MCP_LT_CURRENT@":"@MCP_LT_REVISION@":"@MCP_LT_AGE@" libmission_control_plugins_la_LIBADD = \ $(TELEPATHY_LIBS) \ @@ -61,6 +61,17 @@ libmission_control_plugins_la_SOURCES = \ BUILT_SOURCES = $(nodist_libmission_control_plugins_la_SOURCES) +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer -:PROJECT telepathy-mission-control \ + -:SHARED libmission-control-plugins \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(BUILT_SOURCES) $(libmission_control_plugins_la_SOURCES) \ + -:CFLAGS $(DEFAULT_INCLUDES) $(DEFS) $(CFLAGS) $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) $(INCLUDES) \ + -:LDFLAGS $(libmission_control_plugins_la_LIBADD) \ + > $@ + CLEANFILES = $(BUILT_SOURCES) %-signals-marshal.h: %-signals-marshal.list Makefile diff --git a/mission-control-plugins/loader.c b/mission-control-plugins/loader.c index f7de04c1..7fa600a6 100644 --- a/mission-control-plugins/loader.c +++ b/mission-control-plugins/loader.c @@ -52,6 +52,13 @@ static gboolean debugging = FALSE; G_STMT_START { if (debugging || mcp_is_debugging (MCP_DEBUG_LOADER)) \ g_debug ("%s " format, G_STRLOC, ##__VA_ARGS__); } G_STMT_END +/* Android's build system prefixes the plugins with lib */ +#ifndef __BIONIC__ +#define PLUGIN_PREFIX "mcp-" +#else +#define PLUGIN_PREFIX "libmcp-" +#endif + /** * mcp_set_debug: * @debug: whether to log debug output @@ -146,9 +153,9 @@ mcp_read_dir (const gchar *path) gchar *full_path; GModule *module; - if (!g_str_has_prefix (entry, "mcp-")) + if (!g_str_has_prefix (entry, PLUGIN_PREFIX)) { - DEBUG ("%s isn't a plugin (doesn't start with mcp-)", entry); + DEBUG ("%s isn't a plugin (doesn't start with " PLUGIN_PREFIX ")", entry); continue; } diff --git a/server/Makefile.am b/server/Makefile.am index c363853a..ba734500 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -36,7 +36,21 @@ mission_control_5_SOURCES = mc-server.c mission_control_5_LDADD = \ $(GLIB_LIBS) \ $(TELEPATHY_LIBS) \ + $(DBUS_LIBS) \ $(top_builddir)/src/libmissioncontrol-server.la \ $(top_builddir)/mission-control-plugins/libmission-control-plugins.la +Android.mk: Makefile.am + androgenizer -:PROJECT telepathy-mission-control \ + -:SHARED libmission-control-5 -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(mission_control_5_SOURCES) \ + -:CFLAGS $(DEFAULT_INCLUDES) $(DEFS) $(CFLAGS) $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) $(INCLUDES) \ + -DBUILD_AS_ANDROID_SERVICE \ + -:LDFLAGS $(mission_control_5_LDADD) \ + -:LIBFILTER_STATIC missioncontrol-server mission-control-plugins \ + mcclient \ + > $@ + endif diff --git a/server/mc-server.c b/server/mc-server.c index a7114334..a830c81e 100644 --- a/server/mc-server.c +++ b/server/mc-server.c @@ -33,6 +33,10 @@ static TpDebugSender *debug_sender; +#ifdef BUILD_AS_ANDROID_SERVICE +int telepathy_mission_control_main (int argc, char **argv); +#endif + static void on_abort (McdService * mcd) { @@ -46,7 +50,11 @@ on_abort (McdService * mcd) } int +#ifdef BUILD_AS_ANDROID_SERVICE +telepathy_mission_control_main (int argc, char **argv) +#else main (int argc, char **argv) +#endif { McdService *mcd; diff --git a/src/Makefile.am b/src/Makefile.am index 781bdef3..9f9f06a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -279,6 +279,17 @@ EXTRA_DIST = \ mcd-signals-marshal.list \ stamp-mcd-enum-types.h +Android.mk: Makefile.am $(nodist_libmcd_convenience_la_SOURCES) + androgenizer -:PROJECT telepathy-mission-control \ + -:STATIC libmissioncontrol-server \ + -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libmcd_convenience_la_SOURCES) $(nodist_libmcd_convenience_la_SOURCES) \ + -:CFLAGS $(DEFAULT_INCLUDES) $(INCLUDES) $(DEFS) $(CFLAGS) $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ + -:LDFLAGS $(libmcd_convenience_la_LIBADD) \ + > $@ + # ---- telepathy-glib-style code generation ---- tools_dir = $(top_srcdir)/tools diff --git a/src/client-registry.c b/src/client-registry.c index 8b96bce5..dc58f640 100644 --- a/src/client-registry.c +++ b/src/client-registry.c @@ -478,7 +478,7 @@ mcd_client_registry_dispose (GObject *object) } - tp_clear_pointer (&self->priv->clients, g_hash_table_destroy); + tp_clear_pointer (&self->priv->clients, g_hash_table_unref); if (chain_up != NULL) chain_up (object); diff --git a/src/kludge-transport.c b/src/kludge-transport.c index bdd80b81..636f9cfa 100644 --- a/src/kludge-transport.c +++ b/src/kludge-transport.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include "kludge-transport.h" #include <telepathy-glib/util.h> @@ -42,8 +44,10 @@ struct _McdKludgeTransportPrivate { /* Hold a set of McdAccounts which would like to go online. */ GHashTable *pending_accounts; +#ifdef ENABLE_CONN_SETTING /* Application settings we steal from under Empathy's nose. */ GSettings *settings; +#endif }; static void transport_iface_init ( @@ -86,9 +90,11 @@ mcd_kludge_transport_constructed (GObject *object) priv->pending_accounts = g_hash_table_new_full (NULL, NULL, g_object_unref, NULL); +#ifdef ENABLE_CONN_SETTING priv->settings = g_settings_new ("im.telepathy.MissionControl.FromEmpathy"); g_settings_bind (priv->settings, "use-conn", priv->minotaur, "use-conn", G_SETTINGS_BIND_GET); +#endif } static void @@ -99,7 +105,9 @@ mcd_kludge_transport_dispose (GObject *object) GObjectClass *parent_class = mcd_kludge_transport_parent_class; tp_clear_object (&priv->minotaur); +#ifdef ENABLE_CONN_SETTING tp_clear_object (&priv->settings); +#endif g_list_free (priv->transports); priv->transports = NULL; diff --git a/src/mcd-account-compat.c b/src/mcd-account-compat.c index ab8995f6..56e0ff09 100644 --- a/src/mcd-account-compat.c +++ b/src/mcd-account-compat.c @@ -27,7 +27,6 @@ #include <stdio.h> #include <string.h> #include <glib/gstdio.h> -#include <glib/gi18n.h> #include <config.h> #include <dbus/dbus-glib-lowlevel.h> @@ -61,7 +60,7 @@ emit_compat_property_changed (McdAccount *account, const gchar *key, mc_svc_account_interface_compat_emit_compat_property_changed (account, properties); - g_hash_table_destroy (properties); + g_hash_table_unref (properties); } static void diff --git a/src/mcd-account-conditions.c b/src/mcd-account-conditions.c index 223e055b..8385efcd 100644 --- a/src/mcd-account-conditions.c +++ b/src/mcd-account-conditions.c @@ -27,7 +27,6 @@ #include <stdio.h> #include <string.h> #include <glib/gstdio.h> -#include <glib/gi18n.h> #include <config.h> #include <telepathy-glib/svc-generic.h> diff --git a/src/mcd-account-connection.c b/src/mcd-account-connection.c index 3d289935..7710d444 100644 --- a/src/mcd-account-connection.c +++ b/src/mcd-account-connection.c @@ -27,7 +27,6 @@ #include <stdio.h> #include <string.h> #include <glib/gstdio.h> -#include <glib/gi18n.h> #include <config.h> #include "mcd-master.h" diff --git a/src/mcd-account-manager-query.c b/src/mcd-account-manager-query.c index 95e0068d..24306a4e 100644 --- a/src/mcd-account-manager-query.c +++ b/src/mcd-account-manager-query.c @@ -27,7 +27,6 @@ #include <stdio.h> #include <string.h> #include <glib/gstdio.h> -#include <glib/gi18n.h> #include <config.h> #include <telepathy-glib/svc-generic.h> @@ -335,14 +334,14 @@ account_manager_find_accounts (McSvcAccountManagerInterfaceQuery *self, accounts = _mcd_account_manager_get_accounts (account_manager); g_hash_table_foreach (accounts, find_accounts, &fd); } - g_array_free (fd.params, TRUE); + g_array_unref (fd.params); for (i = 0; i < fd.properties->len; i++) { McdIfaceProperty *prop; prop = &g_array_index (fd.properties, McdIfaceProperty, i); g_free (prop->iface); } - g_array_free (fd.properties, TRUE); + g_array_unref (fd.properties); if (fd.error) { @@ -353,7 +352,7 @@ account_manager_find_accounts (McSvcAccountManagerInterfaceQuery *self, mc_svc_account_manager_interface_query_return_from_find_accounts (context, fd.accounts); - g_ptr_array_free (fd.accounts, TRUE); + g_ptr_array_unref (fd.accounts); } diff --git a/src/mcd-account-manager-sso.c b/src/mcd-account-manager-sso.c index 4f69c094..0cf4e41e 100644 --- a/src/mcd-account-manager-sso.c +++ b/src/mcd-account-manager-sso.c @@ -204,8 +204,7 @@ static void _sso_created (GObject *object, gpointer user_data); static void _sso_toggled (GObject *object, - const gchar *service_name, - gboolean enabled, + AgAccountId id, gpointer data); static gboolean save_setting ( @@ -544,8 +543,6 @@ static void watch_for_updates (McdAccountManagerSso *sso, service = ag_account_get_selected_service (account); - g_signal_connect (account, "enabled", G_CALLBACK (_sso_toggled), sso); - data = make_watch_data (sso); ag_account_select_service (account, NULL); @@ -559,18 +556,15 @@ static void watch_for_updates (McdAccountManagerSso *sso, } static void _sso_toggled (GObject *object, - const gchar *service_name, - gboolean enabled, + AgAccountId id, gpointer data) { - AgAccount *account = AG_ACCOUNT (object); - AgAccountId id = account->id; + AgManager *manager = AG_MANAGER (object); McdAccountManagerSso *sso = MCD_ACCOUNT_MANAGER_SSO (data); McpAccountStorage *mcpa = MCP_ACCOUNT_STORAGE (sso); + AgAccount *account = NULL; gboolean on = FALSE; const gchar *name = NULL; - AgService *service = NULL; - AgManager *manager = NULL; /* If the account manager isn't ready, account state changes are of no * * interest to us: it will pick up the then-current state of the account * @@ -579,25 +573,14 @@ static void _sso_toggled (GObject *object, if (!sso->ready) return; - manager = ag_account_get_manager (account); - service = ag_manager_get_service (manager, service_name); + account = ag_manager_get_account (manager, id); - /* Services of types other than IM (or whatever a subclass has told us to - * care about instead) don't interest us. - */ - if (service != NULL) + if (account != NULL) { - const gchar *service_type = ag_service_get_service_type (service); - const gchar *our_service_type = - account_manager_sso_get_service_type (sso); - - if (tp_strdiff (service_type, our_service_type)) - return; + on = _sso_account_enabled (sso, account, NULL); + name = g_hash_table_lookup (sso->id_name_map, GUINT_TO_POINTER (id)); } - on = _sso_account_enabled (sso, account, service); - name = g_hash_table_lookup (sso->id_name_map, GUINT_TO_POINTER (id)); - if (name != NULL) { const gchar *value = on ? "true" : "false"; @@ -809,6 +792,8 @@ mcd_account_manager_sso_constructed (GObject *object) DEBUG ("Watching for services of type '%s'", service_type); self->ag_manager = ag_manager_new_for_service_type (service_type); + g_signal_connect(self->ag_manager, "enabled-event", + G_CALLBACK (_sso_toggled), self); g_signal_connect(self->ag_manager, "account-deleted", G_CALLBACK (_sso_deleted), self); g_signal_connect(self->ag_manager, "account-created", @@ -995,6 +980,10 @@ _ag_accountid_to_mc_key (McdAccountManagerSso *sso, DEBUG (MC_IDENTITY_KEY " value %p:%s synthesised", name, name); return name; } + else + { + g_value_unset (&value); + } DEBUG (MC_IDENTITY_KEY " not synthesised, returning NULL"); return NULL; diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index b21f0289..4d93220b 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -24,7 +24,6 @@ #include "mcd-account-manager.h" -#include <glib/gi18n.h> #include <string.h> #include <stdio.h> #include <stdlib.h> @@ -1516,7 +1515,7 @@ _mcd_account_manager_finalize (GObject *object) remove (priv->account_connections_file); g_free (priv->account_connections_file); - g_hash_table_destroy (priv->accounts); + g_hash_table_unref (priv->accounts); G_OBJECT_CLASS (mcd_account_manager_parent_class)->finalize (object); } diff --git a/src/mcd-account-requests.c b/src/mcd-account-requests.c index 82e0e690..da8a1e2b 100644 --- a/src/mcd-account-requests.c +++ b/src/mcd-account-requests.c @@ -27,7 +27,6 @@ #include <stdio.h> #include <string.h> #include <glib/gstdio.h> -#include <glib/gi18n.h> #include <config.h> #include <dbus/dbus-glib-lowlevel.h> diff --git a/src/mcd-account.c b/src/mcd-account.c index 115bf920..eb02c8aa 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -29,7 +29,6 @@ #include <string.h> #include <dbus/dbus.h> -#include <glib/gi18n.h> #include <glib/gstdio.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> @@ -543,7 +542,7 @@ account_external_password_storage_get_accounts_cb (TpProxy *cm, props, NULL); - g_hash_table_destroy (props); + g_hash_table_unref (props); } static void @@ -2961,7 +2960,7 @@ _mcd_account_finalize (GObject *object) DEBUG ("%p (%s)", object, priv->unique_name); if (priv->changed_properties) - g_hash_table_destroy (priv->changed_properties); + g_hash_table_unref (priv->changed_properties); if (priv->properties_source != 0) g_source_remove (priv->properties_source); @@ -4262,7 +4261,7 @@ mcd_account_connection_ready_cb (McdAccount *account, mcd_account_self_handle_inspected_cb, NULL, NULL, (GObject *) account); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); /* FIXME: ideally, on protocols with server-stored nicknames, this should * only be done if the local Nickname has been changed since last time we diff --git a/src/mcd-channel.c b/src/mcd-channel.c index e6c23d82..64d12a4d 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -37,8 +37,6 @@ #include "mcd-channel.h" -#include <glib/gi18n.h> - #include <telepathy-glib/dbus.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> @@ -1418,7 +1416,7 @@ mcd_channel_ready_to_depart_cb (TpChannel *channel, channel, -1, a, d->message, d->reason, mcd_channel_depart_cb, NULL, NULL, NULL); - g_array_free (a, TRUE); + g_array_unref (a); g_free (d->message); g_slice_free (DepartData, d); } diff --git a/src/mcd-client.c b/src/mcd-client.c index 8ab492d9..fceba819 100644 --- a/src/mcd-client.c +++ b/src/mcd-client.c @@ -494,7 +494,7 @@ _mcd_client_proxy_set_filters (McdClientProxy *client, client_filters = g_list_prepend (client_filters, new_channel_class); else - g_hash_table_destroy (new_channel_class); + g_hash_table_unref (new_channel_class); } switch (interface) @@ -634,8 +634,8 @@ _mcd_client_recover_observer (McdClientProxy *self, TpChannel *channel, NULL, NULL, NULL, NULL); _mcd_tp_channel_details_free (channels_array); - g_ptr_array_free (satisfied_requests, TRUE); - g_hash_table_destroy (observer_info); + g_ptr_array_unref (satisfied_requests); + g_hash_table_unref (observer_info); } static void @@ -1367,7 +1367,7 @@ mcd_client_proxy_free_client_filters (GList **client_filters) if (*client_filters != NULL) { - g_list_foreach (*client_filters, (GFunc) g_hash_table_destroy, NULL); + g_list_foreach (*client_filters, (GFunc) g_hash_table_unref, NULL); g_list_free (*client_filters); *client_filters = NULL; } @@ -1786,6 +1786,6 @@ _mcd_client_proxy_handle_channels (McdClientProxy *self, callback, user_data, destroy, weak_object); _mcd_tp_channel_details_free (channel_details); - g_ptr_array_free (requests_satisfied, TRUE); + g_ptr_array_unref (requests_satisfied); g_hash_table_unref (handler_info); } diff --git a/src/mcd-connection.c b/src/mcd-connection.c index 4b276333..40a59520 100644 --- a/src/mcd-connection.c +++ b/src/mcd-connection.c @@ -41,7 +41,6 @@ #include <sched.h> #include <glib.h> -#include <glib/gi18n.h> #include <glib/gstdio.h> #include <string.h> @@ -477,7 +476,7 @@ _mcd_connection_setup_presence (McdConnection *connection) (priv->tp_conn, -1, self_handle_array, mcd_connection_initial_presence_cb, priv, NULL, (GObject *) connection); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); tp_cli_dbus_properties_call_get (priv->tp_conn, -1, TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE, @@ -638,7 +637,7 @@ _mcd_connection_setup_capabilities (McdConnection *connection) G_TYPE_UINT, G_TYPE_INVALID); for (i = 0; i < capabilities->len; i++) g_boxed_free (type, g_ptr_array_index (capabilities, i)); - g_ptr_array_free (capabilities, TRUE); + g_ptr_array_unref (capabilities); } static void @@ -849,7 +848,7 @@ avatars_request_tokens_cb (TpConnection *proxy, GHashTable *tokens, { DEBUG ("No avatar set, setting our own"); _mcd_connection_set_avatar (connection, avatar, mime_type); - g_array_free (avatar, TRUE); + g_array_unref (avatar); } g_free (mime_type); } @@ -900,7 +899,7 @@ _mcd_connection_setup_avatar (McdConnection *connection) priv, NULL, (GObject *)connection); } - g_array_free (avatar, TRUE); + g_array_unref (avatar); } g_free (mime_type); } @@ -972,7 +971,7 @@ _mcd_connection_set_nickname (McdConnection *connection, aliasing_set_aliases_cb, priv, NULL, (GObject *)connection); - g_hash_table_destroy (aliases); + g_hash_table_unref (aliases); } static void @@ -1028,7 +1027,7 @@ _mcd_connection_setup_alias (McdConnection *connection) tp_cli_connection_interface_aliasing_call_get_aliases (priv->tp_conn, -1, self_handle_array, _mcd_connection_get_aliases_cb, priv, NULL, (GObject *) connection); - g_array_free (self_handle_array, TRUE); + g_array_unref (self_handle_array); } static void @@ -1542,7 +1541,7 @@ list_channels_cb (TpConnection *connection, g_hash_table_insert (channel_props, TP_IFACE_CHANNEL ".TargetHandle", va->values + 3); mcd_connection_found_channel (self, object_path, channel_props); - g_hash_table_destroy (channel_props); + g_hash_table_unref (channel_props); } self->priv->dispatched_initial_channels = TRUE; @@ -1788,7 +1787,7 @@ mcd_connection_early_get_interfaces_cb (TpConnection *tp_conn, _mcd_connection_update_client_caps (self, client_caps); g_ptr_array_foreach (client_caps, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (client_caps, TRUE); + g_ptr_array_unref (client_caps); } /* else the McdDispatcher hasn't sorted itself out yet, so * we can't usefully pre-load capabilities - we'll be told @@ -1950,7 +1949,7 @@ _mcd_connection_finalize (GObject * object) g_free (priv->alias); if (priv->recognized_presences) - g_hash_table_destroy (priv->recognized_presences); + g_hash_table_unref (priv->recognized_presences); G_OBJECT_CLASS (mcd_connection_parent_class)->finalize (object); } diff --git a/src/mcd-dbusprop.c b/src/mcd-dbusprop.c index d038d819..0e233608 100644 --- a/src/mcd-dbusprop.c +++ b/src/mcd-dbusprop.c @@ -331,7 +331,7 @@ get_all_iter (GetAllData *data) { tp_svc_dbus_properties_return_from_get_all (data->context, data->properties); - g_hash_table_destroy (data->properties); + g_hash_table_unref (data->properties); g_slice_free (GetAllData, data); } diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index f21edf80..dfb87d13 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -31,7 +31,6 @@ #include <dbus/dbus.h> #include <dbus/dbus-glib-lowlevel.h> -#include <glib/gi18n.h> #include <glib/gstdio.h> #include <telepathy-glib/defs.h> @@ -2138,7 +2137,7 @@ _mcd_dispatch_operation_run_observers (McdDispatchOperation *self) g_list_free (observed); } - g_hash_table_destroy (observer_info); + g_hash_table_unref (observer_info); } static void diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index 7ce02dd1..54aa4db8 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -38,7 +38,6 @@ #include <dlfcn.h> #include <glib.h> #include <glib/gprintf.h> -#include <glib/gi18n.h> #include <dbus/dbus-glib-lowlevel.h> @@ -849,7 +848,7 @@ mcd_dispatcher_client_registry_ready_cb (McdClientRegistry *clients, } g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } static void @@ -903,7 +902,7 @@ _mcd_dispatcher_dispose (GObject * object) tp_clear_object (&priv->clients); } - tp_clear_pointer (&priv->connections, g_hash_table_destroy); + tp_clear_pointer (&priv->connections, g_hash_table_unref); tp_clear_object (&priv->master); tp_clear_object (&priv->dbus_daemon); @@ -940,7 +939,7 @@ mcd_dispatcher_update_client_caps (McdDispatcher *self, } g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } static void @@ -2126,7 +2125,7 @@ _mcd_dispatcher_add_connection (McdDispatcher *self, _mcd_connection_start_dispatching (connection, vas); g_ptr_array_foreach (vas, (GFunc) g_value_array_free, NULL); - g_ptr_array_free (vas, TRUE); + g_ptr_array_unref (vas); } /* else _mcd_connection_start_dispatching will be called when we're ready * for it */ diff --git a/src/mcd-handler-map.c b/src/mcd-handler-map.c index 63094b39..18d76d17 100644 --- a/src/mcd-handler-map.c +++ b/src/mcd-handler-map.c @@ -141,7 +141,7 @@ _mcd_handler_map_dispose (GObject *object) { McdHandlerMap *self = MCD_HANDLER_MAP (object); - tp_clear_pointer (&self->priv->handled_channels, g_hash_table_destroy); + tp_clear_pointer (&self->priv->handled_channels, g_hash_table_unref); if (self->priv->handler_processes != NULL) { @@ -160,7 +160,7 @@ _mcd_handler_map_dispose (GObject *object) } - tp_clear_pointer (&self->priv->handler_processes, g_hash_table_destroy); + tp_clear_pointer (&self->priv->handler_processes, g_hash_table_unref); tp_clear_object (&self->priv->dbus_daemon); G_OBJECT_CLASS (_mcd_handler_map_parent_class)->dispose (object); @@ -171,9 +171,9 @@ _mcd_handler_map_finalize (GObject *object) { McdHandlerMap *self = MCD_HANDLER_MAP (object); - tp_clear_pointer (&self->priv->channel_processes, g_hash_table_destroy); - tp_clear_pointer (&self->priv->channel_clients, g_hash_table_destroy); - tp_clear_pointer (&self->priv->channel_accounts, g_hash_table_destroy); + tp_clear_pointer (&self->priv->channel_processes, g_hash_table_unref); + tp_clear_pointer (&self->priv->channel_clients, g_hash_table_unref); + tp_clear_pointer (&self->priv->channel_accounts, g_hash_table_unref); G_OBJECT_CLASS (_mcd_handler_map_parent_class)->finalize (object); } diff --git a/src/mcd-manager.c b/src/mcd-manager.c index ce6e1f27..d19cfc09 100644 --- a/src/mcd-manager.c +++ b/src/mcd-manager.c @@ -44,7 +44,6 @@ #include <stdio.h> #include <string.h> -#include <glib/gi18n.h> #include <telepathy-glib/telepathy-glib.h> #include "mcd-connection.h" diff --git a/src/mcd-master.c b/src/mcd-master.c index 06bb60ce..45d30d9a 100644 --- a/src/mcd-master.c +++ b/src/mcd-master.c @@ -57,7 +57,6 @@ #include <sys/types.h> #endif -#include <glib/gi18n.h> #include <gmodule.h> #include <string.h> #include <dbus/dbus.h> @@ -65,6 +64,10 @@ #include <dbus/dbus-glib-lowlevel.h> #include <telepathy-glib/telepathy-glib.h> +#ifdef G_OS_WIN32 +#include <io.h> +#endif + #include "kludge-transport.h" #include "mcd-master.h" #include "mcd-master-priv.h" @@ -219,13 +222,32 @@ mcd_master_connect_automatic_accounts (McdMaster *master) } } +static const gchar * +mcd_transport_status_to_string (McdTransportStatus status) +{ + switch (status) + { + case MCD_TRANSPORT_STATUS_CONNECTED: + return "connected"; + case MCD_TRANSPORT_STATUS_CONNECTING: + return "connecting"; + case MCD_TRANSPORT_STATUS_DISCONNECTED: + return "disconnected"; + case MCD_TRANSPORT_STATUS_DISCONNECTING: + return "disconnecting"; + } + + return "invalid"; +} + static void on_transport_status_changed (McdTransportPlugin *plugin, McdTransport *transport, McdTransportStatus status, McdMaster *master) { - DEBUG ("Transport %s changed status to %u", - mcd_transport_get_name (plugin, transport), status); + DEBUG ("Transport %s changed status to %u (%s)", + mcd_transport_get_name (plugin, transport), status, + mcd_transport_status_to_string (status)); if (status == MCD_TRANSPORT_STATUS_CONNECTED) mcd_master_transport_connected (master, plugin, transport); @@ -250,7 +272,7 @@ mcd_master_unload_mcd_plugins (McdMaster *master) module = g_ptr_array_index (priv->mcd_plugins, i); g_module_close (module); } - g_ptr_array_free (priv->mcd_plugins, TRUE); + g_ptr_array_unref (priv->mcd_plugins); priv->mcd_plugins = NULL; } @@ -405,7 +427,7 @@ _mcd_master_dispose (GObject * object) object); g_object_unref (plugin); } - g_ptr_array_free (priv->transport_plugins, TRUE); + g_ptr_array_unref (priv->transport_plugins); priv->transport_plugins = NULL; } diff --git a/src/mcd-mission.c b/src/mcd-mission.c index 8bb04307..ca494799 100644 --- a/src/mcd-mission.c +++ b/src/mcd-mission.c @@ -51,7 +51,6 @@ #include "mcd-mission-priv.h" -#include <glib/gi18n.h> #include <telepathy-glib/telepathy-glib.h> #include "mcd-enum-types.h" diff --git a/src/mcd-operation.c b/src/mcd-operation.c index 2dd46a51..6c1595c4 100644 --- a/src/mcd-operation.c +++ b/src/mcd-operation.c @@ -38,7 +38,6 @@ * established. */ -#include <glib/gi18n.h> #include "mcd-operation.h" #include "mcd-mission-priv.h" diff --git a/src/mcd-provisioning-factory.c b/src/mcd-provisioning-factory.c index f1c836de..2c28d2b5 100644 --- a/src/mcd-provisioning-factory.c +++ b/src/mcd-provisioning-factory.c @@ -53,7 +53,7 @@ mcd_provisioning_factory_dispose (GObject *object) McdProvisioningFactoryPriv *priv = MCD_PROVISIONING_FACTORY_GET_PRIV (object); if (priv->provs) { - g_hash_table_destroy (priv->provs); + g_hash_table_unref (priv->provs); priv->provs = NULL; } G_OBJECT_CLASS (mcd_provisioning_factory_parent_class)->dispose (object); diff --git a/src/mcd-proxy.c b/src/mcd-proxy.c index 2d2b2a2b..5c3ef740 100644 --- a/src/mcd-proxy.c +++ b/src/mcd-proxy.c @@ -37,7 +37,6 @@ #include "mcd-proxy.h" -#include <glib/gi18n.h> #include <telepathy-glib/telepathy-glib.h> #define MCD_PROXY_PRIV(proxy) (G_TYPE_INSTANCE_GET_PRIVATE ((proxy), \ diff --git a/util/Makefile.am b/util/Makefile.am index ba595af4..7df5bf6c 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -1,13 +1,17 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ $(DBUS_CFLAGS) \ + $(LIBFFI_CFLAGS) \ $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ $(TELEPATHY_CFLAGS) LDADD = \ + $(LIBFFI_LIBS) \ $(GLIB_LIBS) \ $(DBUS_LIBS) \ - $(TELEPATHY_LIBS) + $(TELEPATHY_LIBS) \ + $(GIO_LIBS) AM_CFLAGS = $(ERROR_CFLAGS) @@ -27,3 +31,14 @@ CLEANFILES = $(man1_MANS) mc-wait-for-name.1: mc-wait-for-name.1.in Makefile $(AM_V_GEN)sed -e 's![@]bindir[@]!@bindir@!g' < $< > $@ + +Android.mk: Makefile.am + androgenizer -:PROJECT telepathy_mission_controll \ + -:EXECUTABLE mc-tool -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(mc_tool_SOURCES) \ + -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ + -:LDFLAGS $(mc_tool_LDADD) \ + > $@ diff --git a/util/mc-tool.c b/util/mc-tool.c index f55d4bb9..1a114881 100644 --- a/util/mc-tool.c +++ b/util/mc-tool.c @@ -42,6 +42,7 @@ show_help (gchar * err) printf ("Usage:\n" " %1$s list\n" + " %1$s summary\n" " %1$s add <manager>/<protocol> <display name> [<param> ...]\n" " %1$s update <account name> [<param>|clear:key] ...\n" " %1$s display <account name> <display name>\n" @@ -135,14 +136,6 @@ static char *ensure_prefix (char const *string) return g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE, string); } -static const char *skip_prefix (char const *string) -{ - const char *prefixed = strip_prefix (string, TP_ACCOUNT_OBJECT_PATH_BASE); - if (prefixed != NULL) - return prefixed; - return string; -} - static void _g_value_free (gpointer data) { @@ -321,6 +314,23 @@ show_presence (gchar const *what, struct presence *presence) presence->type, presence->message); } +static int +show_uri_schemes (const gchar * const *schemes) +{ + int result; + gchar *tmp; + + if (schemes == NULL || schemes[0] == NULL) + tmp = g_strdup (""); + else + tmp = g_strjoinv (", ", (gchar **) schemes); + + result = printf ("%12s: %s\n", "URIScheme", tmp); + + g_free (tmp); + return result; +} + static void free_presence (struct presence *presence) { @@ -495,12 +505,25 @@ getter_by_name(char *name) /* ====================================================================== */ +static gint +compare_accounts (gconstpointer a, + gconstpointer b) +{ + return strcmp (tp_account_get_path_suffix (TP_ACCOUNT (a)), + tp_account_get_path_suffix (TP_ACCOUNT (b))); +} + +static GList * +get_valid_accounts_sorted (TpAccountManager *manager) +{ + return g_list_sort (tp_account_manager_get_valid_accounts (manager), + compare_accounts); +} + static gboolean command_list (TpAccountManager *manager) { - GList *accounts; - - accounts = tp_account_manager_get_valid_accounts (manager); + GList *accounts = get_valid_accounts_sorted (manager); if (accounts != NULL) { GList *ptr; @@ -508,7 +531,7 @@ command_list (TpAccountManager *manager) command.common.ret = 0; for (ptr = accounts; ptr != NULL; ptr = ptr->next) { - puts (skip_prefix (tp_proxy_get_object_path (ptr->data))); + puts (tp_account_get_path_suffix (ptr->data)); } g_list_free (accounts); @@ -517,6 +540,48 @@ command_list (TpAccountManager *manager) return FALSE; /* stop mainloop */ } +static gboolean +command_summary (TpAccountManager *manager) +{ + GList *accounts, *l; + guint longest_account = 0; + + accounts = tp_account_manager_get_valid_accounts (manager); + if (accounts == NULL) { + return FALSE; + } + command.common.ret = 0; + + for (l = accounts; l != NULL; l = l->next) { + TpAccount *account = TP_ACCOUNT (l->data); + + longest_account = MAX (longest_account, + strlen (tp_account_get_path_suffix (account))); + } + + /* The -6 is so we can line up the "Enabled" header to have the ticks and + * crosses below the 7th and final character. We're only guaranteed + * longest_account ≥ 5 in theory (a/b/c is the shortest legal suffix) but + * in practice it's always going to be ≥ 7. + */ + g_return_val_if_fail (longest_account >= 7, FALSE); + printf ("%-*s %s %s\n", longest_account - 6, "Account", "Enabled", "Requested"); + printf ("%-*s %s %s\n", longest_account - 6, "=======", "=======", "========="); + + for (l = accounts; l != NULL; l = l->next) { + TpAccount *account = TP_ACCOUNT (l->data); + gchar *status; + + tp_account_get_requested_presence (account, &status, NULL); + printf ("%-*s %s %s\n", + longest_account, tp_account_get_path_suffix (account), + tp_account_is_enabled (account) ? "✓" : "☐", + status); + } + + g_list_free (accounts); + return FALSE; /* stop mainloop */ +} static void callback_for_create_account (GObject *source, @@ -531,7 +596,7 @@ callback_for_create_account (GObject *source, if (account != NULL) { command.common.ret = 0; - puts (skip_prefix (tp_proxy_get_object_path (account))); + puts (tp_account_get_path_suffix (account)); } else { fprintf (stderr, "%s %s: %s\n", app_name, command.common.name, @@ -574,7 +639,7 @@ callback_for_update_parameters (GObject *source, printf (" %s\n", r); printf ("run:\n"); printf (" %s reconnect %s\n", app_name, - skip_prefix (command.common.account)); + tp_account_get_path_suffix (account)); g_free (r); g_strfreev (reconnect_required); } @@ -620,15 +685,13 @@ command_remove (TpAccount *account) static gboolean command_show (TpAccount *account) { - gchar const *name; const GHashTable *parameters; GHashTableIter i[1]; gpointer keyp, valuep; struct presence automatic, current, requested; + const gchar * const *schemes; - name = skip_prefix (command.common.account); - - show ("Account", name); + show ("Account", tp_account_get_path_suffix (account)); show ("Display Name", tp_account_get_display_name (account)); show ("Normalized", tp_account_get_normalized_name (account)); show ("Enabled", tp_account_is_enabled (account) ? "enabled" : "disabled"); @@ -664,6 +727,11 @@ command_show (TpAccount *account) tp_account_get_changing_presence (account) ? "yes" : "no"); puts (""); + puts ("Addressing:"); + schemes = tp_account_get_uri_schemes (account); + show_uri_schemes (schemes); + + puts (""); parameters = tp_account_get_parameters (account); for (g_hash_table_iter_init (i, (GHashTable *) parameters); @@ -698,7 +766,7 @@ command_connection (TpAccount *account) } else { fprintf(stderr, "%s: no connection\n", - skip_prefix (command.common.account)); + tp_account_get_path_suffix (account)); } return FALSE; @@ -952,6 +1020,14 @@ parse (int argc, char **argv) command.ready.manager = command_list; } + else if (strcmp (argv[1], "summary") == 0) + { + /* List accounts */ + if (argc != 2) + show_help ("Invalid summary command."); + + command.ready.manager = command_summary; + } else if (strcmp (argv[1], "remove") == 0 || strcmp (argv[1], "delete") == 0) { @@ -1202,20 +1278,21 @@ void manager_ready (GObject *manager, } static -void account_ready (GObject *account, +void account_ready (GObject *source, GAsyncResult *res, gpointer user_data) { + TpAccount *account = TP_ACCOUNT (source); GError *error = NULL; if (!tp_proxy_prepare_finish (account, res, &error)) { fprintf (stderr, "%s: couldn't load account '%s': %s\n", app_name, - skip_prefix (command.common.account), error->message); + tp_account_get_path_suffix (account), error->message); fprintf (stderr, "Try '%s list' to list known accounts.\n", app_name); g_error_free (error); } else { - if (command.ready.account (TP_ACCOUNT (account))) + if (command.ready.account (account)) return; } @@ -1250,6 +1327,8 @@ main (int argc, char **argv) tp_proxy_prepare_async (am, NULL, manager_ready, NULL); } else { + const GQuark features[] = { TP_ACCOUNT_FEATURE_CORE, TP_ACCOUNT_FEATURE_ADDRESSING, 0 }; + command.common.account = ensure_prefix (command.common.account); a = tp_account_new (dbus, command.common.account, &error); @@ -1261,7 +1340,7 @@ main (int argc, char **argv) goto out; } - tp_proxy_prepare_async (a, NULL, account_ready, NULL); + tp_proxy_prepare_async (a, features, account_ready, NULL); } main_loop = g_main_loop_new (NULL, FALSE); |