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!!!"; } }
void JMessageReceiptFilter::filter(Jreen::Message &message) { Jreen::Receipt *receipt = message.payload<Jreen::Receipt>().data(); ChatUnit *unit = m_account->conferenceManager()->muc(message.from()); if (!unit) unit = m_account->roster()->contact(message.from(), true); qDebug() << Q_FUNC_INFO << unit << message.from(); if(message.containsPayload<Jreen::Error>()) return; if(receipt) { if(receipt->type() == Jreen::Receipt::Received) { QString id = receipt->id(); if(id.isEmpty()) id = message.id(); //for slowpoke client such as Miranda if(unit) qApp->postEvent(ChatLayer::get(unit), new qutim_sdk_0_3::MessageReceiptEvent(id.toUInt(), true)); } else { //TODO send this request only when message marked as read Jreen::Message request(Jreen::Message::Chat, message.from()); request.setThread(message.thread()); //for slowpoke clients request.setID(message.id()); //correct behaviour request.addExtension(new Jreen::Receipt(Jreen::Receipt::Received,message.id())); m_account->client()->send(request); } } Jreen::ChatState *state = message.payload<Jreen::ChatState>().data(); if(state) { if(unit) unit->setChatState(static_cast<qutim_sdk_0_3::ChatUnit::ChatState>(state->state())); } }
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(); }
void JMessageReceiptFilter::decorate(Jreen::Message &message) { Jreen::Receipt *receipt = new Jreen::Receipt(Jreen::Receipt::Request); message.addExtension(receipt); }