/* * _mcd_channel_get_immutable_properties: * @channel: the #McdChannel. * * Returns: the #GHashTable of the immutable properties. */ GHashTable * _mcd_channel_get_immutable_properties (McdChannel *channel) { GHashTable *ret; g_return_val_if_fail (MCD_IS_CHANNEL (channel), NULL); if (channel->priv->tp_chan == NULL) { DEBUG ("Channel %p has no associated TpChannel", channel); return NULL; } ret = tp_channel_borrow_immutable_properties (channel->priv->tp_chan); if (ret == NULL) { DEBUG ("Channel %p TpChannel %s (%p) has no immutable properties yet", channel, tp_proxy_get_object_path (channel->priv->tp_chan), channel->priv->tp_chan); return NULL; } return ret; }
/** * empathy_server_sasl_handler_can_save_response_somewhere: * @self: * * Returns: %TRUE if the response can be saved somewhere, either the keyring * or via Ch.I.CredentialsStorage */ gboolean empathy_server_sasl_handler_can_save_response_somewhere ( EmpathyServerSASLHandler *self) { EmpathyServerSASLHandlerPriv *priv; gboolean may_save_response, may_save_response_valid; gboolean has_storage_iface; g_return_val_if_fail (EMPATHY_IS_SERVER_SASL_HANDLER (self), FALSE); priv = self->priv; /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean ( tp_channel_borrow_immutable_properties (priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if (!may_save_response_valid) { DEBUG ("MaySaveResponse unknown, assuming TRUE"); may_save_response = TRUE; } has_storage_iface = tp_proxy_has_interface_by_id (priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE); return may_save_response || has_storage_iface; }
gboolean hev_impathy_server_sasl_handler_can_save_response_somewhere( HevImpathyServerSASLHandler *self) { HevImpathyServerSASLHandlerPrivate * priv = NULL; gboolean may_save_response = FALSE, may_save_response_valid = FALSE; gboolean has_storage_iface = FALSE; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_if_fail(HEV_IS_IMPATHY_SERVER_SASL_HANDLER(self)); priv = HEV_IMPATHY_SERVER_SASL_HANDLER_GET_PRIVATE(self); /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean( tp_channel_borrow_immutable_properties(priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if(!may_save_response_valid) { may_save_response = TRUE; } #if 0 /* TODO */ has_storage_iface = tp_proxy_has_interface_by_id(priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE); #endif return may_save_response || has_storage_iface; }
static void empathy_tube_dispatch_constructed (GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); TpChannel *channel; GHashTable *properties; const gchar *service; const gchar *channel_type; TpTubeType type; priv->dbus = tp_dbus_daemon_new (tp_get_bus()); channel = empathy_dispatch_operation_get_channel (priv->operation); properties = tp_channel_borrow_immutable_properties (channel); channel_type = tp_asv_get_string (properties, TP_IFACE_CHANNEL ".ChannelType"); if (channel_type == NULL) goto failed; if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE)) { type = TP_TUBE_TYPE_STREAM; service = tp_asv_get_string (properties, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service"); } else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE)) { type = TP_TUBE_TYPE_DBUS; service = tp_asv_get_string (properties, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE ".ServiceName"); } else { goto failed; } if (service == NULL) goto failed; priv->bus_name = empathy_tube_handler_build_bus_name (type, service); priv->object_path = empathy_tube_handler_build_object_path (type, service); priv->service = g_strdup (service); DEBUG ("Look for tube handler %s\n", priv->bus_name); tp_cli_dbus_daemon_call_name_has_owner (priv->dbus, -1, priv->bus_name, empathy_tube_dispatch_name_has_owner_cb, NULL, NULL, G_OBJECT (self)); return; failed: empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE); }
static void file_transfer_channel_ready (TpChannel *channel, const GError *in_error, gpointer user_data) { GError *error = NULL; handle_error (in_error); GHashTable *map = tp_channel_borrow_immutable_properties (channel); const char *filename = tp_asv_get_string (map, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME); guint64 size = tp_asv_get_uint64 (map, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, NULL); g_print ("New file transfer to %s -- `%s' (%llu bytes)\n", tp_channel_get_identifier (channel), filename, size); /* File transfers in Telepathy work by opening a socket to the * Connection Manager and streaming the file over that socket. * Let's find out what manner of sockets are supported by this CM */ GHashTable *sockets = tp_asv_get_boxed (map, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_AVAILABLE_SOCKET_TYPES, TP_HASH_TYPE_SUPPORTED_SOCKET_MAP); /* let's try for IPv4 */ if (g_hash_table_lookup (sockets, GINT_TO_POINTER (TP_SOCKET_ADDRESS_TYPE_IPV4))) { g_print ("ipv4 supported\n"); } else if (g_hash_table_lookup (sockets, GINT_TO_POINTER (TP_SOCKET_ADDRESS_TYPE_UNIX))) { struct ft_state *state = g_slice_new0 (struct ft_state); state->sa.sun_family = AF_UNIX; tp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed ( channel, file_transfer_unix_state_changed_cb, state, NULL, NULL, &error); handle_error (error); GValue *value = tp_g_value_slice_new_static_string (""); /* set up the socket for providing the file */ tp_cli_channel_type_file_transfer_call_provide_file ( channel, -1, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, value, file_transfer_unix_cb, state, NULL, NULL); tp_g_value_slice_free (value); } }
gboolean empathy_sasl_channel_supports_mechanism (TpChannel *channel, const gchar *mechanism) { GHashTable *props; const gchar * const *available_mechanisms; props = tp_channel_borrow_immutable_properties (channel); available_mechanisms = tp_asv_get_boxed (props, TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_AVAILABLE_MECHANISMS, G_TYPE_STRV); return tp_strv_contains (available_mechanisms, mechanism); }
static void channel_prepared_cb ( GObject *source, GAsyncResult *result, gpointer user_data) { TpFileTransferChannel *channel = TP_FILE_TRANSFER_CHANNEL (source); CallbacksData *cb_data = user_data; EmpathyFTHandler *handler = cb_data->handler; EmpathyFTHandlerPriv *priv = handler->priv; GHashTable *properties; GError *error = NULL; if (!tp_proxy_prepare_finish (channel, result, &error)) { if (!g_cancellable_is_cancelled (priv->cancellable)) g_cancellable_cancel (priv->cancellable); cb_data->callback (handler, error, cb_data->user_data); g_clear_error (&error); callbacks_data_free (cb_data); return; } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" properties = tp_channel_borrow_immutable_properties (TP_CHANNEL (channel)); #pragma GCC diagnostic pop priv->content_hash = g_strdup ( tp_asv_get_string (properties, "ContentHash")); priv->content_hash_type = tp_asv_get_uint32 ( properties, "ContentHashType", NULL); priv->contact = g_object_ref (tp_channel_get_target_contact (TP_CHANNEL (channel))); cb_data->callback (handler, NULL, cb_data->user_data); }
static void on_channel_ready (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpChannel *tp_chan = TP_CHANNEL (source_object); McdChannel *channel, **channel_ptr = user_data; McdChannelPrivate *priv; gboolean requested, valid; GError *error = NULL; if (!tp_proxy_prepare_finish (tp_chan, result, &error)) { DEBUG ("failed to prepare channel: %s", error->message); g_clear_error (&error); return; } channel = *channel_ptr; if (channel) g_object_remove_weak_pointer ((GObject *)channel, (gpointer)channel_ptr); g_slice_free (McdChannel *, channel_ptr); if (error) { DEBUG ("got error: %s", error->message); return; } if (!channel) return; DEBUG ("channel %p is ready", channel); priv = channel->priv; requested = tp_asv_get_boolean (tp_channel_borrow_immutable_properties (tp_chan), TP_IFACE_CHANNEL ".Requested", &valid); if (valid) priv->outgoing = requested; }
static void _mcd_channel_setup (McdChannel *channel, McdChannelPrivate *priv) { McdChannel **channel_ptr; GHashTable *properties; channel_ptr = g_slice_alloc (sizeof (McdChannel *)); *channel_ptr = channel; g_object_add_weak_pointer ((GObject *)channel, (gpointer)channel_ptr); tp_proxy_prepare_async (priv->tp_chan, NULL, on_channel_ready, channel_ptr); g_signal_connect (priv->tp_chan, "invalidated", G_CALLBACK (proxy_destroyed), channel); properties = tp_channel_borrow_immutable_properties (priv->tp_chan); if (properties) { gboolean requested, valid = FALSE; requested = tp_asv_get_boolean (properties, TP_IFACE_CHANNEL ".Requested", &valid); if (valid) priv->outgoing = requested; } }
void empathy_server_sasl_handler_provide_password ( EmpathyServerSASLHandler *handler, const gchar *password, gboolean remember) { EmpathyServerSASLHandlerPriv *priv; GArray *array; gboolean may_save_response, may_save_response_valid; g_return_if_fail (EMPATHY_IS_SERVER_SASL_HANDLER (handler)); priv = handler->priv; array = g_array_sized_new (TRUE, FALSE, sizeof (gchar), strlen (password)); g_array_append_vals (array, password, strlen (password)); DEBUG ("Calling StartMechanismWithData with our password"); tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data ( priv->channel, -1, "X-TELEPATHY-PASSWORD", array, start_mechanism_with_data_cb, NULL, NULL, G_OBJECT (handler)); g_array_unref (array); DEBUG ("%sremembering the password", remember ? "" : "not "); /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean ( tp_channel_borrow_immutable_properties (priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if (!may_save_response_valid) { DEBUG ("MaySaveResponse unknown, assuming TRUE"); may_save_response = TRUE; } if (remember) { if (may_save_response) { g_free (priv->password); /* We'll save the password if we manage to connect */ priv->password = g_strdup (password); priv->save_password = TRUE; } else if (tp_proxy_has_interface_by_id (priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { DEBUG ("Channel implements Ch.I.CredentialsStorage"); } else { DEBUG ("Asked to remember password, but doing so is not permitted"); } } if (!may_save_response) { /* delete any password present, it shouldn't be there */ empathy_keyring_delete_account_password_async (priv->account, NULL, NULL); } /* Additionally, if we implement Ch.I.CredentialsStorage, inform that * whether we want to remember the password */ if (tp_proxy_has_interface_by_id (priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { emp_cli_channel_interface_credentials_storage_call_store_credentials ( TP_PROXY (priv->channel), -1, remember, NULL, NULL, NULL, NULL); } }
void hev_impathy_server_sasl_handler_provide_password( HevImpathyServerSASLHandler *self, const gchar *password, gboolean remember) { HevImpathyServerSASLHandlerPrivate * priv = NULL; GArray *array = NULL; gboolean may_save_response = FALSE, may_save_response_valid = FALSE; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_if_fail(HEV_IS_IMPATHY_SERVER_SASL_HANDLER(self)); priv = HEV_IMPATHY_SERVER_SASL_HANDLER_GET_PRIVATE(self); array = g_array_sized_new(TRUE, FALSE, sizeof(gchar), strlen(password)); g_array_append_vals(array, password, strlen(password)); tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data( priv->channel, -1, "X-TELEPATHY-PASSWORD", array, start_mechanism_with_data_handler, NULL, NULL, G_OBJECT(self)); g_array_unref(array); /* determine if we are permitted to save the password locally */ may_save_response = tp_asv_get_boolean( tp_channel_borrow_immutable_properties(priv->channel), TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_MAY_SAVE_RESPONSE, &may_save_response_valid); if(!may_save_response_valid) { may_save_response = TRUE; } if(remember) { if(may_save_response) { g_free(priv->password); /* We'll save the password if we manage to connect */ priv->password = g_strdup(password); priv->save_password = TRUE; } #if 0 /* TODO */ else if(tp_proxy_has_interface_by_id(priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { } else { } #endif } if(!may_save_response) { /* delete any password present, it shouldn't be there */ hev_impathy_keyring_delete_account_password_async(priv->account, NULL, NULL); } #if 0 /* TODO */ /* Additionally, if we implement Ch.I.CredentialsStorage, inform that * whether we want to remember the password. */ if(tp_proxy_has_interface_by_id(priv->channel, EMP_IFACE_QUARK_CHANNEL_INTERFACE_CREDENTIALS_STORAGE)) { emp_cli_channel_interface_credentials_storage_call_store_credentials( TP_PROXY(priv->channel), -1, remember, NULL, NULL, NULL, NULL); } #endif }