int yahoo_packet_send_and_free(struct yahoo_packet *pkt, YahooData *yd) { int ret; ret = yahoo_packet_send(pkt, yd); yahoo_packet_free(pkt); return ret; }
static void yahoo_chat_join(struct yahoo_data *yd, const char *dn, const char *room, const char *topic) { struct yahoo_packet *pkt; pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 62, "2"); yahoo_packet_hash(pkt, 104, room); yahoo_packet_hash(pkt, 129, "0"); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); }
/* special function to log us on to the yahoo chat service */ static void yahoo_chat_online(GaimConnection *gc) { struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt; pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0); yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); yahoo_packet_hash(pkt, 6, "abcde"); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); }
static void yahoo_chat_invite(struct yahoo_data *yd, const char *dn, const char *buddy, const char *room, const char *msg) { struct yahoo_packet *pkt; pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 1, dn); yahoo_packet_hash(pkt, 118, buddy); yahoo_packet_hash(pkt, 104, room); yahoo_packet_hash(pkt, 117, (msg?msg:"")); yahoo_packet_hash(pkt, 129, "0"); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); }
void yahoo_chat_goto(GaimConnection *gc, const char *name) { struct yahoo_data *yd; struct yahoo_packet *pkt; yd = gc->proto_data; if (!yd->chat_online) yahoo_chat_online(gc); pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 109, name); yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); yahoo_packet_hash(pkt, 62, "2"); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); }
static void yahoo_conf_leave(struct yahoo_data *yd, const char *room, const char *dn, GList *who) { struct yahoo_packet *pkt; GList *w; pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 1, dn); for (w = who; w; w = w->next) { yahoo_packet_hash(pkt, 3, (char *)w->data); } yahoo_packet_hash(pkt, 57, room); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); }
static void yahoo_chat_leave(struct yahoo_data *yd, const char *room, const char *dn) { struct yahoo_packet *pkt; pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 104, room); yahoo_packet_hash(pkt, 109, dn); yahoo_packet_hash(pkt, 108, "1"); yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */ yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); yd->in_chat = 0; if (yd->chat_name) { g_free(yd->chat_name); yd->chat_name = NULL; } }
static void yahoo_sendfile_connected(gpointer data, gint source, const gchar *error_message) { PurpleXfer *xfer; struct yahoo_xfer_data *xd; struct yahoo_packet *pkt; gchar *size, *filename, *encoded_filename, *header; guchar *pkt_buf; const char *host; int port; size_t content_length, header_len, pkt_buf_len; PurpleConnection *gc; PurpleAccount *account; struct yahoo_data *yd; purple_debug(PURPLE_DEBUG_INFO, "yahoo", "AAA - in yahoo_sendfile_connected\n"); if (!(xfer = data)) return; if (!(xd = xfer->data)) return; if (source < 0) { purple_xfer_error(PURPLE_XFER_RECEIVE, purple_xfer_get_account(xfer), xfer->who, _("Unable to connect.")); purple_xfer_cancel_remote(xfer); return; } xfer->fd = source; /* Assemble the tx buffer */ gc = xd->gc; account = purple_connection_get_account(gc); yd = gc->proto_data; pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, YAHOO_STATUS_AVAILABLE, yd->session_id); size = g_strdup_printf("%" G_GSIZE_FORMAT, purple_xfer_get_size(xfer)); filename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); encoded_filename = yahoo_string_encode(gc, filename, NULL); yahoo_packet_hash(pkt, "sssss", 0, purple_connection_get_display_name(gc), 5, xfer->who, 14, "", 27, encoded_filename, 28, size); g_free(size); g_free(encoded_filename); g_free(filename); content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, yd->jp, &pkt_buf); yahoo_packet_free(pkt); host = purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); port = purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); header = g_strdup_printf( "POST http://%s:%d/notifyft HTTP/1.0\r\n" "Content-length: %" G_GSIZE_FORMAT "\r\n" "Host: %s:%d\r\n" "Cookie: Y=%s; T=%s\r\n" "\r\n", host, port, content_length + 4 + purple_xfer_get_size(xfer), host, port, yd->cookie_y, yd->cookie_t); header_len = strlen(header); xd->txbuflen = header_len + pkt_buf_len + 4; xd->txbuf = g_malloc(xd->txbuflen); memcpy(xd->txbuf, header, header_len); g_free(header); memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len); g_free(pkt_buf); memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4); xd->txbuf_written = 0; if (xd->tx_handler == 0) { xd->tx_handler = purple_input_add(source, PURPLE_INPUT_WRITE, yahoo_sendfile_send_cb, xfer); yahoo_sendfile_send_cb(xfer, source, PURPLE_INPUT_WRITE); } }