changeset 1977:7b3f1eb1ef7d

[gaim-migrate @ 1987] updated icqlib. fixed import dialog (watch debug window for errors). adam's (not mid's) patch for oscar. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 09 Jun 2001 14:46:51 +0000
parents 24aed1c31342
children a7bfa23e80a1
files plugins/icq/AUTHORS plugins/icq/CHANGES_SINCE_1.0 plugins/icq/ChangeLog plugins/icq/README plugins/icq/VERSION plugins/icq/chatsession.c plugins/icq/chatsession.h plugins/icq/contacts.c plugins/icq/contacts.h plugins/icq/cyrillic.c plugins/icq/eventhandle.c plugins/icq/eventhandle.h plugins/icq/filesession.c plugins/icq/filesession.h plugins/icq/icq.h plugins/icq/icqbyteorder.c plugins/icq/icqbyteorder.h plugins/icq/icqevent.c plugins/icq/icqevent.h plugins/icq/icqlib.c plugins/icq/icqlib.h plugins/icq/icqpacket.c plugins/icq/icqpacket.h plugins/icq/icqtypes.h plugins/icq/list.c plugins/icq/list.h plugins/icq/proxy.c plugins/icq/queue.c plugins/icq/queue.h plugins/icq/socketmanager.c plugins/icq/socketmanager.h plugins/icq/stdpackets.c plugins/icq/stdpackets.h plugins/icq/tcp.c plugins/icq/tcp.h plugins/icq/tcpchathandle.c plugins/icq/tcpfilehandle.c plugins/icq/tcphandle.c plugins/icq/tcplink.c plugins/icq/tcplink.h plugins/icq/timeout.c plugins/icq/timeout.h plugins/icq/udp.c plugins/icq/udp.h plugins/icq/udphandle.c plugins/icq/util.c plugins/icq/util.h src/dialogs.c src/oscar.c
diffstat 49 files changed, 605 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/icq/AUTHORS	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/AUTHORS	Sat Jun 09 14:46:51 2001 +0000
@@ -1,9 +1,13 @@
 Core Developers
 ---------------
-Denis V. Dmitrienko <denis@null.net>
+Denis V. Dmitrienko <denix@kde.org>
 Bill Soudan <soudan@kde.org>
 
-Secondary Developers
---------------------
+Python Bindings
+---------------
+Michael Hudson <mwh21@cam.ac.uk>
+
+Retired Developers and Contributors
+-----------------------------------
 Vadim Zaliva <lord@crocodile.org>
-Nikita I. Makeev <whale@nichego.net> (retired ;)
+Nikita I. Makeev <whale@nichego.net>
--- a/plugins/icq/CHANGES_SINCE_1.0	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/CHANGES_SINCE_1.0	Sat Jun 09 14:46:51 2001 +0000
@@ -1,5 +1,4 @@
-
-This file is intendended to be a list of source incompatable changes 
+This file is intended to be a list of source incompatible changes 
 that have been made since icqlib-1.0.0.
 
 2000-12-19: ICQLINKs have been reworked.  Members that provide no useful 
@@ -46,7 +45,7 @@
 icq_RequestNotify/ICQ_NOTIFY_FILEDATA  icq_FileNotify/FILE_NOTIFY_DATAPACKET
 icq_RequestNotify/ICQ_NOTIFY_SUCCESS   icq_FileNotify/FILE_NOTIFY_CLOSE
 
-Finally, some fake file status values now come through seperate 
+Finally, some fake file status values now come through separate 
 FILE_NOTIFY events, and one has been renamed:
 
 Old status                         New Notification/Status
@@ -65,7 +64,7 @@
 ICQ_SOCKET_WRITE, and status will be either true or false, true indicating 
 icqlib now needs notification, and false indicating icqlib no longer needs 
 notification.  Your application should use this to install some sort of 
-socket notification object (e.g., in Kicq, we use a QSocketNotifier).  
+socket notification object (e.g., in kicq, we use a QSocketNotifier).  
 When the socket is ready, you should invoke the new 
 icq_HandleReadySocket(socket, type) function.
 
@@ -76,3 +75,7 @@
 2001-02-20: The icq_SetTimeout callback has been moved outside of the 
 ICQLINK structure, and icq_HandleTimeout no longer requires an ICQLINK 
 parameter.
