]> andersk Git - libfaim.git/blobdiff - aim_misc.c
- Sun Feb 11 01:07:36 UTC 2001
[libfaim.git] / aim_misc.c
index b863b6c19ff0395dd7f6a1b855538ad43ba6e16f..16c42d8a88d40cec44e4730b21c9bd33447d336c 100644 (file)
@@ -11,6 +11,7 @@
  *
  */
 
+#define FAIM_INTERNAL
 #include <faim/aim.h> 
 
 /*
@@ -21,9 +22,9 @@
  *  time.  
  *
  */
-u_long aim_bos_setidle(struct aim_session_t *sess,
-                      struct aim_conn_t *conn, 
-                      u_long idletime)
+faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess,
+                                         struct aim_conn_t *conn, 
+                                         u_long idletime)
 {
   return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime);
 }
@@ -57,9 +58,10 @@ u_long aim_bos_setidle(struct aim_session_t *sess,
  *
  *
  */
-u_long aim_bos_changevisibility(struct aim_session_t *sess,
-                               struct aim_conn_t *conn, 
-                               int changetype, char *denylist)
+faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *sess,
+                                                  struct aim_conn_t *conn, 
+                                                  int changetype, 
+                                                  char *denylist)
 {
   struct command_tx_struct *newpacket;
   int packlen = 0;
@@ -134,73 +136,69 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
  * XXX: I can't stress the TODO enough.
  *
  */
-u_long aim_bos_setbuddylist(struct aim_session_t *sess,
-                           struct aim_conn_t *conn, 
-                           char *buddy_list)
+faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess,
+                                              struct aim_conn_t *conn, 
+                                              char *buddy_list)
 {
   int i, j;
 
   struct command_tx_struct *newpacket;
 
-  int packet_login_phase3c_hi_b_len = 0;
+  int len = 0;
 
   char *localcpy = NULL;
   char *tmpptr = NULL;
 
-  packet_login_phase3c_hi_b_len = 16; /* 16b for FLAP and SNAC headers */
+  len = 10; /* 10B SNAC headers */
 
-  /* bail out if we can't make the packet */
-  if (!buddy_list) {
+  if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) 
     return -1;
-  }
-
-  localcpy = (char *) malloc(strlen(buddy_list)+1);
-  memcpy(localcpy, buddy_list, strlen(buddy_list)+1);
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
 
   i = 0;
   tmpptr = strtok(localcpy, "&");
-  while ((tmpptr != NULL) && (i < 100))
-    {
+  while ((tmpptr != NULL) && (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      packet_login_phase3c_hi_b_len += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    len += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 #if debug > 0
-  printf("*** send buddy list len: %d (%x)\n", packet_login_phase3c_hi_b_len, packet_login_phase3c_hi_b_len);
+  printf("*** send buddy list len: %d (%x)\n", len, len);
 #endif
-  free(localcpy);
 
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packet_login_phase3c_hi_b_len - 6)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, len)))
     return -1;
 
   newpacket->lock = 1;
   
-  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0);
 
   j = 10;  /* the next byte */
 
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
   i = 0;
-  tmpptr = strtok(buddy_list, "&");
-  while ((tmpptr != NULL) & (i < 100))
-    {
+  tmpptr = strtok(localcpy, "&");
+  while ((tmpptr != NULL) & (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      newpacket->data[j] = strlen(tmpptr);
-      memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
-      j += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    newpacket->data[j] = strlen(tmpptr);
+    memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
+    j += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 
   newpacket->lock = 0;
 
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  free(localcpy);
+
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -210,11 +208,11 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
  *
  * 
  */
-u_long aim_bos_setprofile(struct aim_session_t *sess,
-                         struct aim_conn_t *conn, 
-                         char *profile,
-                         char *awaymsg,
-                         unsigned int caps)
+faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess,
+                                            struct aim_conn_t *conn, 
+                                            char *profile,
+                                            char *awaymsg,
+                                            unsigned short caps)
 {
   struct command_tx_struct *newpacket;
   int i = 0, tmp, caplen;
@@ -257,94 +255,101 @@ u_long aim_bos_setprofile(struct aim_session_t *sess,
  * a bitwise OR of all the user classes you want to see you.
  *
  */
-u_long aim_bos_setgroupperm(struct aim_session_t *sess,
-                           struct aim_conn_t *conn, 
-                           u_long mask)
+faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *sess,
+                                              struct aim_conn_t *conn, 
+                                              u_long mask)
 {
   return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask);
 }
 
+faim_internal int aim_parse_bosrights(struct aim_session_t *sess,
+                                     struct command_rx_struct *command, ...)
+{
+  rxcallback_t userfunc = NULL;
+  int ret=1;
+  struct aim_tlvlist_t *tlvlist;
+  unsigned short maxpermits = 0, maxdenies = 0;
+
+  /* 
+   * TLVs follow 
+   */
+  if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10)))
+    return ret;
+
+  /*
+   * TLV type 0x0001: Maximum number of buddies on permit list.
+   */
+  if (aim_gettlv(tlvlist, 0x0001, 1))
+    maxpermits = aim_gettlv16(tlvlist, 0x0001, 1);
+
+  /*
+   * TLV type 0x0002: Maximum number of buddies on deny list.
+   *
+   */
+  if (aim_gettlv(tlvlist, 0x0002, 1)) 
+    maxdenies = aim_gettlv16(tlvlist, 0x0002, 1);
+  
+  if ((userfunc = aim_callhandler(command->conn, 0x0009, 0x0003)))
+    ret = userfunc(sess, command, maxpermits, maxdenies);
+
+  aim_freetlvchain(&tlvlist);
+
+  return ret;  
+}
+
 /*
  * aim_bos_clientready()
  * 
  * Send Client Ready.  
  *
- * TODO: Dynamisize.
- *
  */
