diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libfaim/aim_msgcookie.c	Tue Jun 06 09:55:30 2000 +0000
@@ -0,0 +1,99 @@
+
+/*
+ *
+ *
+ */
+
+#include <faim/aim.h>
+
+int aim_cachecookie(struct aim_session_t *sess,
+		    struct aim_msgcookie_t *cookie)
+{
+  struct aim_msgcookie_t *newcook = NULL, *cur = NULL;
+  
+  if (!cookie)
+    return -1;
+
+  if (!(newcook = malloc(sizeof(struct aim_msgcookie_t))))
+    return -1;
+  memcpy(newcook, cookie, sizeof(struct aim_msgcookie_t));
+  newcook->addtime = time(NULL);
+  newcook->next = NULL;
+
+  cur = sess->msgcookies;
+  
+  if (cur == NULL) {
+    sess->msgcookies = newcook;
+    return 0;
+  }
+  while (cur->next != NULL)
+    cur = cur->next;
+  cur->next = newcook;
+
+  return 0;
+}
+
+struct aim_msgcookie_t *aim_uncachecookie(struct aim_session_t *sess, 
+					  char *cookie)
+{
+  struct aim_msgcookie_t *cur;
+
+  if (!cookie)
+    return NULL;
+
+  if (!sess->msgcookies)
+    return NULL;
+
+  if (memcmp(sess->msgcookies->cookie, cookie, 8) == 0) {
+    cur = sess->msgcookies;
+    sess->msgcookies = cur->next;
+    return cur;
+  } 
+
+  cur = sess->msgcookies;
+  while (cur->next) {
+    if (memcmp(cur->next->cookie, cookie, 8) == 0) {
+      struct aim_msgcookie_t *tmp;
+      
+      tmp = cur->next;
+      cur->next = cur->next->next;
+      return tmp;
+    }
+    cur = cur->next;
+  }
+  return NULL;
+}
+
+/*
+ */
+int aim_purgecookies(struct aim_session_t *sess)
+{
+  int maxage = 5*60;
+  struct aim_msgcookie_t *cur;
+  struct aim_msgcookie_t *remed = NULL;
+  time_t curtime;
+ 
+  cur = sess->msgcookies;
+  
+  curtime = time(&curtime);
+ 
+  while (cur) {
+    if ( (cur) && (((cur->addtime) + maxage) < curtime)) {
+#if DEBUG > 1
+      printf("aimmsgcookie: WARNING purged obsolete message cookie %x%x%x%x %x%x%x%x\n",
+	     cur->cookie[0], cur->cookie[1], cur->cookie[2], cur->cookie[3],
+	     cur->cookie[4], cur->cookie[5], cur->cookie[6], cur->cookie[7]);
+#endif
+      remed = aim_uncachecookie(sess, cur->cookie);
+      if (remed) {
+	if (remed->data)
+	  free(remed->data);
+	free(remed);
+      }
+    }
+    cur = cur->next;
+  }
+  
+  return 0;
+}
+