| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "module.h" |
| 19 |
#include "levels.h" |
| 20 |
#include "printtext.h" |
| 21 |
#include "signals.h" |
| 22 |
|
| 23 |
#include "xmpp-servers.h" |
| 24 |
#include "rosters-tools.h" |
| 25 |
#include "tools.h" |
| 26 |
#include "../module-formats.h" |
| 27 |
|
| 28 |
struct vcard_user_data { |
| 29 |
XMPP_SERVER_REC *server; |
| 30 |
const char *jid; |
| 31 |
}; |
| 32 |
|
| 33 |
static void |
| 34 |
func_vcard_value(const char *key, const char *value, struct vcard_user_data *ud) |
| 35 |
{ |
| 36 |
printformat_module(MODULE_NAME, ud->server, ud->jid, MSGLEVEL_CRAP, |
| 37 |
XMPPTXT_VCARD_VALUE, key, value); |
| 38 |
} |
| 39 |
|
| 40 |
#if 0 |
| 41 |
|
| 42 |
static void |
| 43 |
func_vcard_subvalue(const char *key, const char *value, |
| 44 |
struct vcard_user_data *ud) |
| 45 |
{ |
| 46 |
printformat_module(MODULE_NAME, ud->server, ud->jid, MSGLEVEL_CRAP, |
| 47 |
XMPPTXT_VCARD_SUBVALUE, key, value); |
| 48 |
} |
| 49 |
|
| 50 |
#endif |
| 51 |
|
| 52 |
static void |
| 53 |
sig_vcard(XMPP_SERVER_REC *server, const char *jid, GHashTable *ht) |
| 54 |
{ |
| 55 |
XMPP_ROSTER_USER_REC *user; |
| 56 |
struct vcard_user_data ud; |
| 57 |
char *name; |
| 58 |
|
| 59 |
user = rosters_find_user(server->roster, jid, NULL, NULL); |
| 60 |
name = user != NULL && user->name != NULL ? |
| 61 |
g_strdup(user->name) : xmpp_strip_resource(jid); |
| 62 |
printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP, |
| 63 |
XMPPTXT_VCARD, name, jid); |
| 64 |
g_free(name); |
| 65 |
ud.server = server; |
| 66 |
ud.jid = jid; |
| 67 |
g_hash_table_foreach(ht, |
| 68 |
(void (*)(gpointer, gpointer, gpointer))func_vcard_value, &ud); |
| 69 |
printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP, |
| 70 |
XMPPTXT_END_OF_VCARD); |
| 71 |
} |
| 72 |
|
| 73 |
void |
| 74 |
fe_vcard_init(void) |
| 75 |
{ |
| 76 |
signal_add("xmpp vcard", sig_vcard); |
| 77 |
} |
| 78 |
|
| 79 |
void |
| 80 |
fe_vcard_deinit(void) |
| 81 |
{ |
| 82 |
signal_remove("xmpp vcard", sig_vcard); |
| 83 |
} |