int GaduSession::sendMessage( uin_t recipient, const Kopete::Message& msg, int msgClass ) { QString sendMsg; QCString cpMsg; KGaduMessage* gadumessage; if ( isConnected() ) { gadumessage = rtf->convertToGaduMessage( msg ); if ( gadumessage ) { const void* data = (const void*)gadumessage->rtf.data(); cpMsg = textcodec->fromUnicode( gadumessage->message ); int o; o = gg_send_message_richtext( session_, msgClass, recipient, (const unsigned char *)cpMsg.data(), (const unsigned char*) data, gadumessage->rtf.size() ); gadumessage->rtf.resize(0); delete gadumessage; return o; } else { sendMsg = msg.plainBody(); sendMsg.replace( QString::fromAscii( "\n" ), QString::fromAscii( "\r\n" ) ); cpMsg = textcodec->fromUnicode( sendMsg ); return gg_send_message( session_, msgClass, recipient, (const unsigned char *)cpMsg.data() ); } } else { emit error( i18n("Not Connected"), i18n("You are not connected to the server.") ); } return 1; }
/* * msg_queue_flush() * * wysy³a wiadomo¶ci z kolejki. * * 0 je¶li wys³ano, -1 je¶li nast±pi³ b³±d przy wysy³aniu, -2 je¶li * kolejka pusta. */ int msg_queue_flush() { list_t l = msg_queue; if (!l) return -2; for (; l; l = l->next) { struct msg_queue *m = l->data; int new_seq; unsigned char *tmp = xstrdup(m->msg); iso_to_cp(tmp); if (m->uin_count == 1) { if (m->secure) msg_encrypt(m->uins[0], &tmp); new_seq = gg_send_message_richtext(sess, m->msg_class, m->uins[0], tmp, m->format, m->formatlen); } else new_seq = gg_send_message_confer_richtext(sess, m->msg_class, m->uin_count, m->uins, tmp, m->format, m->formatlen); xfree(tmp); if (new_seq != -1) m->msg_seq = new_seq; else return -1; } return 0; }