Wed, 02 Apr 2014 02:37:34 +0200
Custom smileys: simplify storage implementation
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2 | * |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
3 | * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de> |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
4 | * |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
9 | * |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
14 | * |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18555
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
18 | */ |
|
31738
c0a7971ce0d2
purple: Fix some compiler warnings related to new API and missing prototypes.
Paul Aurich <darkrain42@pidgin.im>
parents:
31678
diff
changeset
|
19 | #define _PURPLE_DNSSRV_C_ |
|
11898
a40601f1aed2
[gaim-migrate @ 14189]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11630
diff
changeset
|
20 | |
|
a40601f1aed2
[gaim-migrate @ 14189]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11630
diff
changeset
|
21 | #include "internal.h" |
|
15718
216ce4a9db5b
Include util.h to fix a warning I introduced
Evan Schoenberg <evands@pidgin.im>
parents:
15707
diff
changeset
|
22 | #include "util.h" |
|
11898
a40601f1aed2
[gaim-migrate @ 14189]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11630
diff
changeset
|
23 | |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
24 | #ifndef _WIN32 |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
22351
diff
changeset
|
25 | #include <arpa/nameser.h> |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
26 | #include <resolv.h> |
|
12568
717c7d5cbb77
[gaim-migrate @ 14887]
Richard Laager <rlaager@pidgin.im>
parents:
12451
diff
changeset
|
27 | #ifdef HAVE_ARPA_NAMESER_COMPAT_H |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
28 | #include <arpa/nameser_compat.h> |
|
12568
717c7d5cbb77
[gaim-migrate @ 14887]
Richard Laager <rlaager@pidgin.im>
parents:
12451
diff
changeset
|
29 | #endif |
| 24743 | 30 | #else /* WIN32 */ |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
31 | #include <windns.h> |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
32 | /* Missing from the mingw headers */ |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
33 | #ifndef DNS_TYPE_SRV |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
34 | # define DNS_TYPE_SRV PurpleDnsTypeSrv |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
35 | #endif |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
36 | #ifndef DNS_TYPE_TXT |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
37 | # define DNS_TYPE_TXT PurpleDnsTypeTxt |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
38 | #endif |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
39 | #endif |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
40 | |
|
31676
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
41 | #ifndef T_SRV |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
42 | #define T_SRV PurpleDnsTypeSrv |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
43 | #endif |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
44 | #ifndef T_TXT |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
45 | #define T_TXT PurpleDnsTypeTxt |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
46 | #endif |
|
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
47 | |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
48 | #include "debug.h" |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
49 | #include "dnssrv.h" |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
50 | #include "eventloop.h" |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
51 | #include "network.h" |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
52 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
53 | static PurpleSrvTxtQueryUiOps *srv_txt_query_ui_ops = NULL; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
54 | |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
55 | #ifndef _WIN32 |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
56 | typedef union { |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
57 | HEADER hdr; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
58 | u_char buf[1024]; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
59 | } queryans; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
60 | #endif |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
61 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
62 | struct _PurpleSrvTxtQueryData { |
| 24743 | 63 | union { |
| 64 | PurpleSrvCallback srv; | |
| 65 | PurpleTxtCallback txt; | |
| 66 | } cb; | |
| 67 | ||
|
11382
4458ab177b10
[gaim-migrate @ 13609]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11381
diff
changeset
|
68 | gpointer extradata; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
69 | guint handle; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
70 | int type; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
71 | char *query; |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
72 | #ifdef _WIN32 |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
73 | GThread *resolver; |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
74 | char *error_message; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
75 | GList *results; |
|
15776
cba54f9d2e51
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 <evands@pidgin.im>
parents:
15718
diff
changeset
|
76 | #else |
|
20128
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
77 | int fd_in, fd_out; |
|
15776
cba54f9d2e51
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 <evands@pidgin.im>
parents:
15718
diff
changeset
|
78 | pid_t pid; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
79 | #endif |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
80 | }; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
81 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
82 | typedef struct _PurpleSrvInternalQuery { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
83 | int type; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
84 | char query[256]; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
85 | } PurpleSrvInternalQuery; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
86 | |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
87 | typedef struct _PurpleSrvResponseContainer { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
88 | PurpleSrvResponse *response; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
89 | int sum; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
90 | } PurpleSrvResponseContainer; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
91 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
92 | static gboolean purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data); |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
93 | |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
94 | /* |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
95 | * Sort by priority, then by weight. Strictly numerically--no |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
96 | * randomness. Technically we only need to sort by pref and then |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
97 | * make sure any records with weight 0 are at the beginning of |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
98 | * their group, but it's just as easy to sort by weight. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
99 | */ |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
100 | static gint |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
101 | responsecompare(gconstpointer ar, gconstpointer br) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
102 | { |
| 15884 | 103 | PurpleSrvResponse *a = (PurpleSrvResponse*)ar; |
| 104 | PurpleSrvResponse *b = (PurpleSrvResponse*)br; | |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
105 | |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
106 | if(a->pref == b->pref) { |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
107 | if(a->weight == b->weight) |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
108 | return 0; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
109 | if(a->weight < b->weight) |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
110 | return -1; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
111 | return 1; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
112 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
113 | if(a->pref < b->pref) |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
114 | return -1; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
115 | return 1; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
116 | } |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
117 | |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
118 | /* |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
119 | * select_random_response: |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
120 | * @list: The list of PurpleSrvResponseContainer. This function |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
121 | * removes a node from this list and returns the new list. |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
122 | * @container_ptr: The PurpleSrvResponseContainer that was chosen |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
123 | * will be returned here. |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
124 | * |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
125 | * Iterate over a list of PurpleSrvResponseContainer making the sum |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
126 | * the running total of the sums. Select a random integer in the range |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
127 | * (1, sum+1), then find the first element greater than or equal to the |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
128 | * number selected. From RFC 2782. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
129 | */ |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
130 | static GList * |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
131 | select_random_response(GList *list, PurpleSrvResponseContainer **container_ptr) |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
132 | { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
133 | GList *cur; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
134 | size_t runningtotal; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
135 | int r; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
136 | |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
137 | g_return_val_if_fail(list != NULL, NULL); |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
138 | |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
139 | runningtotal = 0; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
140 | cur = list; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
141 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
142 | while (cur) { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
143 | PurpleSrvResponseContainer *container = cur->data; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
144 | runningtotal += container->response->weight; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
145 | container->sum = runningtotal; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
146 | cur = cur->next; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
147 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
148 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
149 | /* |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
150 | * If the running total is greater than 0, pick a number between |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
151 | * 1 and the runningtotal inclusive. (This is not precisely what |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
152 | * the RFC algorithm describes, but we wish to deal with integers |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
153 | * and avoid floats. This is functionally equivalent.) |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
154 | * If running total is 0, then choose r = 0. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
155 | */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
156 | r = runningtotal ? g_random_int_range(1, runningtotal + 1) : 0; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
157 | cur = list; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
158 | while (r > ((PurpleSrvResponseContainer *)cur->data)->sum) { |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
159 | if (G_UNLIKELY(!cur->next)) |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
160 | break; |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
161 | cur = cur->next; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
162 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
163 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
164 | /* Set the return parameter and remove cur from the list */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
165 | *container_ptr = cur->data; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
166 | return g_list_delete_link(list, cur); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
167 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
168 | |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
169 | /* |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
170 | * Reorder a GList of PurpleSrvResponses that have the same priority |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
171 | * (aka "pref"). |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
172 | */ |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
173 | static void |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
174 | srv_reorder(GList *list, int num) |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
175 | { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
176 | int i; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
177 | GList *cur, *container_list = NULL; |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
178 | PurpleSrvResponseContainer *container; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
179 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
180 | if (num < 2) |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
181 | /* Nothing to sort */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
182 | return; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
183 | |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
184 | g_return_if_fail(list != NULL); |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
185 | |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
186 | /* First build a list of container structs */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
187 | for (i = 0, cur = list; i < num; i++, cur = cur->next) { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
188 | container = g_new(PurpleSrvResponseContainer, 1); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
189 | container->response = cur->data; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
190 | container_list = g_list_prepend(container_list, container); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
191 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
192 | container_list = g_list_reverse(container_list); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
193 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
194 | /* |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
195 | * Re-order the list that was passed in as a parameter. We leave |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
196 | * the list nodes in place, but replace their data pointers. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
197 | */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
198 | cur = list; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
199 | while (container_list) { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
200 | container_list = select_random_response(container_list, &container); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
201 | cur->data = container->response; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
202 | g_free(container); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
203 | cur = cur->next; |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
204 | g_return_if_fail(cur); |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
205 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
206 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
207 | |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
208 | /* |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
209 | * purple_srv_sort: |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
210 | * @list: The original list, resorted |
|
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
211 | * |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
212 | * Sorts a GList of PurpleSrvResponses according to the |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
213 | * algorithm described in RFC 2782. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
214 | * |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
215 | * Returns: GList of PurpleSrvResponse's |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
216 | */ |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
217 | static GList * |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
218 | purple_srv_sort(GList *list) |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
219 | { |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
220 | int pref, count; |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
221 | GList *cur, *start; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
222 | |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
223 | if (!list || !list->next) { |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
224 | /* Nothing to sort */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
225 | return list; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
226 | } |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
227 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
228 | list = g_list_sort(list, responsecompare); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
229 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
230 | start = cur = list; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
231 | count = 1; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
232 | while (cur) { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
233 | PurpleSrvResponse *next_response; |
|
35382
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
234 | |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
235 | g_return_val_if_fail(cur->data, list); |
|
1b75f8a4129c
Fix some clang static analysis warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35378
diff
changeset
|
236 | |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
237 | pref = ((PurpleSrvResponse *)cur->data)->pref; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
238 | next_response = cur->next ? cur->next->data : NULL; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
239 | if (!next_response || next_response->pref != pref) { |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
240 | /* |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
241 | * The 'count' records starting at 'start' all have the same |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
242 | * priority. Sort them by weight. |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
243 | */ |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
244 | srv_reorder(start, count); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
245 | start = cur->next; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
246 | count = 0; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
247 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
248 | count++; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
249 | cur = cur->next; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
250 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
251 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
252 | return list; |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
253 | } |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
254 | |
|
31976
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
255 | static PurpleSrvTxtQueryData * |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
256 | query_data_new(int type, gchar *query, gpointer extradata) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
257 | { |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
258 | PurpleSrvTxtQueryData *query_data = g_new0(PurpleSrvTxtQueryData, 1); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
259 | query_data->type = type; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
260 | query_data->extradata = extradata; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
261 | query_data->query = query; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
262 | #ifndef _WIN32 |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
263 | query_data->fd_in = -1; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
264 | query_data->fd_out = -1; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
265 | #endif |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
266 | return query_data; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
267 | } |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
268 | |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
269 | void |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
270 | purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
271 | { |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
272 | PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops(); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
273 | |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
274 | if (ops && ops->destroy) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
275 | ops->destroy(query_data); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
276 | |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
277 | if (query_data->handle > 0) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
278 | purple_input_remove(query_data->handle); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
279 | #ifdef _WIN32 |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
280 | if (query_data->resolver != NULL) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
281 | { |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
282 | /* |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
283 | * It's not really possible to kill a thread. So instead we |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
284 | * just set the callback to NULL and let the DNS lookup |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
285 | * finish. |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
286 | */ |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
287 | query_data->cb.srv = NULL; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
288 | return; |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
289 | } |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
290 | g_free(query_data->error_message); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
291 | #else |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
292 | if (query_data->fd_out != -1) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
293 | close(query_data->fd_out); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
294 | if (query_data->fd_in != -1) |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
295 | close(query_data->fd_in); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
296 | #endif |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
297 | g_free(query_data->query); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
298 | g_free(query_data); |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
299 | } |
|
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
300 | |
|
28784
0344b94dba21
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <darkrain42@pidgin.im>
parents:
28675
diff
changeset
|
301 | #ifdef USE_IDN |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
302 | static gboolean |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
303 | dns_str_is_ascii(const char *name) |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
304 | { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
305 | guchar *c; |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
306 | for (c = (guchar *)name; c && *c; ++c) { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
307 | if (*c > 0x7f) |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
308 | return FALSE; |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
309 | } |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
310 | |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
311 | return TRUE; |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
312 | } |
|
28784
0344b94dba21
dns: Avoid two warnings when building with --disable-idn.
Paul Aurich <darkrain42@pidgin.im>
parents:
28675
diff
changeset
|
313 | #endif |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
314 | |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
315 | #ifndef _WIN32 |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
316 | static void |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
317 | write_to_parent(int in, int out, gconstpointer data, gsize size) |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
318 | { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
319 | const guchar *buf = data; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
320 | gssize w; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
321 | |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
322 | do { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
323 | w = write(out, buf, size); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
324 | if (w > 0) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
325 | buf += w; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
326 | size -= w; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
327 | } else if (w < 0 && errno == EINTR) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
328 | /* Let's try some more; */ |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
329 | w = 1; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
330 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
331 | } while (size > 0 && w > 0); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
332 | |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
333 | if (size != 0) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
334 | /* An error occurred */ |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
335 | close(out); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
336 | close(in); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
337 | _exit(0); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
338 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
339 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
340 | |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
341 | /* Read size bytes to data. Dies if an error occurs. */ |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
342 | static void |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
343 | read_from_parent(int in, int out, gpointer data, gsize size) |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
344 | { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
345 | guchar *buf = data; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
346 | gssize r; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
347 | |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
348 | do { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
349 | r = read(in, data, size); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
350 | if (r > 0) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
351 | buf += r; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
352 | size -= r; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
353 | } else if (r < 0 && errno == EINTR) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
354 | /* Let's try some more; */ |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
355 | r = 1; |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
356 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
357 | } while (size > 0 && r > 0); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
358 | |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
359 | if (size != 0) { |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
360 | /* An error occurred */ |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
361 | close(out); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
362 | close(in); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
363 | _exit(0); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
364 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
365 | } |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
366 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
367 | |
|
16701
0b41f23396cc
Mark two functions as "noreturn"
Mark Doliner <markdoliner@pidgin.im>
parents:
15890
diff
changeset
|
368 | G_GNUC_NORETURN static void |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
369 | resolve(int in, int out) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
370 | { |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
371 | GList *ret = NULL; |
| 15884 | 372 | PurpleSrvResponse *srvres; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
373 | PurpleTxtResponse *txtres; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
374 | queryans answer; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
375 | int size, qdcount, ancount; |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
376 | guchar *end, *cp; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
377 | gchar name[256]; |
|
13127
0adfbecc67ac
[gaim-migrate @ 15488]
Mark Doliner <markdoliner@pidgin.im>
parents:
12847
diff
changeset
|
378 | guint16 type, dlen, pref, weight, port; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
379 | PurpleSrvInternalQuery query; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
380 | |
|
15707
e9d3280caf69
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 <evands@pidgin.im>
parents:
15435
diff
changeset
|
381 | #ifdef HAVE_SIGNAL_H |
| 15884 | 382 | purple_restore_default_signal_handlers(); |
|
15707
e9d3280caf69
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 <evands@pidgin.im>
parents:
15435
diff
changeset
|
383 | #endif |
| 15859 | 384 | |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
385 | read_from_parent(in, out, &query, sizeof(query)); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
386 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
387 | size = res_query( query.query, C_IN, query.type, (u_char*)&answer, sizeof( answer)); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
388 | if (size == -1) { |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
389 | write_to_parent(in, out, &(query.type), sizeof(query.type)); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
390 | write_to_parent(in, out, &size, sizeof(size)); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
391 | close(out); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
392 | close(in); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
393 | _exit(0); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
394 | } |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
395 | |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
396 | qdcount = ntohs(answer.hdr.qdcount); |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
397 | ancount = ntohs(answer.hdr.ancount); |
|
11381
d3d53604fe0f
[gaim-migrate @ 13608]
Mark Doliner <markdoliner@pidgin.im>
parents:
11379
diff
changeset
|
398 | cp = (guchar*)&answer + sizeof(HEADER); |
|
d3d53604fe0f
[gaim-migrate @ 13608]
Mark Doliner <markdoliner@pidgin.im>
parents:
11379
diff
changeset
|
399 | end = (guchar*)&answer + size; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
400 | |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
401 | /* skip over unwanted stuff */ |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
402 | while (qdcount-- > 0 && cp < end) { |
|
11381
d3d53604fe0f
[gaim-migrate @ 13608]
Mark Doliner <markdoliner@pidgin.im>
parents:
11379
diff
changeset
|
403 | size = dn_expand( (unsigned char*)&answer, end, cp, name, 256); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
404 | if(size < 0) goto end; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
405 | cp += size + QFIXEDSZ; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
406 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
407 | |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
408 | while (ancount-- > 0 && cp < end) { |
|
11381
d3d53604fe0f
[gaim-migrate @ 13608]
Mark Doliner <markdoliner@pidgin.im>
parents:
11379
diff
changeset
|
409 | size = dn_expand((unsigned char*)&answer, end, cp, name, 256); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
410 | if(size < 0) |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
411 | goto end; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
412 | cp += size; |
|
13143
d0a29ff182c8
[gaim-migrate @ 15505]
Mark Doliner <markdoliner@pidgin.im>
parents:
13127
diff
changeset
|
413 | GETSHORT(type,cp); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
414 | |
|
13127
0adfbecc67ac
[gaim-migrate @ 15488]
Mark Doliner <markdoliner@pidgin.im>
parents:
12847
diff
changeset
|
415 | /* skip ttl and class since we already know it */ |
|
0adfbecc67ac
[gaim-migrate @ 15488]
Mark Doliner <markdoliner@pidgin.im>
parents:
12847
diff
changeset
|
416 | cp += 6; |
|
0adfbecc67ac
[gaim-migrate @ 15488]
Mark Doliner <markdoliner@pidgin.im>
parents:
12847
diff
changeset
|
417 | |
|
13143
d0a29ff182c8
[gaim-migrate @ 15505]
Mark Doliner <markdoliner@pidgin.im>
parents:
13127
diff
changeset
|
418 | GETSHORT(dlen,cp); |
|
29253
4621bf356c67
We should be using the type listed in the response, not in the
Mark Doliner <markdoliner@pidgin.im>
parents:
28792
diff
changeset
|
419 | if (type == T_SRV) { |
|
13143
d0a29ff182c8
[gaim-migrate @ 15505]
Mark Doliner <markdoliner@pidgin.im>
parents:
13127
diff
changeset
|
420 | GETSHORT(pref,cp); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
421 | |
|
13143
d0a29ff182c8
[gaim-migrate @ 15505]
Mark Doliner <markdoliner@pidgin.im>
parents:
13127
diff
changeset
|
422 | GETSHORT(weight,cp); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
423 | |
|
13143
d0a29ff182c8
[gaim-migrate @ 15505]
Mark Doliner <markdoliner@pidgin.im>
parents:
13127
diff
changeset
|
424 | GETSHORT(port,cp); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
425 | |
|
11381
d3d53604fe0f
[gaim-migrate @ 13608]
Mark Doliner <markdoliner@pidgin.im>
parents:
11379
diff
changeset
|
426 | size = dn_expand( (unsigned char*)&answer, end, cp, name, 256); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
427 | if(size < 0 ) |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
428 | goto end; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
429 | |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
430 | cp += size; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
431 | |
| 15884 | 432 | srvres = g_new0(PurpleSrvResponse, 1); |
|
32004
4f4a9244be96
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31977
diff
changeset
|
433 | if (strlen(name) > sizeof(srvres->hostname) - 1) { |
|
4f4a9244be96
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31977
diff
changeset
|
434 | purple_debug_error("dnssrv", "hostname is longer than available buffer ('%s', %zd bytes)!", |
|
4f4a9244be96
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31977
diff
changeset
|
435 | name, strlen(name)); |
|
4f4a9244be96
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31977
diff
changeset
|
436 | } |
|
4f4a9244be96
Bounds check hostname lengths for DNS SRV lookups. (EFF)
Ethan Blanton <elb@pidgin.im>
parents:
31977
diff
changeset
|
437 | g_strlcpy(srvres->hostname, name, sizeof(srvres->hostname)); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
438 | srvres->pref = pref; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
439 | srvres->port = port; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
440 | srvres->weight = weight; |
|
11395
1b19bd77adf6
[gaim-migrate @ 13626]
Daniel Atallah <datallah@pidgin.im>
parents:
11382
diff
changeset
|
441 | |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
442 | ret = g_list_prepend(ret, srvres); |
|
29253
4621bf356c67
We should be using the type listed in the response, not in the
Mark Doliner <markdoliner@pidgin.im>
parents:
28792
diff
changeset
|
443 | } else if (type == T_TXT) { |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
444 | txtres = g_new0(PurpleTxtResponse, 1); |
|
26765
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
445 | txtres->content = g_strndup((gchar*)(++cp), dlen-1); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
446 | ret = g_list_append(ret, txtres); |
|
23606
5e648a57bb76
* some further bugfixing, BIND's libresolv does so much for the programmer, just happy it exists
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23605
diff
changeset
|
447 | cp += dlen - 1; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
448 | } else { |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
449 | cp += dlen; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
450 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
451 | } |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
452 | |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
453 | end: |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
454 | size = g_list_length(ret); |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
455 | |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
456 | if (query.type == T_SRV) |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
457 | ret = purple_srv_sort(ret); |
|
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
458 | |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
459 | write_to_parent(in, out, &(query.type), sizeof(query.type)); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
460 | write_to_parent(in, out, &size, sizeof(size)); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
461 | while (ret != NULL) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
462 | { |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
463 | if (query.type == T_SRV) |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
464 | write_to_parent(in, out, ret->data, sizeof(PurpleSrvResponse)); |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
465 | if (query.type == T_TXT) { |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
466 | PurpleTxtResponse *response = ret->data; |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
467 | gsize l = strlen(response->content) + 1 /* null byte */; |
|
28792
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
468 | write_to_parent(in, out, &l, sizeof(l)); |
|
77214d07508f
dns: Check read/write return value to silence a bunch of warnings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28784
diff
changeset
|
469 | write_to_parent(in, out, response->content, l); |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
470 | } |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
471 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
472 | g_free(ret->data); |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
473 | ret = g_list_remove(ret, ret->data); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
474 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
475 | |
|
20128
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
476 | close(out); |
|
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
477 | close(in); |
|
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
478 | |
|
11395
1b19bd77adf6
[gaim-migrate @ 13626]
Daniel Atallah <datallah@pidgin.im>
parents:
11382
diff
changeset
|
479 | _exit(0); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
480 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
481 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
482 | static void |
| 15884 | 483 | resolved(gpointer data, gint source, PurpleInputCondition cond) |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
484 | { |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
485 | int size; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
486 | int type; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
487 | PurpleSrvTxtQueryData *query_data = (PurpleSrvTxtQueryData*)data; |
|
11426
46f761f5c7ad
[gaim-migrate @ 13663]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11395
diff
changeset
|
488 | int i; |
|
15776
cba54f9d2e51
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 <evands@pidgin.im>
parents:
15718
diff
changeset
|
489 | int status; |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
490 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
491 | if (read(source, &type, sizeof(type)) == sizeof(type)) { |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
492 | if (read(source, &size, sizeof(size)) == sizeof(size)) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
493 | if (size == -1 || size == 0) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
494 | if (size == -1) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
495 | purple_debug_warning("dnssrv", "res_query returned an error\n"); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
496 | /* Re-read resolv.conf and friends in case DNS servers have changed */ |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
497 | res_init(); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
498 | } else |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
499 | purple_debug_info("dnssrv", "Found 0 entries, errno is %i\n", errno); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
500 | |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
501 | if (type == T_SRV) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
502 | PurpleSrvCallback cb = query_data->cb.srv; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
503 | cb(NULL, 0, query_data->extradata); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
504 | } else if (type == T_TXT) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
505 | PurpleTxtCallback cb = query_data->cb.txt; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
506 | cb(NULL, query_data->extradata); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
507 | } else { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
508 | purple_debug_error("dnssrv", "type unknown of DNS result entry; errno is %i\n", errno); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
509 | } |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
510 | |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
511 | } else if (size) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
512 | if (type == T_SRV) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
513 | PurpleSrvResponse *res; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
514 | PurpleSrvResponse *tmp; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
515 | PurpleSrvCallback cb = query_data->cb.srv; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
516 | ssize_t red; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
517 | purple_debug_info("dnssrv","found %d SRV entries\n", size); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
518 | tmp = res = g_new0(PurpleSrvResponse, size); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
519 | for (i = 0; i < size; i++) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
520 | red = read(source, tmp++, sizeof(PurpleSrvResponse)); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
521 | if (red != sizeof(PurpleSrvResponse)) { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
522 | purple_debug_error("dnssrv","unable to read srv " |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
523 | "response: %s\n", g_strerror(errno)); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
524 | size = 0; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
525 | g_free(res); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
526 | res = NULL; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
527 | } |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
528 | } |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
529 | |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
530 | cb(res, size, query_data->extradata); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
531 | } else if (type == T_TXT) { |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
532 | GList *responses = NULL; |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
533 | PurpleTxtResponse *res; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
534 | PurpleTxtCallback cb = query_data->cb.txt; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
535 | ssize_t red; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
536 | purple_debug_info("dnssrv","found %d TXT entries\n", size); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
537 | for (i = 0; i < size; i++) { |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
538 | gsize len; |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
539 | |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
540 | red = read(source, &len, sizeof(len)); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
541 | if (red != sizeof(len)) { |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
542 | purple_debug_error("dnssrv","unable to read txt " |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
543 | "response length: %s\n", g_strerror(errno)); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
544 | size = 0; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
545 | g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL); |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
546 | g_list_free(responses); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
547 | responses = NULL; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
548 | break; |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
549 | } |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
550 | |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
551 | res = g_new0(PurpleTxtResponse, 1); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
552 | res->content = g_new0(gchar, len); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
553 | |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
554 | red = read(source, res->content, len); |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
555 | if (red < 0 || (gsize)red != len) { |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
556 | purple_debug_error("dnssrv","unable to read txt " |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
557 | "response: %s\n", g_strerror(errno)); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
558 | size = 0; |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
559 | purple_txt_response_destroy(res); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
560 | g_list_foreach(responses, (GFunc)purple_txt_response_destroy, NULL); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
561 | g_list_free(responses); |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
562 | responses = NULL; |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
563 | break; |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
564 | } |
|
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
565 | responses = g_list_prepend(responses, res); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
566 | } |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
567 | |
|
28674
43442ff173dc
Fix the code dealing with writing a TXT lookup response from child to parent.
Paul Aurich <darkrain42@pidgin.im>
parents:
28612
diff
changeset
|
568 | responses = g_list_reverse(responses); |
|
27157
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
569 | cb(responses, query_data->extradata); |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
570 | } else { |
|
609f187d0ac7
Call res_init() when DNS queries fail in case the failure indicates a timeout
Paul Aurich <darkrain42@pidgin.im>
parents:
26970
diff
changeset
|
571 | purple_debug_error("dnssrv", "type unknown of DNS result entry; errno is %i\n", errno); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
572 | } |
|
22234
4d54e1c5c696
More compiler warning fixes from o_sukhodolsky (with additions by me).
Mark Doliner <markdoliner@pidgin.im>
parents:
20679
diff
changeset
|
573 | } |
|
16957
b74ce411bea8
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 <evands@pidgin.im>
parents:
16701
diff
changeset
|
574 | } |
|
b74ce411bea8
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 <evands@pidgin.im>
parents:
16701
diff
changeset
|
575 | } |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
576 | |
|
15776
cba54f9d2e51
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 <evands@pidgin.im>
parents:
15718
diff
changeset
|
577 | waitpid(query_data->pid, &status, 0); |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
578 | purple_srv_txt_query_destroy(query_data); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
579 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
580 | |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
581 | #else /* _WIN32 */ |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
582 | |
|
35460
96946e21fce5
Fix some more gtk-doc warnings till dnssrv
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
583 | /* The Jabber Server code was inspiration for parts of this. */ |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
584 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
585 | static gboolean |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
586 | res_main_thread_cb(gpointer data) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
587 | { |
| 15884 | 588 | PurpleSrvResponse *srvres = NULL; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
589 | PurpleSrvTxtQueryData *query_data = data; |
|
28291
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
590 | if(query_data->error_message != NULL) { |
|
30792
155b65d26118
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <datallah@pidgin.im>
parents:
29253
diff
changeset
|
591 | purple_debug_error("dnssrv", "%s", query_data->error_message); |
|
28291
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
592 | if (query_data->type == DNS_TYPE_SRV) { |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
593 | if (query_data->cb.srv) |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
594 | query_data->cb.srv(srvres, 0, query_data->extradata); |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
595 | } else if (query_data->type == DNS_TYPE_TXT) { |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
596 | if (query_data->cb.txt) |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
597 | query_data->cb.txt(NULL, query_data->extradata); |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
598 | } |
|
a342ad3611b0
Fix not calling the SRV timeout on the win32 code. Closes #9956.
Paul Aurich <darkrain42@pidgin.im>
parents:
27898
diff
changeset
|
599 | } else { |
|
26968
0527c5cc906b
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <darkrain42@pidgin.im>
parents:
26766
diff
changeset
|
600 | if (query_data->type == DNS_TYPE_SRV) { |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
601 | PurpleSrvResponse *srvres_tmp = NULL; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
602 | GList *lst = query_data->results; |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
603 | int size = g_list_length(lst); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
604 | |
| 24743 | 605 | if(query_data->cb.srv && size > 0) |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
606 | srvres_tmp = srvres = g_new0(PurpleSrvResponse, size); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
607 | while (lst) { |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
608 | PurpleSrvResponse *lstdata = lst->data; |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
609 | lst = g_list_delete_link(lst, lst); |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
610 | |
| 24743 | 611 | if(query_data->cb.srv) |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
612 | memcpy(srvres_tmp++, lstdata, sizeof(PurpleSrvResponse)); |
|
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
613 | g_free(lstdata); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
614 | } |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
615 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
616 | query_data->results = NULL; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
617 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
618 | purple_debug_info("dnssrv", "found %d SRV entries\n", size); |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
619 | |
| 24743 | 620 | if(query_data->cb.srv) query_data->cb.srv(srvres, size, query_data->extradata); |
|
26968
0527c5cc906b
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <darkrain42@pidgin.im>
parents:
26766
diff
changeset
|
621 | } else if (query_data->type == DNS_TYPE_TXT) { |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
622 | GList *lst = query_data->results; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
623 | |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
624 | purple_debug_info("dnssrv", "found %d TXT entries\n", g_list_length(lst)); |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
625 | |
|
26766
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
626 | if (query_data->cb.txt) { |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
627 | query_data->results = NULL; |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
628 | query_data->cb.txt(lst, query_data->extradata); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
629 | } |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
630 | } else { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
631 | purple_debug_error("dnssrv", "unknown query type"); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
632 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
633 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
634 | |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
635 | query_data->resolver = NULL; |
|
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
636 | query_data->handle = 0; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
637 | |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
638 | purple_srv_txt_query_destroy(query_data); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
639 | |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
640 | return FALSE; |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
641 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
642 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
643 | static gpointer |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
644 | res_thread(gpointer data) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
645 | { |
|
12451
d9feea46dac4
[gaim-migrate @ 14760]
Daniel Atallah <datallah@pidgin.im>
parents:
12439
diff
changeset
|
646 | PDNS_RECORD dr = NULL; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
647 | int type; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
648 | DNS_STATUS ds; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
649 | PurpleSrvTxtQueryData *query_data = data; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
650 | type = query_data->type; |
|
33879
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
651 | ds = DnsQuery_UTF8(query_data->query, type, DNS_QUERY_STANDARD, NULL, &dr, NULL); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
652 | if (ds != ERROR_SUCCESS) { |
|
12691
4c178bccdba7
[gaim-migrate @ 15034]
Daniel Atallah <datallah@pidgin.im>
parents:
12686
diff
changeset
|
653 | gchar *msg = g_win32_error_message(ds); |
| 24743 | 654 | if (type == DNS_TYPE_SRV) { |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
655 | query_data->error_message = g_strdup_printf("Couldn't look up SRV record. %s (%lu).\n", msg, ds); |
| 24743 | 656 | } else if (type == DNS_TYPE_TXT) { |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
657 | query_data->error_message = g_strdup_printf("Couldn't look up TXT record. %s (%lu).\n", msg, ds); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
658 | } |
|
12691
4c178bccdba7
[gaim-migrate @ 15034]
Daniel Atallah <datallah@pidgin.im>
parents:
12686
diff
changeset
|
659 | g_free(msg); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
660 | } else { |
| 24743 | 661 | if (type == DNS_TYPE_SRV) { |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
662 | PDNS_RECORD dr_tmp; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
663 | GList *lst = NULL; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
664 | DNS_SRV_DATA *srv_data; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
665 | PurpleSrvResponse *srvres; |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
666 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
667 | for (dr_tmp = dr; dr_tmp != NULL; dr_tmp = dr_tmp->pNext) { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
668 | /* Discard any incorrect entries. I'm not sure if this is necessary */ |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
669 | if (dr_tmp->wType != type || strcmp(dr_tmp->pName, query_data->query) != 0) { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
670 | continue; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
671 | } |
|
12451
d9feea46dac4
[gaim-migrate @ 14760]
Daniel Atallah <datallah@pidgin.im>
parents:
12439
diff
changeset
|
672 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
673 | srv_data = &dr_tmp->Data.SRV; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
674 | srvres = g_new0(PurpleSrvResponse, 1); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
675 | strncpy(srvres->hostname, srv_data->pNameTarget, 255); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
676 | srvres->hostname[255] = '\0'; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
677 | srvres->pref = srv_data->wPriority; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
678 | srvres->port = srv_data->wPort; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
679 | srvres->weight = srv_data->wWeight; |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
680 | |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
681 | lst = g_list_prepend(lst, srvres); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
682 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
683 | |
|
33879
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
684 | DnsRecordListFree(dr, DnsFreeRecordList); |
|
27456
4f0bc5271712
Changes to our DNS SRV record sorting, care of Vijay Vijay Raghunathan
Mark Doliner <markdoliner@pidgin.im>
parents:
27454
diff
changeset
|
685 | query_data->results = purple_srv_sort(lst); |
|
26970
b3dfce2dc9d3
Missed one (copying changes manually between computers is clearly an error-ful
Paul Aurich <darkrain42@pidgin.im>
parents:
26968
diff
changeset
|
686 | } else if (type == DNS_TYPE_TXT) { |
|
26765
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
687 | PDNS_RECORD dr_tmp; |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
688 | GList *lst = NULL; |
|
26765
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
689 | DNS_TXT_DATA *txt_data; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
690 | PurpleTxtResponse *txtres; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
691 | |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
692 | for (dr_tmp = dr; dr_tmp != NULL; dr_tmp = dr_tmp->pNext) { |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
693 | GString *s; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
694 | int i; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
695 | |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
696 | /* Discard any incorrect entries. I'm not sure if this is necessary */ |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
697 | if (dr_tmp->wType != type || strcmp(dr_tmp->pName, query_data->query) != 0) { |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
698 | continue; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
699 | } |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
700 | |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
701 | txt_data = &dr_tmp->Data.TXT; |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
702 | txtres = g_new0(PurpleTxtResponse, 1); |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
703 | |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
704 | s = g_string_new(""); |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
705 | for (i = 0; i < txt_data->dwStringCount; ++i) |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
706 | s = g_string_append(s, txt_data->pStringArray[i]); |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
707 | txtres->content = g_string_free(s, FALSE); |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
708 | |
|
27604
15e124d441cd
I was seeing some crashes when connecting to Google Talk on my work laptop.
Etan Reisner <deryni@pidgin.im>
parents:
27456
diff
changeset
|
709 | lst = g_list_append(lst, txtres); |
|
26765
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
710 | } |
|
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
711 | |
|
33879
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
712 | DnsRecordListFree(dr, DnsFreeRecordList); |
|
26765
fc156c427d59
First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses
Paul Aurich <darkrain42@pidgin.im>
parents:
26531
diff
changeset
|
713 | query_data->results = lst; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
714 | } else { |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
715 | |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
716 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
717 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
718 | |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
719 | /* back to main thread */ |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
720 | /* Note: this should *not* be attached to query_data->handle - it will cause leakage */ |
|
22351
6ca0640b3d31
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <markdoliner@pidgin.im>
parents:
22249
diff
changeset
|
721 | purple_timeout_add(0, res_main_thread_cb, query_data); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
722 | |
|
12691
4c178bccdba7
[gaim-migrate @ 15034]
Daniel Atallah <datallah@pidgin.im>
parents:
12686
diff
changeset
|
723 | g_thread_exit(NULL); |
|
4c178bccdba7
[gaim-migrate @ 15034]
Daniel Atallah <datallah@pidgin.im>
parents:
12686
diff
changeset
|
724 | return NULL; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
725 | } |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
726 | |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
727 | #endif |
|
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
728 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
729 | PurpleSrvTxtQueryData * |
|
32300
59a31f9f67fc
Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32141
diff
changeset
|
730 | purple_srv_resolve(PurpleAccount *account, const char *protocol, |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
731 | const char *transport, const char *domain, PurpleSrvCallback cb, |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
732 | gpointer extradata) |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
733 | { |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
734 | char *query; |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
735 | char *hostname; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
736 | PurpleSrvTxtQueryData *query_data; |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
737 | PurpleProxyType proxy_type; |
|
26968
0527c5cc906b
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <darkrain42@pidgin.im>
parents:
26766
diff
changeset
|
738 | #ifndef _WIN32 |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
739 | PurpleSrvInternalQuery internal_query; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
740 | int in[2], out[2]; |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
741 | int pid; |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
742 | #else |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
743 | GError* err = NULL; |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
744 | #endif |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
745 | |
|
25180
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
746 | if (!protocol || !*protocol || !transport || !*transport || !domain || !*domain) { |
|
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
747 | purple_debug_error("dnssrv", "Wrong arguments\n"); |
|
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
748 | cb(NULL, 0, extradata); |
|
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
749 | g_return_val_if_reached(NULL); |
|
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
750 | } |
|
3aecff7754d5
Fix a crash in DNS SRV resolution when one of the required parameters is NULL.
Florian Quèze <florian@instantbird.org>
parents:
24672
diff
changeset
|
751 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35372
diff
changeset
|
752 | proxy_type = purple_proxy_info_get_proxy_type( |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
753 | purple_proxy_get_setup(account)); |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
754 | if (proxy_type == PURPLE_PROXY_TOR) { |
|
35367
ea5534f263bb
Add some missing logging newlines
Daniel Atallah <datallah@pidgin.im>
parents:
33879
diff
changeset
|
755 | purple_debug_info("dnssrv", "Aborting SRV lookup in Tor Proxy mode.\n"); |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
756 | cb(NULL, 0, extradata); |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
757 | return NULL; |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
758 | } |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
759 | |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
760 | #ifdef USE_IDN |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
761 | if (!dns_str_is_ascii(domain)) { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
762 | int ret = purple_network_convert_idn_to_ascii(domain, &hostname); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
763 | if (ret != 0) { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
764 | purple_debug_error("dnssrv", "IDNA ToASCII failed\n"); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
765 | cb(NULL, 0, extradata); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
766 | return NULL; |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
767 | } |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
768 | } else /* Fallthru is intentional */ |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
769 | #endif |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
770 | hostname = g_strdup(domain); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
771 | |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
772 | query = g_strdup_printf("_%s._%s.%s", protocol, transport, hostname); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
773 | purple_debug_info("dnssrv","querying SRV record for %s: %s\n", domain, |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
774 | query); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
775 | g_free(hostname); |
| 31970 | 776 | |
|
31977
da742b7e1303
dnssrv: Hmph, this is what I get for swapping the argument order around and not paying attention
Paul Aurich <darkrain42@pidgin.im>
parents:
31976
diff
changeset
|
777 | query_data = query_data_new(PurpleDnsTypeSrv, query, extradata); |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
778 | query_data->cb.srv = cb; |
| 31970 | 779 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
780 | if (purple_srv_txt_query_ui_resolve(query_data)) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
781 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
782 | return query_data; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
783 | } |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
784 | |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
785 | #ifndef _WIN32 |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
786 | if(pipe(in) || pipe(out)) { |
| 15884 | 787 | purple_debug_error("dnssrv", "Could not create pipe\n"); |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
788 | g_free(query); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
789 | g_free(query_data); |
|
11382
4458ab177b10
[gaim-migrate @ 13609]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11381
diff
changeset
|
790 | cb(NULL, 0, extradata); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
791 | return NULL; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
792 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
793 | |
|
32141
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
794 | /* |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
795 | * TODO: We should put a cap on the number of forked processes that we |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
796 | * allow at any given time. If we get too many requests they |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
797 | * should be put into a queue and handled later. (This is what |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
798 | * we do for A record lookups.) |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
799 | */ |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
800 | pid = fork(); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
801 | if (pid == -1) { |
| 15884 | 802 | purple_debug_error("dnssrv", "Could not create process!\n"); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
803 | g_free(query); |
|
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
804 | g_free(query_data); |
|
11382
4458ab177b10
[gaim-migrate @ 13609]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11381
diff
changeset
|
805 | cb(NULL, 0, extradata); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
806 | return NULL; |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
807 | } |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
808 | |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
809 | /* Child */ |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
810 | if (pid == 0) |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
811 | { |
|
22249
18041843e873
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <markdoliner@pidgin.im>
parents:
22234
diff
changeset
|
812 | g_free(query); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
813 | g_free(query_data); |
|
22249
18041843e873
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <markdoliner@pidgin.im>
parents:
22234
diff
changeset
|
814 | |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
815 | close(out[0]); |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
816 | close(in[1]); |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
817 | resolve(in[0], out[1]); |
|
22249
18041843e873
Fix a memleak that doesn't matter because it's in a child process
Mark Doliner <markdoliner@pidgin.im>
parents:
22234
diff
changeset
|
818 | /* resolve() does not return */ |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
819 | } |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
820 | |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
821 | close(out[1]); |
|
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
822 | close(in[0]); |
|
11395
1b19bd77adf6
[gaim-migrate @ 13626]
Daniel Atallah <datallah@pidgin.im>
parents:
11382
diff
changeset
|
823 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
824 | internal_query.type = T_SRV; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
825 | strncpy(internal_query.query, query, 255); |
|
28612
5f60e92c2f49
Null-terminate this string explicitly to avoid valgrind complaining.
Paul Aurich <darkrain42@pidgin.im>
parents:
28291
diff
changeset
|
826 | internal_query.query[255] = '\0'; |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
827 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
828 | if (write(in[1], &internal_query, sizeof(internal_query)) < 0) |
| 15884 | 829 | purple_debug_error("dnssrv", "Could not write to SRV resolver\n"); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
830 | |
|
15776
cba54f9d2e51
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 <evands@pidgin.im>
parents:
15718
diff
changeset
|
831 | query_data->pid = pid; |
|
20128
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
832 | query_data->fd_out = out[0]; |
|
272326eb883e
applied changes from 31d62e1a78974a0239e86bfeb42b29ab75216114
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
833 | query_data->fd_in = in[1]; |
| 15884 | 834 | query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data); |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
835 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
836 | return query_data; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
837 | #else |
|
33883
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
838 | query_data->resolver = g_thread_try_new("dnssrv srv resolver", res_thread, query_data, &err); |
|
33879
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
839 | if (query_data->resolver == NULL) { |
|
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
840 | query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", (err && err->message) ? err->message : ""); |
|
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
841 | g_error_free(err); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
842 | } |
|
33883
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
843 | else |
|
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
844 | g_thread_unref(query_data->resolver); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
845 | |
| 15859 | 846 | /* The query isn't going to happen, so finish the SRV lookup now. |
| 847 | * Asynchronously call the callback since stuff may not expect | |
| 848 | * the callback to be called before this returns */ | |
| 849 | if (query_data->error_message != NULL) | |
|
22351
6ca0640b3d31
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <markdoliner@pidgin.im>
parents:
22249
diff
changeset
|
850 | query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
851 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
852 | return query_data; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
853 | #endif |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
854 | } |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
855 | |
|
32300
59a31f9f67fc
Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32141
diff
changeset
|
856 | PurpleSrvTxtQueryData *purple_txt_resolve(PurpleAccount *account, |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
857 | const char *owner, const char *domain, PurpleTxtCallback cb, |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
858 | gpointer extradata) |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
859 | { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
860 | char *query; |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
861 | char *hostname; |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
862 | PurpleSrvTxtQueryData *query_data; |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
863 | PurpleProxyType proxy_type; |
|
26968
0527c5cc906b
Build error/warning fixes. Still not tested because libxmpp.dll won't load.
Paul Aurich <darkrain42@pidgin.im>
parents:
26766
diff
changeset
|
864 | #ifndef _WIN32 |
|
23605
8d2e64e9208e
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23604
diff
changeset
|
865 | PurpleSrvInternalQuery internal_query; |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
866 | int in[2], out[2]; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
867 | int pid; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
868 | #else |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
869 | GError* err = NULL; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
870 | #endif |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
871 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35372
diff
changeset
|
872 | proxy_type = purple_proxy_info_get_proxy_type( |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
873 | purple_proxy_get_setup(account)); |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
874 | if (proxy_type == PURPLE_PROXY_TOR) { |
|
35367
ea5534f263bb
Add some missing logging newlines
Daniel Atallah <datallah@pidgin.im>
parents:
33879
diff
changeset
|
875 | purple_debug_info("dnssrv", "Aborting TXT lookup in Tor Proxy mode.\n"); |
|
31678
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
876 | cb(NULL, extradata); |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
877 | return NULL; |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
878 | } |
|
ad8a9a266b05
Add new DNS-related API to perform lookups in the context of an account.
Daniel Atallah <datallah@pidgin.im>
parents:
31676
diff
changeset
|
879 | |
|
27898
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
880 | #ifdef USE_IDN |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
881 | if (!dns_str_is_ascii(domain)) { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
882 | int ret = purple_network_convert_idn_to_ascii(domain, &hostname); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
883 | if (ret != 0) { |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
884 | purple_debug_error("dnssrv", "IDNA ToASCII failed\n"); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
885 | cb(NULL, extradata); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
886 | return NULL; |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
887 | } |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
888 | } else /* fallthru is intentional */ |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
889 | #endif |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
890 | hostname = g_strdup(domain); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
891 | |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
892 | query = g_strdup_printf("%s.%s", owner, hostname); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
893 | purple_debug_info("dnssrv","querying TXT record for %s: %s\n", domain, |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
894 | query); |
|
4a6450d92e11
Move the IDN support into the DNS routines.
Paul Aurich <darkrain42@pidgin.im>
parents:
27604
diff
changeset
|
895 | g_free(hostname); |
| 31970 | 896 | |
|
31976
5b5accfbac20
dnssrv: Refactor to reduce code duplication
Paul Aurich <darkrain42@pidgin.im>
parents:
31975
diff
changeset
|
897 | query_data = query_data_new(PurpleDnsTypeTxt, query, extradata); |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
898 | query_data->cb.txt = cb; |
| 31970 | 899 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
900 | if (purple_srv_txt_query_ui_resolve(query_data)) { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
901 | /* query intentionally not freed |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
902 | */ |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
903 | return query_data; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
904 | } |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
905 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
906 | #ifndef _WIN32 |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
907 | if(pipe(in) || pipe(out)) { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
908 | purple_debug_error("dnssrv", "Could not create pipe\n"); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
909 | g_free(query); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
910 | g_free(query_data); |
|
26766
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
911 | cb(NULL, extradata); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
912 | return NULL; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
913 | } |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
914 | |
|
32141
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
915 | /* |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
916 | * TODO: We should put a cap on the number of forked processes that we |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
917 | * allow at any given time. If we get too many requests they |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
918 | * should be put into a queue and handled later. (This is what |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
919 | * we do for A record lookups.) |
|
6d31ebf649f7
A while ago I noticed that we don't have enforce a max on the
Mark Doliner <markdoliner@pidgin.im>
parents:
32004
diff
changeset
|
920 | */ |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
921 | pid = fork(); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
922 | if (pid == -1) { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
923 | purple_debug_error("dnssrv", "Could not create process!\n"); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
924 | g_free(query); |
|
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
925 | g_free(query_data); |
|
26766
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
926 | cb(NULL, extradata); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
927 | return NULL; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
928 | } |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
929 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
930 | /* Child */ |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
931 | if (pid == 0) |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
932 | { |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
933 | g_free(query); |
|
31972
814e7451ef09
dnssrv: Proper memory management here, which stops random crashes elsewhere.
Paul Aurich <darkrain42@pidgin.im>
parents:
31971
diff
changeset
|
934 | g_free(query_data); |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
935 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
936 | close(out[0]); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
937 | close(in[1]); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
938 | resolve(in[0], out[1]); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
939 | /* resolve() does not return */ |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
940 | } |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
941 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
942 | close(out[1]); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
943 | close(in[0]); |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
944 | |
|
23605
8d2e64e9208e
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23604
diff
changeset
|
945 | internal_query.type = T_TXT; |
|
8d2e64e9208e
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23604
diff
changeset
|
946 | strncpy(internal_query.query, query, 255); |
|
28675
88bea0ad71ad
Shut up valgrind ("unitialized bytes(s)...") and changelog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28674
diff
changeset
|
947 | internal_query.query[255] = '\0'; |
|
27454
e950ec66bb5e
Strip trailing whitespace and spaces to tab
Mark Doliner <markdoliner@pidgin.im>
parents:
27157
diff
changeset
|
948 | |
|
23605
8d2e64e9208e
* fixing some bugs, finishing support for TXT queries
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23604
diff
changeset
|
949 | if (write(in[1], &internal_query, sizeof(internal_query)) < 0) |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
950 | purple_debug_error("dnssrv", "Could not write to TXT resolver\n"); |
| 31970 | 951 | |
|
23604
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
952 | query_data->pid = pid; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
953 | query_data->fd_out = out[0]; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
954 | query_data->fd_in = in[1]; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
955 | query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data); |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
956 | |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
957 | return query_data; |
|
f34d41640be2
* some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23352
diff
changeset
|
958 | #else |
|
33883
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
959 | query_data->resolver = g_thread_try_new("dnssrv srv resolver", res_thread, query_data, &err); |
|
33879
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
960 | if (query_data->resolver == NULL) { |
|
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
961 | query_data->error_message = g_strdup_printf("TXT thread create failure: %s\n", (err && err->message) ? err->message : ""); |
|
d3ef04981ee5
dnssrv: Link against dnsapi and call DnsQuery_UTF8 and DnsRecordListFree
Daniel Atallah <datallah@pidgin.im>
parents:
32004
diff
changeset
|
962 | g_error_free(err); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
963 | } |
|
33883
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
964 | else |
|
8a0d96bd9cf4
Replace deprecated g_thread_create with g_thread_try_new
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33880
diff
changeset
|
965 | g_thread_unref(query_data->resolver); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
966 | |
|
26766
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
967 | /* The query isn't going to happen, so finish the TXT lookup now. |
| 15859 | 968 | * Asynchronously call the callback since stuff may not expect |
| 969 | * the callback to be called before this returns */ | |
| 970 | if (query_data->error_message != NULL) | |
|
22351
6ca0640b3d31
Change some g_idle_add(...) calls in libpurple to purple_timeout_add(0, ...)
Mark Doliner <markdoliner@pidgin.im>
parents:
22249
diff
changeset
|
971 | query_data->handle = purple_timeout_add(0, res_main_thread_cb, query_data); |
|
14374
a93eedc7aa6b
[gaim-migrate @ 17002]
Daniel Atallah <datallah@pidgin.im>
parents:
14370
diff
changeset
|
972 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
973 | return query_data; |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
974 | #endif |
|
11373
80fd6df6fbe0
[gaim-migrate @ 13598]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
975 | } |
|
11379
a5a66b0e8b6e
[gaim-migrate @ 13605]
Daniel Atallah <datallah@pidgin.im>
parents:
11373
diff
changeset
|
976 | |
|
26766
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
977 | const gchar * |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
978 | purple_txt_response_get_content(PurpleTxtResponse *resp) |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
979 | { |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
980 | g_return_val_if_fail(resp != NULL, NULL); |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
981 | |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
982 | return resp->content; |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
983 | } |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
984 | |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
985 | void purple_txt_response_destroy(PurpleTxtResponse *resp) |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
986 | { |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
987 | g_return_if_fail(resp != NULL); |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
988 | |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
989 | g_free(resp->content); |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
990 | g_free(resp); |
|
854a2eaa3862
Hide PurpleTxtResponse and use a more purple API
Paul Aurich <darkrain42@pidgin.im>
parents:
26765
diff
changeset
|
991 | } |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
992 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
993 | /* |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
994 | * Only used as the callback for the ui ops. |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
995 | */ |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
996 | static void |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
997 | purple_srv_query_resolved(PurpleSrvTxtQueryData *query_data, GList *records) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
998 | { |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
999 | GList *l; |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1000 | PurpleSrvResponse *records_array; |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1001 | int i = 0, length; |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1002 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1003 | g_return_if_fail(records != NULL); |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1004 | |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1005 | if (query_data->cb.srv == NULL) { |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1006 | purple_srv_txt_query_destroy(query_data); |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1007 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1008 | while (records) { |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1009 | g_free(records->data); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1010 | records = g_list_delete_link(records, records); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1011 | } |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1012 | return; |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1013 | } |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1014 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1015 | records = purple_srv_sort(records); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1016 | length = g_list_length(records); |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1017 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1018 | purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1019 | query_data->query, length); |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1020 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1021 | records_array = g_new(PurpleSrvResponse, length); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1022 | for (l = records; l; l = l->next, i++) { |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1023 | records_array[i] = *(PurpleSrvResponse *)l->data; |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1024 | } |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1025 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1026 | query_data->cb.srv(records_array, length, query_data->extradata); |
| 31970 | 1027 | |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1028 | purple_srv_txt_query_destroy(query_data); |
| 31970 | 1029 | |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1030 | while (records) { |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1031 | g_free(records->data); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1032 | records = g_list_delete_link(records, records); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1033 | } |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1034 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1035 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1036 | /* |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1037 | * Only used as the callback for the ui ops. |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1038 | */ |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1039 | static void |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1040 | purple_txt_query_resolved(PurpleSrvTxtQueryData *query_data, GList *entries) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1041 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1042 | g_return_if_fail(entries != NULL); |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1043 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1044 | purple_debug_info("dnssrv", "TXT entries resolved for %s, count: %d\n", query_data->query, g_list_length(entries)); |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1045 | |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1046 | /* the callback should g_free the entries. |
|
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1047 | */ |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1048 | if (query_data->cb.txt != NULL) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1049 | query_data->cb.txt(entries, query_data->extradata); |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1050 | else { |
|
31971
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1051 | while (entries) { |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1052 | g_free(entries->data); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1053 | entries = g_list_delete_link(entries, entries); |
|
8a6873e1920c
dnssrv: Avoid a few extraneous iterations through the list. Refs #12647
Paul Aurich <darkrain42@pidgin.im>
parents:
31970
diff
changeset
|
1054 | } |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1055 | } |
| 31970 | 1056 | |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1057 | purple_srv_txt_query_destroy(query_data); |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1058 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1059 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1060 | static void |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1061 | purple_srv_query_failed(PurpleSrvTxtQueryData *query_data, const gchar *error_message) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1062 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1063 | purple_debug_error("dnssrv", "%s\n", error_message); |
| 31970 | 1064 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1065 | if (query_data->cb.srv != NULL) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1066 | query_data->cb.srv(NULL, 0, query_data->extradata); |
| 31970 | 1067 | |
|
31969
82e51b0825bc
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
31738
diff
changeset
|
1068 | purple_srv_txt_query_destroy(query_data); |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1069 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1070 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1071 | static gboolean |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1072 | purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1073 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1074 | PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops(); |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1075 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1076 | if (ops && ops->resolve) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1077 | return ops->resolve(query_data, (query_data->type == T_SRV ? purple_srv_query_resolved : purple_txt_query_resolved), purple_srv_query_failed); |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1078 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1079 | return FALSE; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1080 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1081 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1082 | void |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1083 | purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1084 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1085 | srv_txt_query_ui_ops = ops; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1086 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1087 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1088 | PurpleSrvTxtQueryUiOps * |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1089 | purple_srv_txt_query_get_ui_ops(void) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1090 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1091 | /* It is perfectly acceptable for srv_txt_query_ui_ops to be NULL; this just |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1092 | * means that the default platform-specific implementation will be used. |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1093 | */ |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1094 | return srv_txt_query_ui_ops; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1095 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1096 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1097 | char * |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1098 | purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data) |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1099 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1100 | g_return_val_if_fail(query_data != NULL, NULL); |
| 31970 | 1101 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1102 | return query_data->query; |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1103 | } |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1104 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1105 | |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1106 | int |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35372
diff
changeset
|
1107 | purple_srv_txt_query_get_query_type(PurpleSrvTxtQueryData *query_data) |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1108 | { |
|
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1109 | g_return_val_if_fail(query_data != NULL, 0); |
| 31970 | 1110 | |
|
31625
1097ed538036
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30792
diff
changeset
|
1111 | return query_data->type; |
|
31676
cb214cdd8a59
The T_SRV and T_TXT defines are needed on WIN32 too.
Daniel Atallah <datallah@pidgin.im>
parents:
31640
diff
changeset
|
1112 | } |
| 35572 | 1113 | |
| 1114 | /************************************************************************** | |
| 1115 | * GBoxed code | |
| 1116 | **************************************************************************/ | |
| 1117 | static PurpleSrvTxtQueryUiOps * | |
| 1118 | purple_srv_txt_query_ui_ops_copy(PurpleSrvTxtQueryUiOps *ops) | |
| 1119 | { | |
| 1120 | PurpleSrvTxtQueryUiOps *ops_new; | |
| 1121 | ||
| 1122 | g_return_val_if_fail(ops != NULL, NULL); | |
| 1123 | ||
| 1124 | ops_new = g_new(PurpleSrvTxtQueryUiOps, 1); | |
| 1125 | *ops_new = *ops; | |
| 1126 | ||
| 1127 | return ops_new; | |
| 1128 | } | |
| 1129 | ||
| 1130 | GType | |
| 1131 | purple_srv_txt_query_ui_ops_get_type(void) | |
| 1132 | { | |
| 1133 | static GType type = 0; | |
| 1134 | ||
| 1135 | if (type == 0) { | |
| 1136 | type = g_boxed_type_register_static("PurpleSrvTxtQueryUiOps", | |
| 1137 | (GBoxedCopyFunc)purple_srv_txt_query_ui_ops_copy, | |
|
35597
7fcfcf147b99
Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents:
35572
diff
changeset
|
1138 | (GBoxedFreeFunc)g_free); |
| 35572 | 1139 | } |
| 1140 | ||
| 1141 | return type; | |
| 1142 | } |