1
Description: strip resource string from jid
2
gchat and others generate semi random character strings (eg:
3
foobar@gmail.com/CSCF76A81E) as the resource id on some contacts. That can
4
change rather rapidly and all of the sudden one can wind up with several
5
different query windows that really are all for the same contact.
6
Bug: http://gna.org/bugs/?18078
11
Creates a new window where the raw XML messages are displayed. Useful for
12
debugging. (default: OFF)
14
+/SET xmpp_strip_resource ON/OFF
15
+ Removes resource part from jid at private message window. This is
16
+ handy for example when chatting with someone using Google talk,
17
+ because Google talk appends random string to resource thus opening
18
+ a new private window every time resource changes. (default: OFF)
20
In "xmpp_proxy" section:
22
See the "Proxy usage" section of this file.
23
--- a/src/core/protocol.c
24
+++ b/src/core/protocol.c
29
+#include "channels.h"
35
LmMessageNode *node, *encrypted;
37
+ const char *from_stripped;
39
+ /* assing from_stripped. If setting xmpp_strip_resource is
40
+ True and from is not from a channel private message set
41
+ from_stripped to same as from, but strip the
42
+ resource. Otherwise just duplicate from to
44
+ str = xmpp_strip_resource(from);
46
+ ((settings_get_bool("xmpp_strip_resource")) &&
47
+ (channel_find(SERVER(server), str)) == NULL) ?
48
+ g_strdup(str) : g_strdup(from);
51
if ((type != LM_MESSAGE_SUB_TYPE_NOT_SET
52
&& type != LM_MESSAGE_SUB_TYPE_HEADLINE
54
str = xmpp_recode_in(node->value);
55
subject = g_strconcat("Subject: ", str, (void *)NULL);
57
- signal_emit("message private", 4, server, subject, from, from);
58
+ signal_emit("message private", 4, server, subject, from_stripped, from);
64
if (g_ascii_strncasecmp(str, "/me ", 4) == 0)
65
signal_emit("message xmpp action", 5,
66
- server, str+4, from, from,
67
+ server, str+4, from_stripped, from,
68
GINT_TO_POINTER(SEND_TARGET_NICK));
70
signal_emit("message private", 4, server,
72
+ str, from_stripped, from);
76
--- a/src/core/xmpp-queries.c
77
+++ b/src/core/xmpp-queries.c
82
+#include "settings.h"
85
#include "xmpp-queries.h"
87
XMPP_SERVER_REC *server;
91
const char *channel_name;
93
g_return_val_if_fail(server_tag != NULL, NULL);
95
rec->name = g_strdup(nick->host);
99
if (rec->name == NULL)
100
rec->name = rosters_resolve_name(server, data);
101
+ if (settings_get_bool("xmpp_strip_resource")) {
102
+ if (rec->name != NULL) {
103
+ str = xmpp_strip_resource(rec->name);
107
+ str = xmpp_strip_resource(data);
109
+ /* if this not a private message from channel we are
110
+ on, strip the resource */
111
+ if (channel_find(SERVER(server), str) == NULL)
112
+ rec->name = g_strdup(str);
115
if (rec->name != NULL) {
116
/* test if the query already exist */
117
if ((rec_tmp = xmpp_query_find(server, rec->name)) != NULL) {
118
--- a/src/fe-common/fe-xmpp-queries.c
119
+++ b/src/fe-common/fe-xmpp-queries.c
121
#include "printtext.h"
123
#include "window-items.h"
124
+#include "settings.h"
126
#include "xmpp-queries.h"
127
#include "rosters-tools.h"
128
#include "fe-xmpp-status.h"
132
sig_presence_changed(XMPP_SERVER_REC *server, const char *full_jid,
136
XMPP_ROSTER_USER_REC *user;
138
+ const char *msg, *stripped_jid;
141
+ stripped_jid = (settings_get_bool("xmpp_strip_resource")) ?
142
+ xmpp_strip_resource(full_jid) : g_strdup(full_jid);
144
g_return_if_fail(server != NULL);
145
- g_return_if_fail(full_jid != NULL);
146
+ g_return_if_fail(stripped_jid != NULL);
147
g_return_if_fail(0 <= show && show < XMPP_PRESENCE_SHOW_LEN);
148
- if ((rec = xmpp_query_find(server, full_jid)) == NULL)
149
+ if ((rec = xmpp_query_find(server, stripped_jid)) == NULL)
151
msg = fe_xmpp_presence_show[show];
152
- user = rosters_find_user(server->roster, full_jid, NULL, NULL);
153
+ user = rosters_find_user(server->roster, stripped_jid, NULL, NULL);
154
name = user != NULL && user->name != NULL ?
155
format_get_text(MODULE_NAME, NULL, server, NULL,
156
- XMPPTXT_FORMAT_NAME, user->name, full_jid) :
157
+ XMPPTXT_FORMAT_NAME, user->name, stripped_jid) :
158
format_get_text(MODULE_NAME, NULL, server, NULL,
159
- XMPPTXT_FORMAT_JID, full_jid);
160
+ XMPPTXT_FORMAT_JID, stripped_jid);
162
- printformat_module(MODULE_NAME, server, full_jid, MSGLEVEL_CRAP,
163
+ printformat_module(MODULE_NAME, server, stripped_jid, MSGLEVEL_CRAP,
164
XMPPTXT_PRESENCE_CHANGE_REASON, name, msg, status);
166
- printformat_module(MODULE_NAME, server, full_jid, MSGLEVEL_CRAP,
167
+ printformat_module(MODULE_NAME, server, stripped_jid, MSGLEVEL_CRAP,
168
XMPPTXT_PRESENCE_CHANGE, name, msg);
171
--- a/src/fe-common/fe-xmpp-status.c
172
+++ b/src/fe-common/fe-xmpp-status.c
175
#include "xmpp-servers.h"
176
#include "rosters-tools.h"
179
const char *fe_xmpp_presence_show[] = {
183
XMPP_ROSTER_USER_REC *user;
186
+ const char *msg, *stripped_jid;
189
+ stripped_jid = (settings_get_bool("xmpp_strip_resource")) ?
190
+ xmpp_strip_resource(full_jid) : g_strdup(full_jid);
192
g_return_if_fail(IS_XMPP_SERVER(server));
193
- g_return_if_fail(full_jid != NULL);
194
+ g_return_if_fail(stripped_jid != NULL);
195
g_return_if_fail(0 <= show && show < XMPP_PRESENCE_SHOW_LEN);
196
window = fe_xmpp_status_get_window(server);
197
msg = fe_xmpp_presence_show[show];
198
- user = rosters_find_user(server->roster, full_jid, NULL, NULL);
199
+ user = rosters_find_user(server->roster, stripped_jid, NULL, NULL);
200
name = user != NULL && user->name != NULL ?
201
format_get_text(MODULE_NAME, NULL, server, NULL,
202
- XMPPTXT_FORMAT_NAME, user->name, full_jid) :
203
+ XMPPTXT_FORMAT_NAME, user->name, stripped_jid) :
204
format_get_text(MODULE_NAME, NULL, server, NULL,
205
- XMPPTXT_FORMAT_JID, full_jid);
206
+ XMPPTXT_FORMAT_JID, stripped_jid);
208
printformat_module_window(MODULE_NAME, window, MSGLEVEL_CRAP,
209
XMPPTXT_PRESENCE_CHANGE_REASON, name, msg, status);
212
settings_add_bool("xmpp_lookandfeel", "xmpp_status_window", FALSE);
214
+ settings_add_bool("xmpp_lookandfeel", "xmpp_strip_resource", FALSE);
216
if (settings_get_bool("xmpp_status_window"))
217
signal_add("xmpp presence changed", sig_presence_changed);