1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 23:26:40 +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

@@ -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()
{
@@ -520,6 +532,12 @@ JabberPlugin::checkSettings()
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()
{

View File

@@ -80,6 +80,7 @@ public slots:
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;