Wed, 12 Dec 2018 16:43:40 -0600
oscar: Remove dead usage of tm.tm_gmtoff and HAVE_TM_GMTOFF config
Oscar at one time used tm.tm_gmtoff in order to offset a timestamp.
Now, the function is always passed 0 for the timestamp, which avoids
this code path. Therefore, this patch removes the timestamp argument
from the function, removes the dead code path which included the only
usage of tm.tm_gmtoff, and gets rid of the check/setting in meson for
HAVE_TM_GMTOFF.
| 13235 | 1 | /* |
| 15884 | 2 | * Purple's oscar protocol plugin |
| 13235 | 3 | * This file is the legal property of its developers. |
| 4 | * Please see the AUTHORS file distributed alongside this file. | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation; either | |
| 9 | * version 2 of the License, or (at your option) any later version. | |
| 10 | * | |
| 11 | * This library is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this library; 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:
17443
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 13235 | 19 | */ |
| 20 | ||
| 21 | /* | |
| 22 | * Family 0x000a - User Search. | |
| 23 | * | |
| 24 | * TODO: Add aim_usersearch_name() | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include "oscar.h" | |
| 29 | ||
| 30 | /* | |
| 31 | * Subtype 0x0001 | |
| 32 | * | |
| 33 | * XXX can this be integrated with the rest of the error handling? | |
| 34 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
35 | static int error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 36 | { |
| 37 | int ret = 0; | |
| 38 | aim_rxcallback_t userfunc; | |
| 39 | aim_snac_t *snac2; | |
| 40 | ||
| 41 | /* XXX the modules interface should have already retrieved this for us */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
42 | if (!(snac2 = aim_remsnac(od, snac->id))) { |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
43 | purple_debug_misc("oscar", "search error: couldn't get a snac for 0x%08x\n", snac->id); |
| 13235 | 44 | return 0; |
| 45 | } | |
| 46 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
47 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
48 | ret = userfunc(od, conn, frame, snac2->data /* address */); |
| 13235 | 49 | |
| 50 | /* XXX freesnac()? */ | |
| 51 | if (snac2) | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
52 | g_free(snac2->data); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
53 | g_free(snac2); |
| 13235 | 54 | |
| 55 | return ret; | |
| 56 | } | |
| 57 | ||
| 58 | /* | |
| 59 | * Subtype 0x0002 | |
| 60 | * | |
| 61 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
62 | int aim_search_address(OscarData *od, const char *address) |
| 13235 | 63 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
64 | FlapConnection *conn; |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
65 | ByteStream bs; |
| 13235 | 66 | aim_snacid_t snacid; |
| 67 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
68 | conn = flap_connection_findbygroup(od, SNAC_FAMILY_USERLOOKUP); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
69 | |
|
13665
c8984bccd64c
[gaim-migrate @ 16066]
Mark Doliner <markdoliner@pidgin.im>
parents:
13663
diff
changeset
|
70 | if (!conn || !address) |
| 13235 | 71 | return -EINVAL; |
| 72 | ||
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
73 | byte_stream_new(&bs, strlen(address)); |
|
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
74 | |
|
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
75 | byte_stream_putstr(&bs, address); |
| 13235 | 76 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23004
diff
changeset
|
77 | snacid = aim_cachesnac(od, SNAC_FAMILY_USERLOOKUP, 0x0002, 0x0000, address, strlen(address)+1); |
|
30678
78aacd015725
Removed unused "flags" parameter.
Ivan Komarov <ivan.komarov@pidgin.im>
parents:
23456
diff
changeset
|
78 | flap_connection_send_snac(od, conn, SNAC_FAMILY_USERLOOKUP, 0x0002, snacid, &bs); |
| 13235 | 79 | |
|
22860
2b0e247173b2
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evands@pidgin.im>
parents:
22622
diff
changeset
|
80 | byte_stream_destroy(&bs); |
|
23004
0d9272ff5e50
Minor changes... mostly whitespace related.
Mark Doliner <markdoliner@pidgin.im>
parents:
22860
diff
changeset
|
81 | |
| 13235 | 82 | return 0; |
| 83 | } | |
| 84 | ||
| 85 | /* | |
| 86 | * Subtype 0x0003 | |
| 87 | * | |
| 88 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
89 | static int reply(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 90 | { |
| 91 | int j = 0, m, ret = 0; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
92 | GSList *tlvlist; |
| 13235 | 93 | char *cur = NULL, *buf = NULL; |
| 94 | aim_rxcallback_t userfunc; | |
| 95 | aim_snac_t *snac2; | |
|
13663
de16367fd001
[gaim-migrate @ 16064]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
96 | const char *searchaddr = NULL; |
| 13235 | 97 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
98 | if ((snac2 = aim_remsnac(od, snac->id))) |
|
13663
de16367fd001
[gaim-migrate @ 16064]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
99 | searchaddr = (const char *)snac2->data; |
| 13235 | 100 | |
| 101 | tlvlist = aim_tlvlist_read(bs); | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
102 | m = aim_tlvlist_count(tlvlist); |
| 13235 | 103 | |
| 104 | /* XXX uhm. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
105 | * This is the only place that uses something other than 1 for the 3rd |
| 13235 | 106 | * parameter to aim_tlv_gettlv_whatever(). |
| 107 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
108 | while ((cur = aim_tlv_getstr(tlvlist, 0x0001, j+1)) && j < m) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
109 | { |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
110 | buf = g_realloc(buf, (j+1) * (MAXSNLEN+1)); |
| 13235 | 111 | |
| 112 | strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN); | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
113 | g_free(cur); |
| 13235 | 114 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
115 | j++; |
| 13235 | 116 | } |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
117 | g_free(cur); |
| 13235 | 118 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17280
diff
changeset
|
119 | aim_tlvlist_free(tlvlist); |
| 13235 | 120 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
121 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
122 | ret = userfunc(od, conn, frame, searchaddr, j, buf); |
| 13235 | 123 | |
| 124 | /* XXX freesnac()? */ | |
| 125 | if (snac2) | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
126 | g_free(snac2->data); |
|
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
127 | g_free(snac2); |
| 13235 | 128 | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
129 | g_free(buf); |
| 13235 | 130 | |
| 131 | return ret; | |
| 132 | } | |
| 133 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
134 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
135 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 136 | { |
| 137 | if (snac->subtype == 0x0001) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
138 | return error(od, conn, mod, frame, snac, bs); |
| 13235 | 139 | else if (snac->subtype == 0x0003) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
140 | return reply(od, conn, mod, frame, snac, bs); |
| 13235 | 141 | |
| 142 | return 0; | |
| 143 | } | |
| 144 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
145 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
146 | search_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 147 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23004
diff
changeset
|
148 | mod->family = SNAC_FAMILY_USERLOOKUP; |
| 13235 | 149 | mod->version = 0x0001; |
| 150 | mod->toolid = 0x0110; | |
| 151 | mod->toolversion = 0x0629; | |
| 152 | mod->flags = 0; | |
| 153 | strncpy(mod->name, "userlookup", sizeof(mod->name)); | |
| 154 | mod->snachandler = snachandler; | |
| 155 | ||
| 156 | return 0; | |
| 157 | } |