-u_long aim_bos_clientready(struct aim_session_t *sess,
-                          struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess,
+                                             struct aim_conn_t *conn)
 {
-  u_char command_2[] = {
-     /* placeholders for dynamic data */
-     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-     0xff, 0xff, 
-     /* real data */
-     0x00, 0x01,   
-     0x00, 0x03, 
-     0x00, 0x04, 
-     0x06, 0x86,  
-     0x00, 0x02, 
-     0x00, 0x01,  
-     0x00, 0x04, 
-     0x00, 0x01, 
-     0x00, 0x03, 
-     0x00, 0x01,  
-     0x00, 0x04, 
-     0x00, 0x01, 
-     0x00, 0x04, 
-     0x00, 0x01, 
-     0x00, 0x04,
-     0x00, 0x01,
-     0x00, 0x06, 
-     0x00, 0x01, 
-     0x00, 0x04,  
-     0x00, 0x01, 
-     0x00, 0x08, 
-     0x00, 0x01, 
-     0x00, 0x04,
-     0x00, 0x01,
-     0x00, 0x09, 
-     0x00, 0x01, 
-     0x00, 0x04,
-     0x00, 0x01, 
-     0x00, 0x0a, 
-     0x00, 0x01, 
-     0x00, 0x04,
-     0x00, 0x01,
-     0x00, 0x0b,
-     0x00, 0x01, 
-     0x00, 0x04,
-     0x00, 0x01
+  struct aim_tool_version tools[] = {
+    {0x0001, 0x0003,    AIM_TOOL_WIN32, 0x0686},
+    {0x0002, 0x0001,    AIM_TOOL_WIN32, 0x0001}, 
+    {0x0003, 0x0001,    AIM_TOOL_WIN32, 0x0001},
+    {0x0004, 0x0001,    AIM_TOOL_WIN32, 0x0001},
+    {0x0006, 0x0001,    AIM_TOOL_WIN32, 0x0001}, 
+    {0x0008, 0x0001,    AIM_TOOL_WIN32, 0x0001},
+    {0x0009, 0x0001,    AIM_TOOL_WIN32, 0x0001}, 
+    {0x000a, 0x0001,    AIM_TOOL_WIN32, 0x0001},
+    {0x000b, 0x0001,    AIM_TOOL_WIN32, 0x0001}
   };
-  int command_2_len = 0x52;
+  int i,j;
   struct command_tx_struct *newpacket;
-  
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, command_2_len)))
+  int toolcount = sizeof(tools)/sizeof(struct aim_tool_version);
+
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
     return -1;
 
   newpacket->lock = 1;
 
-  memcpy(newpacket->data, command_2, command_2_len);
-  
-  /* This write over the dynamic parts of the byte block */
-  aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
+
+  for (j = 0; j < toolcount; j++) {
+    i += aimutil_put16(newpacket->data+i, tools[j].group);
+    i += aimutil_put16(newpacket->data+i, tools[j].version);
+    i += aimutil_put16(newpacket->data+i, tools[j].tool);
+    i += aimutil_put16(newpacket->data+i, tools[j].toolversion);
+  }
+
+  newpacket->commandlen = i;
+  newpacket->lock = 0;
 
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  return sess->snac_nextid;
 }
 
 /* 
  *  Request Rate Information.
  * 
  */