+
+2001-03-03: ICQLINK is now icq_Link, to fit better with the icqlib
+naming conventions.  ICQLINK should be considered depreciated - it is 
+still supported for now, but may disappear in a future icqlib release.
--- a/plugins/icq/ChangeLog	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/ChangeLog	Sat Jun 09 14:46:51 2001 +0000
@@ -1,3 +1,207 @@
+2001-06-08  Denis V. Dmitrienko  <denix@kde.org>
+
+	* admin/acinclude.m4.in, admin/config.guess, admin/config.sub,
+	admin/install-sh, admin/libtool.m4.in, admin/ltcf-c.sh,
+	admin/ltcf-cxx.sh, admin/ltcf-gcj.sh, admin/ltconfig,
+	admin/ltmain.sh, admin/Makefile.am, admin/missing,
+	admin/mkinstalldirs, configure.in:
+	Updated autoconf/automake files from KDE to support autoconf 2.50
+
+	* doc/bindings/python/.cvsignore, doc/bindings/python/Makefile.am,
+	doc/bindings/.cvsignore, doc/bindings/Makefile.am, doc/.cvsignore,
+	doc/Makefile.am, bindings/python/.cvsignore,
+	bindings/python/Makefile.am, bindings/cpp/.cvsignore,
+	bindings/cpp/Makefile.am, bindings/.cvsignore,
+	bindings/Makefile.am, admin/.cvsignore, admin/Makefile.am,
+	configure.in, Makefile.am, README, VERSION:
+	Version bumped to 1.2.0
+
+	* icqlib/icqpacket.c, icqlib/list.c: Fixed Alpha-specific warnings.
+
+	* admin/icqlib.m4.in, icqlib.spec.in, icqlib-1.0.0.lsm, DEVEL,
+	AUTHORS:
+	Changed email address.
+
+	* icqlib/icqlib.c:
+	Added UpdateSuccess & UpdateFailure callacks initialization.
+
+2001-06-05  Denis V. Dmitrienko  <denix@kde.org>
+
+	* icqlib/icqbyteorder.h, configure.in:
+	Applied patch by Lars Christensen <larsch@cs.auc.dk> to use portable
+	autoconf's endianness test.
+
+	* icqlib/icq.h.in, icqlib/udp.h, icqlib/udphandle.c:
+	Applied patch by Lars Christensen <larsch@cs.auc.dk> which adds 2 new
+	callbacks - icq_UpdateSuccess & icq_UpdateFailure
+
+2001-06-05  Denis V. Dmitrienko  <denix@kde.org>
+
+	* icqlib/udphandle.c: Added code to send invisible list on login.
+
+	* AUTHORS: Added Michael Hudson.
+
+	* CHANGES_SINCE_0.1.3:
+	Added 0.1.3 -> 1.0.0 migration comments by Peter M. Lemmen
+	<pmlemmen@users.sourceforge.net>
+
+	* icqlib/icq.h.in, icqlib/contacts.c:
+	Changed parameter's name for readability.
+
+	* icqlib/icqlib.c, icqlib/tcp.c: Cleanups.
+
+	* CHANGES_SINCE_1.0: Spell-checked.
+
+2001-06-05  Michael Hudson  <mwh21@cam.ac.uk>
+
+	* bindings/python/icqlibmodule.c:
+	Whitespace prettyification; no functional changes.
+	These have been sitting around here for weeks!  Oops.
+
+2001-06-04  Denis V. Dmitrienko  <denix@kde.org>
+
+	* icqlib/udphandle.c:
+	Make sure to send Acknowledgement packet before callback.
+
+	* icqlib/udp.c: Added use of ICQ_MAX_UDP_MESSAGE_SIZE constant.
+
+	* icqlib/icqpacket.c, icqlib/icqpacket.h, icqlib/udphandle.c:
+	Added handling for V3 Wrong Password packet.
+
+	* icqlib/proxy.c: "Do it right" fix for the previous one. ;)
+
+	* icqlib/icqtypes.h: More Win32 compatibility fixes.
+
+2001-06-04  Bill Soudan  <soudan@kde.org>
+
+	Applied patch via email from Richard Hughes <richard@rhughes.net>.
+	Applied sf patches #429108 and #429111 from Michael Möller
+	<mcmoe@users.sourceforge.net>.
+
+	* icqlib/filesession.c: win32 compatability fixes, bugfixes.
+
+	* icqlib/icq.h.in: add ICQ_MAX_* constants, away message request
+	and callback.
+
+	* icqlib/icqlib.c: fix crash in icq_LinkDestroy when tcp was
+	disabled, cleanups.
+
+	* icqlib/proxy.c: don't crash if NULL is passed in for pname and
+	ppass to icq_SetProxy
+
+	* icqlib/socketmanager.h, icqlib/tcplink.c: win32 compatability
+	fixes.
+
+	* icqlib/stdpackets.c, icqlib/stdpackets.h: added 
+	icq_TCPCreateAwayReqPacket
+
+	* icqlib/tcp.c: use ICQ_MAX_MESSAGE_SIZE constant, win32 fixes,
+	copy files array in icq_SendFileRequest, bugfix for file xfer.
+
+	* icqlib/tcpchathandle.c, icqlib/tcpfilehandle.c: factoring
+
+	* icqlib/tcphandle.c: away message request support
+
+2001-05-28  Bill Soudan  <soudan@kde.org>
+
+	* icqlib/contacts.c, icqlib/list.h, icqlib/queue.c, 
+	icqlib/socketmanager.c, icqlib/tcplink.c, icqlib/util.c:
+	fix typo, icq_LinkEnqueue->icq_ListEnqueue, icq_LinkDequeue->
+	icq_ListDequeue
+
+	* icqlib/timeout.c: fix icq_Link->icq_List typo, fix memory
+	leak in icq_HandleTimeout
+
+	* icqlib/list.c: don't delete list items if NULL is passed into
+	icq_ListDelete for item_free_f
+
+2001-05-24  Denis V. Dmitrienko  <denix@kde.org>
+
+	* icqlib/udp.c:
+	Fixed memory leak - acknowledgement packet never been freed!!!
+
+2001-05-23  Denis V. Dmitrienko  <denix@kde.org>
+
+	* icqlib/icqlib.c, icqlib/udphandle.c:
+	UDP implementation of the Receive Contact List feature.
+
+	* icqlib/icqbyteorder.c, icqlib/icqbyteorder.h, configure.in:
+	Portability changes.
+
+	* icqlib/icqlib.h, CHANGES_SINCE_1.0: Cleanup.
+
+	* icqlib/cyrillic.c:
+	Applied koi8-u related patch by Kunytsa Olexander <xakep@snark.ukma.kiev.ua>
+
+2001-04-04  Bill Soudan  <soudan@kde.org>
+
+	Reverted my previous commit.
+
+2001-03-08  Bill Soudan  <soudan@kde.org>
+
+	First partial merge from patch by Jindrich Makovicka 
+	<makovick@KMLinux.fjfi.cvut.cz>: add support for czech encoding.
+	
+	* icqlib/cyrillic.c: renamed to encoding.c
+
+	* icqlib/encoding.c, icqlib/encoding.h: added
+
+	* icqlib/filesession.c, icqlib/icqpacket.c,
+	icqlib/icqpacket.h, icqlib/stdpackets.c, icqlib/stdpackets.h,
+	icqlib/tcp.c, icqlib/tcpchathandle.c, icqlib/tcpfilehandle.c,
+	icqlib/tcphandle.c, icqlib/tcplink.c, icqlib/udp.c,
+	icqlib/udphandle.c: Generalized icq_RusConv function to
+	icq_Translate, moved encoding/decoding to icq_Packet abstraction.
+	Encoding/decoding now happens automatically when reading and
+	writing strings to packets.
+
+	* icqlib/icqlib.c, icqlib/icq.h.in: added icq_LinkSetEncoding
+	and new ICQ_ENCODING_NONE, ICQ_ENCODING_RUSSIAN, and
+	ICQ_ENCODING_CZECH constants.
+
+	* icqlib/Makefile.am: cyrillic.c -> encoding.c
+
+2001-03-07  Bill Soudan  <soudan@kde.org>
+
+	* icqlib/*: More source cleanup - simplified dependencies.
+
+2001-03-06  Bill Soudan  <soudan@kde.org>
+
+	* icqlib/*: Many source cleanups!
+
+	1. linked list functions and structures renamed to avoid symbol
+	clashes (from list * to icq_List*) with MySQL
+
+	2. ICQLINK renamed to icq_Link to match existing icqlib style
+	(Note ICQLINK is still defined in the headers to maintain
+	source compatability)
+
+	3. Standard GNU header added to all source files
+
+	4. Many, many --enable-strict cleanups.
+
+	5. new invoke_callback macro used to invoke icqlink callbacks.
+
+	* icqlib/icqlib.c, icqlib/icq.h.in: Added icq_LinkInit and 
+	icq_LinkDestroy functions, to support C++ bindings, removed
+	ICQLINK parameter from icq_Main.
+
+	* icqlib/timeout.c: fixed bug in icq_TimeoutDelete that resulted
+	in erroneous icq_SetTimeout calls
+
+2001-03-05  Bill Soudan  <soudan@kde.org>
+
+	* icqlib/tcplink.c: applied patch from Eric Warmenhoven 
+	<warmenhoven@yahoo.com>, corrects TCP recv error bug that
+	causes 100% cpu usage
+
+	* bindings/cpp/build_icqlink.py, bindings/cpp/icqlink.h.tpl,
+	bindings/cpp/icqlink.cpp.tpl: added very beginnings of C++
+	bindings
+
+	* icqlib/icq.h.in: wrap callbacks with special begin and end
+	indicators for use with C++ bindings build script
+
 2001-03-03  Bill Soudan  <soudan@kde.org>
 
 	* icqlib/chatsession.c, icqlib/filesession.c, icqlib/icq.h.in:
--- a/plugins/icq/README	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/README	Sat Jun 09 14:46:51 2001 +0000
@@ -1,5 +1,5 @@
-icqlib v1.0.0
-Denis V. Dmitrienko <denis@null.net>
+icqlib v1.2.0
+Denis V. Dmitrienko <denix@kde.org>
 Bill Soudan <soudan@kde.org>
 
 DESCRIPTION
@@ -24,8 +24,8 @@
 Home page:
       http://kicq.sourceforge.net/icqlib.shtml
 Direct download:
-      http://download.sourceforge.net/icqlib/icqlib-1.0.0.tar.gz
-      ftp://ftp.kde.org/pub/kde/unstable/apps/network/icqlib-1.0.0.tar.gz
+      http://download.sourceforge.net/icqlib/icqlib-1.2.0.tar.gz
+      ftp://ftp.kde.org/pub/kde/unstable/apps/network/icqlib-1.2.0.tar.gz
 
 INSTALL
 -------
--- a/plugins/icq/VERSION	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/VERSION	Sat Jun 09 14:46:51 2001 +0000
@@ -1,1 +1,1 @@
-1.1.5
+1.2.0
--- a/plugins/icq/chatsession.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/chatsession.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: chatsession.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/chatsession.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/chatsession.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: chatsession.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/contacts.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/contacts.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: contacts.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -80,18 +82,18 @@
   return icq_ListTraverse(icqlink->d->icq_ContactList, _icq_ContactFind, cuin);
 }
 
-void icq_ContactSetVis(icq_Link *icqlink, DWORD cuin, BYTE vu)
+void icq_ContactSetVis(icq_Link *icqlink, DWORD cuin, BOOL on)
 {
   icq_ContactItem *p = icq_ContactFind(icqlink, cuin);
   if(p)
-    p->vis_list = vu;
+    p->vis_list = on;
 }
 
-void icq_ContactSetInvis(icq_Link *icqlink, DWORD cuin, BYTE vu)
+void icq_ContactSetInvis(icq_Link *icqlink, DWORD cuin, BOOL on)
 {
   icq_ContactItem *p = icq_ContactFind(icqlink, cuin);
   if(p)
-    p->invis_list = vu;
+    p->invis_list = on;
 }
 
 icq_ContactItem *icq_ContactGetFirst(icq_Link *icqlink)
--- a/plugins/icq/contacts.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/contacts.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: contacts.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/cyrillic.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/cyrillic.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: cyrillic.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/eventhandle.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/eventhandle.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: eventhandle.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/eventhandle.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/eventhandle.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: eventhandle.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/filesession.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/filesession.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: filesession.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -75,6 +77,7 @@
     while(*p2)
       free(*(p2++));
     free(p->files);
+    p->files=NULL;
   }
 
   if (p->current_fd > -1 ) {
@@ -125,7 +128,11 @@
 
 void icq_FileSessionSetCurrentFile(icq_FileSession *p, const char *filename)
 {
+#ifdef _WIN32
+  struct _stat file_status;
+#else
   struct stat file_status;
+#endif
   char file[1024];
 
   strcpy(file, p->working_dir);
@@ -140,13 +147,22 @@
   p->current_file_progress=0;
 
   /* does the file already exist? */
