Example #1
0
void PrivateChat::handleMessage(const gloox::Message& msg, gloox::MessageSession* session)
{
	if(msg.subtype() == gloox::Message::Chat)
		emit reciveMessage(QString().fromUtf8(msg.body().c_str()), QString().fromUtf8((msg.from().full().c_str())));
	else
		emit reciveNotPrivateMessage(QString().fromUtf8(msg.body().c_str()), QString().fromUtf8((msg.from().full().c_str())), QString().fromUtf8((msg.from().resource().c_str())));
}
Example #2
0
GlooxMessage::GlooxMessage (const gloox::Message& message,
                            QObject *entry,
                            gloox::MessageSession *session)
    : Type_ (MTChatMessage)
    , Direction_ (DIn)
    , Entry_ (entry)
    , Body_ (QString::fromUtf8 (message.body ().c_str ()))
    , Variant_ (QString::fromUtf8 (session->target ().resource ().c_str ()))
    , Session_ (session)
{
}
Example #3
0
void MDMessageCenter::handleMessage( const gloox::Message& msg,gloox::MessageSession* session)
{
	//    stanza.subject();
	//    CCLOG("%s",stanza.suboptarg);
	//    const gloox::JID from(stanza.from());
	//    gloox::Message msg(stanza.from(), "hello world","test" );
	//    j->send( msg );

	CCLOG( "type: %d, subject: %s, message: %s, thread id: %s\n", msg.subtype(),
		msg.subject().c_str(), msg.body().c_str(), msg.thread().c_str() );
}
void SpaceControlClient::handleMessage(const gloox::Message& msg, gloox::MessageSession* session) {
    try {
        // create the command
        // may throw a SpaceCommandFormatException
        const SpaceCommandSerializer::Incoming in = serializer()->to_command(msg.body());
        const std::string threadId(in.first);
        const SpaceCommand cmd = in.second;

        // create shared sink
        Sink sink(threadId, msg.from(), m_client, m_ser);

        // check for access
        if (m_access ? m_access->accepted(msg.from()) : true) {

            // call handler
            if (m_hnd)
                m_hnd->handleSpaceCommand(msg.from(), cmd, &sink);
        } else {
            // send access denied message
            SpaceCommand::space_command_params par;
            par["reason"] = "Denied by access filter!";
            SpaceCommand ex("denied", par);
            sink.sendSpaceCommand(ex);
        }
    } catch (const SpaceCommandFormatException& scfe) {
        SpaceCommand::space_command_params par;
        par["what"] = scfe.what();
        par["body"] = scfe.body();

        // add line number if available
        if (scfe.line_number()) {
// use std::to_string if available
#ifdef COMPILER_SUPPORTS_CXX11
            par["line number"] = std::to_string(scfe.line_number());
#else // COMPILER_SUPPORTS_CXX11
            std::stringstream s;
            s << scfe.line_number();
            par["line number"] = s.str();
#endif // COMPILER_SUPPORTS_CXX11
        }

        SpaceCommand ex("exception", par);

        m_client->send(gloox::Message(gloox::Message::Normal, msg.from(),
                                      serializer()->to_body(ex, "")));
    }
}
Example #5
0
File: chat.cpp Project: klpx/jam
void Chat::handleMessage (const gloox::Message& msg, gloox::MessageSession *session)
{
    qDebug(msg.body().data());
}
Example #6
0
void Channel::handleMUCMessage(gloox::MUCRoom* room, const gloox::Message& msg, bool priv)
{
    if (msg.from().resource() == bot->nick) {
        // The bot got a message from itself.
    }
    else {
        // TODO: Log this.
        std::cout << "[" << room->name() << ": " << msg.from().resource() << "(" << priv << ") ]  " << msg.body() << std::endl;
        bot->processMessage(this, msg, priv);
    }
}