-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

when a user sends a file to another user (dah)  the new socket connection
is done by the same thread of the gui, producing a nasty ui hang until the
connection is established (or time out rises). This shouldnt be much
problem except for trying to send files to nat users with broken
firewalls (yes. my case).

a patch that tries to solve this is attached. there is something i don't
like (may be it is a skin thing ...) but may be is usefull.  AFAIK the
same modificacion is needed for the Chat thing (but i don't know since i
never used the Chat option). 

-----BEGIN PGP SIGNATURE-----

iD8DBQE9k5pVUMlRieHkprgRAj94AKCq2C/Q9RLWHMz45gkQIxJ0dpQP5QCg45AM
WHRMXDP2ccOrCPB8g8PeIAA=
=28id
-----END PGP SIGNATURE-----
Index: include/licq_filetransfer.h
===================================================================
RCS file: /cvsroot/licq/licq/include/licq_filetransfer.h,v
retrieving revision 1.5
diff -u -d -p -r1.5 licq_filetransfer.h
--- include/licq_filetransfer.h	24 May 2002 00:19:01 -0000	1.5
+++ include/licq_filetransfer.h	26 Sep 2002 13:14:33 -0000
@@ -42,8 +42,10 @@
  *       are available in the log.  The type of error is also specified
  *       as FT_ERRORxFILE (file read/write error, PathName() contains the
  *       name of the offending file), FT_ERRORxHANDSHAKE (handshaking error
- *       by the other side), or FT_ERRORxCLOSED (the remote side closed
- *       the connection unexpectedly).
+ *       by the other side), FT_ERRORxCLOSED (the remote side closed
+ *       the connection unexpectedly), FT_ERRORxCONNECT (error reaching 
+ *       remote host), FT_ERRORxBIND (error binding a port when D_REICVER)
+ *       or FT_ERRORxRESOURCES (error creating a new thread).
  * 4.  Call CloseFileTransfer() when done or to cancel, or simply delete the
  *       CFileTransferManager object.
  *
@@ -68,7 +70,9 @@ const unsigned char FT_CONFIRMxFILE  = 6
 const unsigned char FT_ERRORxFILE      = 0xFF;
 const unsigned char FT_ERRORxHANDSHAKE = 0xFE;
 const unsigned char FT_ERRORxCLOSED    = 0xFD;
-
+const unsigned char FT_ERRORxCONNECT   = 0xFC;
+const unsigned char FT_ERRORxBIND      = 0xFB;
+const unsigned char FT_ERRORxRESOURCES = 0xFA;
 
 //=====File=====================================================================
 class CPacketFile : public CPacket
@@ -175,7 +179,7 @@ public:
   ~CFileTransferManager();
 
   bool ReceiveFiles(const char *szDirectory);
-  bool SendFiles(ConstFileList lPathNames, unsigned short nPort);
+  void SendFiles(ConstFileList lPathNames, unsigned short nPort);
 
   void CloseFileTransfer();
 
@@ -238,6 +242,7 @@ protected:
   unsigned short m_nSession, m_nSpeed, m_nState;
 
   char m_szLocalName[64], m_szRemoteName[64];
+  unsigned short m_nPort;
   unsigned long m_nFilePos, m_nBatchPos, m_nBytesTransfered, m_nBatchBytesTransfered;
   unsigned short m_nCurrentFile, m_nBatchFiles;
   unsigned long m_nFileSize, m_nBatchSize;
Index: plugins/qt-gui/src/filedlg.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/filedlg.cpp,v
retrieving revision 1.49
diff -u -d -p -r1.49 filedlg.cpp
--- plugins/qt-gui/src/filedlg.cpp	9 Sep 2002 23:28:41 -0000	1.49
+++ plugins/qt-gui/src/filedlg.cpp	26 Sep 2002 13:14:34 -0000
@@ -313,6 +313,32 @@ void CFileDlg::slot_ft()
         WarnUser(this, tr("Handshake Error.\nSee Network Window for details."));
         break;
       }
+      case FT_ERRORxCONNECT:
+      {
+        btnCancel->setText(tr("Close"));
+        mleStatus->appendNoNewLine(tr("Connection error\n"));
+        ftman->CloseFileTransfer();
+        WarnUser(this, 
+          tr("Unable to reach remote host.\nSee Network Window for details."));
+      }
+      case FT_ERRORxBIND:
+      {
+        btnCancel->setText(tr("Close"));
+        mleStatus->appendNoNewLine(tr("Bind error\n"));
+        ftman->CloseFileTransfer();
+        WarnUser(this, 
+          tr("Unable to bind to any port.\nSee Network Window for details."));
+      }
+      case FT_ERRORxRESOURCES:
+      {
+        btnCancel->setText(tr("Close"));
+        mleStatus->appendNoNewLine(tr("not enough resources\n"));
+        ftman->CloseFileTransfer();
+        WarnUser(this, 
+          tr("Unable to create a thread.\nSee Network Window for details."));
+        
+      }
+
     }
 
     delete e;
