]> andersk Git - libfaim.git/blobdiff - src/chatnav.c
- Sun Oct 14 19:45:54 PDT 2001
[libfaim.git] / src / chatnav.c
index ae693634509d85d77df27fb0be12897bdbfae92c..c9fe9275a6d3fb016f9aacc5d7b79ff43e8bd567 100644 (file)
 /*
  * conn must be a chatnav connection!
  */
-faim_export unsigned long aim_chatnav_reqrights(struct aim_session_t *sess,
-                                               struct aim_conn_t *conn)
+faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn)
 {
-  aim_genericreq_n(sess, conn, 0x000d, 0x0002);
+       return aim_genericreq_n_snacid(sess, conn, 0x000d, 0x0002);
+}
+
+faim_export int aim_chatnav_clientready(aim_session_t *sess, aim_conn_t *conn)
+{
+       aim_frame_t *fr;
+       aim_snacid_t snacid;
+
+       if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 0x20)))
+               return -ENOMEM;
+
+       snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
+       aim_putsnac(&fr->data, 0x0001, 0x0002, 0x0000, snacid);
+
+       aimbs_put16(&fr->data, 0x000d);
+       aimbs_put16(&fr->data, 0x0001);
 
-  return sess->snac_nextid;
+       aimbs_put16(&fr->data, 0x0004);
+       aimbs_put16(&fr->data, 0x0001);
+
+       aimbs_put16(&fr->data, 0x0001);
+       aimbs_put16(&fr->data, 0x0003);
+
+       aimbs_put16(&fr->data, 0x0004);
+       aimbs_put16(&fr->data, 0x0686);
+
+       aim_tx_enqueue(sess, fr);
+
+       return 0;
 }
 
-faim_export unsigned long aim_chatnav_clientready(struct aim_session_t *sess,
-                                                 struct aim_conn_t *conn)
+faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange)
 {
-  struct command_tx_struct *newpacket; 
-  int i;
+       aim_frame_t *fr;
+       aim_snacid_t snacid;
+       aim_tlvlist_t *tl = NULL;
+
+       if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+12+strlen("invite")+strlen(name))))
+               return -ENOMEM;
 
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20)))
-    return -1;
+       snacid = aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0);
+       aim_putsnac(&fr->data, 0x000d, 0x0008, 0x0000, snacid);
 
-  newpacket->lock = 1;
+       /* exchange */
+       aimbs_put16(&fr->data, exchange);
 
-  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+       /* room cookie */
+       aimbs_put8(&fr->data, strlen("invite"));
+       aimbs_putraw(&fr->data, "invite", strlen("invite"));
 
-  i+= aimutil_put16(newpacket->data+i, 0x000d);
-  i+= aimutil_put16(newpacket->data+i, 0x0001);
+       /* 
+        * instance
+        * 
+        * Setting this to 0xffff apparently assigns the last instance.
+        *
+        */
+       aimbs_put16(&fr->data, 0xffff);
 
-  i+= aimutil_put16(newpacket->data+i, 0x0004);
-  i+= aimutil_put16(newpacket->data+i, 0x0001);
+       /* detail level */
+       aimbs_put8(&fr->data, 0x01);
 
-  i+= aimutil_put16(newpacket->data+i, 0x0001);
-  i+= aimutil_put16(newpacket->data+i, 0x0003);
+       /* room name */
+       aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), name);
 
-  i+= aimutil_put16(newpacket->data+i, 0x0004);
-  i+= aimutil_put16(newpacket->data+i, 0x0686);
+       /* tlvcount */
+       aimbs_put16(&fr->data, aim_counttlvchain(&tl));
+       aim_writetlvchain(&fr->data, &tl);
 
-  aim_tx_enqueue(sess, newpacket);
+       aim_freetlvchain(&tl);
 
-  return (sess->snac_nextid++);
+       aim_tx_enqueue(sess, fr);
+
+       return 0;
 }
 