+#ifdef _WIN32
+  if (_stat(file, &file_status)==0) {
+#else
   if (stat(file, &file_status)==0) {
+#endif
     p->current_file_progress=file_status.st_size;
     p->total_transferred_bytes+=file_status.st_size;
+#ifdef _WIN32
+    p->current_fd=open(file, _O_WRONLY | _O_APPEND | _O_BINARY);
+#else
     p->current_fd=open(file, O_WRONLY | O_APPEND);
+#endif
   } else {
 #ifdef _WIN32
-    p->current_fd=open(file, O_WRONLY | O_CREAT);
+    p->current_fd=open(file, _O_WRONLY | _O_CREAT | _O_BINARY, 
+      _S_IREAD|_S_IWRITE);
 #else
     p->current_fd=open(file, O_WRONLY | O_CREAT, S_IRWXU);
 #endif
@@ -174,21 +190,35 @@
   }
 
   if(*files) {
+#ifdef _WIN32
+    struct _stat file_status;
+#else
     struct stat file_status;
+#endif
 
     if (p->current_fd>-1) {
        close(p->current_fd);
        p->current_fd=-1;
     }
 
+#ifdef _WIN32
+    if (_stat(*files, &file_status)==0) {
+       char *basename=*files;
+       char *pos=strrchr(basename, '\\');
+#else
     if (stat(*files, &file_status)==0) {
        char *basename=*files;
        char *pos=strrchr(basename, '/');
+#endif
        if(pos) basename=pos+1;
        strncpy(p->current_file, basename, 64);
        p->current_file_progress=0;
        p->current_file_size=file_status.st_size;
+#ifdef _WIN32
+       p->current_fd=open(*files, O_RDONLY | _O_BINARY);
+#else
        p->current_fd=open(*files, O_RDONLY);
+#endif
     }
 
     /* make sure we have a valid filehandle */
@@ -244,14 +274,15 @@
     icq_TCPLinkClose(plink);
   }
 
+  icq_ListRemove(p->icqlink->d->icq_FileSessions, p);
   icq_FileSessionDelete(p);
-
-  icq_ListRemove(p->icqlink->d->icq_FileSessions, p);		
 }   
 
 void icq_FileSessionSetWorkingDir(icq_FileSession *p, const char *dir)
 {
-  strncpy(p->working_dir, dir, 512);
+  int length = sizeof(p->working_dir);
+  strncpy(p->working_dir, dir, length);
+  p->working_dir[length-1]='\0';
 }  
 
 void icq_FileSessionSetFiles(icq_FileSession *p, char **files)
--- a/plugins/icq/filesession.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/filesession.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: filesession.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/icq.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icq.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icq.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -42,10 +44,10 @@
 #include <time.h>
 
 /* ICQLIB version defines */
-#define ICQLIBVER   0x010105
+#define ICQLIBVER   0x010200
 #define ICQLIBMAJOR 1
-#define ICQLIBMINOR 1
-#define ICQLIBMICRO 5
+#define ICQLIBMINOR 2
+#define ICQLIBMICRO 0
 
 
 #define ICQ_LOG_OFF     0
@@ -77,6 +79,9 @@
 #define ICQ_NOTIFY_CHATSESSION    7
 #define ICQ_NOTIFY_FILESESSION    8
 
+#define ICQ_MAX_MESSAGE_SIZE     1024
+#define ICQ_MAX_UDP_MESSAGE_SIZE 480
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -227,12 +232,16 @@
        const char *nick, const char *first, const char *last,
        const char *email, char auth);
   void (*icq_SearchDone)(icq_Link *icqlink);
+  void (*icq_UpdateSuccess)(icq_Link *icqlink);
+  void (*icq_UpdateFailure)(icq_Link *icqlink);
   void (*icq_UserOnline)(icq_Link *icqlink, unsigned long uin,
        unsigned long status, unsigned long ip, unsigned short port,
        unsigned long real_ip, unsigned char tcp_flag );
   void (*icq_UserOffline)(icq_Link *icqlink, unsigned long uin);
   void (*icq_UserStatusUpdate)(icq_Link *icqlink, unsigned long uin,
        unsigned long status);
+  void (*icq_RecvAwayMsg)(icq_Link *icqlink, unsigned long id,
+       const char *msg);
   void (*icq_InfoReply)(icq_Link *icqlink, unsigned long uin,
        const char *nick, const char *first, const char *last,
        const char *email, char auth);
@@ -371,8 +380,8 @@
 void icq_ContactAdd(icq_Link *icqlink, unsigned long cuin);
 void icq_ContactRemove(icq_Link *icqlink, unsigned long cuin);
 void icq_ContactClear(icq_Link *icqlink );
-void icq_ContactSetVis(icq_Link *icqlink, unsigned long cuin, unsigned char vu);
-void icq_ContactSetInvis(icq_Link *icqlink, unsigned long cuin, unsigned char vu);
+void icq_ContactSetVis(icq_Link *icqlink, unsigned long cuin, unsigned char on);
+void icq_ContactSetInvis(icq_Link *icqlink, unsigned long cuin, unsigned char on);
 
 /*** TCP ***/
 void icq_TCPMain(icq_Link *icqlink);
@@ -383,6 +392,8 @@
      const char *message);
 unsigned long icq_TCPSendURL(icq_Link *icqlink, unsigned long uin,
      const char *message, const char *url);
+unsigned long icq_TCPSendAwayMessageReq(icq_Link *icqlink, unsigned long
+     uin, int status);
 unsigned long icq_SendChatRequest(icq_Link *icqlink, unsigned long uin,
      const char *message);
 void icq_AcceptChatRequest(icq_Link *icqlink, unsigned long uin, unsigned long seq);
--- a/plugins/icq/icqbyteorder.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqbyteorder.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,4 +1,6 @@
 /*
+ * $Id: icqbyteorder.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * This header defines macros to handle ICQ protocol byte order conversion.
  *
  * Vadim Zaliva <lord@crocodile.org>
--- a/plugins/icq/icqbyteorder.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqbyteorder.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,4 +1,6 @@
 /*
+ * $Id: icqbyteorder.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * This header defines macros to handle ICQ protocol byte order conversion.
  *
  * Vadim Zaliva <lord@crocodile.org>
@@ -39,39 +41,6 @@
 #include <config.h>
 #endif         
 
-/* linux way */
-#ifdef HAVE_ENDIAN_H
-# include <endian.h> 
-#endif
-#ifdef HAVE_BYTESWAP_H
-# include <byteswap.h>
-#endif
-
-/* BSD way */
-#ifdef HAVE_MACHINE_ENDIAN_H
-# include <machine/endian.h>
-#endif
-
-/* HP-UX way */
-#ifdef hpux
-# ifdef HAVE_ARPA_NAMESER_H
-#  include <arpa/nameser.h>
-# endif
-#endif
-
-/* Cygwin way */
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
-/*
- * Kind of portable way. this common header, at least I found it on BSD and Solaris.
- * On Solaris this is only place where endiannes is defined.
- */
-#ifdef HAVE_ARPA_NAMESER_COMPAT_H
-# include <arpa/nameser_compat.h>
-#endif
-
 /*
  * I am really trying to use builtin optimized byte swap routines.
  * they are highly optimised on some platforms.
@@ -86,41 +55,16 @@
 # endif
 #endif
 
-#ifdef BYTE_ORDER_LITTLE_ENDIAN
-# define htoicql(x)   (x)
-# define icqtohl(x)   (x)
-# define htoicqs(x)   (x)
-# define icqtohs(x)   (x)
-#else
-
-#ifndef BYTE_ORDER
-#   error "Unknown byte order!"
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-/* host is different from ICQ byte order */
+#ifdef WORDS_BIGENDIAN
 # define htoicql(x)   bswap_32(x)
 # define icqtohl(x)   bswap_32(x)
 # define htoicqs(x)   bswap_16(x)
 # define icqtohs(x)   bswap_16(x)
 #else