-u_long aim_bos_reqrate(struct aim_session_t *sess,
-                      struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess,
+                                         struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
 }
@@ -353,32 +358,30 @@ u_long aim_bos_reqrate(struct aim_session_t *sess,
  *  Rate Information Response Acknowledge.
  *
  */
-u_long aim_bos_ackrateresp(struct aim_session_t *sess,
-                          struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess,
+                                             struct aim_conn_t *conn)
 {
   struct command_tx_struct *newpacket;
-  int packlen = 18, i=0;
+  int packlen = 20, i=0;
 
-  if (conn->type != AIM_CONN_TYPE_BOS)
-    packlen += 2;
-
-  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)));
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
   
   newpacket->lock = 1;
 
-  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0);
   i += aimutil_put16(newpacket->data+i, 0x0001); 
   i += aimutil_put16(newpacket->data+i, 0x0002);
   i += aimutil_put16(newpacket->data+i, 0x0003);
   i += aimutil_put16(newpacket->data+i, 0x0004);
-  
-  if (conn->type != AIM_CONN_TYPE_BOS) {
-    i += aimutil_put16(newpacket->data+i, 0x0005);
-  }
+  i += aimutil_put16(newpacket->data+i, 0x0005);
+
+  newpacket->commandlen = i;
+  newpacket->lock = 0;
 
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -390,9 +393,9 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess,
  *  Bit 2:  Allows other AIM users to see how long you've been a member.
  *
  */
-u_long aim_bos_setprivacyflags(struct aim_session_t *sess,
-                              struct aim_conn_t *conn, 
-                              u_long flags)
+faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess,
+                                                 struct aim_conn_t *conn, 
+                                                 u_long flags)
 {
   return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags);
 }
@@ -404,43 +407,32 @@ u_long aim_bos_setprivacyflags(struct aim_session_t *sess,
  * because aparently it uses SNAC flags.
  *
  */
-u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
-                              struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
+                                                 struct aim_conn_t *conn)
 {
-  struct command_tx_struct *newpacket;
-  
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12)))
-    return -1;
-
-  newpacket->lock = 1;
-
-  aim_putsnac(newpacket->data, 0x000a, 0x0001, 0x000e /* huh? */, sess->snac_nextid);
-  
-  newpacket->data[10] = 0x0d;
-  newpacket->data[11] = 0xda;
-
-  newpacket->lock = 0;
-  aim_tx_enqueue(sess, newpacket);
-
-  return (sess->snac_nextid++);
+  return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
 }
 
-u_long aim_setversions(struct aim_session_t *sess,
-                               struct aim_conn_t *conn)
+faim_export unsigned long aim_setversions(struct aim_session_t *sess,
+                                         struct aim_conn_t *conn)
 {
   struct command_tx_struct *newpacket;
   int i;
 
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*11))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12))))
     return -1;
 
   newpacket->lock = 1;
 
   i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
+  aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
 
   i += aimutil_put16(newpacket->data+i, 0x0001);
   i += aimutil_put16(newpacket->data+i, 0x0003);
 
+  i += aimutil_put16(newpacket->data+i, 0x0013);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
   i += aimutil_put16(newpacket->data+i, 0x0002);
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
@@ -463,24 +455,16 @@ u_long aim_setversions(struct aim_session_t *sess,
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
   i += aimutil_put16(newpacket->data+i, 0x000b);
-  i += aimutil_put16(newpacket->data+i, 0x0002);
-
-  i += aimutil_put16(newpacket->data+i, 0x000c);
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket->data+i, 0x0015);
+  i += aimutil_put16(newpacket->data+i, 0x000c);
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
-#if 0
-  for (j = 0; j < 0x10; j++) {
-    i += aimutil_put16(newpacket->data+i, j); /* family */
-    i += aimutil_put16(newpacket->data+i, 0x0003); /* version */
-  }
-#endif
+  newpacket->commandlen = i;
   newpacket->lock = 0;
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  return sess->snac_nextid;
 }
 
 
@@ -490,7 +474,7 @@ u_long aim_setversions(struct aim_session_t *sess,
  * Service request. 
  *
  */
-u_long aim_bos_reqservice(struct aim_session_t *sess,
+faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess,
                          struct aim_conn_t *conn, 
                          u_short serviceid)
 {
@@ -504,20 +488,43 @@ u_long aim_bos_reqservice(struct aim_session_t *sess,
  * the connection alive.  Its not real necessary.
  *
  */
-u_long aim_bos_nop(struct aim_session_t *sess,
-                  struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_nop(struct aim_session_t *sess,
+                                     struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0001, 0x0016);
 }
 
+/*
+ * aim_flap_nop()
+ *
+ * No-op.  WinAIM 4.x sends these _every minute_ to keep
+ * the connection alive.  
+ */
+faim_export unsigned long aim_flap_nop(struct aim_session_t *sess,
+                                      struct aim_conn_t *conn)
+{
+  struct command_tx_struct *newpacket;
+
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0005, conn, 0)))
+    return sess->snac_nextid;
+
+  newpacket->lock = 1;
+  newpacket->commandlen = 0;
+  newpacket->lock = 0;
+
+  aim_tx_enqueue(sess, newpacket);
+
+  return (sess->snac_nextid);
+}
+
 /*
  * aim_bos_reqrights()
  *
  * Request BOS rights.
  *
  */
-u_long aim_bos_reqrights(struct aim_session_t *sess,
-                        struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess,
+                                           struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0009, 0x0002);
 }
@@ -528,8 +535,8 @@ u_long aim_bos_reqrights(struct aim_session_t *sess,
  * Request Buddy List rights.
  *
  */
-u_long aim_bos_reqbuddyrights(struct aim_session_t *sess,
-                             struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess,
+                                                struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0003, 0x0002);
 }
@@ -544,7 +551,7 @@ u_long aim_bos_reqbuddyrights(struct aim_session_t *sess,
  * returns -1 on error (couldn't alloc packet), next snacid on success.
  *
  */
-int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon)
+faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon)
 {
   struct command_tx_struct *newpacket;
   int curbyte;
@@ -572,15 +579,13 @@ int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *
   return (sess->snac_nextid++);
 }
 
-
-
 /*
  * aim_debugconn_sendconnect()
  *
  * For aimdebugd.  If you don't know what it is, you don't want to.
  */
-u_long aim_debugconn_sendconnect(struct aim_session_t *sess,
-                                struct aim_conn_t *conn)
+faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess,
+                                                   struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT);
 }
@@ -597,9 +602,9 @@ u_long aim_debugconn_sendconnect(struct aim_session_t *sess,
  * back to the single.  I don't see any advantage to doing it either way.
  *
  */
-u_long aim_genericreq_n(struct aim_session_t *sess,
-                       struct aim_conn_t *conn, 
-                       u_short family, u_short subtype)
+faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess,
+                                            struct aim_conn_t *conn, 
+                                            u_short family, u_short subtype)
 {
   struct command_tx_struct *newpacket;
 
@@ -609,18 +614,21 @@ u_long aim_genericreq_n(struct aim_session_t *sess,
   newpacket->lock = 1;
 
   aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
+
+  aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
+
   aim_tx_enqueue(sess, newpacket);
-  return (sess->snac_nextid++);
+  return sess->snac_nextid;
 }
 
 /*
  *
  *
  */
-u_long aim_genericreq_l(struct aim_session_t *sess,
-                       struct aim_conn_t *conn, 
-                       u_short family, u_short subtype, u_long *longdata)
+faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess,
+                                            struct aim_conn_t *conn, 
+                                            u_short family, u_short subtype, 
+                                            u_long *longdata)
 {
   struct command_tx_struct *newpacket;
   u_long newlong;
@@ -635,18 +643,20 @@ u_long aim_genericreq_l(struct aim_session_t *sess,
   newpacket->lock = 1;
 
   aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
 
   /* copy in data */
   newlong = htonl(*longdata);
   memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long));
 
   aim_tx_enqueue(sess, newpacket);
-  return (sess->snac_nextid++);
+  return sess->snac_nextid;
 }
 
-u_long aim_genericreq_s(struct aim_session_t *sess,
-                       struct aim_conn_t *conn, 
-                       u_short family, u_short subtype, u_short *shortdata)
+faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess,
+                                            struct aim_conn_t *conn, 
+                                            u_short family, u_short subtype, 
+                                            u_short *shortdata)
 {
   struct command_tx_struct *newpacket;
   u_short newshort;
@@ -661,13 +671,14 @@ u_long aim_genericreq_s(struct aim_session_t *sess,
   newpacket->lock = 1;
 
   aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
 
   /* copy in data */
   newshort = htons(*shortdata);
   memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short));
 
   aim_tx_enqueue(sess, newpacket);
-  return (sess->snac_nextid++);
+  return sess->snac_nextid;
 }
 
 /*
@@ -676,8 +687,8 @@ u_long aim_genericreq_s(struct aim_session_t *sess,
  * Request Location services rights.
  *
  */
-u_long aim_bos_reqlocaterights(struct aim_session_t *sess,
-                              struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess,
+                                                 struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0002, 0x0002);
 }
@@ -688,9 +699,180 @@ u_long aim_bos_reqlocaterights(struct aim_session_t *sess,
  * Request ICBM parameter information.
  *
  */
-u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
-                               struct aim_conn_t *conn)
+faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
+                                                  struct aim_conn_t *conn)
 {
   return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
 }
 
+/*
+ * Add ICBM parameter? Huh?
+ */
+faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess,
+                                          struct aim_conn_t *conn)
+{
+  struct command_tx_struct *newpacket;
+  int packlen = 10+16, i=0;
+
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
+  
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
+  aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0);
+
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x1f40);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  
+  aim_tx_enqueue(sess, newpacket);
+
+  return sess->snac_nextid;
+}
+
+/* 
+ * Set directory profile data (not the same as aim_bos_setprofile!)
+ */
+faim_export unsigned long aim_setdirectoryinfo(struct aim_session_t *sess, struct aim_conn_t *conn, char *first, char *middle, char *last, char *maiden, char *nickname, char *street, char *city, char *state, char *zip, int country, unsigned short privacy) 
+{
+  struct command_tx_struct *newpacket;
+  int packlen = 0, i = 0;
+
+  packlen += 2+2+2;
+
+  if(first) /* TLV 0001 */
+    packlen += (strlen(first) + 4);
+  if(middle) 
+    packlen += (strlen(middle) + 4);
+  if(last)
+    packlen += (strlen(last) + 4);
+  if(maiden)
+    packlen += (strlen(maiden) + 4);
+  if(nickname)
+    packlen += (strlen(nickname) + 4);
+  if(street)
+    packlen += (strlen(street) + 4);
+  if(state)
+    packlen += (strlen(state) + 4);
+  if(city)
+    packlen += (strlen(city) + 4);
+  if(zip)
+    packlen += (strlen(zip) + 4);
+    
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0);
+
+  /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */
+  i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy);
+
+
+  if (first)
+    i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first);
+  if (middle)
+    i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle);
+  if (last)
+    i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last);
+  if (maiden)
+    i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden);
+  if (nickname)
+    i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname);
+  if (street)
+    i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street);
+  if (city)
+    i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city);
+  if (state)
+    i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state);
+  if (zip)
+    i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip);
+
+  newpacket->commandlen = i;
+  newpacket->lock = 0;
+
+  aim_tx_enqueue(sess, newpacket);
+   
+  return(sess->snac_nextid);
+}
+
+faim_export unsigned long aim_setuserinterests(struct aim_session_t *sess, struct aim_conn_t *conn, char *interest1, char *interest2, char *interest3, char *interest4, char *interest5, unsigned short privacy)
+{
+  struct command_tx_struct *newpacket;
+  int packlen = 0, i = 0;
+
+  packlen += 2+2+2;
+
+  if(interest1)
+    packlen += (strlen(interest1) + 4);
+  if(interest2)
+    packlen += (strlen(interest2) + 4);
+  if(interest3)
+    packlen += (strlen(interest3) + 4);
+  if(interest4)
+    packlen += (strlen(interest4) + 4);
+  if(interest5)
+    packlen += (strlen(interest5) + 4) ;
+
+    
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0);
+
+  /* 000a/0002: 0000 ?? ?privacy? */
+  i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); 
+
+  if(interest1) 
+    i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1);
+  if(interest2) 
+    i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2);
+  if(interest3) 
+    i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3);
+  if(interest4) 
+    i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4);
+  if(interest5) 
+    i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5);
+
+  newpacket->commandlen = i;
+  newpacket->lock = 0;
+    
+  aim_tx_enqueue(sess, newpacket);
+    
+  return(sess->snac_nextid);
+}
+
+faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess,
+                                           struct aim_conn_t *conn, 
+                                           unsigned long status)
+{
+  struct command_tx_struct *newpacket;
+  int i;
+  unsigned long data;
+  
+  data = 0x00030000 | status; /* yay for error checking ;^) */
+
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + 4)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e);
+  i += aim_puttlv_32(newpacket->data+i, 0x0006, data);
+
+  newpacket->commandlen = i;
+  newpacket->lock = 0;
+
+  aim_tx_enqueue(sess, newpacket);
+
+  return(sess->snac_nextid);
+}
This page took 0.103311 seconds and 4 git commands to generate.