annotate src/protocols/oscar/search.c @ 3694:e941bfbacf7c

[gaim-migrate @ 3824] Adds an option for unread mail notification for AIM over oscar. Yippy. This involves making a connection to the email AIM servers (parallel to chatnav, bos, auth, ads, etc.). Also added were functions n' stuff to handle getting mail status updates. AIM does this in a very silly way. They only tell you how many messages you have when you sign on, so I had to change connection_has_mail so it will just say "bleh has new mail," without saying the number of new messages. Also, I haven't really looked into having you auto-login to webmail, though it is possible. This is good for now. Oh, and since I'm sure people will ask... AIM screen names come with an email account @netscape.net. You have to sign in to netscape.net to activate it. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 14 Oct 2002 07:47:51 +0000
parents c41030cfed76
children 07283934dedd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * aim_search.c
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * TODO: Add aim_usersearch_name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 #define FAIM_INTERNAL
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 #include <aim.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
12 faim_export int aim_usersearch_address(aim_session_t *sess, aim_conn_t *conn, const char *address)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
14 aim_frame_t *fr;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
15 aim_snacid_t snacid;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
17 if (!sess || !conn || !address)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
18 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
20 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+strlen(address))))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
21 return -ENOMEM;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
23 snacid = aim_cachesnac(sess, 0x000a, 0x0002, 0x0000, strdup(address), strlen(address)+1);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
24 aim_putsnac(&fr->data, 0x000a, 0x0002, 0x0000, snacid);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
25
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
26 aimbs_putraw(&fr->data, address, strlen(address));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
28 aim_tx_enqueue(sess, fr);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
30 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 /* XXX can this be integrated with the rest of the error handling? */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
34 static int error(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
36 int ret = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
37 aim_rxcallback_t userfunc;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
38 aim_snac_t *snac2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
40 /* XXX the modules interface should have already retrieved this for us */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
41 if (!(snac2 = aim_remsnac(sess, snac->id))) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
42 faimdprintf(sess, 2, "search error: couldn't get a snac for 0x%08lx\n", snac->id);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
43 return 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
44 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
46 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
47 ret = userfunc(sess, rx, snac2->data /* address */);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
49 /* XXX freesnac()? */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
50 if (snac2)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
51 free(snac2->data);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
52 free(snac2);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
53
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
54 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
57 static int reply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
59 int j = 0, m, ret = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
60 aim_tlvlist_t *tlvlist;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
61 char *cur = NULL, *buf = NULL;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
62 aim_rxcallback_t userfunc;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
63 aim_snac_t *snac2;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
64 char *searchaddr = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
66 if ((snac2 = aim_remsnac(sess, snac->id)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
67 searchaddr = (char *)snac2->data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
69 tlvlist = aim_readtlvchain(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
70 m = aim_counttlvchain(&tlvlist);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
72 /* XXX uhm. */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
73 while ((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
74 buf = realloc(buf, (j+1) * (MAXSNLEN+1));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
76 strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
77 free(cur);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
79 j++;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
80 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
82 aim_freetlvchain(&tlvlist);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
84 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
85 ret = userfunc(sess, rx, searchaddr, j, buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
87 /* XXX freesnac()? */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
88 if (snac2)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
89 free(snac2->data);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
90 free(snac2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
92 free(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
94 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
97 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
100 if (snac->subtype == 0x0001)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
101 return error(sess, mod, rx, snac, bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
102 else if (snac->subtype == 0x0003)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
103 return reply(sess, mod, rx, snac, bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
105 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
108 faim_internal int search_modfirst(aim_session_t *sess, aim_module_t *mod)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
111 mod->family = 0x000a;
2672
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2246
diff changeset
112 mod->version = 0x0001;
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2246
diff changeset
113 mod->toolid = 0x0110;
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2246
diff changeset
114 mod->toolversion = 0x047b;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
115 mod->flags = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
116 strncpy(mod->name, "search", sizeof(mod->name));
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
117 mod->snachandler = snachandler;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
119 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
121
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
122