Mercurial > pidgin
comparison src/protocols/oscar/family_userlookup.c @ 13592:6519aeb66b31
[gaim-migrate @ 15978]
Holy cow this is crazy.
34 files changed, 5760 insertions(+), 8517 deletions(-)
* Non-blocking I/O for all of oscar. That includes normal FLAP
connections as well as file transfers and direct IM.
* Kick-ass file transfer and direct IM. Either party can request
the connection. Gaim will try both the "public" IP and the
"client" IP. It'll fall back to transferring through a proxy
if that fails. Should be relatively few memleaks (I didn't
have a lot of confidence in the non-memleakiness of the old
code). And the code is reasonably generic, so it shouldn't
be too much work to add voice chat. This might still be a
LITTLE buggy, but it shouldn't be too bad. If anything, file
transfer will be more buggy than direct IM. And sending a
file will be more buggy than receiving a file. Bug reports
with a series of steps to reproduce are welcome.
* I merged OscarData and aim_session_t
* Somewhere between 50 and 100 hours of work.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 07 Apr 2006 05:10:56 +0000 |
parents | 87a7c3077c19 |
children | b198d0c26b83 |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
30 /* | 30 /* |
31 * Subtype 0x0001 | 31 * Subtype 0x0001 |
32 * | 32 * |
33 * XXX can this be integrated with the rest of the error handling? | 33 * XXX can this be integrated with the rest of the error handling? |
34 */ | 34 */ |
35 static int error(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 35 static int error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
36 { | 36 { |
37 int ret = 0; | 37 int ret = 0; |
38 aim_rxcallback_t userfunc; | 38 aim_rxcallback_t userfunc; |
39 aim_snac_t *snac2; | 39 aim_snac_t *snac2; |
40 | 40 |
41 /* XXX the modules interface should have already retrieved this for us */ | 41 /* XXX the modules interface should have already retrieved this for us */ |
42 if (!(snac2 = aim_remsnac(sess, snac->id))) { | 42 if (!(snac2 = aim_remsnac(od, snac->id))) { |
43 gaim_debug_misc("oscar", "search error: couldn't get a snac for 0x%08lx\n", snac->id); | 43 gaim_debug_misc("oscar", "search error: couldn't get a snac for 0x%08lx\n", snac->id); |
44 return 0; | 44 return 0; |
45 } | 45 } |
46 | 46 |
47 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 47 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
48 ret = userfunc(sess, rx, snac2->data /* address */); | 48 ret = userfunc(od, conn, frame, snac2->data /* address */); |
49 | 49 |
50 /* XXX freesnac()? */ | 50 /* XXX freesnac()? */ |
51 if (snac2) | 51 if (snac2) |
52 free(snac2->data); | 52 free(snac2->data); |
53 free(snac2); | 53 free(snac2); |
57 | 57 |
58 /* | 58 /* |
59 * Subtype 0x0002 | 59 * Subtype 0x0002 |
60 * | 60 * |
61 */ | 61 */ |
62 faim_export int aim_search_address(OscarSession *sess, OscarConnection *conn, const char *address) | 62 int aim_search_address(OscarData *od, const char *address) |
63 { | 63 { |
64 FlapFrame *fr; | 64 FlapConnection *conn; |
65 FlapFrame *frame; | |
65 aim_snacid_t snacid; | 66 aim_snacid_t snacid; |
66 | 67 |
67 if (!sess || !conn || !address) | 68 conn = flap_connection_findbygroup(od, SNAC_FAMILY_USERLOOKUP); |
69 | |
70 if (!od || !conn || !address) | |
68 return -EINVAL; | 71 return -EINVAL; |
69 | 72 |
70 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+strlen(address)))) | 73 frame = flap_frame_new(od, 0x02, 10+strlen(address)); |
71 return -ENOMEM; | |
72 | 74 |
73 snacid = aim_cachesnac(sess, 0x000a, 0x0002, 0x0000, strdup(address), strlen(address)+1); | 75 snacid = aim_cachesnac(od, 0x000a, 0x0002, 0x0000, strdup(address), strlen(address)+1); |
74 aim_putsnac(&fr->data, 0x000a, 0x0002, 0x0000, snacid); | 76 aim_putsnac(&frame->data, 0x000a, 0x0002, 0x0000, snacid); |
75 | |
76 aimbs_putstr(&fr->data, address); | |
77 | 77 |
78 aim_tx_enqueue(sess, fr); | 78 byte_stream_putstr(&frame->data, address); |
79 | |
80 flap_connection_send(conn, frame); | |
79 | 81 |
80 return 0; | 82 return 0; |
81 } | 83 } |
82 | 84 |
83 /* | 85 /* |
84 * Subtype 0x0003 | 86 * Subtype 0x0003 |
85 * | 87 * |
86 */ | 88 */ |
87 static int reply(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 89 static int reply(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
88 { | 90 { |
89 int j = 0, m, ret = 0; | 91 int j = 0, m, ret = 0; |
90 aim_tlvlist_t *tlvlist; | 92 aim_tlvlist_t *tlvlist; |
91 char *cur = NULL, *buf = NULL; | 93 char *cur = NULL, *buf = NULL; |
92 aim_rxcallback_t userfunc; | 94 aim_rxcallback_t userfunc; |
93 aim_snac_t *snac2; | 95 aim_snac_t *snac2; |
94 char *searchaddr = NULL; | 96 char *searchaddr = NULL; |
95 | 97 |
96 if ((snac2 = aim_remsnac(sess, snac->id))) | 98 if ((snac2 = aim_remsnac(od, snac->id))) |
97 searchaddr = (char *)snac2->data; | 99 searchaddr = (char *)snac2->data; |
98 | 100 |
99 tlvlist = aim_tlvlist_read(bs); | 101 tlvlist = aim_tlvlist_read(bs); |
100 m = aim_tlvlist_count(&tlvlist); | 102 m = aim_tlvlist_count(&tlvlist); |
101 | 103 |
102 /* XXX uhm. | 104 /* XXX uhm. |
103 * This is the only place that uses something other than 1 for the 3rd | 105 * This is the only place that uses something other than 1 for the 3rd |
104 * parameter to aim_tlv_gettlv_whatever(). | 106 * parameter to aim_tlv_gettlv_whatever(). |
105 */ | 107 */ |
106 while ((cur = aim_tlv_getstr(tlvlist, 0x0001, j+1)) && j < m) { | 108 while ((cur = aim_tlv_getstr(tlvlist, 0x0001, j+1)) && j < m) |
109 { | |
107 buf = realloc(buf, (j+1) * (MAXSNLEN+1)); | 110 buf = realloc(buf, (j+1) * (MAXSNLEN+1)); |
108 | 111 |
109 strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN); | 112 strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN); |
110 free(cur); | 113 free(cur); |
111 | 114 |
112 j++; | 115 j++; |
113 } | 116 } |
114 | 117 |
115 aim_tlvlist_free(&tlvlist); | 118 aim_tlvlist_free(&tlvlist); |
116 | 119 |
117 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 120 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
118 ret = userfunc(sess, rx, searchaddr, j, buf); | 121 ret = userfunc(od, conn, frame, searchaddr, j, buf); |
119 | 122 |
120 /* XXX freesnac()? */ | 123 /* XXX freesnac()? */ |
121 if (snac2) | 124 if (snac2) |
122 free(snac2->data); | 125 free(snac2->data); |
123 free(snac2); | 126 free(snac2); |
125 free(buf); | 128 free(buf); |
126 | 129 |
127 return ret; | 130 return ret; |
128 } | 131 } |
129 | 132 |
130 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 133 static int |
134 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
131 { | 135 { |
132 | |
133 if (snac->subtype == 0x0001) | 136 if (snac->subtype == 0x0001) |
134 return error(sess, mod, rx, snac, bs); | 137 return error(od, conn, mod, frame, snac, bs); |
135 else if (snac->subtype == 0x0003) | 138 else if (snac->subtype == 0x0003) |
136 return reply(sess, mod, rx, snac, bs); | 139 return reply(od, conn, mod, frame, snac, bs); |
137 | 140 |
138 return 0; | 141 return 0; |
139 } | 142 } |
140 | 143 |
141 faim_internal int search_modfirst(OscarSession *sess, aim_module_t *mod) | 144 int |
145 search_modfirst(OscarData *od, aim_module_t *mod) | |
142 { | 146 { |
143 | |
144 mod->family = 0x000a; | 147 mod->family = 0x000a; |
145 mod->version = 0x0001; | 148 mod->version = 0x0001; |
146 mod->toolid = 0x0110; | 149 mod->toolid = 0x0110; |
147 mod->toolversion = 0x0629; | 150 mod->toolversion = 0x0629; |
148 mod->flags = 0; | 151 mod->flags = 0; |