Esempio n. 1
0
void
XmppSipPlugin::onNewMessage( const Jreen::Message& message )
{
    if ( m_state != Account::Connected )
        return;

    QString from = message.from().full();
    QString msg = message.body();

    if ( msg.isEmpty() )
        return;

    if ( message.subtype() == Jreen::Message::Error )
    {
        tDebug() << Q_FUNC_INFO << "Received error message from" << from << ", not answering... (Condition:"
                 << ( message.error().isNull() ? -1 : message.error()->condition() ) << ")";
        return;
    }

    // FIXME: We do not sent SipInfo in JSON via XMPP, why do we receive it here?
    SipInfo info = SipInfo::fromJson( msg );
    if ( !info.isValid() )
    {
        QString to = from;
        QString response = QString( tr( "I'm sorry -- I'm just an automatic presence used by Tomahawk Player"
                                        " (http://gettomahawk.com). If you are getting this message, the person you"
                                        " are trying to reach is probably not signed on, so please try again later!" ) );

        // this is not a sip message, so we send it directly through the client
        m_client->send( Jreen::Message ( Jreen::Message::Error, Jreen::JID( to ), response) );
        return;
    }

    qDebug() << Q_FUNC_INFO << "From:" << message.from().full() << ":" << message.body();
}
Esempio n. 2
0
void JAttention::onMessageReceived(const Jreen::Message &message)
{
	if(message.containsPayload<Jreen::Attention>() && message.body().isEmpty()) {
		NotificationRequest request(Notification::Attention);
		//request.setObject(this);
		request.setText(tr("%1 trying to attract your attention!").arg(message.from()));
		request.send();
		debug() << "ATTENTION!!!";
	}
}