mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 08:34:34 +02:00
* Style cleanup for XmppSip.
This commit is contained in:
@@ -65,6 +65,10 @@ using namespace Accounts;
|
|||||||
// instead of simply copying this function for another thirdparty lib
|
// instead of simply copying this function for another thirdparty lib
|
||||||
// please make it a meta-function or a macro and put it in Logger.h. kthxbbq
|
// please make it a meta-function or a macro and put it in Logger.h. kthxbbq
|
||||||
#define JREEN_LOG_INFIX "Jreen"
|
#define JREEN_LOG_INFIX "Jreen"
|
||||||
|
#define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" )
|
||||||
|
#define TOMAHAWK_CAP_NODE_NAME QLatin1String( "http://tomahawk-player.org/" )
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JreenMessageHandler( QtMsgType type, const char *msg )
|
JreenMessageHandler( QtMsgType type, const char *msg )
|
||||||
{
|
{
|
||||||
@@ -85,6 +89,7 @@ JreenMessageHandler(QtMsgType type, const char *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XmppSipPlugin::XmppSipPlugin( Account* account )
|
XmppSipPlugin::XmppSipPlugin( Account* account )
|
||||||
: SipPlugin( account )
|
: SipPlugin( account )
|
||||||
, m_state( Account::Disconnected )
|
, m_state( Account::Disconnected )
|
||||||
@@ -97,7 +102,6 @@ XmppSipPlugin::XmppSipPlugin( Account *account )
|
|||||||
Jreen::Logger::addHandler( JreenMessageHandler );
|
Jreen::Logger::addHandler( JreenMessageHandler );
|
||||||
|
|
||||||
m_currentUsername = readUsername();
|
m_currentUsername = readUsername();
|
||||||
|
|
||||||
m_currentServer = readServer();
|
m_currentServer = readServer();
|
||||||
m_currentPassword = readPassword();
|
m_currentPassword = readPassword();
|
||||||
m_currentPort = readPort();
|
m_currentPort = readPort();
|
||||||
@@ -122,6 +126,7 @@ XmppSipPlugin::XmppSipPlugin( Account *account )
|
|||||||
m_xmlConsole->show();
|
m_xmlConsole->show();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// add VCardUpdate extension to own presence
|
// add VCardUpdate extension to own presence
|
||||||
m_client->presence().addExtension( new Jreen::VCardUpdate() );
|
m_client->presence().addExtension( new Jreen::VCardUpdate() );
|
||||||
|
|
||||||
@@ -169,14 +174,15 @@ XmppSipPlugin::XmppSipPlugin( Account *account )
|
|||||||
// Clear status
|
// Clear status
|
||||||
Jreen::Tune::Ptr tune( new Jreen::Tune() );
|
Jreen::Tune::Ptr tune( new Jreen::Tune() );
|
||||||
m_pubSubManager->publishItems( QList<Jreen::Payload::Ptr>() << tune, Jreen::JID() );
|
m_pubSubManager->publishItems( QList<Jreen::Payload::Ptr>() << tune, Jreen::JID() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XmppSipPlugin::~XmppSipPlugin()
|
XmppSipPlugin::~XmppSipPlugin()
|
||||||
{
|
{
|
||||||
//Note: the next two lines don't currently work, because the deletion wipes out internally posted events, need to talk to euro about a fix
|
//Note: the next two lines don't currently work, because the deletion wipes out internally posted events, need to talk to euro about a fix
|
||||||
Jreen::Tune::Ptr tune( new Jreen::Tune() );
|
Jreen::Tune::Ptr tune( new Jreen::Tune() );
|
||||||
m_pubSubManager->publishItems( QList<Jreen::Payload::Ptr>() << tune, Jreen::JID() );
|
m_pubSubManager->publishItems( QList<Jreen::Payload::Ptr>() << tune, Jreen::JID() );
|
||||||
|
|
||||||
delete m_pubSubManager;
|
delete m_pubSubManager;
|
||||||
delete m_avatarManager;
|
delete m_avatarManager;
|
||||||
delete m_roster;
|
delete m_roster;
|
||||||
@@ -205,11 +211,10 @@ XmppSipPlugin::menu()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmppSipPlugin::connectPlugin()
|
XmppSipPlugin::connectPlugin()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( m_client->isConnected() )
|
if ( m_client->isConnected() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Already connected to server, not connecting again...";
|
qDebug() << Q_FUNC_INFO << "Already connected to server, not connecting again...";
|
||||||
@@ -232,7 +237,6 @@ XmppSipPlugin::connectPlugin()
|
|||||||
|
|
||||||
m_state = Account::Connecting;
|
m_state = Account::Connecting;
|
||||||
emit stateChanged( m_state );
|
emit stateChanged( m_state );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -267,8 +271,6 @@ XmppSipPlugin::disconnectPlugin()
|
|||||||
void
|
void
|
||||||
XmppSipPlugin::onConnect()
|
XmppSipPlugin::onConnect()
|
||||||
{
|
{
|
||||||
// qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
// update jid resource, servers like gtalk use resource binding and may
|
// update jid resource, servers like gtalk use resource binding and may
|
||||||
// have changed our requested /resource
|
// have changed our requested /resource
|
||||||
if ( m_client->jid().resource() != m_currentResource )
|
if ( m_client->jid().resource() != m_currentResource )
|
||||||
@@ -277,15 +279,9 @@ XmppSipPlugin::onConnect()
|
|||||||
emit jidChanged( m_client->jid().full() );
|
emit jidChanged( m_client->jid().full() );
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Connected to xmpp as:" << m_client->jid().full();
|
|
||||||
|
|
||||||
// set presence to least valid value
|
// set presence to least valid value
|
||||||
m_client->setPresence( Jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127 );
|
m_client->setPresence( Jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127 );
|
||||||
|
|
||||||
// set ping timeout to 15 secs (TODO: verify if this works)
|
|
||||||
m_client->setPingInterval( 1000 );
|
m_client->setPingInterval( 1000 );
|
||||||
|
|
||||||
// load roster
|
|
||||||
m_roster->load();
|
m_roster->load();
|
||||||
|
|
||||||
// load XmppInfoPlugin
|
// load XmppInfoPlugin
|
||||||
@@ -298,7 +294,7 @@ XmppSipPlugin::onConnect()
|
|||||||
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
||||||
// join MUC with bare jid as nickname
|
// join MUC with bare jid as nickname
|
||||||
//TODO: make the room a list of rooms and make that configurable
|
//TODO: make the room a list of rooms and make that configurable
|
||||||
QString mucNickname = QString( "tomahawk@conference.qutim.org/" ).append( QString( m_client->jid().bare() ).replace( "@", "-" ) );
|
// QString mucNickname = QString( "tomahawk@conference.qutim.org/" ).append( QString( m_client->jid().bare() ).replace( "@", "-" ) );
|
||||||
//m_room = new Jreen::MUCRoom(m_client, Jreen::JID( mucNickname ) );
|
//m_room = new Jreen::MUCRoom(m_client, Jreen::JID( mucNickname ) );
|
||||||
//m_room->setHistorySeconds(0);
|
//m_room->setHistorySeconds(0);
|
||||||
//m_room->join();
|
//m_room->join();
|
||||||
@@ -317,8 +313,6 @@ XmppSipPlugin::onConnect()
|
|||||||
void
|
void
|
||||||
XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
switch( reason )
|
switch( reason )
|
||||||
{
|
{
|
||||||
case Jreen::Client::User:
|
case Jreen::Client::User:
|
||||||
@@ -345,7 +339,7 @@ XmppSipPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
qDebug() << "Not all Client::DisconnectReasons checked" << ( int ) reason;
|
qDebug() << "Not all Client::DisconnectReasons checked" << ( int ) reason;
|
||||||
Q_ASSERT(false);
|
Q_ASSERT( false s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_state = Account::Disconnected;
|
m_state = Account::Disconnected;
|
||||||
@@ -402,26 +396,21 @@ XmppSipPlugin::errorMessage( Jreen::Client::DisconnectReason reason )
|
|||||||
case Jreen::Client::Conflict:
|
case Jreen::Client::Conflict:
|
||||||
return tr( "Conflict" );
|
return tr( "Conflict" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Jreen::Client::Unknown:
|
|
||||||
return tr("Unknown");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Jreen::Client::NoCompressionSupport:
|
case Jreen::Client::NoCompressionSupport:
|
||||||
return tr( "No Compression Support" );
|
return tr( "No Compression Support" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Jreen::Client::NoEncryptionSupport:
|
case Jreen::Client::NoEncryptionSupport:
|
||||||
return tr( "No Encryption Support" );
|
return tr( "No Encryption Support" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Jreen::Client::NoAuthorizationSupport:
|
case Jreen::Client::NoAuthorizationSupport:
|
||||||
return tr( "No Authorization Support" );
|
return tr( "No Authorization Support" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Jreen::Client::NoSupportedFeature:
|
case Jreen::Client::NoSupportedFeature:
|
||||||
return tr( "No Supported Feature" );
|
return tr( "No Supported Feature" );
|
||||||
break;
|
break;
|
||||||
|
case Jreen::Client::Unknown:
|
||||||
|
return tr( "Unknown" );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
qDebug() << "Not all Client::DisconnectReasons checked";
|
qDebug() << "Not all Client::DisconnectReasons checked";
|
||||||
@@ -441,9 +430,8 @@ XmppSipPlugin::sendMsg( const QString& to, const QString& msg )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << to << msg;
|
qDebug() << Q_FUNC_INFO << to << msg;
|
||||||
|
|
||||||
if ( !m_client ) {
|
if ( !m_client )
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
* Obsolete this by a SipMessage class
|
* Obsolete this by a SipMessage class
|
||||||
@@ -456,22 +444,17 @@ XmppSipPlugin::sendMsg( const QString& to, const QString& msg )
|
|||||||
qDebug() << "Invalid JSON in Xmpp msg";
|
qDebug() << "Invalid JSON in Xmpp msg";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap m = v.toMap();
|
QVariantMap m = v.toMap();
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
|
|
||||||
TomahawkXmppMessage *sipMessage;
|
TomahawkXmppMessage *sipMessage;
|
||||||
if ( m["visible"].toBool() )
|
if ( m["visible"].toBool() )
|
||||||
{
|
{
|
||||||
sipMessage = new TomahawkXmppMessage( m["ip"].toString(),
|
sipMessage = new TomahawkXmppMessage( m["ip"].toString(), m["port"].toInt(), m["uniqname"].toString(), m["key"].toString() );
|
||||||
m["port"].toInt(),
|
|
||||||
m["uniqname"].toString(),
|
|
||||||
m["key"].toString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
sipMessage = new TomahawkXmppMessage();
|
sipMessage = new TomahawkXmppMessage();
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Send sip messsage to" << to;
|
qDebug() << "Send sip messsage to" << to;
|
||||||
Jreen::IQ iq( Jreen::IQ::Set, to );
|
Jreen::IQ iq( Jreen::IQ::Set, to );
|
||||||
@@ -485,8 +468,6 @@ XmppSipPlugin::sendMsg( const QString& to, const QString& msg )
|
|||||||
void
|
void
|
||||||
XmppSipPlugin::broadcastMsg( const QString& msg )
|
XmppSipPlugin::broadcastMsg( const QString& msg )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( !m_client )
|
if ( !m_client )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -501,14 +482,11 @@ void
|
|||||||
XmppSipPlugin::addContact( const QString& jid, const QString& msg )
|
XmppSipPlugin::addContact( const QString& jid, const QString& msg )
|
||||||
{
|
{
|
||||||
// Add contact to the Tomahawk group on the roster
|
// Add contact to the Tomahawk group on the roster
|
||||||
|
|
||||||
QString realJid = jid;
|
QString realJid = jid;
|
||||||
if ( !realJid.contains( '@' ) )
|
if ( !realJid.contains( '@' ) )
|
||||||
realJid += defaultSuffix();
|
realJid += defaultSuffix();
|
||||||
|
|
||||||
m_roster->subscribe( realJid, msg, realJid, QStringList() << "Tomahawk" );
|
m_roster->subscribe( realJid, msg, realJid, QStringList() << "Tomahawk" );
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -642,7 +620,9 @@ XmppSipPlugin::configurationChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppSipPlugin::setupClientHelper()
|
|
||||||
|
void
|
||||||
|
XmppSipPlugin::setupClientHelper()
|
||||||
{
|
{
|
||||||
Jreen::JID jid = Jreen::JID( m_currentUsername );
|
Jreen::JID jid = Jreen::JID( m_currentUsername );
|
||||||
m_client->setJID( jid );
|
m_client->setJID( jid );
|
||||||
@@ -662,7 +642,9 @@ void XmppSipPlugin::setupClientHelper()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppSipPlugin::addMenuHelper()
|
|
||||||
|
void
|
||||||
|
XmppSipPlugin::addMenuHelper()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
if ( !m_menu )
|
if ( !m_menu )
|
||||||
@@ -670,12 +652,12 @@ void XmppSipPlugin::addMenuHelper()
|
|||||||
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( readUsername() ).append(")" ) );
|
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( readUsername() ).append(")" ) );
|
||||||
|
|
||||||
QAction* addFriendAction = m_menu->addAction( tr( "Add Friend..." ) );
|
QAction* addFriendAction = m_menu->addAction( tr( "Add Friend..." ) );
|
||||||
connect( addFriendAction, SIGNAL( triggered() ), this, SLOT( showAddFriendDialog() ) );
|
connect( addFriendAction, SIGNAL( triggered() ), SLOT( showAddFriendDialog() ) );
|
||||||
|
|
||||||
if ( readXmlConsoleEnabled() )
|
if ( readXmlConsoleEnabled() )
|
||||||
{
|
{
|
||||||
QAction* showXmlConsoleAction = m_menu->addAction( tr( "XML Console..." ) );
|
QAction* showXmlConsoleAction = m_menu->addAction( tr( "XML Console..." ) );
|
||||||
connect( showXmlConsoleAction, SIGNAL( triggered() ), this, SLOT( showXmlConsole() ) );
|
connect( showXmlConsoleAction, SIGNAL( triggered() ), SLOT( showXmlConsole() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
emit addMenu( m_menu );
|
emit addMenu( m_menu );
|
||||||
@@ -683,7 +665,9 @@ void XmppSipPlugin::addMenuHelper()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppSipPlugin::removeMenuHelper()
|
|
||||||
|
void
|
||||||
|
XmppSipPlugin::removeMenuHelper()
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
if ( m_menu )
|
if ( m_menu )
|
||||||
@@ -697,13 +681,12 @@ void XmppSipPlugin::removeMenuHelper()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::onNewMessage( const Jreen::Message& message )
|
void
|
||||||
|
XmppSipPlugin::onNewMessage( const Jreen::Message& message )
|
||||||
{
|
{
|
||||||
if ( m_state != Account::Connected )
|
if ( m_state != Account::Connected )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// qDebug() << Q_FUNC_INFO << "message type" << message.subtype();
|
|
||||||
|
|
||||||
QString from = message.from().full();
|
QString from = message.from().full();
|
||||||
QString msg = message.body();
|
QString msg = message.body();
|
||||||
|
|
||||||
@@ -718,7 +701,6 @@ void XmppSipPlugin::onNewMessage( const Jreen::Message& message )
|
|||||||
}
|
}
|
||||||
|
|
||||||
SipInfo info = SipInfo::fromJson( msg );
|
SipInfo info = SipInfo::fromJson( msg );
|
||||||
|
|
||||||
if ( !info.isValid() )
|
if ( !info.isValid() )
|
||||||
{
|
{
|
||||||
QString to = from;
|
QString to = from;
|
||||||
@@ -738,7 +720,8 @@ void XmppSipPlugin::onNewMessage( const Jreen::Message& message )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence )
|
void
|
||||||
|
XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence )
|
||||||
{
|
{
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
if ( m_state != Account::Connected )
|
if ( m_state != Account::Connected )
|
||||||
@@ -752,7 +735,8 @@ void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, cons
|
|||||||
if ( jid == m_client->jid() )
|
if ( jid == m_client->jid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( presence.error() ) {
|
if ( presence.error() )
|
||||||
|
{
|
||||||
//qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: no" << "presence error";
|
//qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: no" << "presence error";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -782,12 +766,12 @@ void XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::onSubscriptionReceived( const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence )
|
void
|
||||||
|
XmppSipPlugin::onSubscriptionReceived( const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence )
|
||||||
{
|
{
|
||||||
if ( m_state != Account::Connected )
|
if ( m_state != Account::Connected )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// qDebug() << Q_FUNC_INFO << "presence type:" << presence.subtype();
|
|
||||||
if ( item )
|
if ( item )
|
||||||
qDebug() << Q_FUNC_INFO << presence.from().full() << "subs" << item->subscription() << "ask" << item->ask();
|
qDebug() << Q_FUNC_INFO << presence.from().full() << "subs" << item->subscription() << "ask" << item->ask();
|
||||||
else
|
else
|
||||||
@@ -795,27 +779,21 @@ void XmppSipPlugin::onSubscriptionReceived( const Jreen::RosterItem::Ptr& item,
|
|||||||
|
|
||||||
// don't do anything if the contact is already subscribed to us
|
// don't do anything if the contact is already subscribed to us
|
||||||
if ( presence.subtype() != Jreen::Presence::Subscribe ||
|
if ( presence.subtype() != Jreen::Presence::Subscribe ||
|
||||||
(
|
( item && (item->subscription() == Jreen::RosterItem::From || item->subscription() == Jreen::RosterItem::Both ) ) )
|
||||||
item && (item->subscription() == Jreen::RosterItem::From || item->subscription() == Jreen::RosterItem::Both)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the requester is already on the roster
|
// check if the requester is already on the roster
|
||||||
if ( item &&
|
if ( item &&
|
||||||
(
|
( item->subscription() == Jreen::RosterItem::To || ( item->subscription() == Jreen::RosterItem::None && !item->ask().isEmpty() ) ) )
|
||||||
item->subscription() == Jreen::RosterItem::To ||
|
|
||||||
( item->subscription() == Jreen::RosterItem::None && !item->ask().isEmpty() )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << presence.from().bare() << "already on the roster so we assume ack'ing subscription request is okay...";
|
qDebug() << Q_FUNC_INFO << presence.from().bare() << "already on the roster so we assume ack'ing subscription request is okay...";
|
||||||
m_roster->allowSubscription( presence.from(), true );
|
m_roster->allowSubscription( presence.from(), true );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
// preparing the confirm box for the user
|
// preparing the confirm box for the user
|
||||||
QMessageBox *confirmBox = new QMessageBox(
|
QMessageBox *confirmBox = new QMessageBox(
|
||||||
@@ -857,7 +835,6 @@ XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
|
|||||||
sender()->deleteLater();
|
sender()->deleteLater();
|
||||||
|
|
||||||
QMessageBox::StandardButton allowSubscription = static_cast< QMessageBox::StandardButton >( result );
|
QMessageBox::StandardButton allowSubscription = static_cast< QMessageBox::StandardButton >( result );
|
||||||
|
|
||||||
if ( allowSubscription == QMessageBox::Yes )
|
if ( allowSubscription == QMessageBox::Yes )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << jid.bare() << "accepted by user, adding to roster";
|
qDebug() << Q_FUNC_INFO << jid.bare() << "accepted by user, adding to roster";
|
||||||
@@ -873,7 +850,8 @@ XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
void
|
||||||
|
XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
||||||
{
|
{
|
||||||
if ( m_state != Account::Connected )
|
if ( m_state != Account::Connected )
|
||||||
return;
|
return;
|
||||||
@@ -887,10 +865,9 @@ void XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
Jreen::Disco::Info *discoInfo = iq.payload< Jreen::Disco::Info >().data();
|
Jreen::Disco::Info *discoInfo = iq.payload< Jreen::Disco::Info >().data();
|
||||||
if ( !discoInfo )
|
if ( !discoInfo )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iq.accept();
|
iq.accept();
|
||||||
|
|
||||||
Jreen::JID jid = iq.from();
|
Jreen::JID jid = iq.from();
|
||||||
|
|
||||||
Jreen::DataForm::Ptr form = discoInfo->form();
|
Jreen::DataForm::Ptr form = discoInfo->form();
|
||||||
|
|
||||||
if ( discoInfo->features().contains( TOMAHAWK_FEATURE ) )
|
if ( discoInfo->features().contains( TOMAHAWK_FEATURE ) )
|
||||||
@@ -937,7 +914,6 @@ void XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
info.setVisible( sipMessage->visible() );
|
info.setVisible( sipMessage->visible() );
|
||||||
if ( sipMessage->visible() )
|
if ( sipMessage->visible() )
|
||||||
{
|
{
|
||||||
|
|
||||||
QHostInfo hi;
|
QHostInfo hi;
|
||||||
hi.setHostName( sipMessage->ip() );
|
hi.setHostName( sipMessage->ip() );
|
||||||
info.setHost( hi );
|
info.setHost( hi );
|
||||||
@@ -955,7 +931,8 @@ void XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool XmppSipPlugin::presenceMeansOnline( Jreen::Presence::Type p )
|
bool
|
||||||
|
XmppSipPlugin::presenceMeansOnline( Jreen::Presence::Type p )
|
||||||
{
|
{
|
||||||
switch( p )
|
switch( p )
|
||||||
{
|
{
|
||||||
@@ -964,22 +941,21 @@ bool XmppSipPlugin::presenceMeansOnline( Jreen::Presence::Type p )
|
|||||||
case Jreen::Presence::Error:
|
case Jreen::Presence::Error:
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type presenceType )
|
void
|
||||||
|
XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type presenceType )
|
||||||
{
|
{
|
||||||
QString fulljid = jid.full();
|
QString fulljid = jid.full();
|
||||||
|
|
||||||
// "going offline" event
|
// "going offline" event
|
||||||
if ( !presenceMeansOnline( presenceType ) &&
|
if ( !presenceMeansOnline( presenceType ) &&
|
||||||
( !m_peers.contains( jid ) ||
|
( !m_peers.contains( jid ) || presenceMeansOnline( m_peers.value( jid ) ) ) )
|
||||||
presenceMeansOnline( m_peers.value( jid ) )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
m_peers[ jid ] = presenceType;
|
m_peers[ jid ] = presenceType;
|
||||||
qDebug() << Q_FUNC_INFO << "* Peer goes offline:" << fulljid;
|
qDebug() << Q_FUNC_INFO << "* Peer goes offline:" << fulljid;
|
||||||
@@ -990,10 +966,7 @@ void XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Ty
|
|||||||
|
|
||||||
// "coming online" event
|
// "coming online" event
|
||||||
if ( presenceMeansOnline( presenceType ) &&
|
if ( presenceMeansOnline( presenceType ) &&
|
||||||
( !m_peers.contains( jid ) ||
|
( !m_peers.contains( jid ) || !presenceMeansOnline( m_peers.value( jid ) ) ) )
|
||||||
!presenceMeansOnline( m_peers.value( jid ) )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
m_peers[ jid ] = presenceType;
|
m_peers[ jid ] = presenceType;
|
||||||
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
||||||
@@ -1020,7 +993,8 @@ void XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XmppSipPlugin::onNewAvatar( const QString& jid )
|
void
|
||||||
|
XmppSipPlugin::onNewAvatar( const QString& jid )
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
// qDebug() << Q_FUNC_INFO << jid;
|
// qDebug() << Q_FUNC_INFO << jid;
|
||||||
@@ -1065,6 +1039,7 @@ XmppSipPlugin::readUsername()
|
|||||||
return credentials.contains( "username" ) ? credentials[ "username" ].toString() : QString();
|
return credentials.contains( "username" ) ? credentials[ "username" ].toString() : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
XmppSipPlugin::readPassword()
|
XmppSipPlugin::readPassword()
|
||||||
{
|
{
|
||||||
|
@@ -48,9 +48,6 @@
|
|||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" )
|
|
||||||
#define TOMAHAWK_CAP_NODE_NAME QLatin1String( "http://tomahawk-player.org/" )
|
|
||||||
|
|
||||||
#include "accounts/AccountDllMacro.h"
|
#include "accounts/AccountDllMacro.h"
|
||||||
|
|
||||||
#include "../XmppInfoPlugin.h"
|
#include "../XmppInfoPlugin.h"
|
||||||
@@ -90,8 +87,9 @@ public slots:
|
|||||||
virtual void checkSettings();
|
virtual void checkSettings();
|
||||||
virtual void configurationChanged();
|
virtual void configurationChanged();
|
||||||
virtual void sendMsg( const QString& to, const QString& msg );
|
virtual void sendMsg( const QString& to, const QString& msg );
|
||||||
void broadcastMsg( const QString &msg );
|
|
||||||
virtual void addContact( const QString& jid, const QString& msg = QString() );
|
virtual void addContact( const QString& jid, const QString& msg = QString() );
|
||||||
|
|
||||||
|
void broadcastMsg( const QString& msg );
|
||||||
void showAddFriendDialog();
|
void showAddFriendDialog();
|
||||||
void publishTune( const QUrl& url, const Tomahawk::InfoSystem::InfoStringHash& trackInfo );
|
void publishTune( const QUrl& url, const Tomahawk::InfoSystem::InfoStringHash& trackInfo );
|
||||||
|
|
||||||
@@ -142,11 +140,13 @@ private:
|
|||||||
Jreen::MUCRoom* m_room;
|
Jreen::MUCRoom* m_room;
|
||||||
Jreen::SimpleRoster* m_roster;
|
Jreen::SimpleRoster* m_roster;
|
||||||
QHash< Jreen::JID, Jreen::Presence::Type > m_peers;
|
QHash< Jreen::JID, Jreen::Presence::Type > m_peers;
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QHash< Jreen::JID, QMessageBox* > m_subscriptionConfirmBoxes;
|
QHash< Jreen::JID, QMessageBox* > m_subscriptionConfirmBoxes;
|
||||||
QMenu* m_menu;
|
QMenu* m_menu;
|
||||||
XmlConsole* m_xmlConsole;
|
XmlConsole* m_xmlConsole;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard, RequestVersion, RequestedVersion };
|
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard, RequestVersion, RequestedVersion };
|
||||||
AvatarManager* m_avatarManager;
|
AvatarManager* m_avatarManager;
|
||||||
Jreen::PubSub::Manager* m_pubSubManager;
|
Jreen::PubSub::Manager* m_pubSubManager;
|
||||||
|
Reference in New Issue
Block a user