@@ -326,7 +352,7 @@ bool CFileDlg::SendFiles(const char *szF
 {
   ConstFileList fl;
   fl.push_back(szFile);
-  if (!ftman->SendFiles(fl, nPort)) return false;
+  ftman->SendFiles(fl, nPort);
 
   mleStatus->append(tr("Connecting to remote..."));
   show();
Index: src/icqd-filetransfer.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-filetransfer.cpp,v
retrieving revision 1.11
diff -u -d -p -r1.11 icqd-filetransfer.cpp
--- src/icqd-filetransfer.cpp	17 Aug 2002 08:24:01 -0000	1.11
+++ src/icqd-filetransfer.cpp	26 Sep 2002 13:14:35 -0000
@@ -30,7 +30,6 @@ const unsigned short FT_STATE_SENDINGxFI
 const unsigned short FT_STATE_CONFIRMINGxFILE = 8;
 
 
-
 //=====FILE==================================================================
 
 
@@ -219,23 +218,22 @@ bool CFileTransferManager::ReceiveFiles(
     return false;
   }
 
-  if (!StartFileTransferServer()) return false;
-
   // Create the socket manager thread
   if (pthread_create(&thread_ft, NULL, &FileTransferManager_tep, this) == -1)
-    return false;
-
+  {  PushFileTransferEvent(FT_ERRORxRESOURCES);
+     return false;
+  }
   return true;
 }
 
 
 //-----CFileTransferManager::StartAsClient-------------------------------------------
-bool CFileTransferManager::SendFiles(ConstFileList lPathNames, unsigned short nPort)
+void CFileTransferManager::SendFiles(ConstFileList lPathNames, unsigned short nPort)
 {
   m_nDirection = D_SENDER;
 
   // Validate the pathnames
-  if (lPathNames.size() == 0) return false;
+  if (lPathNames.size() == 0) return;
 
   struct stat buf;
   ConstFileList::iterator iter;
@@ -245,7 +243,7 @@ bool CFileTransferManager::SendFiles(Con
     {
       gLog.Warn("%sFile Transfer: File access error %s:\n%s%s.\n", L_WARNxSTR,
          *iter, L_BLANKxSTR, strerror(errno));
-      return false;
+      return;
     }
     m_lPathNames.push_back(strdup(*iter));
     m_nBatchFiles++;
@@ -254,13 +252,14 @@ bool CFileTransferManager::SendFiles(Con
   m_iPathName = m_lPathNames.begin();
   strcpy(m_szPathName, *m_iPathName);
 
-  if (!ConnectToFileServer(nPort)) return false;
+  m_nPort = nPort;
 
   // Create the socket manager thread
   if (pthread_create(&thread_ft, NULL, &FileTransferManager_tep, this) == -1)
-    return false;
+  {  PushFileTransferEvent(FT_ERRORxRESOURCES);
+     return;
+  }
 
-  return true;
 }
 
 
@@ -926,8 +925,6 @@ void CFileTransferManager::CloseConnecti
   m_nState = FT_STATE_DISCONNECTED;
 }
 
-
-
 void *FileTransferManager_tep(void *arg)
 {
   CFileTransferManager *ftman = (CFileTransferManager *)arg;
@@ -937,6 +934,25 @@ void *FileTransferManager_tep(void *arg)
   struct timeval tv_updates = { 2, 0 };
   int l, nSocketsAvailable, nCurrentSocket;
   char buf[2];
+
+  if( ftman->m_nDirection == D_RECEIVER )
+  {   
+      if( !ftman->StartFileTransferServer() )
+      {  
+         ftman->PushFileTransferEvent(FT_ERRORxBIND);
+         return 0;
+      }
+  }
+  else if( ftman->m_nDirection == D_SENDER )
+  {
+     if(! ftman->ConnectToFileServer(ftman->m_nPort) )
+     { 
+        ftman->PushFileTransferEvent(FT_ERRORxCONNECT);
+        return 0;
+     }
+  }
+  else
+     assert(0);
 
   while (true)
   {

Reply via email to