-/*
- * Since multiple things can trigger this callback,
- * we must lookup the snacid to determine the original
- * snac subtype that was called.
- */
-faim_internal int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command)
+static int parseinfo_perms(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2)
 {
-  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);
-
-  if (!snac)
-    {
-      printf("faim: chatnav_parse_info: received response to unknown request! (%08lx)\n", snacid);
-      return 1;
-    }
-  
-  if (snac->family != 0x000d)
-    {
-      printf("faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac->family);
-      return 1;
-    }
-
-  /*
-   * We now know what the original SNAC subtype was.
-   */
-  switch(snac->type)
-    {
-    case 0x0002: /* request chat rights */
-      {
-         struct aim_tlvlist_t *tlvlist;
-         struct aim_chat_exchangeinfo *exchanges = NULL;
-         int curexchange = 0;
-         struct aim_tlv_t *exchangetlv;
-         u_char maxrooms = 0;
-         struct aim_tlvlist_t *innerlist;
-        
-         tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
-         
-         /* 
-          * Type 0x0002: Maximum concurrent rooms.
-          */ 
-         if (aim_gettlv(tlvlist, 0x0002, 1))
-           maxrooms = aim_gettlv8(tlvlist, 0x0002, 1);
-
-         /* 
-          * Type 0x0003: Exchange information
-          *
-          * There can be any number of these, each one
-          * representing another exchange.  
-          * 
-          */
-         curexchange = 0;
-         while ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1)))
-           {   
-             curexchange++;
-             exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo));
-             
-
-             /* exchange number */
-             exchanges[curexchange-1].number = aimutil_get16(exchangetlv->value);
-             innerlist = aim_readtlvchain(exchangetlv->value+2, exchangetlv->length-2);
-             
-             /* 
-              * Type 0x000d: Unknown.
-              */
-             if (aim_gettlv(innerlist, 0x000d, 1))
-               ;
-             
-             /* 
-              * Type 0x0004: Unknown
-              */
-             if (aim_gettlv(innerlist, 0x0004, 1))
-               ;
-
-             /* 
-              * Type 0x0002: Unknown
-              */
-             if (aim_gettlv(innerlist, 0x0002, 1)) {
-               unsigned short classperms;
-
-               classperms = aim_gettlv16(innerlist, 0x0002, 1);
-               
-               printf("faim: class permissions %x\n", classperms);
-             }
-
-             /*
-              * Type 0x00c9: Unknown
-              */ 
-             if (aim_gettlv(innerlist, 0x00c9, 1))
-               ;
-             
-             /*
-              * Type 0x00ca: Creation Date 
-              */
-             if (aim_gettlv(innerlist, 0x00ca, 1))
-               ;
-             
-             /*
-              * Type 0x00d0: Mandatory Channels?
-              */
-             if (aim_gettlv(innerlist, 0x00d0, 1))
-               ;
-
-             /*
-              * Type 0x00d1: Maximum Message length
-              */
-             if (aim_gettlv(innerlist, 0x00d1, 1))
-               ;
-
-             /*
-              * Type 0x00d2: Maximum Occupancy?
-              */
-             if (aim_gettlv(innerlist, 0x00d2, 1))     
-               ;       
-
-             /*
-              * Type 0x00d3: Exchange Name
-              */
-             if (aim_gettlv(innerlist, 0x00d3, 1))     
-               exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1);
-             else
-               exchanges[curexchange-1].name = NULL;
-
-             /*
-              * Type 0x00d5: Creation Permissions
-              *
-              * 0  Creation not allowed
-              * 1  Room creation allowed
-              * 2  Exchange creation allowed
-              * 
-              */
-             if (aim_gettlv(innerlist, 0x00d5, 1)) {
-               unsigned char createperms;
-
-               createperms = aim_gettlv8(innerlist, 0x00d5, 1);
-             }
-
-             /*
-              * Type 0x00d6: Character Set (First Time)
-              */             
-             if (aim_gettlv(innerlist, 0x00d6, 1))     
-               exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1);
-             else
-               exchanges[curexchange-1].charset1 = NULL;
-             
-             /*
-              * Type 0x00d7: Language (First Time)
-              */             
-             if (aim_gettlv(innerlist, 0x00d7, 1))     
-               exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1);
-             else
-               exchanges[curexchange-1].lang1 = NULL;
-
-             /*
-              * Type 0x00d8: Character Set (Second Time)
-              */             
-             if (aim_gettlv(innerlist, 0x00d8, 1))     
-               exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1);
-             else
-               exchanges[curexchange-1].charset2 = NULL;
-
-             /*
-              * Type 0x00d9: Language (Second Time)
-              */             
-             if (aim_gettlv(innerlist, 0x00d9, 1))     
-               exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1);
-             else
-               exchanges[curexchange-1].lang2 = NULL;
-             
-             aim_freetlvchain(&innerlist);
-           }
-         
-         /*
-          * Call client.
-          */
-         userfunc = aim_callhandler(command->conn, 0x000d, 0x0009);
-         if (userfunc)
-           ret = userfunc(sess, 
-                          command, 
-                          snac->type,
-                          maxrooms,
-                          curexchange, 
-                          exchanges);
-         curexchange--;
-         while(curexchange >= 0)
-           {
-             if (exchanges[curexchange].name)
+       aim_rxcallback_t userfunc;
+       int ret = 0;
+       struct aim_chat_exchangeinfo *exchanges = NULL;
+       int curexchange;
+       aim_tlv_t *exchangetlv;
+       fu8_t maxrooms = 0;
+       aim_tlvlist_t *tlvlist, *innerlist;
+
+       tlvlist = aim_readtlvchain(bs);
+
+       /* 
+        * Type 0x0002: Maximum concurrent rooms.
+        */ 
+       if (aim_gettlv(tlvlist, 0x0002, 1))
+               maxrooms = aim_gettlv8(tlvlist, 0x0002, 1);
+
+       /* 
+        * Type 0x0003: Exchange information
+        *
+        * There can be any number of these, each one
+        * representing another exchange.  
+        * 
+        */
+       for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))); ) {
+               aim_bstream_t tbs;
+
+               aim_bstream_init(&tbs, exchangetlv->value, exchangetlv->length);
+
+               curexchange++;
+       
+               exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo));
+
+               /* exchange number */
+               exchanges[curexchange-1].number = aimbs_get16(&tbs);
+               innerlist = aim_readtlvchain(&tbs);
+
+               /* 
+                * Type 0x000d: Unknown.
+                */
+               if (aim_gettlv(innerlist, 0x000d, 1))
+                       ;
+
+               /* 
+                * Type 0x0004: Unknown
+                */
+               if (aim_gettlv(innerlist, 0x0004, 1))
+                       ;
+
+               /* 
+                * Type 0x0002: Unknown
+                */
+               if (aim_gettlv(innerlist, 0x0002, 1)) {
+                       fu16_t classperms;
+
+                       classperms = aim_gettlv16(innerlist, 0x0002, 1);
+                       
+                       faimdprintf(sess, 1, "faim: class permissions %x\n", classperms);
+               }
+
+               /*
+                * Type 0x00c9: Unknown
+                */ 
+               if (aim_gettlv(innerlist, 0x00c9, 1))
+                       ;
+                     
+               /*
+                * Type 0x00ca: Creation Date 
+                */
+               if (aim_gettlv(innerlist, 0x00ca, 1))
+                       ;
+                     
+               /*
+                * Type 0x00d0: Mandatory Channels?
+                */
+               if (aim_gettlv(innerlist, 0x00d0, 1))
+                       ;
+
+               /*
+                * Type 0x00d1: Maximum Message length
+                */
+               if (aim_gettlv(innerlist, 0x00d1, 1))
+                       ;
+
+               /*
+                * Type 0x00d2: Maximum Occupancy?
+                */
+               if (aim_gettlv(innerlist, 0x00d2, 1))   
+                       ;
+
+               /*
+                * Type 0x00d3: Exchange Name
+                */
+               if (aim_gettlv(innerlist, 0x00d3, 1))   
+                       exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1);
+               else
+                       exchanges[curexchange-1].name = NULL;
+
+               /*
+                * Type 0x00d5: Creation Permissions
+                *
+                * 0  Creation not allowed
+                * 1  Room creation allowed
+                * 2  Exchange creation allowed
+                * 
+                */
+               if (aim_gettlv(innerlist, 0x00d5, 1)) {
+                       fu8_t createperms;
+
+                       createperms = aim_gettlv8(innerlist, 0x00d5, 1);
+               }
+
+               /*
+                * Type 0x00d6: Character Set (First Time)
+                */           
+               if (aim_gettlv(innerlist, 0x00d6, 1))   
+                       exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1);
+               else
+                       exchanges[curexchange-1].charset1 = NULL;
+                     
+               /*
+                * Type 0x00d7: Language (First Time)
+                */           
+               if (aim_gettlv(innerlist, 0x00d7, 1))   
+                       exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1);
+               else
+                       exchanges[curexchange-1].lang1 = NULL;
+
+               /*
+                * Type 0x00d8: Character Set (Second Time)
+                */           
+               if (aim_gettlv(innerlist, 0x00d8, 1))   
+                       exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1);
+               else
+                       exchanges[curexchange-1].charset2 = NULL;
+
+               /*
+                * Type 0x00d9: Language (Second Time)
+                */           
+               if (aim_gettlv(innerlist, 0x00d9, 1))   
+                       exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1);
+               else
+                       exchanges[curexchange-1].lang2 = NULL;
+                     
+               aim_freetlvchain(&innerlist);
+       }
+
+       /*
+        * Call client.
+        */
+       if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+               ret = userfunc(sess, rx, snac2->type, maxrooms, curexchange, exchanges);
+
+       for (curexchange--; curexchange >= 0; curexchange--) {
                free(exchanges[curexchange].name);
-             if (exchanges[curexchange].charset1)
                free(exchanges[curexchange].charset1);
-             if (exchanges[curexchange].lang1)
                free(exchanges[curexchange].lang1);
-             if (exchanges[curexchange].charset2)
                free(exchanges[curexchange].charset2);
-             if (exchanges[curexchange].lang2)
                free(exchanges[curexchange].lang2);
-             curexchange--;
-           }
-         free(exchanges);
-         aim_freetlvchain(&tlvlist);
-         
-         break;
-      }
-    case 0x0003: /* request exchange info */
-      printf("faim: chatnav_parse_info: resposne to exchange info\n");
-      break;
-    case 0x0004: /* request room info */
-      printf("faim: chatnav_parse_info: response to room info\n");
-      break;
-    case 0x0005: /* request more room info */
-      printf("faim: chatnav_parse_info: response to more room info\n");
-      break;
-    case 0x0006: /* request occupant list */
-      printf("faim: chatnav_parse_info: response to occupant info\n");
-      break;
-    case 0x0007: /* search for a room */
-      printf("faim: chatnav_parse_info: search results\n");
-      break;
-    case 0x0008: { /* create room */
-      /*
-       000d 0009 0000 0000 0010 
-       
-       0004 0053 
-            0004 -- exchange
-            0c 7a 6f6f 6f6d 7a6f 6f6f 6d34 32 cookie/name
-            0000 -- instance
-            02 -- detail level
-            0007 -- unknown!
-            006a 000c 7a 6f 6f6f 6d7a 6f6f 6f6d 3432 -- fully qualified name 
-            00c9 0002 0011 -- flags
-            00ca 0004 39c0 0883 -- create time
-            00d1 0002 0200 -- max msg len 
-            00d2 0002 0018 -- max occupants
-            00d3 000c -- name
-                 7a6f 6f6f 6d7a 6f6f 6f6d 3432 
-            00d5 0001 02 -- creation permission
-       */
-      struct aim_tlvlist_t *tlvlist, *innerlist;
-      char *ck = NULL, *fqcn = NULL, *name = NULL;
-      unsigned short exchange, instance, unknown, flags, maxmsglen, maxoccupancy;
-      unsigned long createtime = 0;
-      unsigned char createperms;
-      int i, cklen;
-      struct aim_tlv_t *bigblock;
-
-      i = 10;
-      if (!(tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i))) {
-       printf("faim: unable to read top tlv in create room response\n");
-       break;
-      }
-
-      if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) {
-       printf("faim: no bigblock in top tlv in create room response\n");
+       }
+       free(exchanges);
        aim_freetlvchain(&tlvlist);
