Mercurial > pidgin
comparison libfaim/aim_msgcookie.c @ 338:9d258a0aa560
[gaim-migrate @ 348]
Whoa, all kinds of things happened here. The applet looks better. The
preferences dialog changes based on your compile-time options (oscar,
gnome). Whispering works again. libfaim got updated; it can almost do
RVOUS stuff, and hopefully soon can make requests too. The applet doesn't
need to have its sounds go through GNOME, although it still can. There
is code to facilitate SOCKS5 support (all that needs to be done is to
actually write the code to communicate with the proxy server).
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 06 Jun 2000 09:55:30 +0000 |
parents | |
children | 6e318907bcce |
comparison
equal
deleted
inserted
replaced
337:f5b199e20d12 | 338:9d258a0aa560 |
---|---|
1 | |
2 /* | |
3 * | |
4 * | |
5 */ | |
6 | |
7 #include <faim/aim.h> | |
8 | |
9 int aim_cachecookie(struct aim_session_t *sess, | |
10 struct aim_msgcookie_t *cookie) | |
11 { | |
12 struct aim_msgcookie_t *newcook = NULL, *cur = NULL; | |
13 | |
14 if (!cookie) | |
15 return -1; | |
16 | |
17 if (!(newcook = malloc(sizeof(struct aim_msgcookie_t)))) | |
18 return -1; | |
19 memcpy(newcook, cookie, sizeof(struct aim_msgcookie_t)); | |
20 newcook->addtime = time(NULL); | |
21 newcook->next = NULL; | |
22 | |
23 cur = sess->msgcookies; | |
24 | |
25 if (cur == NULL) { | |
26 sess->msgcookies = newcook; | |
27 return 0; | |
28 } | |
29 while (cur->next != NULL) | |
30 cur = cur->next; | |
31 cur->next = newcook; | |
32 | |
33 return 0; | |
34 } | |
35 | |
36 struct aim_msgcookie_t *aim_uncachecookie(struct aim_session_t *sess, | |
37 char *cookie) | |
38 { | |
39 struct aim_msgcookie_t *cur; | |
40 | |
41 if (!cookie) | |
42 return NULL; | |
43 | |
44 if (!sess->msgcookies) | |
45 return NULL; | |
46 | |
47 if (memcmp(sess->msgcookies->cookie, cookie, 8) == 0) { | |
48 cur = sess->msgcookies; | |
49 sess->msgcookies = cur->next; | |
50 return cur; | |
51 } | |
52 | |
53 cur = sess->msgcookies; | |
54 while (cur->next) { | |
55 if (memcmp(cur->next->cookie, cookie, 8) == 0) { | |
56 struct aim_msgcookie_t *tmp; | |
57 | |
58 tmp = cur->next; | |
59 cur->next = cur->next->next; | |
60 return tmp; | |
61 } | |
62 cur = cur->next; | |
63 } | |
64 return NULL; | |
65 } | |
66 | |
67 /* | |
68 */ | |
69 int aim_purgecookies(struct aim_session_t *sess) | |
70 { | |
71 int maxage = 5*60; | |
72 struct aim_msgcookie_t *cur; | |
73 struct aim_msgcookie_t *remed = NULL; | |
74 time_t curtime; | |
75 | |
76 cur = sess->msgcookies; | |
77 | |
78 curtime = time(&curtime); | |
79 | |
80 while (cur) { | |
81 if ( (cur) && (((cur->addtime) + maxage) < curtime)) { | |
82 #if DEBUG > 1 | |
83 printf("aimmsgcookie: WARNING purged obsolete message cookie %x%x%x%x %x%x%x%x\n", | |
84 cur->cookie[0], cur->cookie[1], cur->cookie[2], cur->cookie[3], | |
85 cur->cookie[4], cur->cookie[5], cur->cookie[6], cur->cookie[7]); | |
86 #endif | |
87 remed = aim_uncachecookie(sess, cur->cookie); | |
88 if (remed) { | |
89 if (remed->data) | |
90 free(remed->data); | |
91 free(remed); | |
92 } | |
93 } | |
94 cur = cur->next; | |
95 } | |
96 | |
97 return 0; | |
98 } | |
99 |