ayttm-commits
[Top][All Lists]
Advanced

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

[Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.16,1.1


From: Philip S Tellis <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/modules/yahoo2/libyahoo2 libyahoo2.c,1.16,1.17 yahoo2.h,1.8,1.9 yahoo2_callbacks.h,1.3,1.4
Date: Mon, 24 Mar 2003 05:56:38 -0500

Update of /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2
In directory subversions:/tmp/cvs-serv15824/modules/yahoo2/libyahoo2

Modified Files:
        libyahoo2.c yahoo2.h yahoo2_callbacks.h 
Log Message:
async connect for yahoo login

Index: libyahoo2.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/libyahoo2.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- libyahoo2.c 22 Mar 2003 18:50:27 -0000      1.16
+++ libyahoo2.c 24 Mar 2003 10:56:36 -0000      1.17
@@ -103,7 +103,7 @@
 
 int yahoo_connect(char * host, int port)
 {
-       return YAHOO_CALLBACK(ext_yahoo_connect)(host, port);
+       return YAHOO_CALLBACK(ext_yahoo_connect_sync)(host, port);
 }
 
 extern char pager_host[];
@@ -1766,39 +1766,52 @@
        return len;
 }
 
-int yahoo_login(const char *username, const char *password, int initial)
+int yahoo_init(const char *username, const char *password)
 {
        struct yahoo_data *yd;
-       struct yahoo_packet *pkt;
-       int fd;
-       int i;
-
-       fd = YAHOO_CALLBACK(ext_yahoo_connect)(pager_host, atoi(pager_port));
-
-       for(i=0; fd <=0 && fallback_ports[i]; i++) {
-               fd = YAHOO_CALLBACK(ext_yahoo_connect)(pager_host, 
-                               fallback_ports[i]);
-       }
-
-       if(fd <= 0)
-               return fd;
 
        yd = y_new0(struct yahoo_data, 1);
-       yd->fd = fd;
+
+       if(!yd)
+               return 0;
 
        yd->user = strdup(username);
        yd->password = strdup(password);
 
-       yd->initial_status = initial;
+       yd->initial_status = -1;
        yd->current_status = -1;
 
        yd->client_id = ++last_id;
 
        add_to_list(yd, yd->fd);
 
+       return yd->client_id;
+}
+
+void yahoo_connected(int id, int fd, int error)
+{
+       static int i;
+       struct yahoo_data *yd = find_conn_by_id(id);
+       struct yahoo_packet *pkt;
+
+       if(!yd)
+               return;
+
+       if(error) {
+               yd->fd = YAHOO_CALLBACK(ext_yahoo_connect)(id, pager_host,
+                               fallback_ports[i++]);
+               if(yd->fd > 0)
+                       yahoo_connected(id, yd->fd, 0);
+               else if(errno != EINPROGRESS)
+                       yahoo_connected(id, yd->fd, errno);
+               return;
+       }
+
+       yd->fd = fd;
+
        pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0);
 
-       yahoo_packet_hash(pkt, 1, username);
+       yahoo_packet_hash(pkt, 1, yd->user);
        NOTICE(("Sending initial packet"));
        yahoo_send_packet(yd, pkt, 0);
 
@@ -1806,7 +1819,23 @@
 
        YAHOO_CALLBACK(ext_yahoo_add_handler)(yd->client_id, yd->fd, 
YAHOO_INPUT_READ);
 
-       return yd->client_id;
+}
+
+void yahoo_login(int id, int initial)
+{
+       struct yahoo_data *yd = find_conn_by_id(id);
+
+       if(!yd)
+               return;
+
+       yd->initial_status = initial;
+
+       yd->fd = YAHOO_CALLBACK(ext_yahoo_connect)(id, pager_host, 
atoi(pager_port));
+
+       if(yd->fd > 0)
+               yahoo_connected(id, yd->fd, 0);
+       else if(errno != EINPROGRESS)
+               yahoo_connected(id, yd->fd, errno);
 }
 
 

Index: yahoo2.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- yahoo2.h    7 Feb 2003 05:24:03 -0000       1.8
+++ yahoo2.h    24 Mar 2003 10:56:36 -0000      1.9
@@ -40,10 +40,15 @@
 /* id is the successful value returned by yahoo_login */
 
 
-/* login returns a connection id used to identify the connection hereon */
+/* init returns a connection id used to identify the connection hereon */
+/* or 0 on failure */
+/* you must call init before calling any other function */
+int  yahoo_init(const char *username, const char *password);
+/* should be called in case of asynchronous connect after connect completes */
+void  yahoo_connected(int id, int fd, int error);
+/* login logs in to the server */
 /* initial is of type enum yahoo_status.  see yahoo2_types.h */
-/* returns <= 0 on error - whatever ext_yahoo_connect returned */
-int  yahoo_login(const char *username, const char *password, int initial);
+void  yahoo_login(int id, int initial);
 void yahoo_logoff(int id);
 /* reloads status of all buddies */
 void yahoo_refresh(int id);

Index: yahoo2_callbacks.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/yahoo2/libyahoo2/yahoo2_callbacks.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- yahoo2_callbacks.h  20 Mar 2003 09:18:58 -0000      1.3
+++ yahoo2_callbacks.h  24 Mar 2003 10:56:36 -0000      1.4
@@ -397,12 +397,14 @@
  * Name: ext_yahoo_connect
  *     Connect to a host:port
  * Params:
+ *     id   - the id that identifies this connection
  *     host - the host to connect to
  *     port - the port to connect on
  * Returns:
  *     a unix file descriptor to the socket
  */
-int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(char *host, int port);
+int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(int id, char *host, int port);
+int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_sync)(char *host, int port);
 
 #ifdef USE_STRUCT_CALLBACKS
 };





reply via email to

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