ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_core.C,1.32,1.33 ms


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/modules/msn2/libmsn2 msn_core.C,1.32,1.33 msn_core.h,1.9,1.10
Date: Wed, 19 Mar 2003 18:15:29 -0500

Update of /cvsroot/ayttm/ayttm/modules/msn2/libmsn2
In directory subversions:/tmp/cvs-serv32284/modules/msn2/libmsn2

Modified Files:
        msn_core.C msn_core.h 
Log Message:
better error handling in msn file tranfre


Index: msn_core.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_core.C,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- msn_core.C  19 Mar 2003 16:42:21 -0000      1.32
+++ msn_core.C  19 Mar 2003 23:15:27 -0000      1.33
@@ -591,7 +591,8 @@
     { break; }
     list=list->next;
     if(list==NULL)
-    { printf("Network traffic not for us\n"); return; } // not for us
+    { if(DEBUG) printf("Network traffic not for us\n"); 
+       return; } // not for us
   }
 
   // first, siphon off any file transfer traffic to the special handler
@@ -680,7 +681,8 @@
     { break; }
     list=list->next;
     if(list==NULL)
-    { printf("Socket close not for us\n"); return; } // not for us
+    { if(DEBUG) printf("Socket close not for us\n"); 
+    return; } // not for us
   }
 
   msn_clean_up(conn);
@@ -1114,14 +1116,50 @@
 }
 
 
+void msn_filetrans_cancel(invitation_ftp * inv)
+{
+  llist *l;
+  int inv_is_out=0;
+  for(l=inv->conn->invitations_out; l && l->data; l=l->next) {
+         if (inv == l->data)
+                 inv_is_out=1;
+  }
+  if(inv_is_out)
+       inv->cancelled = 1;
+  else {
+       write(inv->conn->sock, "CCL\r\n", 5);
+  }
+}
+
+void msn_filetrans_cancel_clean(invitation_ftp *inv) 
+{
+  llist * l;
+  msnconn * conn;
+  // one of the two below will fail, but it will do so safely and quietly
+  msn_del_from_llist(inv->conn->invitations_in, inv);
+  msn_del_from_llist(inv->conn->invitations_out, inv);
+
+  l=connections;
+
+  while(1)
+  {
+    if(l==NULL) { delete inv; return; } // Hmm, couldn't find it...
+
+    conn=(msnconn *)l->data;
+
+    if(conn->type==CONN_FTP && ((authdata_FTP *)(conn->auth))->inv==inv)
+    { break; }
+
+    l=l->next;
+  }
+
+  msn_clean_up(conn);  
+}
+
 void msn_handle_filetrans_incoming(msnconn * conn, int readable, int writable)
 {
   authdata_FTP * auth=(authdata_FTP *)conn->auth;
 
-  if(DEBUG)
-  printf("Incoming from file sender\n");
-  
-
   if(auth->direction==MSNFTP_RECV)
   {
     if(!readable) { return; } // not interested...
@@ -1153,6 +1191,10 @@
 
         write(conn->sock, "TFR\r\n", strlen("TFR\r\n"));
       }
+      if (!strcmp(args[0], "CCL")) {
+       if(DEBUG) printf("got CCL\n");
+       msn_clean_up(conn);      
+      }
       delete [] args;
       auth->num_ignore=3;
     }