-# if BYTE_ORDER == LITTLE_ENDIAN
-/* host byte order match ICQ byte order */
-#   define htoicql(x)   (x)
-#   define icqtohl(x)   (x)
-#   define htoicqs(x)   (x)
-#   define icqtohs(x)   (x)
-# else
-#   error "Unsupported byte order!"
-# endif
+# define htoicql(x)   (x)
+# define icqtohl(x)   (x)
+# define htoicqs(x)   (x)
+# define icqtohs(x)   (x)
 #endif
 
 #endif
-
-/* ICQ byte order is always different from network byte order. */
-# define ntoicql(x)   bswap_32(x)
-# define icqtonl(x)   bswap_32(x)
-# define ntoicqs(x)   bswap_16(x)
-# define icqtons(x)   bswap_16(x)
-
-#endif
--- a/plugins/icq/icqevent.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqevent.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqevent.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/icqevent.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqevent.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqevent.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/icqlib.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqlib.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqlib.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -146,6 +148,8 @@
   icqlink->icq_RecvAuthReq = 0L;
   icqlink->icq_UserFound = 0L;
   icqlink->icq_SearchDone = 0L;
+  icqlink->icq_UpdateSuccess = 0L;
+  icqlink->icq_UpdateFailure = 0L;
   icqlink->icq_UserOnline = 0L;
   icqlink->icq_UserOffline = 0L;
   icqlink->icq_UserStatusUpdate = 0L;
@@ -206,7 +210,8 @@
 
 void icq_LinkDestroy(icq_Link *icqlink)
 {
-  icq_TCPDone(icqlink);
+  if(icqlink->icq_UseTCP)
+    icq_TCPDone(icqlink);
   if(icqlink->icq_Password)
     free(icqlink->icq_Password);
   if(icqlink->icq_Nick)
@@ -271,6 +276,10 @@
   icqlink->icq_ProxyOurPort = ntohs(saddr.sin_port);
   if(icqlink->icq_UseProxy)
   {
+    int hasName = icqlink->icq_ProxyName && strlen(icqlink->icq_ProxyName);
+    int hasPass = icqlink->icq_ProxyPass && strlen(icqlink->icq_ProxyPass);
+    int authEnabled = icqlink->icq_ProxyAuth && hasName && hasPass;
+
     icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "[SOCKS] Trying to use SOCKS5 proxy\n");
     prsin.sin_addr.s_addr = inet_addr(icqlink->icq_ProxyHost);
     if(prsin.sin_addr.s_addr  == (unsigned long)-1) /* name isn't n.n.n.n so must be DNS */
@@ -304,10 +313,8 @@
     }
     buf[0] = 5; /* protocol version */
     buf[1] = 1; /* number of methods */
-    if(!strlen(icqlink->icq_ProxyName) || !strlen(icqlink->icq_ProxyPass) || !icqlink->icq_ProxyAuth)
-      buf[2] = 0; /* no authorization required */
-    else
-      buf[2] = 2; /* method username/password */
+    buf[2] = authEnabled ? 2 : 0; /* authentication method */
+
 #ifdef _WIN32
     send(icqlink->icq_ProxySok, buf, 3, 0);
     res = recv(icqlink->icq_ProxySok, buf, 2, 0);
@@ -315,7 +322,8 @@
     write(icqlink->icq_ProxySok, buf, 3);
     res = read(icqlink->icq_ProxySok, buf, 2);
 #endif
-    if(strlen(icqlink->icq_ProxyName) && strlen(icqlink->icq_ProxyPass) && icqlink->icq_ProxyAuth)
+
+    if(authEnabled)
     {
       if(res != 2 || buf[0] != 5 || buf[1] != 2) /* username/password authentication*/
       {
@@ -460,9 +468,7 @@
 {
   icq_SocketDelete(icqlink->icq_UDPSok);
   if(icqlink->icq_UseProxy)
-  {
     icq_SocketDelete(icqlink->icq_ProxySok);
-  }
   icq_UDPQueueFree(icqlink);
 }
 
--- a/plugins/icq/icqlib.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqlib.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqlib.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/icqpacket.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqpacket.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqpacket.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -234,6 +236,12 @@
   return icq_PacketRead16(p);
 }
 
+WORD icq_PacketReadUDPInCmdV3(icq_Packet *p)
+{
+  icq_PacketGoto(p, 2);
+  return icq_PacketRead16(p);
+}
+
 WORD icq_PacketReadUDPInSeq1(icq_Packet *p)
 {
   icq_PacketGoto(p, 9);
@@ -269,8 +277,8 @@
 
 void icq_PacketShortDump(icq_Packet *p)
 {
-  printf("icq_Packet %x { id=%d, cursor=%x, length=%d }\n", 
-         (int)p, (int)p->id, p->cursor, p->length);
+  printf("icq_Packet %lx { id=%d, cursor=%x, length=%d }\n", 
+         (long)p, (int)p->id, p->cursor, p->length);
 }
 
 void icq_PacketDump(icq_Packet *p)
--- a/plugins/icq/icqpacket.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqpacket.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqpacket.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -66,6 +68,7 @@
 WORD icq_PacketReadUDPOutSeq2(icq_Packet*);
 WORD icq_PacketReadUDPInVer(icq_Packet*);
 WORD icq_PacketReadUDPInCmd(icq_Packet*);
+WORD icq_PacketReadUDPInCmdV3(icq_Packet*);
 WORD icq_PacketReadUDPInSeq1(icq_Packet*);
 WORD icq_PacketReadUDPInSeq2(icq_Packet*);
 DWORD icq_PacketReadUDPInUIN(icq_Packet*);
--- a/plugins/icq/icqtypes.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/icqtypes.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: icqtypes.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -27,10 +29,11 @@
 #include <config.h>
 #endif
 
-#ifndef _WIN32
 typedef unsigned long DWORD;
 typedef unsigned short WORD;
 typedef unsigned char BYTE;
+
+#ifndef _WIN32
 typedef unsigned char BOOL;
 #endif
 
--- a/plugins/icq/list.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/list.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: list.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -200,12 +202,12 @@
 {
   icq_ListNode *p=plist->head;
 
-  printf("list %x { head=%x, tail=%x, count=%d }\ncontents: ",
-         (int)plist, (int)plist->head, (int)plist->tail, plist->count);
+  printf("list %lx { head=%lx, tail=%lx, count=%d }\ncontents: ",
+         (long)plist, (long)plist->head, (long)plist->tail, plist->count);
 
   while(p)
   {
-    printf("%x, ", (int)p->item);
+    printf("%lx, ", (long)p->item);
     p=p->next;
   }
   printf("end\n");
--- a/plugins/icq/list.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/list.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: list.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/proxy.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/proxy.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: proxy.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -57,6 +59,26 @@
     free(icqlink->icq_ProxyName);
   if(icqlink->icq_ProxyPass)
     free(icqlink->icq_ProxyPass);
+
+  if(!phost)
+  {
+    icq_FmtLog(icqlink, ICQ_LOG_ERROR, "[SOCKS] Proxy host is empty\n");
+    icqlink->icq_UseProxy = 0;
+    return;
+  }
+  if(!pname)
+  {
+    icq_FmtLog(icqlink, ICQ_LOG_ERROR, "[SOCKS] User name is empty\n");
+    icqlink->icq_UseProxy = 0;
+    return;
+  }
+  if(!pname)
+  {
+    icq_FmtLog(icqlink, ICQ_LOG_ERROR, "[SOCKS] User password is empty\n");
+    icqlink->icq_UseProxy = 0;
+    return;
+  }
+
   if(strlen(pname)>255)
   {
     icq_FmtLog(icqlink, ICQ_LOG_ERROR, "[SOCKS] User name greater than 255 chars\n");
@@ -69,6 +91,7 @@
     icqlink->icq_UseProxy = 0;
     return;
   }
+
   icqlink->icq_UseProxy = 1;
   icqlink->icq_ProxyHost = strdup(phost);
   icqlink->icq_ProxyPort = pport;
--- a/plugins/icq/queue.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/queue.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: queue.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/queue.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/queue.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: queue.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/socketmanager.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/socketmanager.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: socketmanager.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -72,7 +74,7 @@
  * Creates a new socket by accepting a connection from a listening
  * socket.
  */
-int icq_SocketAccept(int listens, struct sockaddr *addr, unsigned int *addrlen)
+int icq_SocketAccept(int listens, struct sockaddr *addr, socklen_t *addrlen)
 {
   int s = accept(listens, addr, addrlen);
 
--- a/plugins/icq/socketmanager.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/socketmanager.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: socketmanager.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -28,7 +30,16 @@
 #endif
 
 #include <sys/types.h>
+
+#ifndef _WIN32
+#ifdef NEED_SOCKLEN_T
+typedef unsigned int socklen_t;
+#endif
 #include <sys/socket.h>
+#else
+#include <winsock.h>
+typedef unsigned __int32 socklen_t;
+#endif
 
 #include "icq.h"
 #include "list.h"
@@ -45,7 +56,7 @@
 };
 
 int icq_SocketNew(int domain, int type, int protocol);
-int icq_SocketAccept(int listens, struct sockaddr *addr, unsigned int *addrlen);
+int icq_SocketAccept(int listens, struct sockaddr *addr, socklen_t *addrlen);
 void icq_SocketAlloc(int socket_fd);
 int icq_SocketDelete(int socket_fd);
 void icq_SocketSetHandler(int socket_fd, int type, icq_SocketHandler handler,
--- a/plugins/icq/stdpackets.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/stdpackets.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: stdpackets.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -97,6 +99,19 @@
   return p;
 }
 
+icq_Packet *icq_TCPCreateAwayReqPacket(icq_TCPLink *plink, WORD statusMode)
+{
+  icq_Packet *p=icq_TCPCreateStdPacket(
+    plink,
+    ICQ_TCP_MESSAGE,
+    statusMode,           //one of the icq_tcp_msg_read... constants
+    "",
+    0, /* status */
+    0);   
+    
+  return p;
+}
+
 icq_Packet *icq_TCPCreateURLPacket(icq_TCPLink *plink, const char *message,
    const char *url)
 {
--- a/plugins/icq/stdpackets.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/stdpackets.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: stdpackets.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -82,6 +84,7 @@
 icq_Packet *icq_TCPCreateMessagePacket(icq_TCPLink *plink, const char *message);
 icq_Packet *icq_TCPCreateURLPacket(icq_TCPLink *plink, const char *message,
    const char *url);
+icq_Packet *icq_TCPCreateAwayReqPacket(icq_TCPLink *plink, WORD statusMode);
 icq_Packet *icq_TCPCreateChatReqPacket(icq_TCPLink *plink, const char *message);
 icq_Packet *icq_TCPCreateFileReqPacket(icq_TCPLink *plink, 
    const char *message, const char *filename, DWORD size);
--- a/plugins/icq/tcp.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcp.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcp.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -80,9 +82,18 @@
 {
   /* close and deallocate all tcp links, this will also close any attached 
    * file or chat sessions */
-  icq_ListDelete(icqlink->d->icq_TCPLinks, icq_TCPLinkDelete);
-  icq_ListDelete(icqlink->d->icq_ChatSessions, icq_ChatSessionDelete);
-  icq_ListDelete(icqlink->d->icq_FileSessions, icq_FileSessionDelete);
+  if (icqlink->d->icq_TCPLinks) {
+    icq_ListDelete(icqlink->d->icq_TCPLinks, icq_TCPLinkDelete);
+    icqlink->d->icq_TCPLinks = 0;
+  }
+  if (icqlink->d->icq_ChatSessions) {
+    icq_ListDelete(icqlink->d->icq_ChatSessions, icq_ChatSessionDelete);
+    icqlink->d->icq_ChatSessions = 0;
+  }
+  if (icqlink->d->icq_FileSessions) {
+    icq_ListDelete(icqlink->d->icq_FileSessions, icq_FileSessionDelete);
+    icqlink->d->icq_FileSessions = 0;
+  }
 }
 
 icq_TCPLink *icq_TCPCheckLink(icq_Link *icqlink, DWORD uin, int type)
@@ -97,7 +108,6 @@
   }
 
   return plink;
-
 }
 
 DWORD icq_TCPSendMessage(icq_Link *icqlink, DWORD uin, const char *message)
@@ -105,9 +115,10 @@
   icq_TCPLink *plink;
   icq_Packet *p;
   DWORD sequence;
-  char data[512] ;
+  char data[ICQ_MAX_MESSAGE_SIZE] ;
   
-  strncpy(data,message,512) ;
+  strncpy(data,message,sizeof(data)) ;
+  data[sizeof(data)-1]='\0';
   icq_RusConv("kw", data) ;
 
   plink=icq_TCPCheckLink(icqlink, uin, TCP_LINK_MESSAGE);
@@ -128,12 +139,12 @@
   icq_TCPLink *plink;
   icq_Packet *p;
   DWORD sequence;
-  char data[512];
+  char data[ICQ_MAX_MESSAGE_SIZE];
 
   plink=icq_TCPCheckLink(icqlink, uin, TCP_LINK_MESSAGE);
   
-  strncpy(data, message, 512);
-  data[511] = '\0';
+  strncpy(data, message, sizeof(data));
+  data[sizeof(data)-1] = '\0';
   icq_RusConv("kw", data);
 
   /* create and send the url packet */
@@ -152,12 +163,12 @@
   icq_TCPLink *plink;
   icq_Packet *p;
   DWORD sequence;
-  char data[512];
+  char data[ICQ_MAX_MESSAGE_SIZE];
 
   plink=icq_TCPCheckLink(icqlink, uin, TCP_LINK_MESSAGE);
   
-  strncpy(data, message, 512);
-  data[511] = '\0';
+  strncpy(data, message, sizeof(data));
+  data[sizeof(data)-1] = '\0';
   icq_RusConv("kw", data);
 
   /* create and send the url packet */
@@ -179,7 +190,9 @@
   icq_Packet *p;
   unsigned long sequence;
   char filename[64];
-  char data[512];
+  char data[ICQ_MAX_MESSAGE_SIZE];
+  char **filesiterator;
+  char **pfilesiterator;
 
   plink=icq_TCPCheckLink(icqlink, uin, TCP_LINK_MESSAGE);
 
@@ -192,20 +205,36 @@
 
   /* count the number and size of the files */
   pfile->total_files=0;
-  while(*files) {
+  filesiterator = files;
+  while(*filesiterator) {
+#ifdef _WIN32
+    struct _stat file_status;
+    if(_stat(*filesiterator, &file_status)==0) {
+#else
     struct stat file_status;
-
-    if(stat(*files, &file_status)==0) {
+    if(stat(*filesiterator, &file_status)==0) {
+#endif
       pfile->total_files++;
       pfile->total_bytes+=file_status.st_size;
     }
-    files++;
+    filesiterator++;
   }
 
+  pfile->files=(char **)malloc(sizeof(char *)*(pfile->total_files +1));
+  filesiterator = files;
+  pfilesiterator = pfile->files;
+  while (*filesiterator) {
+    *pfilesiterator=(char *)malloc(strlen(*filesiterator)+1);
+    strcpy(*pfilesiterator,*filesiterator);
+    filesiterator++;
+    pfilesiterator++;
+  }
+  *pfilesiterator = NULL;
+
   strncpy(filename, *(pfile->files), 64);
 
-  strncpy(data, message, 512);
-  data[511] = '\0';
+  strncpy(data, message, sizeof(data));
+  data[sizeof(data)-1]='\0';
   icq_RusConv("kw", data);  
 
   /* create and send the file req packet */
@@ -256,19 +285,18 @@
 void icq_TCPSendChatData(icq_Link *icqlink, DWORD uin, const char *data)
 {
   icq_TCPLink *plink=icq_FindTCPLink(icqlink, uin, TCP_LINK_CHAT);
-  char data1[512];
+  char data1[ICQ_MAX_MESSAGE_SIZE];
   int data1_len;
 
   if(!plink)
     return;  
 
-  strncpy(data1,data,512) ;
-  data1[511] = '\0';
+  strncpy(data1,data,sizeof(data1)) ;
+  data1[sizeof(data1)-1] = '\0';
   data1_len = strlen(data);
   icq_ChatRusConv_n("kw", data1, data1_len);
 
   send(plink->socket, data1, data1_len, 0);
-
 }
 
 void icq_TCPSendChatData_n(icq_Link *icqlink, DWORD uin, const char *data, int len)
@@ -284,7 +312,6 @@
   icq_ChatRusConv_n("kw", data1, len);  
 
   send(plink->socket, data1, len, 0);
-
 }
 
 icq_FileSession *icq_AcceptFileRequest(icq_Link *icqlink, DWORD uin,
@@ -310,6 +337,7 @@
   pfile->id=sequence;
   pfile->remote_uin=uin;
   pfile->direction=FILE_STATUS_RECEIVING;
+  pfile->tcplink=plisten;
   icq_FileSessionSetStatus(pfile, FILE_STATUS_LISTENING);
 
   /* create and send the ack packet */
@@ -322,7 +350,6 @@
 #endif
 
   return pfile;
-
 }
 
 void icq_RefuseFileRequest(icq_Link *icqlink, DWORD uin, 
@@ -340,7 +367,6 @@
   printf("file req refuse sent to uin %lu { sequence=%lx, reason=\"%s\" }\n",
     uin, sequence, reason);
 #endif
-
 }
 
 void icq_CancelFileRequest(icq_Link *icqlink, DWORD uin, unsigned long sequence)
@@ -359,7 +385,6 @@
 #ifdef TCP_PACKET_TRACE
   printf("file req cancel sent to uin %lu { sequence=%lx }\n", uin, sequence);
 #endif
-
 }
 
 void icq_RefuseChatRequest(icq_Link *icqlink, DWORD uin, 
@@ -377,17 +402,16 @@
   printf("chat req refuse sent to uin %lu { sequence=%lx, reason=\"%s\" }\n",
     uin, sequence, reason);
 #endif
-
 }
 
 void icq_CancelChatRequest(icq_Link *icqlink, DWORD uin, unsigned long sequence)
 {
   icq_TCPLink *pmessage=icq_TCPCheckLink(icqlink, uin, TCP_LINK_MESSAGE);
-  icq_FileSession *psession=icq_FindFileSession(icqlink, uin, sequence);
+  icq_ChatSession *psession=icq_FindChatSession(icqlink, uin);
   icq_Packet *p;
 
   if (psession)
-    icq_FileSessionClose(psession);
+    icq_ChatSessionClose(psession);
 
   /* create and send the cancel packet */
   p=icq_TCPCreateChatReqCancel(pmessage,
@@ -397,5 +421,4 @@
 #ifdef TCP_PACKET_TRACE
   printf("chat req cancel sent to uin %lu { sequence=%lx }\n", uin, sequence);
 #endif
-
 }
--- a/plugins/icq/tcp.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcp.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcp.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/tcpchathandle.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcpchathandle.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcpchathandle.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -33,9 +35,6 @@
   icq_ChatSession *pchat;
   icq_Packet *p2;
 
-  invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, 
-    p->id, ICQ_NOTIFY_ACK, 0, NULL);
-
   pchatlink=icq_TCPLinkNew(plink->icqlink);
   pchatlink->type=TCP_LINK_CHAT;
   pchatlink->id=p->id;
@@ -49,8 +48,6 @@
 
   invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, p->id,
     ICQ_NOTIFY_CHATSESSION, sizeof(icq_ChatSession), pchat);
-  invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, p->id,
-    ICQ_NOTIFY_SUCCESS, 0, NULL);
 
   icq_ChatSessionSetStatus(pchat, CHAT_STATUS_CONNECTING);
   icq_TCPLinkConnect(pchatlink, plink->remote_uin, port);
--- a/plugins/icq/tcpfilehandle.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcpfilehandle.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcpfilehandle.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -221,9 +223,6 @@
   icq_FileSession *pfile;
   icq_Packet *p2;
 
-  invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, 
-    p->id, ICQ_NOTIFY_ACK, 0, NULL);
-
   pfilelink=icq_TCPLinkNew(plink->icqlink);
   pfilelink->type=TCP_LINK_FILE;
   pfilelink->id=p->id;
