1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-10 08:04: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 ) SipHandler::removeSipPlugin( SipPlugin* p )
{ {
p->disconnectPlugin(); p->disconnectPlugin();
p->deletePlugin();
emit pluginRemoved( p ); emit pluginRemoved( p );
// emit first so sipmodel can find the indexOf // emit first so sipmodel can find the indexOf

View File

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

View File

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

View File

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

View File

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

View File

@@ -467,7 +467,12 @@ void
JabberPlugin::addContact(const QString& jid, const QString& msg) JabberPlugin::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
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; return;
} }
@@ -486,6 +491,13 @@ JabberPlugin::showAddFriendDialog()
addContact( id ); addContact( id );
} }
QString
JabberPlugin::defaultSuffix() const
{
return "@jabber.org";
}
void void
JabberPlugin::showXmlConsole() JabberPlugin::showXmlConsole()
{ {
@@ -520,6 +532,12 @@ JabberPlugin::checkSettings()
m_currentServer = readServer(); m_currentServer = readServer();
m_currentPort = readPort(); m_currentPort = readPort();
if ( !m_currentUsername.contains( '@' ) )
{
m_currentUsername += defaultSuffix();
TomahawkSettings::instance()->setValue( pluginId() + "/username", m_currentUsername );
}
if ( reconnect ) if ( reconnect )
{ {
qDebug() << Q_FUNC_INFO << "Reconnecting jreen plugin..."; qDebug() << Q_FUNC_INFO << "Reconnecting jreen plugin...";
@@ -540,7 +558,6 @@ JabberPlugin::checkSettings()
void JabberPlugin::setupClientHelper() void JabberPlugin::setupClientHelper()
{ {
Jreen::JID jid = Jreen::JID( m_currentUsername ); Jreen::JID jid = Jreen::JID( m_currentUsername );
m_client->setJID( jid ); m_client->setJID( jid );
m_client->setPassword( m_currentPassword ); m_client->setPassword( m_currentPassword );
@@ -981,6 +998,12 @@ JabberPlugin::saveConfig()
checkSettings(); checkSettings();
} }
void
JabberPlugin::deletePlugin()
{
TomahawkSettings::instance()->remove( pluginId() );
}
SipPlugin::ConnectionState SipPlugin::ConnectionState
JabberPlugin::connectionState() const JabberPlugin::connectionState() const

View File

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

View File

@@ -283,6 +283,12 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user )
} }
} }
void
TwitterPlugin::deletePlugin()
{
TomahawkSettings::instance()->remove( pluginId() );
}
void void
TwitterPlugin::checkTimerFired() TwitterPlugin::checkTimerFired()
{ {

View File

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