Mercurial > pidgin
comparison libpurple/protocols/oscar/family_odir.c @ 17369:f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
No functionality change.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 29 May 2007 09:51:51 +0000 |
parents | 1927f4ead3ca |
children | 44b4e8bd759b |
comparison
equal
deleted
inserted
replaced
17368:b31f53796f3b | 17369:f80f7e1047be |
---|---|
41 int aim_odir_email(OscarData *od, const char *region, const char *email) | 41 int aim_odir_email(OscarData *od, const char *region, const char *email) |
42 { | 42 { |
43 FlapConnection *conn; | 43 FlapConnection *conn; |
44 FlapFrame *frame; | 44 FlapFrame *frame; |
45 aim_snacid_t snacid; | 45 aim_snacid_t snacid; |
46 aim_tlvlist_t *tl = NULL; | 46 GSList *tlvlist = NULL; |
47 | 47 |
48 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region || !email) | 48 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region || !email) |
49 return -EINVAL; | 49 return -EINVAL; |
50 | 50 |
51 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 51 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
52 aim_tlvlist_add_str(&tl, 0x001c, region); | 52 aim_tlvlist_add_str(&tlvlist, 0x001c, region); |
53 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ | 53 aim_tlvlist_add_16(&tlvlist, 0x000a, 0x0001); /* Type of search */ |
54 aim_tlvlist_add_str(&tl, 0x0005, email); | 54 aim_tlvlist_add_str(&tlvlist, 0x0005, email); |
55 | 55 |
56 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); | 56 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(tlvlist)); |
57 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); | 57 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
58 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); | 58 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
59 | 59 |
60 aim_tlvlist_write(&frame->data, &tl); | 60 aim_tlvlist_write(&frame->data, &tlvlist); |
61 aim_tlvlist_free(&tl); | 61 aim_tlvlist_free(tlvlist); |
62 | 62 |
63 flap_connection_send(conn, frame); | 63 flap_connection_send(conn, frame); |
64 | 64 |
65 return 0; | 65 return 0; |
66 } | 66 } |
89 int aim_odir_name(OscarData *od, const char *region, const char *first, const char *middle, const char *last, const char *maiden, const char *nick, const char *city, const char *state, const char *country, const char *zip, const char *address) | 89 int aim_odir_name(OscarData *od, const char *region, const char *first, const char *middle, const char *last, const char *maiden, const char *nick, const char *city, const char *state, const char *country, const char *zip, const char *address) |
90 { | 90 { |
91 FlapConnection *conn; | 91 FlapConnection *conn; |
92 FlapFrame *frame; | 92 FlapFrame *frame; |
93 aim_snacid_t snacid; | 93 aim_snacid_t snacid; |
94 aim_tlvlist_t *tl = NULL; | 94 GSList *tlvlist = NULL; |
95 | 95 |
96 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) | 96 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) |
97 return -EINVAL; | 97 return -EINVAL; |
98 | 98 |
99 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 99 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
100 aim_tlvlist_add_str(&tl, 0x001c, region); | 100 aim_tlvlist_add_str(&tlvlist, 0x001c, region); |
101 aim_tlvlist_add_16(&tl, 0x000a, 0x0000); /* Type of search */ | 101 aim_tlvlist_add_16(&tlvlist, 0x000a, 0x0000); /* Type of search */ |
102 if (first) | 102 if (first) |
103 aim_tlvlist_add_str(&tl, 0x0001, first); | 103 aim_tlvlist_add_str(&tlvlist, 0x0001, first); |
104 if (last) | 104 if (last) |
105 aim_tlvlist_add_str(&tl, 0x0002, last); | 105 aim_tlvlist_add_str(&tlvlist, 0x0002, last); |
106 if (middle) | 106 if (middle) |
107 aim_tlvlist_add_str(&tl, 0x0003, middle); | 107 aim_tlvlist_add_str(&tlvlist, 0x0003, middle); |
108 if (maiden) | 108 if (maiden) |
109 aim_tlvlist_add_str(&tl, 0x0004, maiden); | 109 aim_tlvlist_add_str(&tlvlist, 0x0004, maiden); |
110 if (country) | 110 if (country) |
111 aim_tlvlist_add_str(&tl, 0x0006, country); | 111 aim_tlvlist_add_str(&tlvlist, 0x0006, country); |
112 if (state) | 112 if (state) |
113 aim_tlvlist_add_str(&tl, 0x0007, state); | 113 aim_tlvlist_add_str(&tlvlist, 0x0007, state); |
114 if (city) | 114 if (city) |
115 aim_tlvlist_add_str(&tl, 0x0008, city); | 115 aim_tlvlist_add_str(&tlvlist, 0x0008, city); |
116 if (nick) | 116 if (nick) |
117 aim_tlvlist_add_str(&tl, 0x000c, nick); | 117 aim_tlvlist_add_str(&tlvlist, 0x000c, nick); |
118 if (zip) | 118 if (zip) |
119 aim_tlvlist_add_str(&tl, 0x000d, zip); | 119 aim_tlvlist_add_str(&tlvlist, 0x000d, zip); |
120 if (address) | 120 if (address) |
121 aim_tlvlist_add_str(&tl, 0x0021, address); | 121 aim_tlvlist_add_str(&tlvlist, 0x0021, address); |
122 | 122 |
123 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); | 123 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(tlvlist)); |
124 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); | 124 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
125 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); | 125 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
126 | 126 |
127 aim_tlvlist_write(&frame->data, &tl); | 127 aim_tlvlist_write(&frame->data, &tlvlist); |
128 aim_tlvlist_free(&tl); | 128 aim_tlvlist_free(tlvlist); |
129 | 129 |
130 flap_connection_send(conn, frame); | 130 flap_connection_send(conn, frame); |
131 | 131 |
132 return 0; | 132 return 0; |
133 } | 133 } |
143 int aim_odir_interest(OscarData *od, const char *region, const char *interest) | 143 int aim_odir_interest(OscarData *od, const char *region, const char *interest) |
144 { | 144 { |
145 FlapConnection *conn; | 145 FlapConnection *conn; |
146 FlapFrame *frame; | 146 FlapFrame *frame; |
147 aim_snacid_t snacid; | 147 aim_snacid_t snacid; |
148 aim_tlvlist_t *tl = NULL; | 148 GSList *tlvlist = NULL; |
149 | 149 |
150 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) | 150 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) |
151 return -EINVAL; | 151 return -EINVAL; |
152 | 152 |
153 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 153 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
154 aim_tlvlist_add_str(&tl, 0x001c, region); | 154 aim_tlvlist_add_str(&tlvlist, 0x001c, region); |
155 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ | 155 aim_tlvlist_add_16(&tlvlist, 0x000a, 0x0001); /* Type of search */ |
156 if (interest) | 156 if (interest) |
157 aim_tlvlist_add_str(&tl, 0x0001, interest); | 157 aim_tlvlist_add_str(&tlvlist, 0x0001, interest); |
158 | 158 |
159 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); | 159 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(tlvlist)); |
160 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); | 160 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
161 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); | 161 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
162 | 162 |
163 aim_tlvlist_write(&frame->data, &tl); | 163 aim_tlvlist_write(&frame->data, &tlvlist); |
164 aim_tlvlist_free(&tl); | 164 aim_tlvlist_free(tlvlist); |
165 | 165 |
166 flap_connection_send(conn, frame); | 166 flap_connection_send(conn, frame); |
167 | 167 |
168 return 0; | 168 return 0; |
169 } | 169 } |
187 numresults = byte_stream_get16(bs); /* Number of results to follow */ | 187 numresults = byte_stream_get16(bs); /* Number of results to follow */ |
188 | 188 |
189 /* Allocate a linked list, 1 node per result */ | 189 /* Allocate a linked list, 1 node per result */ |
190 while (numresults) { | 190 while (numresults) { |
191 struct aim_odir *new; | 191 struct aim_odir *new; |
192 aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, byte_stream_get16(bs)); | 192 GSList *tlvlist = aim_tlvlist_readnum(bs, byte_stream_get16(bs)); |
193 new = (struct aim_odir *)g_malloc(sizeof(struct aim_odir)); | 193 new = (struct aim_odir *)g_malloc(sizeof(struct aim_odir)); |
194 new->first = aim_tlv_getstr(tl, 0x0001, 1); | 194 new->first = aim_tlv_getstr(tlvlist, 0x0001, 1); |
195 new->last = aim_tlv_getstr(tl, 0x0002, 1); | 195 new->last = aim_tlv_getstr(tlvlist, 0x0002, 1); |
196 new->middle = aim_tlv_getstr(tl, 0x0003, 1); | 196 new->middle = aim_tlv_getstr(tlvlist, 0x0003, 1); |
197 new->maiden = aim_tlv_getstr(tl, 0x0004, 1); | 197 new->maiden = aim_tlv_getstr(tlvlist, 0x0004, 1); |
198 new->email = aim_tlv_getstr(tl, 0x0005, 1); | 198 new->email = aim_tlv_getstr(tlvlist, 0x0005, 1); |
199 new->country = aim_tlv_getstr(tl, 0x0006, 1); | 199 new->country = aim_tlv_getstr(tlvlist, 0x0006, 1); |
200 new->state = aim_tlv_getstr(tl, 0x0007, 1); | 200 new->state = aim_tlv_getstr(tlvlist, 0x0007, 1); |
201 new->city = aim_tlv_getstr(tl, 0x0008, 1); | 201 new->city = aim_tlv_getstr(tlvlist, 0x0008, 1); |
202 new->sn = aim_tlv_getstr(tl, 0x0009, 1); | 202 new->sn = aim_tlv_getstr(tlvlist, 0x0009, 1); |
203 new->interest = aim_tlv_getstr(tl, 0x000b, 1); | 203 new->interest = aim_tlv_getstr(tlvlist, 0x000b, 1); |
204 new->nick = aim_tlv_getstr(tl, 0x000c, 1); | 204 new->nick = aim_tlv_getstr(tlvlist, 0x000c, 1); |
205 new->zip = aim_tlv_getstr(tl, 0x000d, 1); | 205 new->zip = aim_tlv_getstr(tlvlist, 0x000d, 1); |
206 new->region = aim_tlv_getstr(tl, 0x001c, 1); | 206 new->region = aim_tlv_getstr(tlvlist, 0x001c, 1); |
207 new->address = aim_tlv_getstr(tl, 0x0021, 1); | 207 new->address = aim_tlv_getstr(tlvlist, 0x0021, 1); |
208 new->next = results; | 208 new->next = results; |
209 results = new; | 209 results = new; |
210 numresults--; | 210 numresults--; |
211 } | 211 } |
212 | 212 |