1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 01:09:42 +01:00

sipjreen: do proper reconnection handling now. even with translated errors :P

This commit is contained in:
Dominik Schmidt 2011-05-04 14:50:02 +02:00
parent d8023b285f
commit e2890c1e93
2 changed files with 44 additions and 51 deletions

View File

@ -293,55 +293,13 @@ JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
{
qDebug() << Q_FUNC_INFO;
QString errorMessage;
switch( reason )
{
case Jreen::Client::User:
errorMessage = "User Interaction";
break;
case Jreen::Client::HostUnknown:
errorMessage = "Host is unknown";
break;
case Jreen::Client::ItemNotFound:
errorMessage = "Item not found";
break;
case Jreen::Client::AuthorizationError:
errorMessage = "Authorization Error";
break;
case Jreen::Client::RemoteStreamError:
errorMessage = "Remote Stream Error";
break;
case Jreen::Client::RemoteConnectionFailed:
errorMessage = "Remote Connection failed";
break;
case Jreen::Client::InternalServerError:
errorMessage = "Internal Server Error";
break;
case Jreen::Client::SystemShutdown:
errorMessage = "System shutdown";
break;
case Jreen::Client::Conflict:
errorMessage = "Conflict";
break;
case Jreen::Client::Unknown:
errorMessage = "Unknown";
break;
default:
qDebug() << "Not all Client::DisconnectReasons checked";
Q_ASSERT(false);
break;
}
bool reconnect = false;
switch( reason )
{
case Jreen::Client::User:
break;
case Jreen::Client::AuthorizationError:
emit error( SipPlugin::AuthError, errorMessage );
emit error( SipPlugin::AuthError, errorMessage( reason ) );
break;
case Jreen::Client::HostUnknown:
@ -352,8 +310,7 @@ JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
case Jreen::Client::SystemShutdown:
case Jreen::Client::Conflict:
case Jreen::Client::Unknown:
emit error( SipPlugin::ConnectionError, errorMessage );
reconnect = true;
emit error( SipPlugin::ConnectionError, errorMessage( reason ) );
break;
default:
@ -365,15 +322,51 @@ JabberPlugin::onDisconnect( Jreen::Client::DisconnectReason reason )
emit stateChanged( m_state );
removeMenuHelper();
if(reconnect)
QTimer::singleShot(15*1000, this, SLOT(connectPlugin()));
}
void
JabberPlugin::onAuthError( int code, const QString& msg )
QString JabberPlugin::errorMessage(Jreen::Client::DisconnectReason reason)
{
switch( reason )
{
case Jreen::Client::User:
return tr("User Interaction");
break;
case Jreen::Client::HostUnknown:
return tr("Host is unknown");
break;
case Jreen::Client::ItemNotFound:
return tr("Item not found");
break;
case Jreen::Client::AuthorizationError:
return tr("Authorization Error");
break;
case Jreen::Client::RemoteStreamError:
return tr("Remote Stream Error");
break;
case Jreen::Client::RemoteConnectionFailed:
return tr("Remote Connection failed");
break;
case Jreen::Client::InternalServerError:
return tr("Internal Server Error");
break;
case Jreen::Client::SystemShutdown:
return tr("System shutdown");
break;
case Jreen::Client::Conflict:
return tr("Conflict");
break;
case Jreen::Client::Unknown:
return tr("Unknown");
break;
default:
qDebug() << "Not all Client::DisconnectReasons checked";
Q_ASSERT(false);
break;
}
return QString();
}
void

View File

@ -101,7 +101,6 @@ private slots:
void showAddFriendDialog();
void onConnect();
void onDisconnect(Jreen::Client::DisconnectReason reason);
void onAuthError(int code, const QString &msg);
void onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence );
void onSubscriptionReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence );
@ -121,6 +120,7 @@ private:
bool readAutoConnect();
int readPort();
QString errorMessage( Jreen::Client::DisconnectReason reason );
void setupClientHelper();
void addMenuHelper();
void removeMenuHelper();