@@ -236,8 +235,6 @@
 
   invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink,
     pfile->id, ICQ_NOTIFY_FILESESSION, sizeof(icq_FileSession), pfile);
-  invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink,
-    pfile->id, ICQ_NOTIFY_SUCCESS, 0, NULL);
   
   icq_FileSessionSetStatus(pfile, FILE_STATUS_CONNECTING);
   icq_TCPLinkConnect(pfilelink, plink->remote_uin, port);
--- a/plugins/icq/tcphandle.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcphandle.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcphandle.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -74,6 +76,11 @@
     case ICQ_TCP_MSG_MSG:
     case ICQ_TCP_MSG_URL:
     case ICQ_TCP_MSG_CONTACTLIST:
+    case ICQ_TCP_MSG_READAWAY:
+    case ICQ_TCP_MSG_READNA:
+    case ICQ_TCP_MSG_READDND:
+    case ICQ_TCP_MSG_READOCCUPIED:
+    case ICQ_TCP_MSG_READFFC:
       p->id=icq_PacketRead32(p);
       break;
 
@@ -138,6 +145,8 @@
       break;
 
     case ICQ_TCP_ACK:
+      invoke_callback(plink->icqlink, icq_RequestNotify)
+        (plink->icqlink, p->id, ICQ_NOTIFY_ACK, status, (void *)message);
       switch(type)
       {
         case ICQ_TCP_MSG_CHAT:
@@ -150,16 +159,23 @@
 
         case ICQ_TCP_MSG_MSG:
         case ICQ_TCP_MSG_URL:
-          if(plink->icqlink->icq_RequestNotify)
-          {
-            icq_FmtLog(plink->icqlink, ICQ_LOG_MESSAGE, "received ack %d\n", p->id);
-            invoke_callback(plink->icqlink, icq_RequestNotify)
-              (plink->icqlink, p->id, ICQ_NOTIFY_ACK, status, (void *)message);
-            invoke_callback(plink->icqlink, icq_RequestNotify)
-              (plink->icqlink, p->id, ICQ_NOTIFY_SUCCESS, 0, NULL);
-          }
+          icq_FmtLog(plink->icqlink, ICQ_LOG_MESSAGE, "received ack %d\n", 
+            p->id);
+          break;
+
+        case ICQ_TCP_MSG_READAWAY:
+        case ICQ_TCP_MSG_READNA:
+        case ICQ_TCP_MSG_READDND:
+        case ICQ_TCP_MSG_READOCCUPIED:
+        case ICQ_TCP_MSG_READFFC:
+          icq_FmtLog(plink->icqlink, ICQ_LOG_MESSAGE, 
+            "received away msg, seq %d\n", p->id);
+          invoke_callback(plink->icqlink, icq_RecvAwayMsg)
+            (plink->icqlink, p->id, message);
           break;
       }
+      invoke_callback(plink->icqlink, icq_RequestNotify)
+        (plink->icqlink, p->id, ICQ_NOTIFY_SUCCESS, 0, NULL);
       break;
 
     case ICQ_TCP_CANCEL:
@@ -234,7 +250,7 @@
 
 void icq_TCPOnMessageReceived(icq_Link *icqlink, DWORD uin, const char *message, DWORD id, icq_TCPLink *plink)
 {
-  char data[512];
+  char data[ICQ_MAX_MESSAGE_SIZE];
 
   /* use the current system time for time received */
   time_t t=time(0);
@@ -246,8 +262,9 @@
          uin, (int)id);
 #endif
 
-  strncpy(data,message,512) ;
-  icq_RusConv("wk",data) ;
+  strncpy(data,message,sizeof(data));
+  data[sizeof(data)-1]='\0';
+  icq_RusConv("wk",data);
 
   invoke_callback(icqlink,icq_RecvMessage)(icqlink, uin, ptime->tm_hour, 
     ptime->tm_min, ptime->tm_mday, ptime->tm_mon+1, ptime->tm_year+1900, data);
