Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/jutil.c @ 27050:fd7dc5cc0310
Allow incoming stanzas to match 'our account' if they come from our resource.
This makes little sense but is allowed by rfc3921 7.2 for roster pushes and
is what ejabberd 2.0.5 uses.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 29 May 2009 20:56:46 +0000 |
parents | e8795ced8c9b |
children | 5048054d319a |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple - Jabber Protocol Plugin |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15891
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 #include "internal.h" |
15891
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
22 #include "account.h" |
24641
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
23 #include "cipher.h" |
15891
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
24 #include "conversation.h" |
24641
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
25 #include "debug.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "server.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "util.h" |
15891
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
28 #include "xmlnode.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "chat.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "presence.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "jutil.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 gboolean jabber_nodeprep_validate(const char *str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 const char *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 if(!str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 if(strlen(str) > 1023) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 c = str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 while(c && *c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 gunichar ch = g_utf8_get_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 if(ch == '\"' || ch == '&' || ch == '\'' || ch == '/' || ch == ':' || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 ch == '<' || ch == '>' || ch == '@' || !g_unichar_isgraph(ch)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 c = g_utf8_next_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 gboolean jabber_nameprep_validate(const char *str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 const char *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 if(!str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 if(strlen(str) > 1023) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 c = str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 while(c && *c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 gunichar ch = g_utf8_get_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 if(!g_unichar_isgraph(ch)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 c = g_utf8_next_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 gboolean jabber_resourceprep_validate(const char *str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 const char *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 if(!str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 if(strlen(str) > 1023) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 c = str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 while(c && *c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 gunichar ch = g_utf8_get_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 if(!g_unichar_isgraph(ch) && ch != ' ') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 c = g_utf8_next_char(c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 JabberID* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 jabber_id_new(const char *str) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 char *at; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 char *slash; |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
108 char *node = NULL; |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
109 char *domain; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 JabberID *jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 if(!str || !g_utf8_validate(str, -1, NULL)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 jid = g_new0(JabberID, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 at = g_utf8_strchr(str, -1, '@'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 slash = g_utf8_strchr(str, -1, '/'); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 if(at) { |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
121 node = g_utf8_normalize(str, at-str, G_NORMALIZE_NFKC); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 if(slash) { |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
123 domain = g_utf8_normalize(at+1, slash-(at+1), G_NORMALIZE_NFKC); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 } else { |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
126 domain = g_utf8_normalize(at+1, -1, G_NORMALIZE_NFKC); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 if(slash) { |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
130 domain = g_utf8_normalize(str, slash-str, G_NORMALIZE_NFKC); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 jid->resource = g_utf8_normalize(slash+1, -1, G_NORMALIZE_NFKC); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 } else { |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
133 domain = g_utf8_normalize(str, -1, G_NORMALIZE_NFKC); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
137 if (node) { |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
138 jid->node = g_utf8_strdown(node, -1); |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
139 g_free(node); |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
140 } |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
141 |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
142 if (domain) { |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
143 jid->domain = g_utf8_strdown(domain, -1); |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
144 g_free(domain); |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
145 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 if(!jabber_nodeprep_validate(jid->node) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 !jabber_nameprep_validate(jid->domain) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 !jabber_resourceprep_validate(jid->resource)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 return jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 jabber_id_free(JabberID *jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 if(jid) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 if(jid->node) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 g_free(jid->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 if(jid->domain) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 g_free(jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 if(jid->resource) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 g_free(jid->resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 g_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 char *jabber_get_resource(const char *in) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 JabberID *jid = jabber_id_new(in); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 char *out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 out = g_strdup(jid->resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 return out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 char *jabber_get_bare_jid(const char *in) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 JabberID *jid = jabber_id_new(in); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 char *out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 out = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 jid->node ? "@" : "", jid->domain); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 return out; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 |
15823 | 201 const char *jabber_normalize(const PurpleAccount *account, const char *in) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 { |
15823 | 203 PurpleConnection *gc = account ? account->gc : NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 JabberStream *js = gc ? gc->proto_data : NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 static char buf[3072]; /* maximum legal length of a jabber jid */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 JabberID *jid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 jid = jabber_id_new(in); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 if(!jid) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
213 if(js && jid->node && jid->resource && |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
214 jabber_chat_find(js, jid->node, jid->domain)) |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
215 g_snprintf(buf, sizeof(buf), "%s@%s/%s", jid->node, jid->domain, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 jid->resource); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 else |
26979
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
218 g_snprintf(buf, sizeof(buf), "%s%s%s", jid->node ? jid->node : "", |
34e4e2ca7db9
jabber_id_new() needs to be case-folding the node and domain.
Paul Aurich <paul@darkrain42.org>
parents:
24641
diff
changeset
|
219 jid->node ? "@" : "", jid->domain); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 jabber_id_free(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 |
27023
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
226 gboolean |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
227 jabber_is_own_server(JabberStream *js, const char *str) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
228 { |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
229 JabberID *jid; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
230 gboolean equal; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
231 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
232 if (str == NULL) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
233 return FALSE; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
234 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
235 g_return_val_if_fail(*str != '\0', FALSE); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
236 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
237 jid = jabber_id_new(str); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
238 if (!jid) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
239 return FALSE; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
240 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
241 equal = (jid->node == NULL && |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
242 g_str_equal(jid->domain, js->user->domain) && |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
243 jid->resource == NULL); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
244 jabber_id_free(jid); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
245 return equal; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
246 } |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
247 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
248 gboolean |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
249 jabber_is_own_account(JabberStream *js, const char *str) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
250 { |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
251 JabberID *jid; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
252 gboolean equal; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
253 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
254 if (str == NULL) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
255 return TRUE; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
256 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
257 g_return_val_if_fail(*str != '\0', FALSE); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
258 |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
259 jid = jabber_id_new(str); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
260 if (!jid) |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
261 return FALSE; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
262 |
27050
fd7dc5cc0310
Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents:
27023
diff
changeset
|
263 equal = (purple_strequal(jid->node, js->user->node) && |
27023
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
264 g_str_equal(jid->domain, js->user->domain) && |
27050
fd7dc5cc0310
Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents:
27023
diff
changeset
|
265 (jid->resource == NULL || |
fd7dc5cc0310
Allow incoming stanzas to match 'our account' if they come from our resource.
Paul Aurich <paul@darkrain42.org>
parents:
27023
diff
changeset
|
266 g_str_equal(jid->resource, js->user->resource))); |
27023
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
267 jabber_id_free(jid); |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
268 return equal; |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
269 } |
e8795ced8c9b
Add two helper functions useful for matching the 'from' attribute on packets to either our server or our account.
Paul Aurich <paul@darkrain42.org>
parents:
26979
diff
changeset
|
270 |
15823 | 271 PurpleConversation * |
272 jabber_find_unnormalized_conv(const char *name, PurpleAccount *account) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 { |
15823 | 274 PurpleConversation *c = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 GList *cnv; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 g_return_val_if_fail(name != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 |
15823 | 279 for(cnv = purple_get_conversations(); cnv; cnv = cnv->next) { |
280 c = (PurpleConversation*)cnv->data; | |
281 if(purple_conversation_get_type(c) == PURPLE_CONV_TYPE_IM && | |
282 !purple_utf8_strcasecmp(name, purple_conversation_get_name(c)) && | |
283 account == purple_conversation_get_account(c)) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 return c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 |
24641
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
290 /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */ |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
291 char * |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
292 jabber_calculate_data_sha1sum(gconstpointer data, size_t len) |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
293 { |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
294 PurpleCipherContext *context; |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
295 static gchar digest[41]; |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
296 |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
297 context = purple_cipher_context_new_by_name("sha1", NULL); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
298 if (context == NULL) |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
299 { |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
300 purple_debug_error("jabber", "Could not find sha1 cipher\n"); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
301 g_return_val_if_reached(NULL); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
302 } |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
303 |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
304 /* Hash the data */ |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
305 purple_cipher_context_append(context, data, len); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
306 if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL)) |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
307 { |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
308 purple_debug_error("jabber", "Failed to get SHA-1 digest.\n"); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
309 g_return_val_if_reached(NULL); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
310 } |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
311 purple_cipher_context_destroy(context); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
312 |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
313 return g_strdup(digest); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
314 } |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
19680
diff
changeset
|
315 |