/* initial XMPP stream setup, up to sending features stanza */ static WockyStanza * feature_stanza (TestConnectorServer *self) { TestConnectorServerPrivate *priv = self->priv; XmppProblem problem = priv->problem.connector->xmpp; const gchar *name = NULL; WockyStanza *feat = NULL; WockyNode *node = NULL; DEBUG (""); if (problem & XMPP_PROBLEM_OTHER_HOST) return error_stanza ("host-unknown", "some sort of DNS error", TRUE); name = (problem & XMPP_PROBLEM_FEATURES) ? "badger" : "features"; feat = wocky_stanza_new (name, WOCKY_XMPP_NS_STREAM); node = wocky_stanza_get_top_node (feat); DEBUG ("constructing <%s...>... stanza", name); if (priv->problem.sasl != SERVER_PROBLEM_NO_SASL) { if (priv->sasl == NULL) priv->sasl = test_sasl_auth_server_new (NULL, priv->mech, priv->user, priv->pass, NULL, priv->problem.sasl, FALSE); test_sasl_auth_server_set_mechs (G_OBJECT (priv->sasl), feat); } if (problem & XMPP_PROBLEM_OLD_AUTH_FEATURE) wocky_node_add_child_ns (node, "auth", WOCKY_JABBER_NS_AUTH_FEATURE); if (!(problem & XMPP_PROBLEM_NO_TLS) && !priv->tls_started) wocky_node_add_child_ns (node, "starttls", WOCKY_XMPP_NS_TLS); return feat; }
/* resume control after the sasl auth server is done: */ static void after_auth (GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; WockyStanza *feat = NULL; WockyNode *node = NULL; TestSaslAuthServer *tsas = TEST_SASL_AUTH_SERVER (source); TestConnectorServer *tcs = TEST_CONNECTOR_SERVER (data); TestConnectorServerPrivate *priv = tcs->priv; WockyXmppConnection *conn = priv->conn; DEBUG ("Auth finished: %d", priv->outstanding); if (!test_sasl_auth_server_auth_finish (tsas, res, &error)) { g_object_unref (priv->sasl); priv->sasl = NULL; if (server_dec_outstanding (tcs)) return; server_enc_outstanding (tcs); wocky_xmpp_connection_send_close_async (conn, priv->cancellable, xmpp_close, data); return; } priv->used_mech = g_strdup (test_sasl_auth_server_get_selected_mech (priv->sasl)); g_object_unref (priv->sasl); priv->sasl = NULL; if (server_dec_outstanding (tcs)) return; feat = wocky_stanza_build (WOCKY_STANZA_TYPE_STREAM_FEATURES, WOCKY_STANZA_SUB_TYPE_NONE, NULL, NULL, NULL); node = wocky_stanza_get_top_node (feat); if (!(priv->problem.connector->xmpp & XMPP_PROBLEM_NO_SESSION)) wocky_node_add_child_ns (node, "session", WOCKY_XMPP_NS_SESSION); if (!(priv->problem.connector->xmpp & XMPP_PROBLEM_CANNOT_BIND)) wocky_node_add_child_ns (node, "bind", WOCKY_XMPP_NS_BIND); priv->state = SERVER_STATE_FEATURES_SENT; server_enc_outstanding (tcs); wocky_xmpp_connection_send_stanza_async (conn, feat, priv->cancellable, xmpp_init, data); g_object_unref (feat); }
static void location_set_location (TpSvcConnectionInterfaceLocation *iface, GHashTable *location, DBusGMethodInvocation *context) { GabbleConnection *conn = GABBLE_CONNECTION (iface); LmMessage *msg; LmMessageNode *geoloc; WockyNode *item; GHashTableIter iter; gpointer key, value; GError *err = NULL; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED ((TpBaseConnection *) conn, context); if (!(conn->features & GABBLE_CONNECTION_FEATURES_PEP)) { GError error = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, "Server does not support PEP, cannot publish geolocation" }; dbus_g_method_return_error (context, &error); return; } gabble_connection_ensure_capabilities (conn, gabble_capabilities_get_geoloc_notify ()); msg = wocky_pep_service_make_publish_stanza (conn->pep_location, &item); geoloc = wocky_node_add_child_ns (item, "geoloc", NS_GEOLOC); DEBUG ("SetLocation to"); build_mapping_tables (); g_hash_table_iter_init (&iter, location); while (g_hash_table_iter_next (&iter, &key, &value)) { if (!add_to_geoloc_node ((const gchar *) key, (GValue *) value, geoloc, &err)) { DEBUG ("%s", err->message); dbus_g_method_return_error (context, err); g_error_free (err); goto out; } } if (!_gabble_connection_send_with_reply (conn, msg, set_location_sent_cb, G_OBJECT (conn), context, NULL)) { GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR, "Failed to send msg" }; dbus_g_method_return_error (context, &error); } out: lm_message_unref (msg); }
/* error stanza */ static WockyStanza * error_stanza (const gchar *cond, const gchar *msg, gboolean extended) { WockyStanza *error = wocky_stanza_new ("error", WOCKY_XMPP_NS_STREAM); WockyNode *node = wocky_stanza_get_top_node (error); wocky_node_add_child_ns (node, cond, WOCKY_XMPP_NS_STREAMS); if ((msg != NULL) && (*msg != '\0')) wocky_node_add_child_with_content_ns (node, "text", msg, WOCKY_XMPP_NS_STREAMS); if (extended) wocky_node_add_child_with_content_ns (node, "something", "blah", "urn:ietf:a:namespace:I:made:up"); return error; }
static void produce_description (WockyJingleContent *content, WockyNode *content_node) { GabbleJingleShare *self = GABBLE_JINGLE_SHARE (content); GabbleJingleSharePrivate *priv = self->priv; GList *i; WockyNode *desc_node; WockyNode *manifest_node; WockyNode *protocol_node; WockyNode *http_node; WockyNode *url_node; DEBUG ("produce description called"); ensure_manifest (self); desc_node = wocky_node_add_child_ns (content_node, "description", NS_GOOGLE_SESSION_SHARE); manifest_node = wocky_node_add_child (desc_node, "manifest"); for (i = priv->manifest->entries; i; i = i->next) { GabbleJingleShareManifestEntry *m = i->data; WockyNode *file_node; WockyNode *image_node; gchar *size_str, *width_str, *height_str; if (m->folder) file_node = wocky_node_add_child (manifest_node, "folder"); else file_node = wocky_node_add_child (manifest_node, "file"); if (m->size > 0) { size_str = g_strdup_printf ("%" G_GUINT64_FORMAT, m->size); wocky_node_set_attribute (file_node, "size", size_str); g_free (size_str); } wocky_node_add_child_with_content (file_node, "name", m->name); if (m->image && (m->image_width > 0 || m->image_height > 0)) { image_node = wocky_node_add_child (file_node, "image"); if (m->image_width > 0) { width_str = g_strdup_printf ("%d", m->image_width); wocky_node_set_attribute (image_node, "width", width_str); g_free (width_str); } if (m->image_height > 0) { height_str = g_strdup_printf ("%d", m->image_height); wocky_node_set_attribute (image_node, "height", height_str); g_free (height_str); } } } protocol_node = wocky_node_add_child (desc_node, "protocol"); http_node = wocky_node_add_child (protocol_node, "http"); url_node = wocky_node_add_child_with_content (http_node, "url", priv->manifest->source_url); wocky_node_set_attribute (url_node, "name", "source-path"); url_node = wocky_node_add_child_with_content (http_node, "url", priv->manifest->preview_url); wocky_node_set_attribute (url_node, "name", "preview-path"); }