annotate src/protocols/oscar/odir.c @ 12143:cbebda5f019c

[gaim-migrate @ 14444] SF Patch #1360399 from Evan Schoenberg (evands) "I discussed this previously with Mark and he said it'd be fine. This factors out the part of the send_file function which creates a new GaimXfer into a separate prpl function, new_xfer. It's called in each of the existing send_file functions. This is needed so that another client (okay, Adium) can get a new outgoing GaimXfer from a prpl without depending upon the specific ft.c logic of send_file; previously I was adding a duplicate method to each prpl and then calling it directly." I fixed a couple small bugs in this. Otherwise, it looks good, and seems like a reasonable libgaim request. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 19 Nov 2005 00:26:12 +0000
parents 1798ad0be460
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * Family 0x000f - Newer Search Method
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Used for searching for other AIM users by email address, name,
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * location, commmon interests, and a few other similar things.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 #define FAIM_INTERNAL
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 #include <aim.h>
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 /**
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * Subtype 0x0002 - Submit a User Search Request
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * Search for an AIM screen name based on their email address.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * @param sess The oscar session.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * @param region Should be "us-ascii" unless you know what you're doing.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * @param email The email address you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * @return Return 0 if no errors, otherwise return the error number.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 faim_export int aim_odir_email(aim_session_t *sess, const char *region, const char *email)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 aim_conn_t *conn;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 aim_frame_t *fr;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 aim_snacid_t snacid;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 aim_tlvlist_t *tl = NULL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region || !email)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 return -EINVAL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
33 aim_tlvlist_add_str(&tl, 0x001c, region);
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
34 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
35 aim_tlvlist_add_str(&tl, 0x0005, email);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
37 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl))))
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 return -ENOMEM;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
42 aim_tlvlist_write(&fr->data, &tl);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
43 aim_tlvlist_free(&tl);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 aim_tx_enqueue(sess, fr);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 return 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 /**
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 * Subtype 0x0002 - Submit a User Search Request
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 * Search for an AIM screen name based on various info
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 * about the person.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 * @param sess The oscar session.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * @param region Should be "us-ascii" unless you know what you're doing.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 * @param first The first name of the person you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 * @param middle The middle name of the person you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 * @param last The last name of the person you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 * @param maiden The maiden name of the person you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 * @param nick The nick name of the person you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 * @param city The city where the person you want to search for resides.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65 * @param state The state where the person you want to search for resides.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 * @param country The country where the person you want to search for resides.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 * @param zip The zip code where the person you want to search for resides.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 * @param address The street address where the person you want to seach for resides.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 * @return Return 0 if no errors, otherwise return the error number.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 faim_export int aim_odir_name(aim_session_t *sess, 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)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 aim_conn_t *conn;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 aim_frame_t *fr;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 aim_snacid_t snacid;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 aim_tlvlist_t *tl = NULL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 return -EINVAL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
82 aim_tlvlist_add_str(&tl, 0x001c, region);
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
83 aim_tlvlist_add_16(&tl, 0x000a, 0x0000); /* Type of search */
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 if (first)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
85 aim_tlvlist_add_str(&tl, 0x0001, first);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86 if (last)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
87 aim_tlvlist_add_str(&tl, 0x0002, last);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 if (middle)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
89 aim_tlvlist_add_str(&tl, 0x0003, middle);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90 if (maiden)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
91 aim_tlvlist_add_str(&tl, 0x0004, maiden);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92 if (country)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
93 aim_tlvlist_add_str(&tl, 0x0006, country);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 if (state)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
95 aim_tlvlist_add_str(&tl, 0x0007, state);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 if (city)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
97 aim_tlvlist_add_str(&tl, 0x0008, city);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 if (nick)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
99 aim_tlvlist_add_str(&tl, 0x000c, nick);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 if (zip)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
101 aim_tlvlist_add_str(&tl, 0x000d, zip);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 if (address)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
103 aim_tlvlist_add_str(&tl, 0x0021, address);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
105 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl))))
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 return -ENOMEM;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
110 aim_tlvlist_write(&fr->data, &tl);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
111 aim_tlvlist_free(&tl);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
112
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
113 aim_tx_enqueue(sess, fr);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
114
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115 return 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
116 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
117
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
118
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
119 /**
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
120 * Subtype 0x0002 - Submit a User Search Request
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
121 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
122 * @param sess The oscar session.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
123 * @param interest1 An interest you want to search for.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
124 * @return Return 0 if no errors, otherwise return the error number.
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125 */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
126 faim_export int aim_odir_interest(aim_session_t *sess, const char *region, const char *interest)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
127 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
128 aim_conn_t *conn;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
129 aim_frame_t *fr;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
130 aim_snacid_t snacid;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131 aim_tlvlist_t *tl = NULL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
132
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 return -EINVAL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
136 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
137 aim_tlvlist_add_str(&tl, 0x001c, region);
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
138 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 if (interest)
10991
1798ad0be460 [gaim-migrate @ 12829]
Mark Doliner <mark@kingant.net>
parents: 10986
diff changeset
140 aim_tlvlist_add_str(&tl, 0x0001, interest);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
142 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl))))
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 return -ENOMEM;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
147 aim_tlvlist_write(&fr->data, &tl);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
148 aim_tlvlist_free(&tl);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150 aim_tx_enqueue(sess, fr);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 return 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
153 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
154
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
155
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
156 /**
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 * Subtype 0x0003 - Receive Reply From a User Search
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
158 *
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 static int parseresults(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
162 int ret = 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163 aim_rxcallback_t userfunc;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 fu16_t tmp, numresults;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 struct aim_odir *results = NULL;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 tmp = aimbs_get16(bs); /* Unknown */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168 tmp = aimbs_get16(bs); /* Unknown */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 aim_bstream_advance(bs, tmp);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 numresults = aimbs_get16(bs); /* Number of results to follow */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 /* Allocate a linked list, 1 node per result */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174 while (numresults) {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 struct aim_odir *new;
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
176 aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, aimbs_get16(bs));
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 new = (struct aim_odir *)malloc(sizeof(struct aim_odir));
7167
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
178 new->first = aim_tlv_getstr(tl, 0x0001, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
179 new->last = aim_tlv_getstr(tl, 0x0002, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
180 new->middle = aim_tlv_getstr(tl, 0x0003, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
181 new->maiden = aim_tlv_getstr(tl, 0x0004, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
182 new->email = aim_tlv_getstr(tl, 0x0005, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
183 new->country = aim_tlv_getstr(tl, 0x0006, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
184 new->state = aim_tlv_getstr(tl, 0x0007, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
185 new->city = aim_tlv_getstr(tl, 0x0008, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
186 new->sn = aim_tlv_getstr(tl, 0x0009, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
187 new->interest = aim_tlv_getstr(tl, 0x000b, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
188 new->nick = aim_tlv_getstr(tl, 0x000c, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
189 new->zip = aim_tlv_getstr(tl, 0x000d, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
190 new->region = aim_tlv_getstr(tl, 0x001c, 1);
6d3d8f11e765 [gaim-migrate @ 7734]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
191 new->address = aim_tlv_getstr(tl, 0x0021, 1);
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
192 new->next = results;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193 results = new;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194 numresults--;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
198 ret = userfunc(sess, rx, results);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200 /* Now free everything from above */
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201 while (results) {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202 struct aim_odir *del = results;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203 results = results->next;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
204 free(del->first);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
205 free(del->last);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 free(del->middle);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
207 free(del->maiden);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
208 free(del->email);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
209 free(del->country);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
210 free(del->state);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211 free(del->city);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
212 free(del->sn);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
213 free(del->interest);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
214 free(del->nick);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
215 free(del->zip);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
216 free(del->region);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
217 free(del->address);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
218 free(del);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
219 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
221 return ret;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
222 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
225 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
226
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
227 if (snac->subtype == 0x0003)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 return parseresults(sess, mod, rx, snac, bs);
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
230 return 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
231 }
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
233 faim_internal int odir_modfirst(aim_session_t *sess, aim_module_t *mod)
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
234 {
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
235
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
236 mod->family = 0x000f;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
237 mod->version = 0x0001;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
238 mod->toolid = 0x0010;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 mod->toolversion = 0x0629;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
240 mod->flags = 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241 strncpy(mod->name, "odir", sizeof(mod->name));
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
242 mod->snachandler = snachandler;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
243
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244 return 0;
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245 }