void TCPAccountHandler::_handleMessages(boost::shared_ptr<Session> session_ptr) { UT_DEBUGMSG(("TCPAccountHandler::_handleMessages()\n")); UT_return_if_fail(session_ptr); // handle all packets waiting in our queue int packet_size; char* packet_data; while (session_ptr->pop(packet_size, &packet_data)) { // get the buddy for this session TCPBuddyPtr pBuddy = _getBuddy(session_ptr); UT_continue_if_fail(pBuddy); // TODO: shouldn't we just disconnect here? // construct the packet // FIXME: inefficient copying of data std::string packet_str(packet_size, ' '); memcpy(&packet_str[0], packet_data, packet_size); FREEP(packet_data); Packet* pPacket = _createPacket(packet_str, pBuddy); UT_continue_if_fail(pPacket); // TODO: shouldn't we just disconnect here? // handle! handleMessage(pPacket, pBuddy); } }
void TelepathyAccountHandler::addContact(TpContact* contact) { UT_DEBUGMSG(("TelepathyAccountHandler::addContact()\n")); UT_return_if_fail(contact); TelepathyBuddyPtr pBuddy = boost::shared_ptr<TelepathyBuddy>(new TelepathyBuddy(this, contact)); TelepathyBuddyPtr pExistingBuddy = _getBuddy(pBuddy); if (!pExistingBuddy) addBuddy(pBuddy); }
void XMPPAccountHandler::handleMessage(const gchar* packet_data, const std::string& from_address) { UT_return_if_fail(packet_data); UT_return_if_fail(from_address.size() > 0); XMPPBuddyPtr pBuddy = _getBuddy(from_address); if (!pBuddy) { // yay, a message from a new buddy pBuddy = XMPPBuddyPtr(new XMPPBuddy(this, from_address.c_str())); addBuddy(pBuddy); } // construct the packet // NOTE: all packets are base64 encoded when sent over this backend, so we need to decode them // FIXME: inefficient copying of data std::string packet_str = packet_data; size_t len = gsf_base64_decode_simple((guint8*)(&packet_str[0]), packet_str.size()); packet_str.resize(len); Packet* pPacket = _createPacket(packet_str, pBuddy); UT_return_if_fail(pPacket); AccountHandler::handleMessage(pPacket, pBuddy); }