• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
managedconnectionaccount.cpp
Go to the documentation of this file.
1 /*
2  managedconnectionaccount.h - Kopete Account that uses a manager to
3  control its connection and respond to connection events
4 
5  Copyright (c) 2005 by Will Stephenson <wstephenson@kde.org>
6  Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
7 
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  *************************************************************************
16 */
17 
18 #include "managedconnectionaccount.h"
19 
20 #include "connectionmanager.h"
21 #include "kopeteuiglobal.h"
22 
23 
24 namespace Kopete
25 {
26 
27 ManagedConnectionAccount::ManagedConnectionAccount( Protocol *parent, const QString &acctId )
28  : PasswordedAccount( parent, acctId ), m_waitingForConnection( false )
29 {
30  QObject::connect( ConnectionManager::self(), SIGNAL(statusChanged(QString,NetworkStatus::EnumStatus)),
31  SLOT(slotConnectionStatusChanged(QString,NetworkStatus::EnumStatus)) );
32 }
33 
34 void ManagedConnectionAccount::connectWithPassword( const QString &password )
35 {
36  m_password = password;
37  NetworkStatus::EnumStatus status = ConnectionManager::self()->status( QString() );
38  if ( status == NetworkStatus::NoNetworks )
39  performConnectWithPassword( password );
40  else
41  {
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 )
47  {
48  m_waitingForConnection = false;
49  performConnectWithPassword( password );
50  }
51  else if ( response == NetworkStatus::UserRefused || response == NetworkStatus::Unavailable )
52  disconnect();
53  }
54 }
55 
56 void ManagedConnectionAccount::slotConnectionStatusChanged( const QString & host, NetworkStatus::EnumStatus status )
57 {
58  Q_UNUSED(host); // as above, we didn't register a hostname, so treat any connection as our own.
59 
60  if ( m_waitingForConnection && ( status == NetworkStatus::Online || status == NetworkStatus::NoNetworks ) )
61  {
62  m_waitingForConnection = false;
63  performConnectWithPassword( m_password );
64  }
65  else if ( isConnected() && ( status == NetworkStatus::Offline
66  || status == NetworkStatus::ShuttingDown
67  || status == NetworkStatus::OfflineDisconnected
68  || status == NetworkStatus::OfflineFailed ) )
69  disconnect();
70 }
71 
72 } // end namespace Kopete
73 #include "managedconnectionaccount.moc"
status
OnlineStatus::StatusType status
Definition: kopeteonlinestatus.cpp:103
Kopete::Account::disconnect
virtual void disconnect()=0
Go offline for this service.
NetworkStatus::Unavailable
Definition: networkstatuscommon.h:10
NetworkStatus::UserRefused
Definition: networkstatuscommon.h:10
Kopete::ManagedConnectionAccount::connectWithPassword
void connectWithPassword(const QString &password)
Begin the connection process, by checking if the connection is available with the ConnectionManager...
Definition: managedconnectionaccount.cpp:34
NetworkStatus::ShuttingDown
Definition: networkstatuscommon.h:9
Kopete::Protocol
base class of every protocol.
Definition: kopeteprotocol.h:62
NetworkStatus::OfflineDisconnected
Definition: networkstatuscommon.h:9
ConnectionManager::status
NetworkStatus::EnumStatus status(const QString &host)
Definition: connectionmanager.cpp:103
NetworkStatus::EnumRequestResult
EnumRequestResult
Definition: networkstatuscommon.h:10
NetworkStatus::Connected
Definition: networkstatuscommon.h:10
kopeteuiglobal.h
NetworkStatus::NoNetworks
Definition: networkstatuscommon.h:9
ConnectionManager::self
static ConnectionManager * self()
Definition: connectionmanager.cpp:51
managedconnectionaccount.h
Kopete::ManagedConnectionAccount::performConnectWithPassword
virtual void performConnectWithPassword(const QString &password)=0
Connect to the server, once the network is available.
NetworkStatus::Online
Definition: networkstatuscommon.h:9
QString
Kopete::PasswordedAccount
An account requiring a password to connect.
Definition: kopetepasswordedaccount.h:36
Kopete::Account::isConnected
bool isConnected() const
Indicate whether the account is connected at all.
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
Kopete::ManagedConnectionAccount::ManagedConnectionAccount
ManagedConnectionAccount(Protocol *parent, const QString &acctId)
ManagedConnectionAccount constructor.
Definition: managedconnectionaccount.cpp:27
NetworkStatus::OfflineFailed
Definition: networkstatuscommon.h:9
NetworkStatus::Offline
Definition: networkstatuscommon.h:9
Kopete::PasswordedAccount::password
Password & password()
Returns a reference to the password object stored in this account.
Definition: kopetepasswordedaccount.cpp:44
NetworkStatus::EnumStatus
EnumStatus
Definition: networkstatuscommon.h:9
ConnectionManager::requestConnection
NetworkStatus::EnumRequestResult requestConnection(QWidget *mainWidget, const QString &host, bool userInitiated)
Definition: connectionmanager.cpp:116
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
connectionmanager.h
Kopete::ManagedConnectionAccount::slotConnectionStatusChanged
virtual void slotConnectionStatusChanged(const QString &host, NetworkStatus::EnumStatus status)
Handle a change in the network connection Called by the ConnectionManager when the network comes up o...
Definition: managedconnectionaccount.cpp:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal