]> andersk Git - libfaim.git/commitdiff
- Sun May 21 14:59:20 GMT 2000
authormid <mid>
Sun, 21 May 2000 23:14:30 +0000 (23:14 +0000)
committermid <mid>
Sun, 21 May 2000 23:14:30 +0000 (23:14 +0000)
   - Added infotype parameter to aim_getinfo() for requesting
       different types of messages.  AIM_GETINFO_GENERALINFO
       will get you the normal stuff, AIM_GETINFO_AWAYMESSAGE
       will get the normal stuff, with the profile replaced with
       the user's away message.  Also, the callback adds an
       unsigned short to the end to give you the value that
       was originally passed to the request.
   - There were a few server-pertinent changes that didn't get
       documented from last month.  I have no idea what they were.

CHANGES
aim_info.c
faim/aim.h
utils/faimtest/faimtest.c

diff --git a/CHANGES b/CHANGES
index 27200cad42010a2f47d621cd5254e9d6eb1a55c4..0b3605076fca1c110bf46985e0b3844a340f5daa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,17 @@
 
 No release numbers
 ------------------
+ - Sun May 21 14:59:20 GMT 2000
+   - Added infotype parameter to aim_getinfo() for requesting
+       different types of messages.  AIM_GETINFO_GENERALINFO
+       will get you the normal stuff, AIM_GETINFO_AWAYMESSAGE
+       will get the normal stuff, with the profile replaced with
+       the user's away message.  Also, the callback adds an 
+       unsigned short to the end to give you the value that
+       was originally passed to the request.
+   - There were a few server-pertinent changes that didn't get 
+       documented from last month.  I have no idea what they were.
+
  - Sun Apr  2 07:29:11 UTC 2000
    - Redid much of the tx path to remove the superfluous copy.  But
        it touches every function that transmits.  Its been a long 
index 7a70321ce3b86d337b69b1bbc1af479d88852ddd..13ac60e0d75ca288ea3f0683e73c1f1d38b8ce52 100644 (file)
@@ -9,9 +9,15 @@
 
 #include <faim/aim.h>
 
