perror("read");
printf("faim: rend: read error (fd: %i) %02x%02x%02x%02x%02x%02x (%i)\n", conn->fd, hdrbuf1[0],hdrbuf1[1],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrlen);
faim_mutex_unlock(&conn->active);
- aim_conn_kill(sess, &conn);
+ aim_conn_close(conn);
return -1;
}
printf("faim: rend: read2 error\n");
free(hdr);
faim_mutex_unlock(&conn->active);
- aim_conn_kill(sess, &conn);
+ aim_conn_close(conn);
return 0; /* see comment on previous read check */
}
printf("faim: rend: read3 error\n");
free(msg);
faim_mutex_unlock(&conn->active);
- aim_conn_kill(sess, &conn);
- return 0;
+ aim_conn_close(conn);
+ return -1;
}
faim_mutex_unlock(&conn->active);
msg[payloadlength] = '\0';
case 0x0204: { /* get file: finished. close it up */
printf("looks like we're done with a transfer (oft 0x0204)\n");
faim_mutex_unlock(&conn->active);
- aim_conn_kill(sess, &conn);
+ aim_conn_close(conn);
break;
}
default: {
workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x0007, workingPtr);
break;
case 0x000a:
- workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x000a, workingPtr);
+ workingPtr->handled = aim_parse_ratechange_middle(sess, workingPtr);
break;
case 0x000f:
workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x000f, workingPtr);
case 0x000a:
workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0004, 0x000a, workingPtr);
break;
+ case 0x000c:
+ workingPtr->handled = aim_parse_msgack_middle(sess, workingPtr);
+ break;
default:
workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_DEFAULT, workingPtr);
}
return 0;
}
+int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command)
+{
+ rxcallback_t userfunc = NULL;
+ char sn[MAXSNLEN];
+ unsigned short type;
+ int i = 10+8; /* skip SNAC and cookie */
+ int ret = 1;
+ unsigned char snlen;
+
+ type = aimutil_get16(command->data+i);
+ i += 2;
+
+ snlen = aimutil_get8(command->data+i);
+ i++;
+
+ memset(sn, 0, sizeof(sn));
+ strncpy(sn, command->data+i, snlen);
+
+ if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x000c)))
+ ret = userfunc(sess, command, type, sn);
+
+ return ret;
+}
+
+int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command)
+{
+ rxcallback_t userfunc = NULL;
+ int i = 10; /* skip SNAC */
+ int ret = 1;
+ unsigned long newrate;
+
+ if (command->commandlen != 0x2f) {
+ printf("faim: unknown rate change length 0x%04x\n", command->commandlen);
+ return 1;
+ }
+
+ newrate = aimutil_get32(command->data+34);
+
+ if ((userfunc = aim_callhandler(command->conn, 0x0001, 0x000a)))
+ ret = userfunc(sess, command, newrate);
+
+ return ret;
+}
+
int aim_parsemotd_middle(struct aim_session_t *sess,
struct command_rx_struct *command, ...)
{
int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...);
+int faimtest_parse_msgack(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...);
int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...);
int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...);
+int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...);
int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...)
{
aim_rxdispatch(&aimsess);
} else {
printf("connection error\n");
+ aim_conn_kill(&aimsess, &waitingconn);
if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) {
printf("major connetion error\n");
keepgoing = 0;
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
- aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0);
+ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
-
+ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0);
+
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
aim_logoff(sess);
} else if (strstr(tmpstr, "goodday")) {
printf("faimtest: icbm: sending response\n");
- aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too.");
+ aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");
} else if (!strncmp(tmpstr, "open chatnav", 12)) {
aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
//aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
/* go right into main loop (don't open a BOS connection, etc) */
return 1;
}
+
+/*
+ * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
+ */
+int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...)
+{
+ va_list ap;
+ unsigned short type;
+ char *sn = NULL;
+
+ ap = va_start(ap, command);
+ type = va_arg(ap, unsigned short);
+ sn = va_arg(ap, char *);
+ va_end(ap);
+
+ printf("faimtest: msgack: 0x%04x / %s\n", type, sn);
+
+ return 1;
+}
+
+int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...)
+{
+ va_list ap;
+ unsigned long newrate;
+
+ va_start(ap, command);
+ newrate = va_arg(ap, unsigned long);
+ va_end(ap);
+
+ printf("faimtest: ratechange: %lu\n", newrate);
+
+ return (1);
+};