Added include path for libv4l2 includes, rather than assuming they are
[kdenetwork.git] / kopete / libkopete / managedconnectionaccount.cpp
blobb5142ba356df3cccd6ed1cfd1dfeb960e86c3910
1 /*
2 managedconnectionaccount.h - Kopete Account that uses a manager to
3 control its connection and respond to connection events
5 Copyright (c) 2005 by Will Stephenson <wstephenson@kde.org>
6 Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
9 * *
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
14 * *
15 *************************************************************************
18 #include "connectionmanager.h"
19 #include "kopeteuiglobal.h"
21 #include "managedconnectionaccount.h"
24 namespace Kopete
27 ManagedConnectionAccount::ManagedConnectionAccount( Protocol *parent, const QString &acctId )
28 : PasswordedAccount( parent, acctId ), m_waitingForConnection( false )
30 QObject::connect( ConnectionManager::self(), SIGNAL(statusChanged(const QString&, NetworkStatus::EnumStatus ) ),
31 SLOT(slotConnectionStatusChanged(const QString&, NetworkStatus::EnumStatus ) ) );
34 void ManagedConnectionAccount::connectWithPassword( const QString &password )
36 m_password = password;
37 NetworkStatus::EnumStatus status = ConnectionManager::self()->status( QString() );
38 if ( status == NetworkStatus::NoNetworks )
39 performConnectWithPassword( password );
40 else
42 m_waitingForConnection = true;
43 // need to adapt libkopete so we know the hostname in this class and whether the connection was user initiated
44 // for now, these are the default parameters to always bring up a connection to "the internet".
45 NetworkStatus::EnumRequestResult response = ConnectionManager::self()->requestConnection( Kopete::UI::Global::mainWidget(), QString(), true );
46 if ( response == NetworkStatus::Connected )
48 m_waitingForConnection = false;
49 performConnectWithPassword( password );
51 else if ( response == NetworkStatus::UserRefused || response == NetworkStatus::Unavailable )
52 disconnect();
56 void ManagedConnectionAccount::slotConnectionStatusChanged( const QString & host, NetworkStatus::EnumStatus status )
58 Q_UNUSED(host); // as above, we didn't register a hostname, so treat any connection as our own.
60 if ( m_waitingForConnection && ( status == NetworkStatus::Online || status == NetworkStatus::NoNetworks ) )
62 m_waitingForConnection = false;
63 performConnectWithPassword( m_password );
65 else if ( isConnected() && ( status == NetworkStatus::Offline
66 || status == NetworkStatus::ShuttingDown
67 || status == NetworkStatus::OfflineDisconnected
68 || status == NetworkStatus::OfflineFailed ) )
69 disconnect();
72 } // end namespace Kopete
73 #include "managedconnectionaccount.moc"