-       break;
-      }
-      i = 0;
 
-      exchange = aimutil_get16(bigblock->value+i);
-      i += 2;
+       return ret;
+}
 
-      cklen = aimutil_get8(bigblock->value+i);
-      i++;
+static int parseinfo_create(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs, aim_snac_t *snac2)
+{
+       aim_rxcallback_t userfunc;
+       aim_tlvlist_t *tlvlist, *innerlist;
+       char *ck = NULL, *fqcn = NULL, *name = NULL;
+       fu16_t exchange = 0, instance = 0, unknown = 0, flags = 0, maxmsglen = 0, maxoccupancy = 0;
+       fu32_t createtime = 0;
+       fu8_t createperms = 0, detaillevel;
+       int cklen;
+       aim_tlv_t *bigblock;
+       int ret = 0;
+       aim_bstream_t bbbs;
 
-      ck = malloc(cklen+1);
-      memcpy(ck, bigblock->value+i, cklen);
-      ck[cklen] = '\0';
-      i += cklen;
+       tlvlist = aim_readtlvchain(bs);
 
-      instance = aimutil_get16(bigblock->value+i);
-      i += 2;
+       if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) {
+               faimdprintf(sess, 0, "no bigblock in top tlv in create room response\n");
+               aim_freetlvchain(&tlvlist);
+               return 0;
+       }
 