--- a/plugins/icq/tcplink.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcplink.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcplink.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -184,20 +186,20 @@
 {
   char buf[1024];
 
+  int hasName = plink->icqlink->icq_ProxyName &&
+    strlen(plink->icqlink->icq_ProxyName);
+  int hasPass = plink->icqlink->icq_ProxyPass &&
+    strlen(plink->icqlink->icq_ProxyPass);
+  int authEnabled = hasName && hasPass && plink->icqlink->icq_ProxyAuth;
+
   plink->mode = (plink->mode & (~TCP_LINK_SOCKS_CONNECTING));
   buf[0] = 5; /* protocol version */
   buf[1] = 1; /* number of methods */
-  if(!strlen(plink->icqlink->icq_ProxyName) || !strlen(plink->icqlink->icq_ProxyPass) ||
-     !plink->icqlink->icq_ProxyAuth)
-  {
-    buf[2] = 0; /* no authorization required */
-    plink->mode |= TCP_LINK_SOCKS_NOAUTHSTATUS;
-  }
-  else
-  {
-    buf[2] = 2; /* method username/password */
-    plink->mode |= TCP_LINK_SOCKS_AUTHORIZATION;
-  }
+  buf[2] = authEnabled ? 2 : 0; /* authentication method */
+
+  plink->mode |= authEnabled ? TCP_LINK_SOCKS_AUTHORIZATION :
+    TCP_LINK_SOCKS_NOAUTHSTATUS;
+
 #ifdef _WIN32
   if(send(plink->socket, buf, 3, 0) != 3)
     return errno;
@@ -496,7 +498,7 @@
   /* set the socket to non-blocking */
 #ifdef _WIN32
   iosflag = TRUE;
-  ioctlsocket(plink->socket, FIONBIO, &iosflag);
+  ioctlsocket(pnewlink->socket, FIONBIO, &iosflag);
 #else
   flags=fcntl(pnewlink->socket, F_GETFL, 0);
   fcntl(pnewlink->socket, F_SETFL, flags | O_NONBLOCK);
@@ -665,11 +667,17 @@
 
   } while (recv_result > 0);
 
+#ifdef _WIN32
+  if (recv_result <= 0 && WSAGetLastError()!=EWOULDBLOCK) {
+    /* receive error - log it */
+    icq_FmtLog(plink->icqlink, ICQ_LOG_WARNING, "recv failed from %d (%d),"
+      " closing link\n", plink->remote_uin, WSAGetLastError());
+#else
   if (recv_result <= 0 && errno!=EWOULDBLOCK) {
-
     /* receive error - log it */
     icq_FmtLog(plink->icqlink, ICQ_LOG_WARNING, "recv failed from %d (%d-%s),"
       " closing link\n", plink->remote_uin, errno, strerror(errno));
+#endif
 
     icq_TCPLinkClose(plink);
 
--- a/plugins/icq/tcplink.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/tcplink.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: tcplink.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/timeout.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/timeout.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: timeout.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/timeout.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/timeout.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: timeout.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/udp.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/udp.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: udp.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -415,10 +417,11 @@
 ***************************************************/
 WORD icq_UDPSendMessage(icq_Link *icqlink, DWORD uin, const char *text) /* V5 */
 {
-  char buf[512]; /* message may be only 450 bytes long */
+  char buf[ICQ_MAX_UDP_MESSAGE_SIZE];
   icq_Packet *p;
 
-  strncpy(buf, text, 512);
+  strncpy(buf, text, sizeof(buf));
+  buf[sizeof(buf)-1] = 0;
   icq_RusConv("kw", buf);
 
   p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV);
@@ -432,12 +435,14 @@
 
 WORD icq_UDPSendURL(icq_Link *icqlink, DWORD uin, const char *url, const char *descr) /* V5 */
 {
-  char buf1[512], buf2[512];
+  char buf1[ICQ_MAX_UDP_MESSAGE_SIZE], buf2[ICQ_MAX_UDP_MESSAGE_SIZE];
   icq_Packet *p;
 
-  strncpy(buf1, descr, 512);
+  strncpy(buf1, descr, sizeof(buf1));
+  buf1[sizeof(buf1)-1] = 0;
   icq_RusConv("kw", buf1);
-  strncpy(buf2, url, 512);
+  strncpy(buf2, url, sizeof(buf2));
+  buf2[sizeof(buf2)-1] = 0;
 
   p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV);
   icq_PacketAppend32(p, uin);
--- a/plugins/icq/udp.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/udp.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: udp.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -77,7 +79,8 @@
 #define UDP_SRV_STATUS_UPDATE      0x01A4
 #define UDP_SRV_X1                 0x021C
 #define UDP_SRV_X2                 0x00E6
-#define UDP_SRV_UPDATE             0x01E0
+#define UDP_SRV_UPDATE_OK          0x01E0
+#define UDP_SRV_UPDATE_FAIL        0x01EA
 #define UDP_SRV_UPDATE_EXT         0x00C8
 #define UDP_SRV_NEW_UIN            0x0046
 #define UDP_SRV_NEW_USER           0x00B4
--- a/plugins/icq/udphandle.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/udphandle.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: udphandle.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
@@ -182,8 +184,8 @@
   icq_RusConv("wk", ptr3);
   icq_RusConv("wk", ptr4);
   icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Info reply for %lu\n", uin);
+  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   invoke_callback(icqlink,icq_InfoReply)(icqlink, uin, ptr1, ptr2, ptr3, ptr4, icq_PacketRead8(p));
-  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   free(ptr1);
   free(ptr2);
   free(ptr3);
@@ -214,9 +216,9 @@
   icq_RusConv("wk", ptr4);
   icq_RusConv("wk", ptr5);
   icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Extended info reply for %lu\n", uin);
+  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   invoke_callback(icqlink,icq_ExtInfoReply)(icqlink, uin, (char*)ptr1, cnt_code, cnt_stat, (char*)ptr2,
                                             age, gender, (char*)ptr3, (char*)ptr4, (char*)ptr5);
-  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   free(ptr1);
   free(ptr2);
   free(ptr3);
@@ -241,9 +243,9 @@
   auth = icq_PacketRead8(p);
   icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "User found %lu, Nick: %s, First Name: %s, Last Name: %s, "
              "EMail: %s, Auth: %s\n", uin, ptr1, ptr2, ptr3, ptr4, auth==1?"no":"yes");
+  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   invoke_callback(icqlink,icq_UserFound)(icqlink, uin, (char*)ptr1, (char*)ptr2,
                                          (char*)ptr3, (char*)ptr4, auth);
-  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   free(ptr1);
   free(ptr2);
   free(ptr3);
@@ -261,7 +263,6 @@
   icq_PacketGotoUDPInData(p, 0);
   remote_uin = icq_PacketRead32(p);
   icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "User %lu logged off\n", remote_uin);
-  invoke_callback(icqlink,icq_UserOffline)(icqlink, remote_uin);
 
   ptr=icq_ContactFind(icqlink, remote_uin);
   if(ptr)
@@ -270,6 +271,7 @@
     ptr->remote_port = 0;
   }
   icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
+  invoke_callback(icqlink,icq_UserOffline)(icqlink, remote_uin);
 }
 
 void icq_HandleUserOnline(icq_Link *icqlink, icq_Packet *p)
@@ -291,8 +293,6 @@
              "User %lu (%s = 0x%X) logged on. tcp_flag=0x%X IP=%08X, real IP=%08X, port=%d\n",
              remote_uin, icq_ConvertStatus2Str(new_status), new_status, tcp_flag, remote_ip,
              remote_real_ip, remote_port);
-  invoke_callback(icqlink,icq_UserOnline)(icqlink, remote_uin, new_status, remote_ip,
-                                          remote_port, remote_real_ip, tcp_flag);
 
   ptr=icq_ContactFind(icqlink, remote_uin);
   if(ptr)
@@ -303,6 +303,8 @@
     ptr->tcp_flag = tcp_flag;
   }
   icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
+  invoke_callback(icqlink,icq_UserOnline)(icqlink, remote_uin, new_status, remote_ip,
+                                          remote_port, remote_real_ip, tcp_flag);
 }
 
 void icq_HandleStatusChange(icq_Link *icqlink, icq_Packet *p)
@@ -314,8 +316,8 @@
   new_status = icq_PacketRead32(p);
   icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "%lu changed status to %s (0x%X)\n", remote_uin,
              icq_ConvertStatus2Str(new_status), new_status);
+  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   invoke_callback(icqlink,icq_UserStatusUpdate)(icqlink, remote_uin, new_status);
-  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
 }
 
 void icq_HandleMetaUserInfo(icq_Link *icqlink, icq_Packet *p)
@@ -346,6 +348,7 @@
   icq_PacketGotoUDPInData(p, 0);
   subcmd = icq_PacketRead16(p);
   res = icq_PacketRead8(p);
+  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
   if(res == META_SRV_FAILURE)
   {
     icq_FmtLog(icqlink, ICQ_LOG_WARNING, "META failure\n");
@@ -585,7 +588,6 @@
         icq_PacketUDPDump(p);
         break;
     }
-  icq_UDPAck(icqlink, icq_PacketReadUDPInSeq1(p));
 }
 
 void icq_HandleMultiPacket(icq_Link *icqlink, icq_Packet *p)
@@ -615,13 +617,14 @@
   int len;
   struct in_addr in_a;
   DWORD uin;
