annotate libpurple/dnssrv.c @ 31928:f0de3178dd87

The T_SRV and T_TXT defines are needed on WIN32 too.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 19 Apr 2011 00:21:32 +0000
parents 25d12d5929e0
children 0eceb1304f53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
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: 19680
diff changeset
3 */
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
4
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19680
diff changeset
5 /* purple
15374
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
19680
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
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "internal.h"
15657
ca1c878be941 Include util.h to fix a warning I introduced
Evan Schoenberg <evan.s@dreskin.net>
parents: 15646
diff changeset
25 #include "util.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #ifndef _WIN32
23203
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
28 #include <arpa/nameser.h>
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include <resolv.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include <arpa/nameser_compat.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #endif
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
33 #else /* WIN32 */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include <windns.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 /* Missing from the mingw headers */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #ifndef DNS_TYPE_SRV
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
37 # define DNS_TYPE_SRV PurpleDnsTypeSrv
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #endif
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
39 #ifndef DNS_TYPE_TXT
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
40 # define DNS_TYPE_TXT PurpleDnsTypeTxt
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
41 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
31928
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
44 #ifndef T_SRV
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
45 #define T_SRV PurpleDnsTypeSrv
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
46 #endif
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
47 #ifndef T_TXT
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
48 #define T_TXT PurpleDnsTypeTxt
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
49 #endif
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
50
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
51 #include "debug.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 #include "dnssrv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 #include "eventloop.h"
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
54 #include "network.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
56 static PurpleSrvTxtQueryUiOps *srv_txt_query_ui_ops = NULL;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
57
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 #ifndef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 typedef union {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 HEADER hdr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 u_char buf[1024];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 } queryans;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 #else
18401
3c6bc8785af9 Fix up some linkage to compile on Visual Studio. He claims this doesn't
Nick Hebner <hebnern@gmail.com>
parents: 16914
diff changeset
64 static DNS_STATUS (WINAPI *MyDnsQuery_UTF8) (
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 PCSTR lpstrName, WORD wType, DWORD fOptions,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 PIP4_ARRAY aipServers, PDNS_RECORD* ppQueryResultsSet,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 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: 16914
diff changeset
68 static void (WINAPI *MyDnsRecordListFree) (PDNS_RECORD pRecordList,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 DNS_FREE_TYPE FreeType) = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
72 struct _PurpleSrvTxtQueryData {
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
73 union {
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
74 PurpleSrvCallback srv;
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
75 PurpleTxtCallback txt;
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
76 } cb;
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
77
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 gpointer extradata;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 guint handle;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
80 int type;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
81 char *query;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 GThread *resolver;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 char *error_message;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
85 GList *results;
15713
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: 15657
diff changeset
86 #else
20232
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
87 int fd_in, fd_out;
15713
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: 15657
diff changeset
88 pid_t pid;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
92 typedef struct _PurpleSrvInternalQuery {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
93 int type;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
94 char query[256];
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
95 } PurpleSrvInternalQuery;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
96
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
97 typedef struct _PurpleSrvResponseContainer {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
98 PurpleSrvResponse *response;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
99 int sum;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
100 } PurpleSrvResponseContainer;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
101
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
102 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: 30983
diff changeset
103
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
104 /**
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
105 * 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: 27294
diff changeset
106 * 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: 27294
diff changeset
107 * 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: 27294
diff changeset
108 * 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: 27294
diff changeset
109 */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 static gint
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 responsecompare(gconstpointer ar, gconstpointer br)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
113 PurpleSrvResponse *a = (PurpleSrvResponse*)ar;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
114 PurpleSrvResponse *b = (PurpleSrvResponse*)br;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 if(a->pref == b->pref) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 if(a->weight == b->weight)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 if(a->weight < b->weight)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 return -1;
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 if(a->pref < b->pref)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 return -1;
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
128 /**
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
129 * 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: 27294
diff changeset
130 * 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: 27294
diff changeset
131 * (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: 27294
diff changeset
132 * number selected. From RFC 2782.
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
133 *
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
134 * @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: 27294
diff changeset
135 * 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: 27294
diff changeset
136 * @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: 27294
diff changeset
137 * will be returned here.
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
138 */
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
139 static GList *
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
140 select_random_response(GList *list, PurpleSrvResponseContainer **container_ptr)
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
141 {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
142 GList *cur;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
143 size_t runningtotal;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
144 int r;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
145
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
146 runningtotal = 0;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
147 cur = list;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
148
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
149 while (cur) {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
150 PurpleSrvResponseContainer *container = cur->data;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
151 runningtotal += container->response->weight;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
152 container->sum = runningtotal;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
153 cur = cur->next;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
154 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
155
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
156 /*
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
157 * 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: 27294
diff changeset
158 * 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: 27294
diff changeset
159 * 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: 27294
diff changeset
160 * 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: 27294
diff changeset
161 * 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: 27294
diff changeset
162 */
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
163 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: 27294
diff changeset
164 cur = list;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
165 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: 27294
diff changeset
166 cur = cur->next;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
167 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
168
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
169 /* 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: 27294
diff changeset
170 *container_ptr = cur->data;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
171 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: 27294
diff changeset
172 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
173
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
174 /**
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
175 * 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: 27294
diff changeset
176 * (aka "pref").
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
177 */
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
178 static void
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
179 srv_reorder(GList *list, int num)
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
180 {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
181 int i;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
182 GList *cur, *container_list = NULL;
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
183 PurpleSrvResponseContainer *container;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
184
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
185 if (num < 2)
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
186 /* Nothing to sort */
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
187 return;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
188
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
189 /* 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: 27294
diff changeset
190 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: 27294
diff changeset
191 container = g_new(PurpleSrvResponseContainer, 1);
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
192 container->response = cur->data;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
193 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: 27294
diff changeset
194 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
195 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: 27294
diff changeset
196
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
197 /*
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
198 * 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: 27294
diff changeset
199 * 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: 27294
diff changeset
200 */
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
201 cur = list;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
202 while (container_list) {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
203 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: 27294
diff changeset
204 cur->data = container->response;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
205 g_free(container);
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
206 cur = cur->next;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
207 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
208 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
209
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
210 /**
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
211 * Sorts a GList of PurpleSrvResponses according to the
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
212 * algorithm described in RFC 2782.
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
213 *
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
214 * @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: 27294
diff changeset
215 * @param The original list, resorted
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
216 */
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
217 static GList *
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
218 purple_srv_sort(GList *list)
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
219 {
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
220 int pref, count;
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
221 GList *cur, *start;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
222
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
223 if (!list || !list->next) {
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
224 /* Nothing to sort */
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
225 return list;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
226 }
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
227
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
228 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: 27294
diff changeset
229
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
230 start = cur = list;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
231 count = 1;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
232 while (cur) {
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
233 PurpleSrvResponse *next_response;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
234 pref = ((PurpleSrvResponse *)cur->data)->pref;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
235 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: 27294
diff changeset
236 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: 27294
diff changeset
237 /*
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
238 * 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: 27294
diff changeset
239 * priority. Sort them by weight.
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
240 */
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
241 srv_reorder(start, count);
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
242 start = cur->next;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
243 count = 0;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
244 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
245 count++;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
246 cur = cur->next;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
247 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
248
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
249 return list;
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
250 }
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
251
28847
1c6c53143afe dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
252 #ifdef USE_IDN
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
253 static gboolean
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
254 dns_str_is_ascii(const char *name)
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
255 {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
256 guchar *c;
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
257 for (c = (guchar *)name; c && *c; ++c) {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
258 if (*c > 0x7f)
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
259 return FALSE;
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
260 }
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
261
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
262 return TRUE;
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
263 }
28847
1c6c53143afe dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <paul@darkrain42.org>
parents: 28744
diff changeset
264 #endif
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
265
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 #ifndef _WIN32
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
267 static void
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
268 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: 28847
diff changeset
269 {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
270 const guchar *buf = data;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
271 gssize w;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
272
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
273 do {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
274 w = write(out, buf, size);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
275 if (w > 0) {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
276 buf += w;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
277 size -= w;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
278 } 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: 28847
diff changeset
279 /* Let's try some more; */
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
280 w = 1;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
281 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
282 } while (size > 0 && w > 0);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
283
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
284 if (size != 0) {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
285 /* An error occurred */
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
286 close(out);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
287 close(in);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
288 _exit(0);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
289 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
290 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
291
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
292 /* 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: 28847
diff changeset
293 static void
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
294 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: 28847
diff changeset
295 {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
296 guchar *buf = data;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
297 gssize r;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
298
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
299 do {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
300 r = read(in, data, size);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
301 if (r > 0) {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
302 buf += r;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
303 size -= r;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
304 } 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: 28847
diff changeset
305 /* Let's try some more; */
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
306 r = 1;
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
307 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
308 } while (size > 0 && r > 0);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
309
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
310 if (size != 0) {
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
311 /* An error occurred */
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
312 close(out);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
313 close(in);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
314 _exit(0);
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
315 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
316 }
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
317
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318
16642
c028fc690b5d Mark two functions as "noreturn"
Mark Doliner <mark@kingant.net>
parents: 15829
diff changeset
319 G_GNUC_NORETURN static void
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 resolve(int in, int out)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 GList *ret = NULL;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
323 PurpleSrvResponse *srvres;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
324 PurpleTxtResponse *txtres;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 queryans answer;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
326 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: 27295
diff changeset
327 guchar *end, *cp;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 gchar name[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 guint16 type, dlen, pref, weight, port;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
330 PurpleSrvInternalQuery query;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
15646
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: 15374
diff changeset
332 #ifdef HAVE_SIGNAL_H
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
333 purple_restore_default_signal_handlers();
15646
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: 15374
diff changeset
334 #endif
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
335
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
336 read_from_parent(in, out, &query, sizeof(query));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
338 size = res_query( query.query, C_IN, query.type, (u_char*)&answer, sizeof( answer));
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
339 if (size == -1) {
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
340 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: 28847
diff changeset
341 write_to_parent(in, out, &size, sizeof(size));
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
342 close(out);
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
343 close(in);
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
344 _exit(0);
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
345 }
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
346
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 qdcount = ntohs(answer.hdr.qdcount);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 ancount = ntohs(answer.hdr.ancount);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 cp = (guchar*)&answer + sizeof(HEADER);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 end = (guchar*)&answer + size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 /* skip over unwanted stuff */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 while (qdcount-- > 0 && cp < end) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 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
355 if(size < 0) goto end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 cp += size + QFIXEDSZ;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 while (ancount-- > 0 && cp < end) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 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
361 if(size < 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 goto end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 cp += size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 GETSHORT(type,cp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 /* 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
367 cp += 6;
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 GETSHORT(dlen,cp);
29321
55cda40d5cf4 We should be using the type listed in the response, not in the
Mark Doliner <mark@kingant.net>
parents: 28851
diff changeset
370 if (type == T_SRV) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 GETSHORT(pref,cp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 GETSHORT(weight,cp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 GETSHORT(port,cp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 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
378 if(size < 0 )
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 goto end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 cp += size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
383 srvres = g_new0(PurpleSrvResponse, 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 strcpy(srvres->hostname, name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 srvres->pref = pref;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 srvres->port = port;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 srvres->weight = weight;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
389 ret = g_list_prepend(ret, srvres);
29321
55cda40d5cf4 We should be using the type listed in the response, not in the
Mark Doliner <mark@kingant.net>
parents: 28851
diff changeset
390 } else if (type == T_TXT) {
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
391 txtres = g_new0(PurpleTxtResponse, 1);
26671
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
392 txtres->content = g_strndup((gchar*)(++cp), dlen-1);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
393 ret = g_list_append(ret, txtres);
25595
94c8bef52c66 * some further bugfixing, BIND's libresolv does so much for the programmer, just happy it exists
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25594
diff changeset
394 cp += dlen - 1;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 cp += dlen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 end:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 size = g_list_length(ret);
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
402
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
403 if (query.type == T_SRV)
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
404 ret = purple_srv_sort(ret);
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
405
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
406 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: 28847
diff changeset
407 write_to_parent(in, out, &size, sizeof(size));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 while (ret != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 {
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
410 if (query.type == T_SRV)
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
411 write_to_parent(in, out, ret->data, sizeof(PurpleSrvResponse));
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
412 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: 28683
diff changeset
413 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: 28683
diff changeset
414 gsize l = strlen(response->content) + 1 /* null byte */;
28851
22a577a9f009 dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <paul@darkrain42.org>
parents: 28847
diff changeset
415 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: 28847
diff changeset
416 write_to_parent(in, out, response->content, l);
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
417 }
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
418
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 g_free(ret->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 ret = g_list_remove(ret, ret->data);
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
20232
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
423 close(out);
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
424 close(in);
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
425
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 _exit(0);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
430 resolved(gpointer data, gint source, PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 int size;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
433 int type;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
434 PurpleSrvTxtQueryData *query_data = (PurpleSrvTxtQueryData*)data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 int i;
15713
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: 15657
diff changeset
436 int status;
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
437
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
438 if (read(source, &type, sizeof(type)) == sizeof(type)) {
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
439 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: 26829
diff changeset
440 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: 26829
diff changeset
441 if (size == -1) {
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
442 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: 26829
diff changeset
443 /* 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: 26829
diff changeset
444 res_init();
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
445 } else
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
446 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: 26829
diff changeset
447
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
448 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: 26829
diff changeset
449 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: 26829
diff changeset
450 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: 26829
diff changeset
451 } 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: 26829
diff changeset
452 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: 26829
diff changeset
453 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: 26829
diff changeset
454 } else {
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
455 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: 26829
diff changeset
456 }
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
457
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
458 } else if (size) {
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
459 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: 26829
diff changeset
460 PurpleSrvResponse *res;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
461 PurpleSrvResponse *tmp;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
462 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: 26829
diff changeset
463 ssize_t red;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
464 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: 26829
diff changeset
465 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: 26829
diff changeset
466 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: 26829
diff changeset
467 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: 26829
diff changeset
468 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: 26829
diff changeset
469 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: 26829
diff changeset
470 "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: 26829
diff changeset
471 size = 0;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
472 g_free(res);
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
473 res = NULL;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
474 }
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
475 }
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
476
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
477 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: 26829
diff changeset
478 } else if (type == T_TXT) {
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
479 GList *responses = NULL;
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
480 PurpleTxtResponse *res;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
481 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: 26829
diff changeset
482 ssize_t red;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
483 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: 26829
diff changeset
484 for (i = 0; i < size; i++) {
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
485 gsize len;
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
486
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
487 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: 28683
diff changeset
488 if (red != sizeof(len)) {
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
489 purple_debug_error("dnssrv","unable to read txt "
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
490 "response length: %s\n", g_strerror(errno));
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
491 size = 0;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
492 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: 27295
diff changeset
493 g_list_free(responses);
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
494 responses = NULL;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
495 break;
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
496 }
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
497
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
498 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: 28683
diff changeset
499 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: 28683
diff changeset
500
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
501 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: 28683
diff changeset
502 if (red != len) {
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
503 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: 28683
diff changeset
504 "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: 28683
diff changeset
505 size = 0;
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
506 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: 28683
diff changeset
507 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: 28683
diff changeset
508 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: 28683
diff changeset
509 responses = NULL;
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
510 break;
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
511 }
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
512 responses = g_list_prepend(responses, res);
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
513 }
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
514
28743
d54834e7ad0f Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <paul@darkrain42.org>
parents: 28683
diff changeset
515 responses = g_list_reverse(responses);
27016
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
516 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: 26829
diff changeset
517 } else {
c162a088489f Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <paul@darkrain42.org>
parents: 26829
diff changeset
518 purple_debug_error("dnssrv", "type unknown of DNS result entry; errno is %i\n", errno);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
519 }
22107
bfe1854bbf87 More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <mark@kingant.net>
parents: 20636
diff changeset
520 }
16914
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: 16642
diff changeset
521 }
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: 16642
diff changeset
522 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523
15713
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: 15657
diff changeset
524 waitpid(query_data->pid, &status, 0);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
525 purple_srv_cancel(query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 #else /* _WIN32 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 /** 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
531
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 res_main_thread_cb(gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
535 PurpleSrvResponse *srvres = NULL;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
536 PurpleSrvTxtQueryData *query_data = data;
28361
bbb9e0ea67fe Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
537 if(query_data->error_message != NULL) {
30983
47ea27481972 Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29321
diff changeset
538 purple_debug_error("dnssrv", "%s", query_data->error_message);
28361
bbb9e0ea67fe Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
539 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: 27711
diff changeset
540 if (query_data->cb.srv)
bbb9e0ea67fe Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
541 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: 27711
diff changeset
542 } 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: 27711
diff changeset
543 if (query_data->cb.txt)
bbb9e0ea67fe Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
544 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: 27711
diff changeset
545 }
bbb9e0ea67fe Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <paul@darkrain42.org>
parents: 27711
diff changeset
546 } else {
26827
e5c874075b42 Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents: 26672
diff changeset
547 if (query_data->type == DNS_TYPE_SRV) {
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
548 PurpleSrvResponse *srvres_tmp = NULL;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
549 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: 27295
diff changeset
550 int size = g_list_length(lst);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
552 if(query_data->cb.srv && size > 0)
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
553 srvres_tmp = srvres = g_new0(PurpleSrvResponse, size);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
554 while (lst) {
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
555 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: 27295
diff changeset
556 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: 27295
diff changeset
557
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
558 if(query_data->cb.srv)
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
559 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: 27295
diff changeset
560 g_free(lstdata);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
561 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
562
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
563 query_data->results = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
565 purple_debug_info("dnssrv", "found %d SRV entries\n", size);
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
566
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
567 if(query_data->cb.srv) query_data->cb.srv(srvres, size, query_data->extradata);
26827
e5c874075b42 Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents: 26672
diff changeset
568 } else if (query_data->type == DNS_TYPE_TXT) {
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
569 GList *lst = query_data->results;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
570
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
571 purple_debug_info("dnssrv", "found %d TXT entries\n", g_list_length(lst));
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
572
26672
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
573 if (query_data->cb.txt) {
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
574 query_data->results = NULL;
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
575 query_data->cb.txt(lst, query_data->extradata);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
576 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
577 } else {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
578 purple_debug_error("dnssrv", "unknown query type");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 }
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 query_data->resolver = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 query_data->handle = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
585 purple_srv_cancel(query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 static gpointer
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 res_thread(gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 PDNS_RECORD dr = NULL;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
594 int type;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 DNS_STATUS ds;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
596 PurpleSrvTxtQueryData *query_data = data;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
597 type = query_data->type;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 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
599 if (ds != ERROR_SUCCESS) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 gchar *msg = g_win32_error_message(ds);
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
601 if (type == DNS_TYPE_SRV) {
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
602 query_data->error_message = g_strdup_printf("Couldn't look up SRV record. %s (%lu).\n", msg, ds);
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
603 } else if (type == DNS_TYPE_TXT) {
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
604 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: 23203
diff changeset
605 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 } else {
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
608 if (type == DNS_TYPE_SRV) {
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
609 PDNS_RECORD dr_tmp;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
610 GList *lst = NULL;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
611 DNS_SRV_DATA *srv_data;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
612 PurpleSrvResponse *srvres;
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
613
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
614 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: 23203
diff changeset
615 /* 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: 23203
diff changeset
616 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: 23203
diff changeset
617 continue;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
618 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
620 srv_data = &dr_tmp->Data.SRV;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
621 srvres = g_new0(PurpleSrvResponse, 1);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
622 strncpy(srvres->hostname, srv_data->pNameTarget, 255);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
623 srvres->hostname[255] = '\0';
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
624 srvres->pref = srv_data->wPriority;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
625 srvres->port = srv_data->wPort;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
626 srvres->weight = srv_data->wWeight;
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
627
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
628 lst = g_list_prepend(lst, srvres);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
631 MyDnsRecordListFree(dr, DnsFreeRecordList);
27295
3e516701dd33 Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <mark@kingant.net>
parents: 27294
diff changeset
632 query_data->results = purple_srv_sort(lst);
26829
7b0231e5c818 Missed one (copying changes manually between computers is clearly an error-ful
Paul Aurich <paul@darkrain42.org>
parents: 26827
diff changeset
633 } else if (type == DNS_TYPE_TXT) {
26671
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
634 PDNS_RECORD dr_tmp;
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
635 GList *lst = NULL;
26671
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
636 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: 26352
diff changeset
637 PurpleTxtResponse *txtres;
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
638
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
639 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: 26352
diff changeset
640 GString *s;
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
641 int i;
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
642
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
643 /* 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: 26352
diff changeset
644 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: 26352
diff changeset
645 continue;
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
646 }
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
647
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
648 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: 26352
diff changeset
649 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: 26352
diff changeset
650
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
651 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: 26352
diff changeset
652 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: 26352
diff changeset
653 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: 26352
diff changeset
654 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: 26352
diff changeset
655
27430
e400cd35542b I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <pidgin@unreliablesource.net>
parents: 27295
diff changeset
656 lst = g_list_append(lst, txtres);
26671
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
657 }
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
658
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
659 MyDnsRecordListFree(dr, DnsFreeRecordList);
400f74b95c0e First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <paul@darkrain42.org>
parents: 26352
diff changeset
660 query_data->results = lst;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
661 } else {
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
662
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 /* back to main thread */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 /* 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
668 purple_timeout_add(0, res_main_thread_cb, query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 g_thread_exit(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
676 PurpleSrvTxtQueryData *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
677 purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 char *query;
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
680 char *hostname;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
681 PurpleSrvTxtQueryData *query_data;
26827
e5c874075b42 Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents: 26672
diff changeset
682 #ifndef _WIN32
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
683 PurpleSrvInternalQuery internal_query;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 int in[2], out[2];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 int pid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 GError* err = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 static gboolean initialized = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690
24698
d1da5c4c1e6b Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents: 24394
diff changeset
691 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: 24394
diff changeset
692 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: 24394
diff changeset
693 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: 24394
diff changeset
694 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: 24394
diff changeset
695 }
d1da5c4c1e6b Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents: 24394
diff changeset
696
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
697 #ifdef USE_IDN
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
698 if (!dns_str_is_ascii(domain)) {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
699 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: 27430
diff changeset
700 if (ret != 0) {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
701 purple_debug_error("dnssrv", "IDNA ToASCII failed\n");
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
702 cb(NULL, 0, extradata);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
703 return NULL;
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
704 }
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
705 } else /* Fallthru is intentional */
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
706 #endif
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
707 hostname = g_strdup(domain);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
708
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
709 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: 27430
diff changeset
710 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: 27430
diff changeset
711 query);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
712 g_free(hostname);
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
713
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
714 query_data = g_new0(PurpleSrvTxtQueryData, 1);
31890
25d12d5929e0 Fix the build on Windows of the added SRV/TXT UI ops. Based on a patch from Josh Mueller.
thijsalkemade@gmail.com
parents: 31876
diff changeset
715 query_data->type = PurpleDnsTypeSrv;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
716 query_data->cb.srv = cb;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
717 query_data->extradata = extradata;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
718 query_data->query = query;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
719
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
720 if (purple_srv_txt_query_ui_resolve(query_data))
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
721 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
722 return query_data;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
723 }
15374
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 #ifndef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 if(pipe(in) || pipe(out)) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
727 purple_debug_error("dnssrv", "Could not create pipe\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 g_free(query);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 cb(NULL, 0, extradata);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 pid = fork();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 if (pid == -1) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
735 purple_debug_error("dnssrv", "Could not create process!\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 cb(NULL, 0, extradata);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 g_free(query);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 return NULL;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 /* Child */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 if (pid == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 {
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
744 g_free(query);
df77b89a4025 Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <mark@kingant.net>
parents: 22107
diff changeset
745
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 close(out[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 close(in[1]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 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
749 /* resolve() does not return */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 close(out[1]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 close(in[0]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
755 internal_query.type = T_SRV;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
756 strncpy(internal_query.query, query, 255);
28683
3397fb5f89cf Null-terminate this string explicitly to avoid valgrind complaining.
Paul Aurich <paul@darkrain42.org>
parents: 28361
diff changeset
757 internal_query.query[255] = '\0';
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
758
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
759 if (write(in[1], &internal_query, sizeof(internal_query)) < 0)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
760 purple_debug_error("dnssrv", "Could not write to SRV resolver\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761
15713
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: 15657
diff changeset
762 query_data->pid = pid;
20232
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
763 query_data->fd_out = out[0];
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
764 query_data->fd_in = in[1];
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
765 query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 g_free(query);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 return query_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 if (!initialized) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
772 MyDnsQuery_UTF8 = (void*) wpurple_find_and_loadproc("dnsapi.dll", "DnsQuery_UTF8");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
773 MyDnsRecordListFree = (void*) wpurple_find_and_loadproc(
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 "dnsapi.dll", "DnsRecordListFree");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 initialized = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
778 if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree)
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
779 query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n");
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
780 else {
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
781 query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err);
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
782 if (query_data->resolver == NULL) {
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
783 query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", (err && err->message) ? err->message : "");
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
784 g_error_free(err);
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
785 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
788 /* The query isn't going to happen, so finish the SRV lookup now.
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
789 * Asynchronously call the callback since stuff may not expect
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
790 * the callback to be called before this returns */
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
791 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
792 query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 return query_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
798 PurpleSrvTxtQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata)
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
799 {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
800 char *query;
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
801 char *hostname;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
802 PurpleSrvTxtQueryData *query_data;
26827
e5c874075b42 Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <paul@darkrain42.org>
parents: 26672
diff changeset
803 #ifndef _WIN32
25594
3c3480683075 * fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25593
diff changeset
804 PurpleSrvInternalQuery internal_query;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
805 int in[2], out[2];
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
806 int pid;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
807 #else
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
808 GError* err = NULL;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
809 static gboolean initialized = FALSE;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
810 #endif
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
811
27711
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
812 #ifdef USE_IDN
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
813 if (!dns_str_is_ascii(domain)) {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
814 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: 27430
diff changeset
815 if (ret != 0) {
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
816 purple_debug_error("dnssrv", "IDNA ToASCII failed\n");
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
817 cb(NULL, extradata);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
818 return NULL;
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
819 }
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
820 } else /* fallthru is intentional */
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
821 #endif
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
822 hostname = g_strdup(domain);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
823
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
824 query = g_strdup_printf("%s.%s", owner, hostname);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
825 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: 27430
diff changeset
826 query);
7fbf964c6c6c Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents: 27430
diff changeset
827 g_free(hostname);
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
828
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
829 query_data = g_new0(PurpleSrvTxtQueryData, 1);
31890
25d12d5929e0 Fix the build on Windows of the added SRV/TXT UI ops. Based on a patch from Josh Mueller.
thijsalkemade@gmail.com
parents: 31876
diff changeset
830 query_data->type = PurpleDnsTypeTxt;
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
831 query_data->cb.txt = cb;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
832 query_data->extradata = extradata;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
833 query_data->query = query;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
834
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
835 if (purple_srv_txt_query_ui_resolve(query_data)) {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
836 /* query intentionally not freed
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
837 */
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
838 return query_data;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
839 }
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
840
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
841 #ifndef _WIN32
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
842 if(pipe(in) || pipe(out)) {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
843 purple_debug_error("dnssrv", "Could not create pipe\n");
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
844 g_free(query);
26672
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
845 cb(NULL, extradata);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
846 return NULL;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
847 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
848
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
849 pid = fork();
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
850 if (pid == -1) {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
851 purple_debug_error("dnssrv", "Could not create process!\n");
26672
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
852 cb(NULL, extradata);
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
853 g_free(query);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
854 return NULL;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
855 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
856
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
857 /* Child */
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
858 if (pid == 0)
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
859 {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
860 g_free(query);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
861
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
862 close(out[0]);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
863 close(in[1]);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
864 resolve(in[0], out[1]);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
865 /* resolve() does not return */
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
866 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
867
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
868 close(out[1]);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
869 close(in[0]);
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
870
25594
3c3480683075 * fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25593
diff changeset
871 internal_query.type = T_TXT;
3c3480683075 * fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25593
diff changeset
872 strncpy(internal_query.query, query, 255);
28744
e191f5fedce1 Shut up valgrind ("unitialized bytes(s)...") and changelog.
Paul Aurich <paul@darkrain42.org>
parents: 28743
diff changeset
873 internal_query.query[255] = '\0';
27294
862b8208a546 Strip trailing whitespace and spaces to tab
Mark Doliner <mark@kingant.net>
parents: 27016
diff changeset
874
25594
3c3480683075 * fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25593
diff changeset
875 if (write(in[1], &internal_query, sizeof(internal_query)) < 0)
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
876 purple_debug_error("dnssrv", "Could not write to TXT resolver\n");
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
877
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
878 query_data->pid = pid;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
879 query_data->fd_out = out[0];
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
880 query_data->fd_in = in[1];
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
881 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: 23203
diff changeset
882
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
883 g_free(query);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
884
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
885 return query_data;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
886 #else
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
887 if (!initialized) {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
888 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: 23203
diff changeset
889 MyDnsRecordListFree = (void*) wpurple_find_and_loadproc(
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
890 "dnsapi.dll", "DnsRecordListFree");
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
891 initialized = TRUE;
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
892 }
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
893
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
894 if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree)
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
895 query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n");
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
896 else {
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
897 query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err);
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
898 if (query_data->resolver == NULL) {
25767
816c096d1ea8 Cut-n-paste typo
Paul Aurich <paul@darkrain42.org>
parents: 25766
diff changeset
899 query_data->error_message = g_strdup_printf("TXT thread create failure: %s\n", (err && err->message) ? err->message : "");
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
900 g_error_free(err);
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
901 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
26672
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
904 /* The query isn't going to happen, so finish the TXT lookup now.
15800
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
905 * Asynchronously call the callback since stuff may not expect
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
906 * the callback to be called before this returns */
76bdff454d6f Minor cleanup.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15713
diff changeset
907 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
908 query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 return query_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 void
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
915 purple_srv_cancel(PurpleSrvTxtQueryData *query_data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 {
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
917 PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops();
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
918
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
919 if (ops && ops->destroy)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
920 ops->destroy(query_data);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
921
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 if (query_data->handle > 0)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15713
diff changeset
923 purple_input_remove(query_data->handle);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 if (query_data->resolver != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 * It's not really possible to kill a thread. So instead we
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 * just set the callback to NULL and let the DNS lookup
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 * finish.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 */
25766
d853f56dad8b dnssrv.c:
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
932 query_data->cb.srv = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 g_free(query_data->query);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 g_free(query_data->error_message);
20232
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
937 #else
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
938 close(query_data->fd_out);
b7c0c79585f9 applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
939 close(query_data->fd_in);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 g_free(query_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 }
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
943
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
944 void
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
945 purple_txt_cancel(PurpleSrvTxtQueryData *query_data)
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
946 {
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
947 purple_srv_cancel(query_data);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23203
diff changeset
948 }
26672
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
949
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
950 const gchar *
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
951 purple_txt_response_get_content(PurpleTxtResponse *resp)
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
952 {
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
953 g_return_val_if_fail(resp != NULL, NULL);
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
954
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
955 return resp->content;
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
956 }
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
957
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
958 void purple_txt_response_destroy(PurpleTxtResponse *resp)
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
959 {
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
960 g_return_if_fail(resp != NULL);
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
961
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
962 g_free(resp->content);
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
963 g_free(resp);
acee7d2b1983 Hide PurpleTxtResponse and use a more purple API
Paul Aurich <paul@darkrain42.org>
parents: 26671
diff changeset
964 }
31876
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
965
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
966 /*
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
967 * Only used as the callback for the ui ops.
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
968 */
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
969 static void
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
970 purple_srv_query_resolved(PurpleSrvTxtQueryData *query_data, GList *records)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
971 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
972 g_return_if_fail(records != NULL);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
973
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
974 purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", query_data->query, g_list_length(records));
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
975
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
976 if (query_data->cb.srv != NULL)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
977 query_data->cb.srv(purple_srv_sort(records)->data, g_list_length(records), query_data->extradata);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
978 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
979
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
980 /*
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
981 * Only used as the callback for the ui ops.
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
982 */
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
983 static void
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
984 purple_txt_query_resolved(PurpleSrvTxtQueryData *query_data, GList *entries)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
985 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
986 g_return_if_fail(entries != NULL);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
987
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
988 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: 30983
diff changeset
989
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
990 if (query_data->cb.txt != NULL)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
991 query_data->cb.txt(entries, query_data->extradata);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
992 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
993
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
994 static void
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
995 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: 30983
diff changeset
996 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
997 purple_debug_error("dnssrv", "%s\n", error_message);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
998
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
999 if (query_data->cb.srv != NULL)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1000 query_data->cb.srv(NULL, 0, query_data->extradata);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1001
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1002 purple_srv_cancel(query_data);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1003 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1004
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1005 static gboolean
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1006 purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1007 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1008 PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops();
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1009
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1010 if (ops && ops->resolve)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1011 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: 30983
diff changeset
1012
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1013 return FALSE;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1014 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1015
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1016 void
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1017 purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1018 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1019 srv_txt_query_ui_ops = ops;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1020 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1021
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1022 PurpleSrvTxtQueryUiOps *
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1023 purple_srv_txt_query_get_ui_ops(void)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1024 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1025 /* 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: 30983
diff changeset
1026 * 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: 30983
diff changeset
1027 */
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1028 return srv_txt_query_ui_ops;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1029 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1030
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1031 char *
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1032 purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1033 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1034 g_return_val_if_fail(query_data != NULL, NULL);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1035
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1036 return query_data->query;
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1037 }
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1038
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1039
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1040 int
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1041 purple_srv_txt_query_get_type(PurpleSrvTxtQueryData *query_data)
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1042 {
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1043 g_return_val_if_fail(query_data != NULL, 0);
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1044
08dcd2d4f0b7 Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
thijsalkemade@gmail.com
parents: 30983
diff changeset
1045 return query_data->type;
31928
f0de3178dd87 The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31890
diff changeset
1046 }