diff --git a/src/sip/jabber/jabber_p.cpp b/src/sip/jabber/jabber_p.cpp index 1b0af71cf..3cb9b69d7 100644 --- a/src/sip/jabber/jabber_p.cpp +++ b/src/sip/jabber/jabber_p.cpp @@ -28,6 +28,7 @@ #include #include #include +#include using namespace gloox; using namespace std; @@ -150,6 +151,7 @@ Jabber_p::go() m_client->registerPresenceHandler( this ); m_client->registerConnectionListener( this ); + m_client->rosterManager()->registerRosterListener( this ); m_client->logInstance().registerLogHandler( LogLevelWarning, LogAreaAll, this ); m_client->registerMessageHandler( this ); @@ -609,10 +611,24 @@ bool Jabber_p::handleSubscriptionRequest( const JID& jid, const std::string& /*msg*/ ) { qDebug() << Q_FUNC_INFO << jid.bare().c_str(); - StringList groups; - groups.push_back( "Tomahawk" ); - m_client->rosterManager()->subscribe( jid, "", groups, "" ); - return true; + + QMessageBox::StandardButton allowSubscription; + allowSubscription = QMessageBox::question( 0, + tr("Friend Request in Jabber"), + QString(tr("Do you want to be friends with %1?")).arg(QLatin1String(jid.bare().c_str())), + QMessageBox::Ok | QMessageBox::Cancel + ); + + if(allowSubscription == QMessageBox::Ok) + { + StringList groups; + groups.push_back( "Tomahawk" ); + m_client->rosterManager()->subscribe( jid, "", groups, "" ); + + return true; + } + + return false; } diff --git a/src/sip/jabber/jabber_p.h b/src/sip/jabber/jabber_p.h index 3e14c7c69..f051915bc 100644 --- a/src/sip/jabber/jabber_p.h +++ b/src/sip/jabber/jabber_p.h @@ -76,6 +76,7 @@ class SIPDLLEXPORT Jabber_p : public gloox::MessageHandler, public gloox::VCardHandler, public gloox::PresenceHandler, + public gloox::RosterListener, gloox::LogHandler //public gloox::DiscoHandler, { @@ -109,6 +110,11 @@ public: virtual void handleRoster( const gloox::Roster& roster ); virtual void handleRosterError( const gloox::IQ& /*iq*/ ); + + // not actually used, just needed for the interface to support subscription requests, see handlePresence for presence handling + virtual void handleRosterPresence( const gloox::RosterItem&, const std::string&, gloox::Presence::PresenceType, const std::string& ) {} + virtual void handleSelfPresence( const gloox::RosterItem&, const std::string&, gloox::Presence::PresenceType, const std::string& ) {} + virtual void handlePresence( const gloox::Presence& presence ); virtual bool handleSubscription( const gloox::JID& jid, const std::string& /*msg*/ ); virtual bool handleSubscriptionRequest( const gloox::JID& jid, const std::string& /*msg*/ );