-      if (aimutil_get8(bigblock->value+i) != 0x02) {
-       printf("faim: unknown detaillevel in create room response (0x%02x)\n", aimutil_get8(bigblock->value+i));
-       aim_freetlvchain(&tlvlist);
-       free(ck);       
-       break;
-      }
-      i += 1;
-      
-      unknown = aimutil_get16(bigblock->value+i);
-      i += 2;
-
-      if (!(innerlist = aim_readtlvchain(bigblock->value+i, bigblock->length-i))) {
-       printf("faim: unable to read inner tlv chain in create room response\n");
-       aim_freetlvchain(&tlvlist);
-       free(ck);
-       break;
-      }
+       aim_bstream_init(&bbbs, bigblock->value, bigblock->length);
+
+       exchange = aimbs_get16(&bbbs);
+       cklen = aimbs_get8(&bbbs);
+       ck = aimbs_getstr(&bbbs, cklen);
+       instance = aimbs_get16(&bbbs);
+       detaillevel = aimbs_get8(&bbbs);
+
+       if (detaillevel != 0x02) {
+               faimdprintf(sess, 0, "unknown detaillevel in create room response (0x%02x)\n", detaillevel);
+               aim_freetlvchain(&tlvlist);
+               free(ck);
+               return 0;
+       }
+
+       unknown = aimbs_get16(&bbbs);
 