+struct aim_priv_inforeq {
+  char sn[MAXSNLEN];
+  unsigned short infotype;
+};
+
 u_long aim_getinfo(struct aim_session_t *sess,
                   struct aim_conn_t *conn, 
-                  const char *sn)
+                  const char *sn,
+                  unsigned short infotype)
 {
   struct command_tx_struct *newpacket;
   int i = 0;
@@ -26,7 +32,7 @@ u_long aim_getinfo(struct aim_session_t *sess,
 
   i = aim_putsnac(newpacket->data, 0x0002, 0x0005, 0x0000, sess->snac_nextid);
 
-  i += aimutil_put16(newpacket->data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, infotype);
   i += aimutil_put8(newpacket->data+i, strlen(sn));
   i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
 
@@ -41,8 +47,9 @@ u_long aim_getinfo(struct aim_session_t *sess,
     snac.type = 0x0005;
     snac.flags = 0x0000;
 
-    snac.data = malloc(strlen(sn)+1);
-    strcpy(snac.data, sn);
+    snac.data = malloc(sizeof(struct aim_priv_inforeq));
+    strcpy(((struct aim_priv_inforeq *)snac.data)->sn, sn);
+    ((struct aim_priv_inforeq *)snac.data)->infotype = infotype;
 
     aim_newsnac(sess, &snac);
   }
@@ -356,59 +363,78 @@ int aim_parse_userinfo_middle(struct aim_session_t *sess,
                              struct command_rx_struct *command)
 {
   struct aim_userinfo_s userinfo;
-  char *prof_encoding = NULL;
-  char *prof = NULL;
+  char *text_encoding = NULL;
+  char *text = NULL;
   u_int i = 0;
   rxcallback_t userfunc=NULL;
   struct aim_tlvlist_t *tlvlist;
+  struct aim_snac_t *origsnac = NULL;
+  u_long snacid;
+  struct aim_priv_inforeq *inforeq;
+  
+  snacid = aimutil_get32(&command->data[6]);
+  origsnac = aim_remsnac(sess, snacid);
 
-  {
-    u_long snacid = 0x000000000;
-    struct aim_snac_t *snac = NULL;
-
-    snacid = aimutil_get32(&command->data[6]);
-    snac = aim_remsnac(sess, snacid);
-
-    if (snac)
-      {
-       if (snac->data)
-         free(snac->data);
-       else
-         printf("faim: parse_userinfo_middle: warning: no ->data in cached SNAC\n");
-       free(snac);
-      }
-    else
-      printf("faim: parseuserinfo_middle: warning: no SNAC cached with for this response (%08lx)\n", snacid);
-
+  if (!origsnac || !origsnac->data) {
+    printf("faim: parse_userinfo_middle: major problem: no snac stored!\n");
+    return 1;
   }
-  
-  i = 10;
 
-  /*
-   * extractuserinfo will give us the basic metaTLV information
-   */
-  i += aim_extractuserinfo(command->data+i, &userinfo);
+  inforeq = (struct aim_priv_inforeq *)origsnac->data;
+
+  switch (inforeq->infotype) {
+  case AIM_GETINFO_GENERALINFO:
+  case AIM_GETINFO_AWAYMESSAGE:
+    i = 10;
+
+    /*
+     * extractuserinfo will give us the basic metaTLV information
+     */
+    i += aim_extractuserinfo(command->data+i, &userinfo);
   
-  /*
-   * However, in this command, there's usually more TLVs following...
-   */ 
-  tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
-  prof_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
-  prof = aim_gettlv_str(tlvlist, 0x0002, 1);
+    /*
+     * However, in this command, there's usually more TLVs following...
+     */ 
+    tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
+
+    /* 
+     * Depending on what informational text was requested, different
+     * TLVs will appear here.
+     *
+     * Profile will be 1 and 2, away message will be 3 and 4.
+     */
+    if (aim_gettlv(tlvlist, 0x0001, 1)) {
+      text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
+      text = aim_gettlv_str(tlvlist, 0x0002, 1);
+    } else if (aim_gettlv(tlvlist, 0x0003, 1)) {
+      text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1);
+      text = aim_gettlv_str(tlvlist, 0x0004, 1);
+    }
 
-  userfunc = aim_callhandler(command->conn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO);
-  if (userfunc)
-    {
+    userfunc = aim_callhandler(command->conn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO);
+    if (userfunc) {
       i = userfunc(sess,
                   command, 
                   &userinfo, 
-                  prof_encoding, 
-                  prof); 
+                  text_encoding, 
+                  text,
+                  inforeq->infotype); 
     }
   
-  free(prof_encoding);
-  free(prof);
-  aim_freetlvchain(&tlvlist);
+    free(text_encoding);
+    free(text);
+    aim_freetlvchain(&tlvlist);
+    break;
+  default:
+    printf("faim: parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype);
+    break;
+  }
+
+  if (origsnac) {
+    if (origsnac->data)
+      free(origsnac->data);
+    free(origsnac);
+  }
 
   return 1;
 }
@@ -499,3 +525,4 @@ int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, c
 
   return 0;
 }
+
index 1d6a770218ace2961c11921e6ec4f79d4795acbe..82166283f039cb99b50e05817adbba82d341028e 100644 (file)
@@ -400,7 +400,11 @@ int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *
 #define AIM_CAPS_GETFILE 0x10
 #define AIM_CAPS_SENDFILE 0x20
 extern u_char aim_caps[6][16];
-u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *);
+
+#define AIM_GETINFO_GENERALINFO 0x00001
+#define AIM_GETINFO_AWAYMESSAGE 0x00003
+
+u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
 int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
 int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *);
index 853922c1b3d969ac72e2fca5e4bcfce744d2ca0e..03313be5ca0160ae58ebe5a60c756bbf888b7eb4 100644 (file)
@@ -547,7 +547,10 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str
            }
          else if (!strncmp(tmpstr, "leave", 5))
            aim_chat_leaveroom(sess, "worlddomination");
-         else 
+         else if (!strncmp(tmpstr, "getinfo", 7)) {
+           aim_getinfo(sess, command->conn, "midendian", AIM_GETINFO_GENERALINFO);
+           aim_getinfo(sess, command->conn, "midendian", AIM_GETINFO_AWAYMESSAGE);
+         } else 
            {
 #if 0
              printf("faimtest: icbm:  starting chat...\n");
This page took 0.062828 seconds and 5 git commands to generate.