diff plugins/icq/udp.c @ 1498:0ef6603d986e

[gaim-migrate @ 1508] updating icqlib committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 22 Feb 2001 23:07:34 +0000
parents 4c510ca3563f
children ba8e6e211af5
line wrap: on
line diff
--- a/plugins/icq/udp.c	Thu Feb 22 22:50:03 2001 +0000
+++ b/plugins/icq/udp.c	Thu Feb 22 23:07:34 2001 +0000
@@ -1,9 +1,12 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2  -*- */
 /*
-$Id: udp.c 1442 2001-01-28 01:52:27Z warmenhoven $
+$Id: udp.c 1508 2001-02-22 23:07:34Z warmenhoven $
 $Log$
-Revision 1.3  2001/01/28 01:52:27  warmenhoven
-icqlib 1.1.5
+Revision 1.4  2001/02/22 23:07:34  warmenhoven
+updating icqlib
+
+Revision 1.28  2001/02/22 05:40:04  bills
+port tcp connect timeout code and UDP queue to new timeout manager
 
 Revision 1.27  2001/01/16 00:10:13  denis
 Invisible list has been finished.
@@ -259,16 +262,8 @@
 
 int icq_UDPSockWrite(ICQLINK *link, icq_Packet *p)
 {
-  icq_Packet *qp;
-  WORD cmd = icq_PacketReadUDPOutCmd(p);
-  if(cmd != UDP_CMD_ACK && cmd != UDP_CMD_SEND_TEXT_CODE)
-  {
-    qp = (icq_Packet*)malloc(sizeof(icq_Packet));
-    memcpy(qp, p, sizeof(icq_Packet));
-    icq_UDPQueuePut(link, qp, 1);
-    if(link->icq_SetTimeout)
-      link->icq_SetTimeout(link, icq_UDPQueueInterval(link));
-  }
+  icq_UDPQueuePut(link, p);
+
   return icq_UDPSockWriteDirect(link, p);
 }
 
@@ -302,33 +297,6 @@
   }
 }
 
-void icq_HandleTimeout(ICQLINK *link)
-{
-  icq_UDPQueueItem *ptr = 0;
-  icq_Packet *sp = 0, *pack = 0;
-  int attempt;
-  while(icq_UDPQueueInterval(link) == 0)
-  {
-    ptr = (icq_UDPQueueItem*)list_first(link->d->icq_UDPQueue);
-    attempt = ptr->attempts + 1;
-    if(attempt > 6)
-    {
-      icq_Disconnect(link);
-      if(link->icq_Disconnected)
-        link->icq_Disconnected(link);
-      return;
-    }
-    pack = icq_UDPQueueGet(link);
-    sp = (icq_Packet*)malloc(sizeof(icq_Packet));
-    memcpy(sp, pack, sizeof(icq_Packet));
-    icq_UDPQueuePut(link, pack, attempt);
-    if(link->icq_SetTimeout)
-      link->icq_SetTimeout(link, icq_UDPQueueInterval(link));
-    icq_UDPSockWriteDirect(link, sp);
-    icq_PacketDelete(sp);
-  }
-}
-
 /****************************************
 This must be called every 2 min.
 so the server knows we're still alive.
@@ -339,16 +307,9 @@
 {
   icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_KEEP_ALIVE, link->d->icq_UDPSeqNum1++);
   icq_PacketAppend32(p, rand());
-  icq_UDPSockWrite(link, p);
+  icq_UDPSockWriteDirect(link, p); /* don't queue keep alive packets! */
   icq_PacketDelete(p);
 
-/*  icq_Packet *p = icq_UDPCreateStdPacket(UDP_CMD_KEEP_ALIVE);
-  icq_UDPSockWrite(icq_UDPSok, p);
-  icq_PacketDelete(p);*/
-/*  p = icq_UDPCreateStdPacket(UDP_CMD_KEEP_ALIVE2);
-  icq_UDPSockWrite(icq_Sok, p);
-  icq_PacketDelete(p);*/
-
   icq_FmtLog(link, ICQ_LOG_MESSAGE, "Send Keep Alive packet to the server\n");
 
   return link->d->icq_UDPSeqNum1-1;
