mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 19:30:21 +02:00
Make the Connect/Disconnect button do as advertised. Needs some more safety checks likely, but this will do for now.
This commit is contained in:
@@ -19,6 +19,7 @@ public:
|
||||
void add( const Tomahawk::source_ptr& s );
|
||||
void remove( const Tomahawk::source_ptr& s );
|
||||
void remove( Tomahawk::Source* s );
|
||||
void removeAllRemote();
|
||||
|
||||
QList<Tomahawk::source_ptr> sources() const;
|
||||
Tomahawk::source_ptr get( const QString& username ) const;
|
||||
|
@@ -12,6 +12,7 @@
|
||||
SipHandler::SipHandler( QObject* parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
m_connected = false;
|
||||
loadPlugins();
|
||||
}
|
||||
|
||||
@@ -80,6 +81,7 @@ SipHandler::connect()
|
||||
{
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
sip->connect();
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +90,17 @@ SipHandler::disconnect()
|
||||
{
|
||||
foreach( SipPlugin* sip, m_plugins )
|
||||
sip->disconnect();
|
||||
APP->sourcelist().removeAllRemote();
|
||||
m_connected = false;
|
||||
}
|
||||
|
||||
void
|
||||
SipHandler::toggleConnect()
|
||||
{
|
||||
if( m_connected )
|
||||
disconnect();
|
||||
else
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -21,6 +21,7 @@ public slots:
|
||||
|
||||
void connect();
|
||||
void disconnect();
|
||||
void toggleConnect();
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
@@ -38,6 +39,7 @@ private:
|
||||
void loadPlugin( QObject* plugin );
|
||||
|
||||
QList< SipPlugin* > m_plugins;
|
||||
bool m_connected;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -247,6 +247,7 @@ Jabber_p::onDisconnect( ConnectionError e )
|
||||
{
|
||||
qDebug() << "Jabber Disconnected";
|
||||
QString error;
|
||||
bool triggeredDisconnect = false;
|
||||
|
||||
switch( e )
|
||||
{
|
||||
@@ -330,14 +331,17 @@ Jabber_p::onDisconnect( ConnectionError e )
|
||||
|
||||
default :
|
||||
error = "UNKNOWN ERROR";
|
||||
triggeredDisconnect = true;
|
||||
}
|
||||
|
||||
qDebug() << "Connection error msg:" << error;
|
||||
|
||||
emit authError( e, error );
|
||||
// Assume that an unknown error is due to a disconnect triggered by the user
|
||||
if( !triggeredDisconnect )
|
||||
emit authError( e, error ); // trigger reconnect
|
||||
emit disconnected();
|
||||
|
||||
// trigger reconnect
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -66,8 +66,6 @@ public:
|
||||
|
||||
void setProxy( QNetworkProxy* proxy );
|
||||
|
||||
void disconnect();
|
||||
|
||||
/// GLOOX IMPLEMENTATION STUFF FOLLOWS
|
||||
virtual void onConnect();
|
||||
virtual void onDisconnect( gloox::ConnectionError e );
|
||||
@@ -124,6 +122,7 @@ public slots:
|
||||
void sendMsg( const QString& to, const QString& msg );
|
||||
void broadcastMsg( const QString& msg );
|
||||
void addContact( const QString& jid, const QString& msg = QString() );
|
||||
void disconnect();
|
||||
|
||||
private slots:
|
||||
void doJabberRecv();
|
||||
|
@@ -69,6 +69,16 @@ SourceList::remove( Tomahawk::Source* s )
|
||||
emit sourceRemoved( src );
|
||||
}
|
||||
|
||||
void
|
||||
SourceList::removeAllRemote()
|
||||
{
|
||||
foreach( source_ptr s, m_sources )
|
||||
{
|
||||
if( s != m_local )
|
||||
remove( s );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList<source_ptr>
|
||||
SourceList::sources() const
|
||||
|
@@ -170,6 +170,7 @@ TomahawkWindow::setupSignals()
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
||||
connect( ui->statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT(toggleConnect() ) );
|
||||
|
||||
// <SipHandler>
|
||||
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
|
||||
|
Reference in New Issue
Block a user