1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-01 14:42:25 +02:00

Allow for omitting @foo.com domains for jabber and google.

Also, make sip plugins clean up the config after themselves
This commit is contained in:
Leo Franchi 2011-06-04 21:59:39 -04:00
parent 4e2c5b23f7
commit 424424cf7b
9 changed files with 62 additions and 11 deletions

View File

@ -283,6 +283,8 @@ void
SipHandler::removeSipPlugin( SipPlugin* p )
{
p->disconnectPlugin();
p->deletePlugin();
emit pluginRemoved( p );
// emit first so sipmodel can find the indexOf

View File

@ -111,3 +111,9 @@ SipPlugin::onPeerOffline(const QString& peerId)
m_peersOnline.removeAll( peerId );
}
void
SipPlugin::deletePlugin()
{
}

View File

@ -91,6 +91,8 @@ public slots:
virtual void refreshProxy();
// so plugins can clean up after themselves
virtual void deletePlugin();
signals:
void error( int, const QString& );
void stateChanged( SipPlugin::ConnectionState state );

View File

@ -53,6 +53,13 @@ GoogleWrapper::icon() const
return QIcon( ":/gmail-logo.png" );
}
QString
GoogleWrapper::defaultSuffix() const
{
return "@gmail.com";
}
void
GoogleWrapper::showAddFriendDialog()
{

View File

@ -47,6 +47,9 @@ public:
virtual const QString friendlyName() const { return "Google"; }
virtual QIcon icon() const;
protected:
QString defaultSuffix() const;
public slots:
void showAddFriendDialog();
};

View File

@ -157,10 +157,10 @@ JabberPlugin::refreshProxy()
if( !m_client->connection() )
return;
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
m_usedProxy = proxyToUse;
if( proxyToUse.type() != QNetworkProxy::NoProxy && ( m_currentServer.isEmpty() || !(m_currentPort > 0) ) )
{
qDebug() << Q_FUNC_INFO << " proxy type is not noproxy but no server/port set";
@ -467,7 +467,12 @@ void
JabberPlugin::addContact(const QString& jid, const QString& msg)
{
// Add contact to the Tomahawk group on the roster
m_roster->subscribe( jid, msg, jid, QStringList() << "Tomahawk" );
QString realJid = jid;
if( !realJid.contains( '@' ) )
realJid += defaultSuffix();
m_roster->subscribe( realJid, msg, realJid, QStringList() << "Tomahawk" );
return;
}
@ -486,6 +491,13 @@ JabberPlugin::showAddFriendDialog()
addContact( id );
}
QString
JabberPlugin::defaultSuffix() const
{
return "@jabber.org";
}
void
JabberPlugin::showXmlConsole()
{
@ -513,13 +525,19 @@ JabberPlugin::checkSettings()
proxyToUse.type() != m_usedProxy.type() ||
proxyToUse.capabilities() != m_usedProxy.capabilities()
)
reconnect = true;
reconnect = true;
m_currentUsername = accountName();
m_currentPassword = readPassword();
m_currentServer = readServer();
m_currentPort = readPort();
if ( !m_currentUsername.contains( '@' ) )
{
m_currentUsername += defaultSuffix();
TomahawkSettings::instance()->setValue( pluginId() + "/username", m_currentUsername );
}
if ( reconnect )
{
qDebug() << Q_FUNC_INFO << "Reconnecting jreen plugin...";
@ -540,7 +558,6 @@ JabberPlugin::checkSettings()
void JabberPlugin::setupClientHelper()
{
Jreen::JID jid = Jreen::JID( m_currentUsername );
m_client->setJID( jid );
m_client->setPassword( m_currentPassword );
@ -981,6 +998,12 @@ JabberPlugin::saveConfig()
checkSettings();
}
void
JabberPlugin::deletePlugin()
{
TomahawkSettings::instance()->remove( pluginId() );
}
SipPlugin::ConnectionState
JabberPlugin::connectionState() const

View File

@ -82,6 +82,7 @@ public:
virtual QIcon icon() const;
virtual QWidget* configWidget();
virtual void saveConfig();
virtual void deletePlugin();
signals:
void jidChanged( const QString& );
@ -97,6 +98,8 @@ public slots:
void showAddFriendDialog();
protected:
virtual QString defaultSuffix() const;
Ui_JabberConfig* m_ui; // so the google wrapper can change the config dialog a bit
private slots:

View File

@ -283,6 +283,12 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user )
}
}
void
TwitterPlugin::deletePlugin()
{
TomahawkSettings::instance()->remove( pluginId() );
}
void
TwitterPlugin::checkTimerFired()
{
@ -596,7 +602,7 @@ TwitterPlugin::registerOffer( const QString &screenName, const QHash< QString, Q
if ( !m_cachedAvatars.contains( screenName ) )
QMetaObject::invokeMethod( this, "fetchAvatar", Q_ARG( QString, screenName ) );
QHash< QString, QVariant > _peerData( peerData );
if ( _peerData.contains( "dirty" ) )
@ -906,7 +912,7 @@ TwitterPlugin::twitterCachedFriendsSinceId() const
s->sync();
}
s->endGroup();
return s->value( pluginId() + "/cachedfriendssinceid", 0 ).toLongLong();
}
@ -1004,7 +1010,7 @@ TwitterPlugin::twitterCachedPeers() const
s->setValue( "cachedpeers",
s->value( "cachedpeers_tmp" ).toHash() );
s->remove( "cachedpeers_tmp" );
s->sync();
}
s->endGroup();

View File

@ -74,12 +74,13 @@ public:
signals:
void avatarReceived( QString, QPixmap );
public slots:
virtual bool connectPlugin( bool startup );
void disconnectPlugin();
void checkSettings();
void refreshProxy();
void deletePlugin();
void sendMsg( const QString& to, const QString& msg )
{
@ -135,8 +136,6 @@ private:
void setTwitterCachedDirectMessagesSinceId( qint64 sinceid );
QHash<QString, QVariant> twitterCachedPeers() const;
void setTwitterCachedPeers( const QHash<QString, QVariant> &cachedPeers );
bool twitterAutoConnect() const;
void setTwitterAutoConnect( bool autoConnect );
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline;