mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
XEP-0157: Print contact addresses
This commit is contained in:
parent
2f5aa124ca
commit
ef96bea82e
@ -837,6 +837,20 @@ cons_show_disco_items(GSList* items, const char* const jid)
|
||||
cons_alert(NULL);
|
||||
}
|
||||
|
||||
static void _cons_print_contact_information_item(gpointer key, gpointer value, gpointer userdata)
|
||||
{
|
||||
cons_show("%s: %s", (char*)key, (char*)value);
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_disco_contact_information(GHashTable* addresses)
|
||||
{
|
||||
cons_show("");
|
||||
cons_show("Server contact information:");
|
||||
|
||||
g_hash_table_foreach(addresses, _cons_print_contact_information_item, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_status(const char* const barejid)
|
||||
{
|
||||
|
@ -276,6 +276,7 @@ void cons_show_bookmarks(const GList* list);
|
||||
void cons_show_bookmarks_ignore(gchar** list, gsize len);
|
||||
void cons_show_disco_items(GSList* items, const char* const jid);
|
||||
void cons_show_disco_info(const char* from, GSList* identities, GSList* features);
|
||||
void cons_show_disco_contact_information(GHashTable* addresses);
|
||||
void cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason);
|
||||
void cons_check_version(gboolean not_available_msg);
|
||||
void cons_show_typing(const char* const barejid);
|
||||
|
@ -2343,22 +2343,9 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
|
||||
}
|
||||
}
|
||||
} else if (g_strcmp0(child_type, STANZA_TYPE_RESULT) == 0) {
|
||||
/*
|
||||
DataForm* form = form_create(child);
|
||||
ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, NULL, NULL, NULL);
|
||||
confwin_handle_configuration(confwin, form);
|
||||
*/
|
||||
/*g_hash_table_new () with field var='security-addresses' as key
|
||||
* a list of <value>xmpp:security@shakespeare.lit</value> as value
|
||||
*/
|
||||
stanza_get_service_contact_addresses(connection_get_ctx(), child);
|
||||
/*
|
||||
char* text;
|
||||
size_t text_size;
|
||||
xmpp_stanza_to_text(child, &text, &text_size);
|
||||
cons_show(text);
|
||||
free(text);
|
||||
*/
|
||||
GHashTable *adr = stanza_get_service_contact_addresses(connection_get_ctx(), child);
|
||||
cons_show_disco_contact_information(adr);
|
||||
g_hash_table_destroy(adr);
|
||||
}
|
||||
|
||||
child = xmpp_stanza_get_next(child);
|
||||
|
@ -2839,9 +2839,11 @@ stanza_create_muc_register_nick(xmpp_ctx_t* ctx, const char* const id, const cha
|
||||
return iq;
|
||||
}
|
||||
|
||||
void
|
||||
GHashTable*
|
||||
stanza_get_service_contact_addresses(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
|
||||
{
|
||||
GHashTable* addresses = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
xmpp_stanza_t* fields = xmpp_stanza_get_children(stanza);
|
||||
while (fields) {
|
||||
const char* child_name = xmpp_stanza_get_name(fields);
|
||||
@ -2850,22 +2852,27 @@ stanza_get_service_contact_addresses(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
|
||||
if (g_strcmp0(child_name, STANZA_NAME_FIELD) == 0 && g_strcmp0(child_type, STANZA_TYPE_LIST_MULTI) == 0) {
|
||||
// key
|
||||
const char* var = xmpp_stanza_get_attribute(fields, STANZA_ATTR_VAR );
|
||||
var = var;
|
||||
|
||||
// values
|
||||
xmpp_stanza_t* values = xmpp_stanza_get_children(fields);
|
||||
if (values) {
|
||||
while (values) {
|
||||
const char* value_name = xmpp_stanza_get_name(values);
|
||||
if (value_name && (g_strcmp0(value_name, STANZA_NAME_VALUE) == 0)) {
|
||||
char* value_text = xmpp_stanza_get_text(values);
|
||||
if (value_text) {
|
||||
//add to list
|
||||
g_hash_table_insert(addresses, g_strdup(var), g_strdup(value_text));
|
||||
|
||||
xmpp_free(ctx, value_text);
|
||||
}
|
||||
}
|
||||
|
||||
values = xmpp_stanza_get_next(values);
|
||||
}
|
||||
}
|
||||
|
||||
fields = xmpp_stanza_get_next(fields);
|
||||
}
|
||||
|
||||
return addresses;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ char* stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza);
|
||||
const char* stanza_get_actor(xmpp_stanza_t* stanza);
|
||||
char* stanza_get_reason(xmpp_stanza_t* stanza);
|
||||
|
||||
void stanza_get_service_contact_addresses(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
|
||||
GHashTable* stanza_get_service_contact_addresses(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
|
||||
|
||||
Resource* stanza_resource_from_presence(XMPPPresence* presence);
|
||||
XMPPPresence* stanza_parse_presence(xmpp_stanza_t* stanza, int* err);
|
||||
|
Loading…
Reference in New Issue
Block a user