-  WORD year, type, seq, cmd;
+  WORD year, type, seq, cmd, ver;
   BYTE month, day, hour, minute;
 
   seq = icq_PacketReadUDPInSeq1(p);
   cmd = icq_PacketReadUDPInCmd(p);
+  ver = icq_PacketReadUDPInVer(p);
 
-  if(icq_PacketReadUDPInVer(p) == 5) /* We understand only V5 packets! */
+  if(ver == 5) /* We understand only V5 packets! */
   {
     switch(cmd)
     {
@@ -651,6 +654,7 @@
         icq_SendLogin1(icqlink);
         icq_SendContactList(icqlink);
         icq_SendVisibleList(icqlink);
+        icq_SendInvisibleList(icqlink);
         invoke_callback(icqlink,icq_Logged)(icqlink);
         break;
       case UDP_SRV_OFFLINE_MESSAGE: /* Offline message through the server */
@@ -663,8 +667,8 @@
         minute = icq_PacketRead8(p);
         type = icq_PacketRead16(p);
         len = icq_PacketRead16(p);
+        icq_UDPAck(icqlink, seq);
         icq_DoMsg(icqlink, type, len, (char*)&p->data[p->cursor], uin, hour, minute, day, month, year);
-        icq_UDPAck(icqlink, seq);
         break;
       case UDP_SRV_X1: /* unknown message sent after login*/
         icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Acknowleged UDP_SRV_X1 (Begin messages)\n");
@@ -696,13 +700,23 @@
         break;
       case UDP_SRV_GO_AWAY:
         icq_FmtLog(icqlink, ICQ_LOG_ERROR, "Server has forced us to disconnect\n");
-        if(icqlink->icq_Disconnected)
-          (*icqlink->icq_Disconnected)(icqlink);
+        icq_UDPAck(icqlink, seq);
+        invoke_callback(icqlink, icq_Disconnected)(icqlink);
         break;
       case UDP_SRV_END_OF_SEARCH:
         icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Search done\n");
-        invoke_callback(icqlink,icq_SearchDone)(icqlink);
+        icq_UDPAck(icqlink, seq);
+        invoke_callback(icqlink, icq_SearchDone)(icqlink);
+        break;
+      case UDP_SRV_UPDATE_OK:
+        icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "User info successfully updated\n");
         icq_UDPAck(icqlink, seq);
+        invoke_callback(icqlink, icq_UpdateSuccess)(icqlink);
+        break;
+      case UDP_SRV_UPDATE_FAIL:
+        icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "User info update failed\n");
+        icq_UDPAck(icqlink, seq);
+        invoke_callback(icqlink, icq_UpdateFailure)(icqlink);
         break;
       case UDP_SRV_USER_FOUND:
         icq_HandleSearchReply(icqlink, p);
@@ -714,9 +728,9 @@
         uin = icq_PacketRead32(p);
         type = icq_PacketRead16(p);
         len = icq_PacketRead16(p);
+        icq_UDPAck(icqlink, seq);
         icq_DoMsg(icqlink, type, len, (char*)&p->data[p->cursor], uin, tm_str->tm_hour,
                   tm_str->tm_min, tm_str->tm_mday, tm_str->tm_mon+1, tm_str->tm_year+1900);
-        icq_UDPAck(icqlink, seq);
         break;
       case UDP_SRV_WRONG_PASSWORD:
         icq_FmtLog(icqlink, ICQ_LOG_ERROR, "Wrong password\n");
@@ -733,8 +747,24 @@
         break;
       default: /* commands we dont handle yet */
         icq_FmtLog(icqlink, ICQ_LOG_WARNING, "Unhandled message %04x, Version: %x, "
-                   "Sequence: %04x, Size: %d\n", cmd, icq_PacketReadUDPInVer(p),
-                   seq, p->length);
+                   "Sequence: %04x, Size: %d\n", cmd, ver, seq, p->length);
+        icq_UDPAck(icqlink, seq); /* fake like we know what we're doing */
+        break;
+    }
+  }
+  else if(ver == 3) /* And some of V3... */
+  {
+    cmd = icq_PacketReadUDPInCmdV3(p);
+    switch(cmd)
+    {
+      case UDP_SRV_WRONG_PASSWORD:
+        icq_FmtLog(icqlink, ICQ_LOG_ERROR, "Wrong password\n");
+        icq_UDPAck(icqlink, seq);
+        invoke_callback(icqlink,icq_WrongPassword)(icqlink);
+        break;
+      default: /* commands we dont handle yet */
+        icq_FmtLog(icqlink, ICQ_LOG_WARNING, "Unhandled message %04x, Version: %x, "
+                   "Sequence: %04x, Size: %d\n", cmd, ver, seq, p->length);
         icq_UDPAck(icqlink, seq); /* fake like we know what we're doing */
         break;
     }
@@ -742,8 +772,7 @@
   else
   {
     icq_FmtLog(icqlink, ICQ_LOG_WARNING, "Unhandled protocol version! Message %04x, Version: %x, "
-               "Sequence: %04x, Size: %d\n", cmd, icq_PacketReadUDPInVer(p),
-               seq, p->length);
+               "Sequence: %04x, Size: %d\n", cmd, ver, seq, p->length);
 /*    icq_UDPAck(icqlink, seq);  DO NOT ACK unhandled protocol version! */
   }
 }
@@ -765,6 +794,7 @@
     icq_FmtLog(icqlink, ICQ_LOG_FATAL, "Connection terminated\n");
     icq_Disconnect(icqlink);
     invoke_callback(icqlink,icq_Disconnected)(icqlink);
+    return;
   }
   seq = icq_PacketReadUDPInSeq1(p);
   cmd = icq_PacketReadUDPInCmd(p);
--- a/plugins/icq/util.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/util.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: util.c 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/plugins/icq/util.h	Fri Jun 08 23:17:17 2001 +0000
+++ b/plugins/icq/util.h	Sat Jun 09 14:46:51 2001 +0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /*
+ * $Id: util.h 1987 2001-06-09 14:46:51Z warmenhoven $
+ *
  * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
  *                          Bill Soudan <soudan@kde.org>
  *
--- a/src/dialogs.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/src/dialogs.c	Sat Jun 09 14:46:51 2001 +0000
@@ -2889,13 +2889,16 @@
 	gboolean from_dialog = FALSE;
 
 	if ( !gc ) {
+		debug_printf("want to import file ");
 		file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog));
-				strncpy( path, file, PATHSIZE - 1 );
-		if (file_is_dir(path, importdialog)) {
+		debug_printf("%s", file);
+		if (file_is_dir(file, importdialog)) {
+			debug_printf(" but it is a directory\n");
 			g_free (buf);
 			g_free (first);
 			return;
 		}
+		strncpy( path, file, PATHSIZE - 1 );
 		/* FIXME : import buddy list file. moderately important */
 		gc = connections->data;
 		from_dialog = TRUE;
@@ -2910,12 +2913,15 @@
 			g_free(g_screenname);
 		} else {
 			g_free(g_screenname);
+			g_free(buf);
+			g_free(first);
 			return;
 		}
 	}
 
 	if (!(f = fopen(path,"r"))) {
-		if ( !gc ) {
+		if (from_dialog) {
+			debug_printf(" but it can't be opened\n");
                 	g_snprintf(buf, BUF_LONG / 2, _("Error reading file %s"), path);
                 	do_error_dialog(buf, _("Error"));
                 	destroy_dialog(NULL, importdialog);
@@ -2960,7 +2966,8 @@
                 g_free(buf2);
 	/* Something else */
         } else {
-		if ( !gc ) {
+		if (from_dialog) {
+			debug_printf(" but I don't recognize the format\n");
                 	destroy_dialog(NULL, importdialog);
                 	importdialog = NULL;
 		}
@@ -2970,6 +2977,9 @@
                 return;
 	}
 
+	if (from_dialog)
+		debug_printf("\n");
+
         parse_toc_buddy_list(gc, buf, 1);
 
 	fclose( f );
--- a/src/oscar.c	Fri Jun 08 23:17:17 2001 +0000
+++ b/src/oscar.c	Sat Jun 09 14:46:51 2001 +0000
@@ -1018,7 +1018,7 @@
 	aim_auth_sendcookie(sess, tstconn, tstconn->priv);
 	g_free(tstconn->priv);
 	tstconn->priv = NULL;
-	odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
+	odata->paspa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
 				oscar_callback, tstconn);
 	debug_printf("chatnav: connected\n");
 }