Mercurial > pidgin
annotate libpurple/dnssrv.c @ 31911:8a55048115ab
Add an entry for 0ea4521b22507f8cc23de316fa55e3368d9f4029
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 22 Aug 2011 04:24:12 +0000 |
parents | 9ed25c58e7ce |
children | efe38e6319f2 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file dnssrv.c |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
3 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 /* purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * 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
|
16 * 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
|
17 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * 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
|
20 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18401
diff
changeset
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
31528
92f3d821653f
purple: Fix some compiler warnings related to new API and missing prototypes.
Paul Aurich <paul@darkrain42.org>
parents:
31479
diff
changeset
|
23 #define _PURPLE_DNSSRV_C_ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include "internal.h" |
15656
ca1c878be941
Include util.h to fix a warning I introduced
Evan Schoenberg <evan.s@dreskin.net>
parents:
15645
diff
changeset
|
26 #include "util.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #ifndef _WIN32 |
23201
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22224
diff
changeset
|
29 #include <arpa/nameser.h> |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include <resolv.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #ifdef HAVE_ARPA_NAMESER_COMPAT_H |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include <arpa/nameser_compat.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #endif |
25170 | 34 #else /* WIN32 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #include <windns.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 /* Missing from the mingw headers */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #ifndef DNS_TYPE_SRV |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
38 # define DNS_TYPE_SRV PurpleDnsTypeSrv |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #endif |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
40 #ifndef DNS_TYPE_TXT |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
41 # define DNS_TYPE_TXT PurpleDnsTypeTxt |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
42 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
31477
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
45 #ifndef T_SRV |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
46 #define T_SRV PurpleDnsTypeSrv |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
47 #endif |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
48 #ifndef T_TXT |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
49 #define T_TXT PurpleDnsTypeTxt |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
50 #endif |
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
51 |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
52 #include "debug.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 #include "dnssrv.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 #include "eventloop.h" |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
55 #include "network.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
57 static PurpleSrvTxtQueryUiOps *srv_txt_query_ui_ops = NULL; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
58 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 typedef union { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 HEADER hdr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 u_char buf[1024]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 } queryans; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 #else |
18401
3c6bc8785af9
Fix up some linkage to compile on Visual Studio. He claims this doesn't
Nick Hebner <hebnern@gmail.com>
parents:
16903
diff
changeset
|
65 static DNS_STATUS (WINAPI *MyDnsQuery_UTF8) ( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 PCSTR lpstrName, WORD wType, DWORD fOptions, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 PIP4_ARRAY aipServers, PDNS_RECORD* ppQueryResultsSet, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 PVOID* pReserved) = NULL; |
18401
3c6bc8785af9
Fix up some linkage to compile on Visual Studio. He claims this doesn't
Nick Hebner <hebnern@gmail.com>
parents:
16903
diff
changeset
|
69 static void (WINAPI *MyDnsRecordListFree) (PDNS_RECORD pRecordList, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 DNS_FREE_TYPE FreeType) = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
73 struct _PurpleSrvTxtQueryData { |
25170 | 74 union { |
75 PurpleSrvCallback srv; | |
76 PurpleTxtCallback txt; | |
77 } cb; | |
78 | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 gpointer extradata; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 guint handle; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
81 int type; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
82 char *query; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 GThread *resolver; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 char *error_message; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
86 GList *results; |
15712
4530f15fe5af
Patch from Graham Booker which ensures that a process forked by dnsserv cleans up afterwards, calling waitpid() to make sure no zombies are left over.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15656
diff
changeset
|
87 #else |
20232
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
88 int fd_in, fd_out; |
15712
4530f15fe5af
Patch from Graham Booker which ensures that a process forked by dnsserv cleans up afterwards, calling waitpid() to make sure no zombies are left over.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15656
diff
changeset
|
89 pid_t pid; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
93 typedef struct _PurpleSrvInternalQuery { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
94 int type; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
95 char query[256]; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
96 } PurpleSrvInternalQuery; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
97 |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
98 typedef struct _PurpleSrvResponseContainer { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
99 PurpleSrvResponse *response; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
100 int sum; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
101 } PurpleSrvResponseContainer; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
102 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
103 static gboolean purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data); |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
104 |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
105 /** |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
106 * Sort by priority, then by weight. Strictly numerically--no |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
107 * randomness. Technically we only need to sort by pref and then |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
108 * make sure any records with weight 0 are at the beginning of |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
109 * their group, but it's just as easy to sort by weight. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
110 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 static gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 responsecompare(gconstpointer ar, gconstpointer br) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 { |
15822 | 114 PurpleSrvResponse *a = (PurpleSrvResponse*)ar; |
115 PurpleSrvResponse *b = (PurpleSrvResponse*)br; | |
15373
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 if(a->pref == b->pref) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 if(a->weight == b->weight) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 if(a->weight < b->weight) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 return 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 if(a->pref < b->pref) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 return 1; |
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 |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
129 /** |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
130 * Iterate over a list of PurpleSrvResponseContainer making the sum |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
131 * the running total of the sums. Select a random integer in the range |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
132 * (1, sum+1), then find the first element greater than or equal to the |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
133 * number selected. From RFC 2782. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
134 * |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
135 * @param list The list of PurpleSrvResponseContainer. This function |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
136 * removes a node from this list and returns the new list. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
137 * @param container_ptr The PurpleSrvResponseContainer that was chosen |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
138 * will be returned here. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
139 */ |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
140 static GList * |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
141 select_random_response(GList *list, PurpleSrvResponseContainer **container_ptr) |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
142 { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
143 GList *cur; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
144 size_t runningtotal; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
145 int r; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
146 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
147 runningtotal = 0; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
148 cur = list; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
149 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
150 while (cur) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
151 PurpleSrvResponseContainer *container = cur->data; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
152 runningtotal += container->response->weight; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
153 container->sum = runningtotal; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
154 cur = cur->next; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
155 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
156 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
157 /* |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
158 * If the running total is greater than 0, pick a number between |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
159 * 1 and the runningtotal inclusive. (This is not precisely what |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
160 * the RFC algorithm describes, but we wish to deal with integers |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
161 * and avoid floats. This is functionally equivalent.) |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
162 * If running total is 0, then choose r = 0. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
163 */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
164 r = runningtotal ? g_random_int_range(1, runningtotal + 1) : 0; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
165 cur = list; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
166 while (r > ((PurpleSrvResponseContainer *)cur->data)->sum) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
167 cur = cur->next; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
168 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
169 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
170 /* Set the return parameter and remove cur from the list */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
171 *container_ptr = cur->data; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
172 return g_list_delete_link(list, cur); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
173 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
174 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
175 /** |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
176 * Reorder a GList of PurpleSrvResponses that have the same priority |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
177 * (aka "pref"). |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
178 */ |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
179 static void |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
180 srv_reorder(GList *list, int num) |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
181 { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
182 int i; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
183 GList *cur, *container_list = NULL; |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
184 PurpleSrvResponseContainer *container; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
185 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
186 if (num < 2) |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
187 /* Nothing to sort */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
188 return; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
189 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
190 /* First build a list of container structs */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
191 for (i = 0, cur = list; i < num; i++, cur = cur->next) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
192 container = g_new(PurpleSrvResponseContainer, 1); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
193 container->response = cur->data; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
194 container_list = g_list_prepend(container_list, container); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
195 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
196 container_list = g_list_reverse(container_list); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
197 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
198 /* |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
199 * Re-order the list that was passed in as a parameter. We leave |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
200 * the list nodes in place, but replace their data pointers. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
201 */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
202 cur = list; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
203 while (container_list) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
204 container_list = select_random_response(container_list, &container); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
205 cur->data = container->response; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
206 g_free(container); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
207 cur = cur->next; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
208 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
209 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
210 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
211 /** |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
212 * Sorts a GList of PurpleSrvResponses according to the |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
213 * algorithm described in RFC 2782. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
214 * |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
215 * @param response GList of PurpleSrvResponse's |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
216 * @param The original list, resorted |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
217 */ |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
218 static GList * |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
219 purple_srv_sort(GList *list) |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
220 { |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
221 int pref, count; |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
222 GList *cur, *start; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
223 |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
224 if (!list || !list->next) { |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
225 /* Nothing to sort */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
226 return list; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
227 } |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
228 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
229 list = g_list_sort(list, responsecompare); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
230 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
231 start = cur = list; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
232 count = 1; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
233 while (cur) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
234 PurpleSrvResponse *next_response; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
235 pref = ((PurpleSrvResponse *)cur->data)->pref; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
236 next_response = cur->next ? cur->next->data : NULL; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
237 if (!next_response || next_response->pref != pref) { |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
238 /* |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
239 * The 'count' records starting at 'start' all have the same |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
240 * priority. Sort them by weight. |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
241 */ |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
242 srv_reorder(start, count); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
243 start = cur->next; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
244 count = 0; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
245 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
246 count++; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
247 cur = cur->next; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
248 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
249 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
250 return list; |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
251 } |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
252 |
31749
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
253 static PurpleSrvTxtQueryData * |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
254 query_data_new(int type, gchar *query, gpointer extradata) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
255 { |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
256 PurpleSrvTxtQueryData *query_data = g_new0(PurpleSrvTxtQueryData, 1); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
257 query_data->type = type; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
258 query_data->extradata = extradata; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
259 query_data->query = query; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
260 #ifndef _WIN32 |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
261 query_data->fd_in = -1; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
262 query_data->fd_out = -1; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
263 #endif |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
264 return query_data; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
265 } |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
266 |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
267 void |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
268 purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
269 { |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
270 PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops(); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
271 |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
272 if (ops && ops->destroy) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
273 ops->destroy(query_data); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
274 |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
275 if (query_data->handle > 0) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
276 purple_input_remove(query_data->handle); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
277 #ifdef _WIN32 |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
278 if (query_data->resolver != NULL) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
279 { |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
280 /* |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
281 * It's not really possible to kill a thread. So instead we |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
282 * just set the callback to NULL and let the DNS lookup |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
283 * finish. |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
284 */ |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
285 query_data->cb.srv = NULL; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
286 return; |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
287 } |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
288 g_free(query_data->error_message); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
289 #else |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
290 if (query_data->fd_out != -1) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
291 close(query_data->fd_out); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
292 if (query_data->fd_in != -1) |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
293 close(query_data->fd_in); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
294 #endif |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
295 g_free(query_data->query); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
296 g_free(query_data); |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
297 } |
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
298 |
28474
1c6c53143afe
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents:
28375
diff
changeset
|
299 #ifdef USE_IDN |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
300 static gboolean |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
301 dns_str_is_ascii(const char *name) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
302 { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
303 guchar *c; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
304 for (c = (guchar *)name; c && *c; ++c) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
305 if (*c > 0x7f) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
306 return FALSE; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
307 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
308 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
309 return TRUE; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
310 } |
28474
1c6c53143afe
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents:
28375
diff
changeset
|
311 #endif |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
312 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 #ifndef _WIN32 |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
314 static void |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
315 write_to_parent(int in, int out, gconstpointer data, gsize size) |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
316 { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
317 const guchar *buf = data; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
318 gssize w; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
319 |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
320 do { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
321 w = write(out, buf, size); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
322 if (w > 0) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
323 buf += w; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
324 size -= w; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
325 } else if (w < 0 && errno == EINTR) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
326 /* Let's try some more; */ |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
327 w = 1; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
328 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
329 } while (size > 0 && w > 0); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
330 |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
331 if (size != 0) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
332 /* An error occurred */ |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
333 close(out); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
334 close(in); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
335 _exit(0); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
336 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
337 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
338 |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
339 /* Read size bytes to data. Dies if an error occurs. */ |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
340 static void |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
341 read_from_parent(int in, int out, gpointer data, gsize size) |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
342 { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
343 guchar *buf = data; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
344 gssize r; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
345 |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
346 do { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
347 r = read(in, data, size); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
348 if (r > 0) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
349 buf += r; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
350 size -= r; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
351 } else if (r < 0 && errno == EINTR) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
352 /* Let's try some more; */ |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
353 r = 1; |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
354 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
355 } while (size > 0 && r > 0); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
356 |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
357 if (size != 0) { |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
358 /* An error occurred */ |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
359 close(out); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
360 close(in); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
361 _exit(0); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
362 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
363 } |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
364 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 |
16634
c028fc690b5d
Mark two functions as "noreturn"
Mark Doliner <mark@kingant.net>
parents:
15828
diff
changeset
|
366 G_GNUC_NORETURN static void |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 resolve(int in, int out) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 GList *ret = NULL; |
15822 | 370 PurpleSrvResponse *srvres; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
371 PurpleTxtResponse *txtres; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 queryans answer; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
373 int size, qdcount, ancount; |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
374 guchar *end, *cp; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 gchar name[256]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 guint16 type, dlen, pref, weight, port; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
377 PurpleSrvInternalQuery query; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15373
diff
changeset
|
379 #ifdef HAVE_SIGNAL_H |
15822 | 380 purple_restore_default_signal_handlers(); |
15645
61b42cf81aa4
Restore default signal handlers in fork()'d children. This adds a gaim_restore_default_signal_handlers() utility function since children are made in multiple places.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15373
diff
changeset
|
381 #endif |
15799 | 382 |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
383 read_from_parent(in, out, &query, sizeof(query)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
385 size = res_query( query.query, C_IN, query.type, (u_char*)&answer, sizeof( answer)); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
386 if (size == -1) { |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
387 write_to_parent(in, out, &(query.type), sizeof(query.type)); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
388 write_to_parent(in, out, &size, sizeof(size)); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
389 close(out); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
390 close(in); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
391 _exit(0); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
392 } |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
393 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 qdcount = ntohs(answer.hdr.qdcount); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 ancount = ntohs(answer.hdr.ancount); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 cp = (guchar*)&answer + sizeof(HEADER); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 end = (guchar*)&answer + size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 /* skip over unwanted stuff */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 while (qdcount-- > 0 && cp < end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 size = dn_expand( (unsigned char*)&answer, end, cp, name, 256); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 if(size < 0) goto end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 cp += size + QFIXEDSZ; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 while (ancount-- > 0 && cp < end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 size = dn_expand((unsigned char*)&answer, end, cp, name, 256); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 if(size < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 goto end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 cp += size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 GETSHORT(type,cp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 /* skip ttl and class since we already know it */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 cp += 6; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 GETSHORT(dlen,cp); |
28932
55cda40d5cf4
We should be using the type listed in the response, not in the
Mark Doliner <mark@kingant.net>
parents:
28478
diff
changeset
|
417 if (type == T_SRV) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 GETSHORT(pref,cp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 GETSHORT(weight,cp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 GETSHORT(port,cp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 size = dn_expand( (unsigned char*)&answer, end, cp, name, 256); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 if(size < 0 ) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 goto end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 cp += size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 |
15822 | 430 srvres = g_new0(PurpleSrvResponse, 1); |
31787
32ced32caca7
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31750
diff
changeset
|
431 if (strlen(name) > sizeof(srvres->hostname) - 1) { |
32ced32caca7
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31750
diff
changeset
|
432 purple_debug_error("dnssrv", "hostname is longer than available buffer ('%s', %zd bytes)!", |
32ced32caca7
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31750
diff
changeset
|
433 name, strlen(name)); |
32ced32caca7
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31750
diff
changeset
|
434 } |
32ced32caca7
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31750
diff
changeset
|
435 g_strlcpy(srvres->hostname, name, sizeof(srvres->hostname)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 srvres->pref = pref; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 srvres->port = port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 srvres->weight = weight; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
440 ret = g_list_prepend(ret, srvres); |
28932
55cda40d5cf4
We should be using the type listed in the response, not in the
Mark Doliner <mark@kingant.net>
parents:
28478
diff
changeset
|
441 } else if (type == T_TXT) { |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
442 txtres = g_new0(PurpleTxtResponse, 1); |
26589
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
443 txtres->content = g_strndup((gchar*)(++cp), dlen-1); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
444 ret = g_list_append(ret, txtres); |
25037
94c8bef52c66
* some further bugfixing, BIND's libresolv does so much for the programmer, just happy it exists
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25036
diff
changeset
|
445 cp += dlen - 1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 cp += dlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 end: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 size = g_list_length(ret); |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
453 |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
454 if (query.type == T_SRV) |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
455 ret = purple_srv_sort(ret); |
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
456 |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
457 write_to_parent(in, out, &(query.type), sizeof(query.type)); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
458 write_to_parent(in, out, &size, sizeof(size)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 while (ret != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 { |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
461 if (query.type == T_SRV) |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
462 write_to_parent(in, out, ret->data, sizeof(PurpleSrvResponse)); |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
463 if (query.type == T_TXT) { |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
464 PurpleTxtResponse *response = ret->data; |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
465 gsize l = strlen(response->content) + 1 /* null byte */; |
28478
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
466 write_to_parent(in, out, &l, sizeof(l)); |
22a577a9f009
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents:
28474
diff
changeset
|
467 write_to_parent(in, out, response->content, l); |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
468 } |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
469 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 g_free(ret->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 ret = g_list_remove(ret, ret->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 |
20232
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
474 close(out); |
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
475 close(in); |
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
476 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 _exit(0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 static void |
15822 | 481 resolved(gpointer data, gint source, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 int size; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
484 int type; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
485 PurpleSrvTxtQueryData *query_data = (PurpleSrvTxtQueryData*)data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 int i; |
15712
4530f15fe5af
Patch from Graham Booker which ensures that a process forked by dnsserv cleans up afterwards, calling waitpid() to make sure no zombies are left over.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15656
diff
changeset
|
487 int status; |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
488 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
489 if (read(source, &type, sizeof(type)) == sizeof(type)) { |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
490 if (read(source, &size, sizeof(size)) == sizeof(size)) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
491 if (size == -1 || size == 0) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
492 if (size == -1) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
493 purple_debug_warning("dnssrv", "res_query returned an error\n"); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
494 /* Re-read resolv.conf and friends in case DNS servers have changed */ |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
495 res_init(); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
496 } else |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
497 purple_debug_info("dnssrv", "Found 0 entries, errno is %i\n", errno); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
498 |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
499 if (type == T_SRV) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
500 PurpleSrvCallback cb = query_data->cb.srv; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
501 cb(NULL, 0, query_data->extradata); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
502 } else if (type == T_TXT) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
503 PurpleTxtCallback cb = query_data->cb.txt; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
504 cb(NULL, query_data->extradata); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
505 } else { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
506 purple_debug_error("dnssrv", "type unknown of DNS result entry; errno is %i\n", errno); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
507 } |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
508 |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
509 } else if (size) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
510 if (type == T_SRV) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
511 PurpleSrvResponse *res; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
512 PurpleSrvResponse *tmp; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
513 PurpleSrvCallback cb = query_data->cb.srv; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
514 ssize_t red; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
515 purple_debug_info("dnssrv","found %d SRV entries\n", size); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
516 tmp = res = g_new0(PurpleSrvResponse, size); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
517 for (i = 0; i < size; i++) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
518 red = read(source, tmp++, sizeof(PurpleSrvResponse)); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
519 if (red != sizeof(PurpleSrvResponse)) { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
520 purple_debug_error("dnssrv","unable to read srv " |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
521 "response: %s\n", g_strerror(errno)); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
522 size = 0; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
523 g_free(res); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
524 res = NULL; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
525 } |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
526 } |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
527 |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
528 cb(res, size, query_data->extradata); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
529 } else if (type == T_TXT) { |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
530 GList *responses = NULL; |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
531 PurpleTxtResponse *res; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
532 PurpleTxtCallback cb = query_data->cb.txt; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
533 ssize_t red; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
534 purple_debug_info("dnssrv","found %d TXT entries\n", size); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
535 for (i = 0; i < size; i++) { |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
536 gsize len; |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
537 |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
538 red = read(source, &len, sizeof(len)); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
539 if (red != sizeof(len)) { |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
540 purple_debug_error("dnssrv","unable to read txt " |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
541 "response length: %s\n", g_strerror(errno)); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
542 size = 0; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
543 g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL); |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
544 g_list_free(responses); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
545 responses = NULL; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
546 break; |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
547 } |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
548 |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
549 res = g_new0(PurpleTxtResponse, 1); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
550 res->content = g_new0(gchar, len); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
551 |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
552 red = read(source, res->content, len); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
553 if (red != len) { |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
554 purple_debug_error("dnssrv","unable to read txt " |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
555 "response: %s\n", g_strerror(errno)); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
556 size = 0; |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
557 purple_txt_response_destroy(res); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
558 g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
559 g_list_free(responses); |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
560 responses = NULL; |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
561 break; |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
562 } |
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
563 responses = g_list_prepend(responses, res); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
564 } |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
565 |
28374
d54834e7ad0f
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents:
28316
diff
changeset
|
566 responses = g_list_reverse(responses); |
26934
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
567 cb(responses, query_data->extradata); |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
568 } else { |
c162a088489f
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents:
26747
diff
changeset
|
569 purple_debug_error("dnssrv", "type unknown of DNS result entry; errno is %i\n", errno); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
570 } |
22107
bfe1854bbf87
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents:
20636
diff
changeset
|
571 } |
16903
11a0f2b4ac83
If the read() in resolved() fails, we should detect the failure and set size (which it would otherwise set, since it is passed by reference) to 0 and res to NULL. This ''may'' fix a rather odd crash described in Adium Trac #6623 (http://trac.adiumx.com/ticket/6623), and it is certainly good sanity checking.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16634
diff
changeset
|
572 } |
11a0f2b4ac83
If the read() in resolved() fails, we should detect the failure and set size (which it would otherwise set, since it is passed by reference) to 0 and res to NULL. This ''may'' fix a rather odd crash described in Adium Trac #6623 (http://trac.adiumx.com/ticket/6623), and it is certainly good sanity checking.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16634
diff
changeset
|
573 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 |
15712
4530f15fe5af
Patch from Graham Booker which ensures that a process forked by dnsserv cleans up afterwards, calling waitpid() to make sure no zombies are left over.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15656
diff
changeset
|
575 waitpid(query_data->pid, &status, 0); |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
576 purple_srv_txt_query_destroy(query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 #else /* _WIN32 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 /** The Jabber Server code was inspiration for parts of this. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 res_main_thread_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 { |
15822 | 586 PurpleSrvResponse *srvres = NULL; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
587 PurpleSrvTxtQueryData *query_data = data; |
28011
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
588 if(query_data->error_message != NULL) { |
30550
47ea27481972
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
28932
diff
changeset
|
589 purple_debug_error("dnssrv", "%s", query_data->error_message); |
28011
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
590 if (query_data->type == DNS_TYPE_SRV) { |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
591 if (query_data->cb.srv) |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
592 query_data->cb.srv(srvres, 0, query_data->extradata); |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
593 } else if (query_data->type == DNS_TYPE_TXT) { |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
594 if (query_data->cb.txt) |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
595 query_data->cb.txt(NULL, query_data->extradata); |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
596 } |
bbb9e0ea67fe
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents:
27635
diff
changeset
|
597 } else { |
26745
e5c874075b42
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents:
26590
diff
changeset
|
598 if (query_data->type == DNS_TYPE_SRV) { |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
599 PurpleSrvResponse *srvres_tmp = NULL; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
600 GList *lst = query_data->results; |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
601 int size = g_list_length(lst); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 |
25170 | 603 if(query_data->cb.srv && size > 0) |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
604 srvres_tmp = srvres = g_new0(PurpleSrvResponse, size); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
605 while (lst) { |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
606 PurpleSrvResponse *lstdata = lst->data; |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
607 lst = g_list_delete_link(lst, lst); |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
608 |
25170 | 609 if(query_data->cb.srv) |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
610 memcpy(srvres_tmp++, lstdata, sizeof(PurpleSrvResponse)); |
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
611 g_free(lstdata); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
612 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
613 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
614 query_data->results = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
616 purple_debug_info("dnssrv", "found %d SRV entries\n", size); |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
617 |
25170 | 618 if(query_data->cb.srv) query_data->cb.srv(srvres, size, query_data->extradata); |
26745
e5c874075b42
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents:
26590
diff
changeset
|
619 } else if (query_data->type == DNS_TYPE_TXT) { |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
620 GList *lst = query_data->results; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
621 |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
622 purple_debug_info("dnssrv", "found %d TXT entries\n", g_list_length(lst)); |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
623 |
26590
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
624 if (query_data->cb.txt) { |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
625 query_data->results = NULL; |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
626 query_data->cb.txt(lst, query_data->extradata); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
627 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
628 } else { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
629 purple_debug_error("dnssrv", "unknown query type"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 query_data->resolver = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 query_data->handle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
636 purple_srv_txt_query_destroy(query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 static gpointer |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 res_thread(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 PDNS_RECORD dr = NULL; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
645 int type; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 DNS_STATUS ds; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
647 PurpleSrvTxtQueryData *query_data = data; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
648 type = query_data->type; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 ds = MyDnsQuery_UTF8(query_data->query, type, DNS_QUERY_STANDARD, NULL, &dr, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 if (ds != ERROR_SUCCESS) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 gchar *msg = g_win32_error_message(ds); |
25170 | 652 if (type == DNS_TYPE_SRV) { |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
653 query_data->error_message = g_strdup_printf("Couldn't look up SRV record. %s (%lu).\n", msg, ds); |
25170 | 654 } else if (type == DNS_TYPE_TXT) { |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
655 query_data->error_message = g_strdup_printf("Couldn't look up TXT record. %s (%lu).\n", msg, ds); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
656 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 } else { |
25170 | 659 if (type == DNS_TYPE_SRV) { |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
660 PDNS_RECORD dr_tmp; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
661 GList *lst = NULL; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
662 DNS_SRV_DATA *srv_data; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
663 PurpleSrvResponse *srvres; |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
664 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
665 for (dr_tmp = dr; dr_tmp != NULL; dr_tmp = dr_tmp->pNext) { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
666 /* Discard any incorrect entries. I'm not sure if this is necessary */ |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
667 if (dr_tmp->wType != type || strcmp(dr_tmp->pName, query_data->query) != 0) { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
668 continue; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
669 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
671 srv_data = &dr_tmp->Data.SRV; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
672 srvres = g_new0(PurpleSrvResponse, 1); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
673 strncpy(srvres->hostname, srv_data->pNameTarget, 255); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
674 srvres->hostname[255] = '\0'; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
675 srvres->pref = srv_data->wPriority; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
676 srvres->port = srv_data->wPort; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
677 srvres->weight = srv_data->wWeight; |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
678 |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
679 lst = g_list_prepend(lst, srvres); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
682 MyDnsRecordListFree(dr, DnsFreeRecordList); |
27213
3e516701dd33
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents:
27212
diff
changeset
|
683 query_data->results = purple_srv_sort(lst); |
26747
7b0231e5c818
Missed one (copying changes manually between computers is clearly an error-ful
Paul Aurich <paul@darkrain42.org>
parents:
26745
diff
changeset
|
684 } else if (type == DNS_TYPE_TXT) { |
26589
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
685 PDNS_RECORD dr_tmp; |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
686 GList *lst = NULL; |
26589
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
687 DNS_TXT_DATA *txt_data; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
688 PurpleTxtResponse *txtres; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
689 |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
690 for (dr_tmp = dr; dr_tmp != NULL; dr_tmp = dr_tmp->pNext) { |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
691 GString *s; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
692 int i; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
693 |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
694 /* Discard any incorrect entries. I'm not sure if this is necessary */ |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
695 if (dr_tmp->wType != type || strcmp(dr_tmp->pName, query_data->query) != 0) { |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
696 continue; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
697 } |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
698 |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
699 txt_data = &dr_tmp->Data.TXT; |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
700 txtres = g_new0(PurpleTxtResponse, 1); |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
701 |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
702 s = g_string_new(""); |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
703 for (i = 0; i < txt_data->dwStringCount; ++i) |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
704 s = g_string_append(s, txt_data->pStringArray[i]); |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
705 txtres->content = g_string_free(s, FALSE); |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
706 |
27348
e400cd35542b
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents:
27213
diff
changeset
|
707 lst = g_list_append(lst, txtres); |
26589
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
708 } |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
709 |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
710 MyDnsRecordListFree(dr, DnsFreeRecordList); |
400f74b95c0e
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents:
26270
diff
changeset
|
711 query_data->results = lst; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
712 } else { |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
713 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 /* back to main thread */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 /* Note: this should *not* be attached to query_data->handle - it will cause leakage */ |
22224
d1b36a8c920a
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <mark@kingant.net>
parents:
22124
diff
changeset
|
719 purple_timeout_add(0, res_main_thread_cb, query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 g_thread_exit(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
727 PurpleSrvTxtQueryData * |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
728 purple_srv_resolve(const char *protocol, const char *transport, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
729 const char *domain, PurpleSrvCallback cb, gpointer extradata) |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
730 { |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
731 return purple_srv_resolve_account(NULL, protocol, transport, domain, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
732 cb, extradata); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
733 } |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
734 |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
735 PurpleSrvTxtQueryData * |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
736 purple_srv_resolve_account(PurpleAccount *account, const char *protocol, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
737 const char *transport, const char *domain, PurpleSrvCallback cb, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
738 gpointer extradata) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 char *query; |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
741 char *hostname; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
742 PurpleSrvTxtQueryData *query_data; |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
743 PurpleProxyType proxy_type; |
26745
e5c874075b42
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents:
26590
diff
changeset
|
744 #ifndef _WIN32 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
745 PurpleSrvInternalQuery internal_query; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 int in[2], out[2]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 int pid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 GError* err = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 static gboolean initialized = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 |
24747
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
753 if (!protocol || !*protocol || !transport || !*transport || !domain || !*domain) { |
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
754 purple_debug_error("dnssrv", "Wrong arguments\n"); |
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
755 cb(NULL, 0, extradata); |
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
756 g_return_val_if_reached(NULL); |
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
757 } |
d1da5c4c1e6b
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24451
diff
changeset
|
758 |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
759 proxy_type = purple_proxy_info_get_type( |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
760 purple_proxy_get_setup(account)); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
761 if (proxy_type == PURPLE_PROXY_TOR) { |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
762 purple_debug_info("dnssrv", "Aborting SRV lookup in Tor Proxy mode."); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
763 cb(NULL, 0, extradata); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
764 return NULL; |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
765 } |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
766 |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
767 #ifdef USE_IDN |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
768 if (!dns_str_is_ascii(domain)) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
769 int ret = purple_network_convert_idn_to_ascii(domain, &hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
770 if (ret != 0) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
771 purple_debug_error("dnssrv", "IDNA ToASCII failed\n"); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
772 cb(NULL, 0, extradata); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
773 return NULL; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
774 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
775 } else /* Fallthru is intentional */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
776 #endif |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
777 hostname = g_strdup(domain); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
778 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
779 query = g_strdup_printf("_%s._%s.%s", protocol, transport, hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
780 purple_debug_info("dnssrv","querying SRV record for %s: %s\n", domain, |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
781 query); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
782 g_free(hostname); |
31743 | 783 |
31750
cb4705abb991
dnssrv: Hmph, this is what I get for swapping the argument order around and not paying attention
Paul Aurich <paul@darkrain42.org>
parents:
31749
diff
changeset
|
784 query_data = query_data_new(PurpleDnsTypeSrv, query, extradata); |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
785 query_data->cb.srv = cb; |
31743 | 786 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
787 if (purple_srv_txt_query_ui_resolve(query_data)) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
788 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
789 return query_data; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
790 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 if(pipe(in) || pipe(out)) { |
15822 | 794 purple_debug_error("dnssrv", "Could not create pipe\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 g_free(query); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
796 g_free(query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 cb(NULL, 0, extradata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 |
31856
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
801 /* |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
802 * TODO: We should put a cap on the number of forked processes that we |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
803 * allow at any given time. If we get too many requests they |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
804 * should be put into a queue and handled later. (This is what |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
805 * we do for A record lookups.) |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
806 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 pid = fork(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 if (pid == -1) { |
15822 | 809 purple_debug_error("dnssrv", "Could not create process!\n"); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
810 g_free(query); |
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
811 g_free(query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 cb(NULL, 0, extradata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 /* Child */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 if (pid == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 { |
22124
df77b89a4025
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <mark@kingant.net>
parents:
22107
diff
changeset
|
819 g_free(query); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
820 g_free(query_data); |
22124
df77b89a4025
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <mark@kingant.net>
parents:
22107
diff
changeset
|
821 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 close(out[0]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 close(in[1]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 resolve(in[0], out[1]); |
22124
df77b89a4025
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <mark@kingant.net>
parents:
22107
diff
changeset
|
825 /* resolve() does not return */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 close(out[1]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 close(in[0]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
831 internal_query.type = T_SRV; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
832 strncpy(internal_query.query, query, 255); |
28316
3397fb5f89cf
Null-terminate this string explicitly to avoid valgrind complaining.
Paul Aurich <paul@darkrain42.org>
parents:
28011
diff
changeset
|
833 internal_query.query[255] = '\0'; |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
834 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
835 if (write(in[1], &internal_query, sizeof(internal_query)) < 0) |
15822 | 836 purple_debug_error("dnssrv", "Could not write to SRV resolver\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 |
15712
4530f15fe5af
Patch from Graham Booker which ensures that a process forked by dnsserv cleans up afterwards, calling waitpid() to make sure no zombies are left over.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15656
diff
changeset
|
838 query_data->pid = pid; |
20232
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
839 query_data->fd_out = out[0]; |
b7c0c79585f9
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
840 query_data->fd_in = in[1]; |
15822 | 841 query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 return query_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 if (!initialized) { |
15822 | 846 MyDnsQuery_UTF8 = (void*) wpurple_find_and_loadproc("dnsapi.dll", "DnsQuery_UTF8"); |
847 MyDnsRecordListFree = (void*) wpurple_find_and_loadproc( | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 "dnsapi.dll", "DnsRecordListFree"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 initialized = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 |
15799 | 852 if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree) |
853 query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n"); | |
854 else { | |
855 query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err); | |
856 if (query_data->resolver == NULL) { | |
857 query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", (err && err->message) ? err->message : ""); | |
858 g_error_free(err); | |
859 } | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 |
15799 | 862 /* The query isn't going to happen, so finish the SRV lookup now. |
863 * Asynchronously call the callback since stuff may not expect | |
864 * the callback to be called before this returns */ | |
865 if (query_data->error_message != NULL) | |
22224
d1b36a8c920a
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <mark@kingant.net>
parents:
22124
diff
changeset
|
866 query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
868 return query_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
870 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
871 |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
872 PurpleSrvTxtQueryData *purple_txt_resolve(const char *owner, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
873 const char *domain, PurpleTxtCallback cb, gpointer extradata) |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
874 { |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
875 return purple_txt_resolve_account(NULL, owner, domain, cb, extradata); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
876 } |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
877 |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
878 PurpleSrvTxtQueryData *purple_txt_resolve_account(PurpleAccount *account, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
879 const char *owner, const char *domain, PurpleTxtCallback cb, |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
880 gpointer extradata) |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
881 { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
882 char *query; |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
883 char *hostname; |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
884 PurpleSrvTxtQueryData *query_data; |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
885 PurpleProxyType proxy_type; |
26745
e5c874075b42
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents:
26590
diff
changeset
|
886 #ifndef _WIN32 |
25036
3c3480683075
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25035
diff
changeset
|
887 PurpleSrvInternalQuery internal_query; |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
888 int in[2], out[2]; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
889 int pid; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
890 #else |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
891 GError* err = NULL; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
892 static gboolean initialized = FALSE; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
893 #endif |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
894 |
31479
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
895 proxy_type = purple_proxy_info_get_type( |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
896 purple_proxy_get_setup(account)); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
897 if (proxy_type == PURPLE_PROXY_TOR) { |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
898 purple_debug_info("dnssrv", "Aborting TXT lookup in Tor Proxy mode."); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
899 cb(NULL, extradata); |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
900 return NULL; |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
901 } |
0eceb1304f53
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31477
diff
changeset
|
902 |
27635
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
903 #ifdef USE_IDN |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
904 if (!dns_str_is_ascii(domain)) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
905 int ret = purple_network_convert_idn_to_ascii(domain, &hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
906 if (ret != 0) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
907 purple_debug_error("dnssrv", "IDNA ToASCII failed\n"); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
908 cb(NULL, extradata); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
909 return NULL; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
910 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
911 } else /* fallthru is intentional */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
912 #endif |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
913 hostname = g_strdup(domain); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
914 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
915 query = g_strdup_printf("%s.%s", owner, hostname); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
916 purple_debug_info("dnssrv","querying TXT record for %s: %s\n", domain, |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
917 query); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27348
diff
changeset
|
918 g_free(hostname); |
31743 | 919 |
31749
9526ffc3a9f5
dnssrv: Refactor to reduce code duplication
Paul Aurich <paul@darkrain42.org>
parents:
31748
diff
changeset
|
920 query_data = query_data_new(PurpleDnsTypeTxt, query, extradata); |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
921 query_data->cb.txt = cb; |
31743 | 922 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
923 if (purple_srv_txt_query_ui_resolve(query_data)) { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
924 /* query intentionally not freed |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
925 */ |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
926 return query_data; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
927 } |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
928 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
929 #ifndef _WIN32 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
930 if(pipe(in) || pipe(out)) { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
931 purple_debug_error("dnssrv", "Could not create pipe\n"); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
932 g_free(query); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
933 g_free(query_data); |
26590
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
934 cb(NULL, extradata); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
935 return NULL; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
936 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
937 |
31856
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
938 /* |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
939 * TODO: We should put a cap on the number of forked processes that we |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
940 * allow at any given time. If we get too many requests they |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
941 * should be put into a queue and handled later. (This is what |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
942 * we do for A record lookups.) |
9ed25c58e7ce
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <mark@kingant.net>
parents:
31787
diff
changeset
|
943 */ |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
944 pid = fork(); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
945 if (pid == -1) { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
946 purple_debug_error("dnssrv", "Could not create process!\n"); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
947 g_free(query); |
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
948 g_free(query_data); |
26590
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
949 cb(NULL, extradata); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
950 return NULL; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
951 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
952 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
953 /* Child */ |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
954 if (pid == 0) |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
955 { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
956 g_free(query); |
31745
451242c455ca
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <paul@darkrain42.org>
parents:
31744
diff
changeset
|
957 g_free(query_data); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
958 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
959 close(out[0]); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
960 close(in[1]); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
961 resolve(in[0], out[1]); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
962 /* resolve() does not return */ |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
963 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
964 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
965 close(out[1]); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
966 close(in[0]); |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
967 |
25036
3c3480683075
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25035
diff
changeset
|
968 internal_query.type = T_TXT; |
3c3480683075
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25035
diff
changeset
|
969 strncpy(internal_query.query, query, 255); |
28375
e191f5fedce1
Shut up valgrind ("unitialized bytes(s)...") and changelog.
Paul Aurich <paul@darkrain42.org>
parents:
28374
diff
changeset
|
970 internal_query.query[255] = '\0'; |
27212
862b8208a546
Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents:
26934
diff
changeset
|
971 |
25036
3c3480683075
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
25035
diff
changeset
|
972 if (write(in[1], &internal_query, sizeof(internal_query)) < 0) |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
973 purple_debug_error("dnssrv", "Could not write to TXT resolver\n"); |
31743 | 974 |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
975 query_data->pid = pid; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
976 query_data->fd_out = out[0]; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
977 query_data->fd_in = in[1]; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
978 query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
979 |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
980 return query_data; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
981 #else |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
982 if (!initialized) { |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
983 MyDnsQuery_UTF8 = (void*) wpurple_find_and_loadproc("dnsapi.dll", "DnsQuery_UTF8"); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
984 MyDnsRecordListFree = (void*) wpurple_find_and_loadproc( |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
985 "dnsapi.dll", "DnsRecordListFree"); |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
986 initialized = TRUE; |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
987 } |
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
988 |
15799 | 989 if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree) |
990 query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n"); | |
991 else { | |
992 query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err); | |
993 if (query_data->resolver == NULL) { | |
25171 | 994 query_data->error_message = g_strdup_printf("TXT thread create failure: %s\n", (err && err->message) ? err->message : ""); |
15799 | 995 g_error_free(err); |
996 } | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 |
26590
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
999 /* The query isn't going to happen, so finish the TXT lookup now. |
15799 | 1000 * Asynchronously call the callback since stuff may not expect |
1001 * the callback to be called before this returns */ | |
1002 if (query_data->error_message != NULL) | |
22224
d1b36a8c920a
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <mark@kingant.net>
parents:
22124
diff
changeset
|
1003 query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 return query_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 void |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1010 purple_txt_cancel(PurpleSrvTxtQueryData *query_data) |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
1011 { |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1012 purple_srv_txt_query_destroy(query_data); |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1013 } |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1014 |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1015 void |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1016 purple_srv_cancel(PurpleSrvTxtQueryData *query_data) |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1017 { |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1018 purple_srv_txt_query_destroy(query_data); |
25035
affaa4c4836e
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23201
diff
changeset
|
1019 } |
26590
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1020 |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1021 const gchar * |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1022 purple_txt_response_get_content(PurpleTxtResponse *resp) |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1023 { |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1024 g_return_val_if_fail(resp != NULL, NULL); |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1025 |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1026 return resp->content; |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1027 } |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1028 |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1029 void purple_txt_response_destroy(PurpleTxtResponse *resp) |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1030 { |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1031 g_return_if_fail(resp != NULL); |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1032 |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1033 g_free(resp->content); |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1034 g_free(resp); |
acee7d2b1983
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents:
26589
diff
changeset
|
1035 } |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1036 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1037 /* |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1038 * Only used as the callback for the ui ops. |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1039 */ |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1040 static void |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1041 purple_srv_query_resolved(PurpleSrvTxtQueryData *query_data, GList *records) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1042 { |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1043 GList *l; |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1044 PurpleSrvResponse *records_array; |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1045 int i = 0, length; |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1046 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1047 g_return_if_fail(records != NULL); |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1048 |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1049 if (query_data->cb.srv == NULL) { |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1050 purple_srv_txt_query_destroy(query_data); |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1051 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1052 while (records) { |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1053 g_free(records->data); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1054 records = g_list_delete_link(records, records); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1055 } |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1056 return; |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1057 } |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1058 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1059 records = purple_srv_sort(records); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1060 length = g_list_length(records); |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1061 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1062 purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1063 query_data->query, length); |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1064 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1065 records_array = g_new(PurpleSrvResponse, length); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1066 for (l = records; l; l = l->next, i++) { |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1067 records_array[i] = *(PurpleSrvResponse *)l->data; |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1068 } |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1069 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1070 query_data->cb.srv(records_array, length, query_data->extradata); |
31743 | 1071 |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1072 purple_srv_txt_query_destroy(query_data); |
31743 | 1073 |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1074 while (records) { |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1075 g_free(records->data); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1076 records = g_list_delete_link(records, records); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1077 } |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1078 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1079 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1080 /* |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1081 * Only used as the callback for the ui ops. |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1082 */ |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1083 static void |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1084 purple_txt_query_resolved(PurpleSrvTxtQueryData *query_data, GList *entries) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1085 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1086 g_return_if_fail(entries != NULL); |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1087 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1088 purple_debug_info("dnssrv", "TXT entries resolved for %s, count: %d\n", query_data->query, g_list_length(entries)); |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1089 |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1090 /* the callback should g_free the entries. |
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1091 */ |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1092 if (query_data->cb.txt != NULL) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1093 query_data->cb.txt(entries, query_data->extradata); |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1094 else { |
31744
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1095 while (entries) { |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1096 g_free(entries->data); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1097 entries = g_list_delete_link(entries, entries); |
4739488955a7
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <paul@darkrain42.org>
parents:
31743
diff
changeset
|
1098 } |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1099 } |
31743 | 1100 |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1101 purple_srv_txt_query_destroy(query_data); |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1102 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1103 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1104 static void |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1105 purple_srv_query_failed(PurpleSrvTxtQueryData *query_data, const gchar *error_message) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1106 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1107 purple_debug_error("dnssrv", "%s\n", error_message); |
31743 | 1108 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1109 if (query_data->cb.srv != NULL) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1110 query_data->cb.srv(NULL, 0, query_data->extradata); |
31743 | 1111 |
31742
ad79fa168cee
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
thijsalkemade@gmail.com
parents:
31528
diff
changeset
|
1112 purple_srv_txt_query_destroy(query_data); |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1113 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1114 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1115 static gboolean |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1116 purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1117 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1118 PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops(); |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1119 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1120 if (ops && ops->resolve) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1121 return ops->resolve(query_data, (query_data->type == T_SRV ? purple_srv_query_resolved : purple_txt_query_resolved), purple_srv_query_failed); |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1122 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1123 return FALSE; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1124 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1125 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1126 void |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1127 purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1128 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1129 srv_txt_query_ui_ops = ops; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1130 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1131 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1132 PurpleSrvTxtQueryUiOps * |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1133 purple_srv_txt_query_get_ui_ops(void) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1134 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1135 /* It is perfectly acceptable for srv_txt_query_ui_ops to be NULL; this just |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1136 * means that the default platform-specific implementation will be used. |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1137 */ |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1138 return srv_txt_query_ui_ops; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1139 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1140 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1141 char * |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1142 purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1143 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1144 g_return_val_if_fail(query_data != NULL, NULL); |
31743 | 1145 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1146 return query_data->query; |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1147 } |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1148 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1149 |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1150 int |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1151 purple_srv_txt_query_get_type(PurpleSrvTxtQueryData *query_data) |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1152 { |
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1153 g_return_val_if_fail(query_data != NULL, 0); |
31743 | 1154 |
31426
08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents:
30550
diff
changeset
|
1155 return query_data->type; |
31477
f0de3178dd87
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31440
diff
changeset
|
1156 } |