@@ -1176,11 +1218,19 @@
     {
       if(read(conn->sock, &c, 1)<1)
       {
+       ext_filetrans_failed((invitation_ftp *)auth->inv, 0, "Connection 
dropped");
+       msn_del_from_llist(auth->inv->conn->invitations_in, auth->inv);
         msn_clean_up(conn);
         return;
       }
       if(auth->num_ignore>0)
       {
+       if(auth->num_ignore == 3 && c == 1) {
+               ext_filetrans_failed((invitation_ftp *)auth->inv, 0, "Cancelled 
by remote user");
+               msn_del_from_llist(auth->inv->conn->invitations_in, auth->inv);
+               msn_clean_up(conn);      
+               return;
+       }
         auth->num_ignore--;
         continue;
       }
@@ -1285,16 +1335,19 @@
          delete [] args;
         }
       } else {
+             
         // just pumping data now
 
 #ifndef __MINGW32__
         struct pollfd pfd;
+       struct pollfd pin;
 #endif
         char c;
 #ifndef __MINGW32__
         pfd.fd=conn->sock;
         pfd.events=POLLOUT;
-
+       pin.fd=conn->sock;
+       pin.events=POLLIN;
         while(poll(&pfd, 1, 0)==1)
 #else
         fd_set fds;
@@ -1309,14 +1362,35 @@
            char check[3];
 #else
             unsigned char check[3];
+           if (poll(&pin, 1, 0)==1) {
+               int numargs;
+               char **args =msn_read_line(conn->sock, &numargs);
+               if (!strcmp(args[0],"CCL")) {
+                       /* remote cancelled reception */
+                       ext_filetrans_failed(auth->inv, 0, "Remote user 
cancelled");
+                       msn_del_from_llist(auth->inv->conn->invitations_out, 
auth->inv);
+                       msn_clean_up(conn);
+                       return;
+               }
+    
+           }
 #endif
             int 
to_go=(auth->inv->filesize-auth->bytes_done>2045)?(2045):(auth->inv->filesize-auth->bytes_done);
 
-
-            check[0]='\0';
-            check[1]=to_go%256;
-            check[2]=to_go/256;
-            write(conn->sock, check, 3);
+            if (!auth->inv->cancelled) {
+                   check[0]='\0';
+                   check[1]=to_go%256;
+                   check[2]=to_go/256;
+                   write(conn->sock, check, 3);
+           } else {
+                   check[0]=1;
+                   check[1]=0;
+                   check[2]=0;
+                   write(conn->sock, check, 3);
+                   msn_filetrans_cancel_clean(auth->inv);
+                   return;
+           }
+            
           }
 
           if(read(auth->fd, &c, 1)<1)
@@ -1390,12 +1464,12 @@
 
   sprintf(buf, "Invitation-Command: ACCEPT\r\n"
                  "Invitation-Cookie: %s\r\n"
-                 "IP-Address: %s\r\n"
+                 "IP-Address: 62.212.100.143\r\n"
                  "Port: %d\r\n"
                  "AuthCookie: %s\r\n"
                  "Launch-Application: FALSE\r\n"
                  "Request-Data: IP-Address:\r\n\r\n",
-    inv->cookie, ext_get_IP(), port, auth->cookie);
+    inv->cookie, /*ext_get_IP(),*/ port, auth->cookie);
 
   msg->body=msn_permstring(buf);
 
@@ -1670,32 +1744,6 @@
 if(DEBUG)
    printf("Accepting netmeeting\n");
 
-}
-
-void msn_filetrans_cancel(invitation_ftp * inv)
-{
-  llist * l;
-  msnconn * conn;
-
-  // one of the two below will fail, but it will do so safely and quietly
-  msn_del_from_llist(inv->conn->invitations_in, inv);
-  msn_del_from_llist(inv->conn->invitations_out, inv);
-
-  l=connections;
-
-  while(1)
-  {
-    if(l==NULL) { delete inv; return; } // Hmm, couldn't find it...
-
-    conn=(msnconn *)l->data;
-
-    if(conn->type==CONN_FTP && ((authdata_FTP *)(conn->auth))->inv==inv)
-    { break; }
-
-    l=l->next;
-  }
-
-  msn_clean_up(conn);
 }
 
 invitation_ftp * msn_filetrans_send(msnconn * conn, char * path)

Index: msn_core.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/libmsn2/msn_core.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- msn_core.h  19 Mar 2003 16:42:21 -0000      1.9
+++ msn_core.h  19 Mar 2003 23:15:27 -0000      1.10
@@ -149,8 +149,8 @@
   public:
   char * filename;
   long unsigned filesize;
-
-  invitation_ftp() { filename=NULL; }
+  int cancelled;
+  invitation_ftp() { filename=NULL; cancelled=0;}
   ~invitation_ftp()
     { if(filename!=NULL) { delete filename; } }
 };
@@ -223,6 +223,8 @@
 void msn_filetrans_accept(invitation_ftp * inv, char * dest);
 
 void msn_filetrans_reject(invitation_ftp * inv);
+
+void msn_filetrans_cancel(invitation_ftp * inv);
 
 void msn_netmeeting_accept(invitation_voice * inv);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]