-      if (aim_gettlv(innerlist, 0x006a, 1))
-       fqcn = aim_gettlv_str(innerlist, 0x006a, 1);
+       innerlist = aim_readtlvchain(&bbbs);
 
-      if (aim_gettlv(innerlist, 0x00c9, 1))
-       flags = aim_gettlv16(innerlist, 0x00c9, 1);
+       if (aim_gettlv(innerlist, 0x006a, 1))
+               fqcn = aim_gettlv_str(innerlist, 0x006a, 1);
 
-      if (aim_gettlv(innerlist, 0x00ca, 1))
-       createtime = aim_gettlv32(innerlist, 0x00ca, 1);
+       if (aim_gettlv(innerlist, 0x00c9, 1))
+               flags = aim_gettlv16(innerlist, 0x00c9, 1);
 
-      if (aim_gettlv(innerlist, 0x00d1, 1))
-       maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1);
+       if (aim_gettlv(innerlist, 0x00ca, 1))
+               createtime = aim_gettlv32(innerlist, 0x00ca, 1);
 
-      if (aim_gettlv(innerlist, 0x00d2, 1))
-       maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1);
+       if (aim_gettlv(innerlist, 0x00d1, 1))
+               maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1);
 
-      if (aim_gettlv(innerlist, 0x00d3, 1))
-       name = aim_gettlv_str(innerlist, 0x00d3, 1);
+       if (aim_gettlv(innerlist, 0x00d2, 1))
+               maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1);
 
-      if (aim_gettlv(innerlist, 0x00d5, 1))
-       createperms = aim_gettlv8(innerlist, 0x00d5, 1);
+       if (aim_gettlv(innerlist, 0x00d3, 1))
+               name = aim_gettlv_str(innerlist, 0x00d3, 1);
+
+       if (aim_gettlv(innerlist, 0x00d5, 1))
+               createperms = aim_gettlv8(innerlist, 0x00d5, 1);
+
+       if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
+               ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck);
+       }
 
-      if ((userfunc = aim_callhandler(command->conn, 0x000d, 0x0009))) {
-       ret = userfunc(sess, command, snac->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck);
-      }
-     
-      if (ck)
        free(ck);
-      if (name)
        free(name);
-      if (fqcn)
        free(fqcn);