@@ -363,7 +324,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_ACK_MESSAGES);
   icq_PacketAppend32(p, rand());
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /*************************************
@@ -389,7 +349,6 @@
     icq_PacketGotoUDPOutData(p, 0);
     icq_PacketAppend8(p, num_used);
     icq_UDPSockWrite(link, p);
-    icq_PacketDelete(p);
   }
 }
 
@@ -398,7 +357,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_ADD_TO_LIST);
   icq_PacketAppend32(p, uin);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /*************************************
@@ -428,8 +386,8 @@
     icq_PacketGotoUDPOutData(p, 0);
     icq_PacketAppend8(p, num_used);
     icq_UDPSockWrite(link, p);
-  }
-  icq_PacketDelete(p);
+  } else
+    icq_PacketDelete(p);
 }
 
 void icq_SendInvisibleList(ICQLINK *link) /* V5 */
@@ -454,8 +412,8 @@
     icq_PacketGotoUDPOutData(p, 0);
     icq_PacketAppend8(p, num_used);
     icq_UDPSockWrite(link, p);
-  }
-  icq_PacketDelete(p);
+  } else
+    icq_PacketDelete(p);
 }
 
 /**************************************
@@ -467,7 +425,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_LOGIN_1);
   icq_PacketAppend32(p, rand());
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /************************************
@@ -515,7 +472,6 @@
   icq_PacketAppend32(p, LOGIN_X5_DEF);
 
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /**********************
@@ -527,7 +483,7 @@
   icq_PacketAppendString(p, "B_USER_DISCONNECTED");
   icq_PacketAppend8(p, 5);
   icq_PacketAppend8(p, 0);
-  icq_UDPSockWrite(link, p);
+  icq_UDPSockWriteDirect(link, p); /* don't queue */
   icq_PacketDelete(p);
 }
 
@@ -543,7 +499,6 @@
 
   icq_FmtLog(link, ICQ_LOG_MESSAGE, "Acking\n");
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /***************************************************
@@ -564,7 +519,6 @@
   icq_PacketAppendString(p, buf);
 
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -585,7 +539,6 @@
   icq_PacketAppendString0(p, buf2);
 
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -600,7 +553,6 @@
   icq_PacketAppend32(p, TYPE_AUTH);
   icq_PacketAppend16(p, 0);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 
   return link->d->icq_UDPSeqNum1-1;
 }
@@ -614,7 +566,6 @@
   icq_PacketAppend32(p, status);
   link->icq_Status = status;
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /********************************************************
@@ -625,7 +576,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_INFO_REQ);
   icq_PacketAppend32(p, uin);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -637,7 +587,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_EXT_INFO_REQ);
   icq_PacketAppend32(p, uin);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -653,7 +602,6 @@
   icq_PacketAppendString(p, last);
   icq_PacketAppendString(p, email);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /**************************************************************
@@ -664,7 +612,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_SEARCH_UIN);
   icq_PacketAppend32(p, uin);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
 }
 
 /**************************************************
@@ -685,7 +632,6 @@
   icq_PacketAppend32(p, rand());
   icq_UDPSockWrite(link, p);
   icq_FmtLog(link, ICQ_LOG_MESSAGE, "Send RegNewUser packet to the server\n");
-  icq_PacketDelete(p);
 }
 
 WORD icq_UpdateUserInfo(ICQLINK *link, const char *nick, const char *first, const char *last,
@@ -698,7 +644,6 @@
   icq_PacketAppendString(p, email);
 /* auth (byte)? */
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -707,7 +652,6 @@
   icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_UPDATE_AUTH);
   icq_PacketAppend32(p, auth); /* NOT auth? */
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -736,7 +680,6 @@
   icq_PacketAppend8(p, cnt_stat);
   icq_PacketAppend8(p, emailhide);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum2-1;
 }
 
@@ -756,7 +699,6 @@
   icq_PacketAppend8(p, 0xFF /* lang2 */);
   icq_PacketAppend8(p, 0xFF /* lang3 */);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum2-1;
 }
 
@@ -766,7 +708,6 @@
   icq_PacketAppend16(p, META_CMD_SET_ABOUT);
   icq_PacketAppendString(p, about);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum2-1;
 }
 
@@ -779,7 +720,6 @@
   icq_PacketAppend8(p, webpresence);
   icq_PacketAppend8(p, pubip);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum2-1;
 }
 
@@ -795,7 +735,6 @@
   icq_PacketAppend8(p, 1);
   icq_PacketAppend8(p, 1);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum1-1;
 }
 
@@ -805,6 +744,5 @@
   icq_PacketAppend16(p, META_CMD_REQ_INFO);
   icq_PacketAppend32(p, uin);
   icq_UDPSockWrite(link, p);
-  icq_PacketDelete(p);
   return link->d->icq_UDPSeqNum2-1;
 }