mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 20:41:58 +02:00
Merge remote-tracking branch 'origin/stable'
This commit is contained in:
commit
db4f514181
@ -44,6 +44,7 @@ public:
|
||||
public slots:
|
||||
virtual bool connectPlugin( bool startup = false ) = 0;
|
||||
virtual void disconnectPlugin() = 0;
|
||||
virtual void checkSettings() = 0;
|
||||
|
||||
virtual void addContact( const QString &jid, const QString& msg = QString() ) = 0;
|
||||
virtual void sendMsg( const QString& to, const QString& msg ) = 0;
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "network/controlconnection.h"
|
||||
#include "sourcelist.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -59,8 +58,7 @@ SipHandler::plugins() const
|
||||
void
|
||||
SipHandler::onSettingsChanged()
|
||||
{
|
||||
disconnectPlugins();
|
||||
connectPlugins();
|
||||
checkSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -166,23 +164,19 @@ SipHandler::pluginLoaded( const QString& name ) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::checkSettings()
|
||||
{
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
{
|
||||
sip->checkSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SipHandler::connectPlugins( bool startup, const QString &pluginName )
|
||||
{
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
if ( !TomahawkSettings::instance()->acceptedLegalWarning() )
|
||||
{
|
||||
int result = QMessageBox::question(
|
||||
TomahawkApp::instance()->mainWindow(), "Legal Warning",
|
||||
"By pressing OK below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemify the Tomahawk developers and project from liability should you choose to break those laws.\n\nFor more information, please see http://gettomahawk.com/legal",
|
||||
"I Do Not Agree", "I Agree"
|
||||
);
|
||||
if ( result != 1 )
|
||||
return;
|
||||
else
|
||||
TomahawkSettings::instance()->setAcceptedLegalWarning( true );
|
||||
}
|
||||
#endif
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
{
|
||||
if ( pluginName.isEmpty() || ( !pluginName.isEmpty() && sip->name() == pluginName ) )
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
public slots:
|
||||
void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; }
|
||||
|
||||
void checkSettings();
|
||||
void connectPlugins( bool startup = false, const QString &pluginName = QString() );
|
||||
void disconnectPlugins( const QString &pluginName = QString() );
|
||||
void toggleConnect();
|
||||
|
@ -76,12 +76,14 @@ JabberPlugin::connectPlugin( bool startup )
|
||||
if ( startup && !TomahawkSettings::instance()->jabberAutoConnect() )
|
||||
return false;
|
||||
|
||||
QString jid = TomahawkSettings::instance()->jabberUsername();
|
||||
QString server = TomahawkSettings::instance()->jabberServer();
|
||||
QString password = TomahawkSettings::instance()->jabberPassword();
|
||||
unsigned int port = TomahawkSettings::instance()->jabberPort();
|
||||
m_currentUsername = TomahawkSettings::instance()->jabberUsername();
|
||||
m_currentPassword = TomahawkSettings::instance()->jabberPassword();
|
||||
m_currentServer = TomahawkSettings::instance()->jabberServer();
|
||||
m_currentPort = TomahawkSettings::instance()->jabberPort();
|
||||
|
||||
QStringList splitJid = jid.split( '@', QString::SkipEmptyParts );
|
||||
QString server = m_currentServer;
|
||||
|
||||
QStringList splitJid = m_currentUsername.split( '@', QString::SkipEmptyParts );
|
||||
if ( splitJid.size() < 2 )
|
||||
{
|
||||
qDebug() << "JID did not have an @ in it, could not find a server part";
|
||||
@ -91,14 +93,14 @@ JabberPlugin::connectPlugin( bool startup )
|
||||
if ( server.isEmpty() )
|
||||
server = splitJid[1];
|
||||
|
||||
if ( port < 1 || port > 65535 || jid.isEmpty() || password.isEmpty() )
|
||||
if ( m_currentPort < 1 || m_currentPort > 65535 || m_currentUsername.isEmpty() || m_currentPassword.isEmpty() )
|
||||
{
|
||||
qDebug() << "Jabber credentials look wrong, not connecting";
|
||||
return false;
|
||||
}
|
||||
|
||||
delete p;
|
||||
p = new Jabber_p( jid, password, server, port );
|
||||
p = new Jabber_p( m_currentUsername, m_currentPassword, server, m_currentPort );
|
||||
|
||||
QObject::connect( p, SIGNAL( peerOnline( QString ) ), SIGNAL( peerOnline( QString ) ) );
|
||||
QObject::connect( p, SIGNAL( peerOffline( QString ) ), SIGNAL( peerOffline( QString ) ) );
|
||||
@ -174,4 +176,31 @@ JabberPlugin::showAddFriendDialog()
|
||||
addContact( id );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberPlugin::checkSettings()
|
||||
{
|
||||
bool reconnect = false;
|
||||
|
||||
if ( m_currentUsername != TomahawkSettings::instance()->jabberUsername() )
|
||||
reconnect = true;
|
||||
if ( m_currentPassword != TomahawkSettings::instance()->jabberPassword() )
|
||||
reconnect = true;
|
||||
if ( m_currentServer != TomahawkSettings::instance()->jabberServer() )
|
||||
reconnect = true;
|
||||
if ( m_currentPort != TomahawkSettings::instance()->jabberPort() )
|
||||
reconnect = true;
|
||||
|
||||
m_currentUsername = TomahawkSettings::instance()->jabberUsername();
|
||||
m_currentPassword = TomahawkSettings::instance()->jabberPassword();
|
||||
m_currentServer = TomahawkSettings::instance()->jabberServer();
|
||||
m_currentPort = TomahawkSettings::instance()->jabberPort();
|
||||
|
||||
if ( reconnect && ( p || TomahawkSettings::instance()->jabberAutoConnect() ) )
|
||||
{
|
||||
disconnectPlugin();
|
||||
connectPlugin( false );
|
||||
}
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2( sip, JabberPlugin )
|
||||
|
@ -51,7 +51,7 @@ public slots:
|
||||
void disconnectPlugin()
|
||||
{
|
||||
onDisconnected();
|
||||
|
||||
|
||||
if ( p )
|
||||
p->disconnect();
|
||||
|
||||
@ -59,6 +59,8 @@ public slots:
|
||||
p = 0;
|
||||
}
|
||||
|
||||
void checkSettings();
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
if ( p )
|
||||
@ -82,11 +84,16 @@ private slots:
|
||||
void showAddFriendDialog();
|
||||
void onConnected();
|
||||
void onDisconnected();
|
||||
|
||||
|
||||
private:
|
||||
Jabber_p* p;
|
||||
QMenu* m_menu;
|
||||
QAction* m_addFriendAction;
|
||||
|
||||
QString m_currentServer;
|
||||
QString m_currentUsername;
|
||||
QString m_currentPassword;
|
||||
unsigned int m_currentPort;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -168,7 +168,6 @@ TwitterPlugin::disconnectPlugin()
|
||||
m_twitterAuth.data()->deleteLater();
|
||||
|
||||
m_cachedPeers.empty();
|
||||
m_attemptedConnects.empty();
|
||||
delete m_twitterAuth.data();
|
||||
m_isOnline = false;
|
||||
}
|
||||
@ -584,16 +583,14 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q
|
||||
qDebug() << "TwitterPlugin did not send offer because external address is " << Servent::instance()->externalAddress() << " and external port is " << Servent::instance()->externalPort();
|
||||
}
|
||||
|
||||
if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) )
|
||||
QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) );
|
||||
|
||||
if ( peersChanged )
|
||||
{
|
||||
m_cachedPeers[screenName] = QVariant::fromValue< QHash< QString, QVariant > >( _peerData );
|
||||
TomahawkSettings::instance()->setTwitterCachedPeers( m_cachedPeers );
|
||||
m_attemptedConnects[screenName] = false;
|
||||
}
|
||||
|
||||
if ( m_isOnline && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) )
|
||||
QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), QGenericArgument( "QHash< QString, QVariant >", (const void*)&_peerData ) );
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -614,11 +611,6 @@ void
|
||||
TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( m_attemptedConnects.contains( screenName ) && m_attemptedConnects[screenName] )
|
||||
{
|
||||
qDebug() << "Already attempted to connect to this peer with no change in their status, not trying again for now";
|
||||
return;
|
||||
}
|
||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin could not find host and/or port and/or pkey for peer " << screenName;
|
||||
@ -631,7 +623,6 @@ TwitterPlugin::makeConnection( const QString &screenName, const QHash< QString,
|
||||
peerData["pkey"].toString(),
|
||||
friendlyName,
|
||||
peerData["node"].toString() );
|
||||
m_attemptedConnects[screenName] = true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -639,7 +630,6 @@ TwitterPlugin::directMessagePosted( const QTweetDMStatus& message )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "TwitterPlugin sent message to " << message.recipientScreenName() << " containing: " << message.text();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -656,4 +646,11 @@ TwitterPlugin::directMessageDestroyed( const QTweetDMStatus& message )
|
||||
qDebug() << "TwitterPlugin destroyed message " << message.text();
|
||||
}
|
||||
|
||||
void
|
||||
TwitterPlugin::checkSettings()
|
||||
{
|
||||
disconnectPlugin();
|
||||
connectPlugin( false );
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2( sip, TwitterPlugin )
|
||||
|
@ -59,8 +59,8 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual bool connectPlugin( bool startup );
|
||||
|
||||
void disconnectPlugin();
|
||||
void checkSettings();
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
@ -108,7 +108,6 @@ private:
|
||||
qint64 m_cachedMentionsSinceId;
|
||||
qint64 m_cachedDirectMessagesSinceId;
|
||||
QHash< QString, QVariant > m_cachedPeers;
|
||||
QHash< QString, bool > m_attemptedConnects;
|
||||
QSet<QString> m_keyCache;
|
||||
bool m_finishedFriends;
|
||||
bool m_finishedMentions;
|
||||
|
@ -52,8 +52,8 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual bool connectPlugin( bool startup );
|
||||
|
||||
void disconnectPlugin();
|
||||
void checkSettings() {}
|
||||
|
||||
void sendMsg( const QString& to, const QString& msg )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user