-      aim_freetlvchain(&innerlist);
-      aim_freetlvchain(&tlvlist);
-
-      break;
-    }
-    default: /* unknown */
-      printf("faim: chatnav_parse_info: unknown request subtype (%04x)\n", snac->type);
-    }
-
-  if (snac && snac->data)
-    free(snac->data);
-  if (snac)
-    free(snac);
-  
-  return ret;
+       aim_freetlvchain(&innerlist);
+       aim_freetlvchain(&tlvlist);
+
+       return ret;
 }
 
-faim_export unsigned long aim_chatnav_createroom(struct aim_session_t *sess,
-                                                struct aim_conn_t *conn,
-                                                char *name, 
-                                                u_short exchange)
+/*
+ * Since multiple things can trigger this callback, we must lookup the 
+ * snacid to determine the original snac subtype that was called.
+ */
+static int parseinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
 {
-  struct command_tx_struct *newpacket; 
-  int i;
-
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+12+strlen("invite")+strlen(name))))
-    return -1;
-
-  newpacket->lock = 1;
-
-  i = aim_putsnac(newpacket->data, 0x000d, 0x0008, 0x0000, sess->snac_nextid);
-
-  /* exchange */
-  i+= aimutil_put16(newpacket->data+i, exchange);
+       aim_snac_t *snac2;
+       int ret = 0;
+
+       if (!(snac2 = aim_remsnac(sess, snac->id))) {
+               faimdprintf(sess, 0, "faim: chatnav_parse_info: received response to unknown request! (%08lx)\n", snac->id);
+               return 0;
+       }
+
+       if (snac2->family != 0x000d) {
+               faimdprintf(sess, 0, "faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac2->family);
+               return 0;
+       }
+
+       /*
+        * We now know what the original SNAC subtype was.
+        */
+       if (snac2->type == 0x0002) /* request chat rights */
+               ret = parseinfo_perms(sess, mod, rx, snac, bs, snac2);
+       else if (snac2->type == 0x0003) /* request exchange info */
+               faimdprintf(sess, 0, "chatnav_parse_info: resposne to exchange info\n");
+       else if (snac2->type == 0x0004) /* request room info */
+               faimdprintf(sess, 0, "chatnav_parse_info: response to room info\n");
+       else if (snac2->type == 0x0005) /* request more room info */
+               faimdprintf(sess, 0, "chatnav_parse_info: response to more room info\n");
+       else if (snac2->type == 0x0006) /* request occupant list */
+               faimdprintf(sess, 0, "chatnav_parse_info: response to occupant info\n");
+       else if (snac2->type == 0x0007) /* search for a room */
+               faimdprintf(sess, 0, "chatnav_parse_info: search results\n");
+       else if (snac2->type == 0x0008) /* create room */
+               ret = parseinfo_create(sess, mod, rx, snac, bs, snac2);
+       else
+               faimdprintf(sess, 0, "chatnav_parse_info: unknown request subtype (%04x)\n", snac2->type);
+
+       if (snac2)
+               free(snac2->data);
+       free(snac2);
+
+       return ret;
+}
 
-  /* room cookie */
-  i+= aimutil_put8(newpacket->data+i, strlen("invite"));
-  i+= aimutil_putstr(newpacket->data+i, "invite", strlen("invite"));
+static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
+{
 
-  /* instance */
-  i+= aimutil_put16(newpacket->data+i, 0xffff);
-  
-  /* detail level */
-  i+= aimutil_put8(newpacket->data+i, 0x01);
-  
-  /* tlvcount */
-  i+= aimutil_put16(newpacket->data+i, 0x0001);
+       if (snac->subtype == 0x0009)
+               return parseinfo(sess, mod, rx, snac, bs);
 
-  /* room name */
-  i+= aim_puttlv_str(newpacket->data+i, 0x00d3, strlen(name), name);
+       return 0;
+}
 
-  aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0);
+faim_internal int chatnav_modfirst(aim_session_t *sess, aim_module_t *mod)
+{
 
-  aim_tx_enqueue(sess, newpacket);
+       mod->family = 0x000d;
+       mod->version = 0x0000;
+       mod->flags = 0;
+       strncpy(mod->name, "chatnav", sizeof(mod->name));
+       mod->snachandler = snachandler;
 
-  return sess->snac_nextid;
+       return 0;
 }
This page took 0.074088 seconds and 4 git commands to generate.