]> andersk Git - libfaim.git/blobdiff - aim_chatnav.c
- Thu Aug 17 23:19:40 UTC 2000
[libfaim.git] / aim_chatnav.c
index b6764e1c152dfe827d787b428540ae716edb61f0..adbd095993c90a8686fcada127052decaa4a2f66 100644 (file)
@@ -31,33 +31,29 @@ u_long aim_chatnav_reqrights(struct aim_session_t *sess,
 u_long aim_chatnav_clientready(struct aim_session_t *sess,
                               struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket; 
+  struct command_tx_struct *newpacket; 
   int i;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 0x20;
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20)))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  newpacket->lock = 1;
 
-  i+= aimutil_put16(newpacket.data+i, 0x000d);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x000d);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
-  i+= aimutil_put16(newpacket.data+i, 0x0003);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0686);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0003);
 
-  aim_tx_enqueue(sess, &newpacket);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0686);
+
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -72,6 +68,7 @@ int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct
   struct aim_snac_t *snac;
   u_long snacid;
   rxcallback_t userfunc;
+  int ret=1;
   
   snacid = aimutil_get32(command->data+6);
   snac = aim_remsnac(sess, snacid);
@@ -100,7 +97,6 @@ int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct
          int curexchange = 0;
          struct aim_tlv_t *exchangetlv;
          u_char maxrooms = 0;
-         int ret = 1;
          struct aim_tlvlist_t *innerlist;
         
          tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
@@ -219,7 +215,8 @@ int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct
                exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1);
              else
                exchanges[curexchange-1].lang2 = NULL;
-
+             
+             aim_freetlvchain(&innerlist);
            }
          
          /*
@@ -249,33 +246,38 @@ int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct
              curexchange--;
            }
          free(exchanges);
-         aim_freetlvchain(&innerlist);
          aim_freetlvchain(&tlvlist);
-         return ret;
+         
+         break;
       }
     case 0x0003: /* request exchange info */
       printf("faim: chatnav_parse_info: resposne to exchange info\n");
-      return 1;
+      break;
     case 0x0004: /* request room info */
       printf("faim: chatnav_parse_info: response to room info\n");
-      return 1;
+      break;
     case 0x0005: /* request more room info */
       printf("faim: chatnav_parse_info: response to more room info\n");
-      return 1;
+      break;
     case 0x0006: /* request occupant list */
       printf("faim: chatnav_parse_info: response to occupant info\n");
-      return 1;
+      break;
     case 0x0007: /* search for a room */
       printf("faim: chatnav_parse_info: search results\n");
-      return 1;
+      break;
     case 0x0008: /* create room */
       printf("faim: chatnav_parse_info: response to create room\n");
-      return 1;
+      break;
     default: /* unknown */
       printf("faim: chatnav_parse_info: unknown request subtype (%04x)\n", snac->type);
     }
 
-  return 1; /* shouldn't get here */
+  if (snac && snac->data)
+    free(snac->data);
+  if (snac)
+    free(snac);
+  
+  return ret;
 }
 
 u_long aim_chatnav_createroom(struct aim_session_t *sess,
@@ -283,40 +285,35 @@ u_long aim_chatnav_createroom(struct aim_session_t *sess,
                              char *name, 
                              u_short exchange)
 {
-  struct command_tx_struct newpacket; 
+  struct command_tx_struct *newpacket; 
   int i;
   struct aim_snac_t snac;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
-  newpacket.type = 0x02;
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+12+strlen("invite")+strlen(name))))
+    return -1;
 
-  newpacket.commandlen = 10 + 12 + strlen("invite") + strlen(name);
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x000d, 0x0008, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x000d, 0x0008, 0x0000, sess->snac_nextid);
 
   /* exchange */
-  i+= aimutil_put16(newpacket.data+i, exchange);
+  i+= aimutil_put16(newpacket->data+i, exchange);
 
   /* room cookie */
-  i+= aimutil_put8(newpacket.data+i, strlen("invite"));
-  i+= aimutil_putstr(newpacket.data+i, "invite", strlen("invite"));
+  i+= aimutil_put8(newpacket->data+i, strlen("invite"));
+  i+= aimutil_putstr(newpacket->data+i, "invite", strlen("invite"));
 
   /* instance */
-  i+= aimutil_put16(newpacket.data+i, 0xffff);
+  i+= aimutil_put16(newpacket->data+i, 0xffff);
   
   /* detail level */
-  i+= aimutil_put8(newpacket.data+i, 0x01);
+  i+= aimutil_put8(newpacket->data+i, 0x01);
   
   /* tlvcount */
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
   /* room name */
-  i+= aim_puttlv_str(newpacket.data+i, 0x00d3, strlen(name), name);
+  i+= aim_puttlv_str(newpacket->data+i, 0x00d3, strlen(name), name);
 
   snac.id = sess->snac_nextid;
   snac.family = 0x000d;
@@ -326,7 +323,7 @@ u_long aim_chatnav_createroom(struct aim_session_t *sess,
   
   aim_newsnac(sess, &snac);
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
This page took 0.054775 seconds and 4 git commands to generate.