2
* $Id: fe-vcard.c,v 1.1 2008/08/19 23:57:15 cdidier Exp $
4
* Copyright (C) 2007 Colin DIDIER
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
#include "printtext.h"
25
#include "xmpp-servers.h"
26
#include "rosters-tools.h"
28
#include "../module-formats.h"
30
struct vcard_user_data {
31
XMPP_SERVER_REC *server;
36
func_vcard_value(const char *key, const char *value, struct vcard_user_data *ud)
38
printformat_module(MODULE_NAME, ud->server, ud->jid, MSGLEVEL_CRAP,
39
XMPPTXT_VCARD_VALUE, key, value);
43
func_vcard_subvalue(const char *key, const char *value,
44
struct vcard_user_data *ud)
46
printformat_module(MODULE_NAME, ud->server, ud->jid, MSGLEVEL_CRAP,
47
XMPPTXT_VCARD_SUBVALUE, key, value);
51
sig_vcard(XMPP_SERVER_REC *server, const char *jid, GHashTable *ht)
53
XMPP_ROSTER_USER_REC *user;
54
struct vcard_user_data ud;
57
user = rosters_find_user(server->roster, jid, NULL, NULL);
58
name = user != NULL && user->name != NULL ?
59
g_strdup(user->name) : xmpp_strip_resource(jid);
60
printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
61
XMPPTXT_VCARD, name, jid);
65
g_hash_table_foreach(ht,
66
(void (*)(gpointer, gpointer, gpointer))func_vcard_value, &ud);
67
printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
68
XMPPTXT_END_OF_VCARD);
74
signal_add("xmpp vcard", sig_vcard);
80
signal_remove("xmpp vcard", sig_vcard);