Logo Search packages:      
Sourcecode: kmess version File versions  Download package

ApplicationList Class Reference
[network/applications]

#include <applicationlist.h>

List of all members.


Detailed Description

Maintenance of applications and direct connections for one contact.

This class is used in the following message flow:

This class has the intermediate role between the ChatMaster and Application classes. Each Contact has a reference to one ApplicationList object, created with Contact::createApplicationList(). Each P2PApplication class has a reference to this class as well to access the direct connection. The direct connection is re-used by applications of the same contact.

The ChatMaster delivers the message with gotMessage(). When an incoming message starts a new invitation (creating a new application object), it's registered automatically in this class. The application signals putMsg() and deleteMe() are handled internally by this class. Other signals (notably status messages) are not handled. Instead, the newApplication() signal is fired so the ChatMaster can connect to those signals.

When a mesage needs to be sent back, the application calls sendMessage(). This method either delivers the message through the direct connection, or it emits a putMsg() signal. This signal is picked up be the ChatMaster to deliver the message at one of the available switchboard connections. Sometimes, a switchboard connection is unable to send more messages. The ChatMaster calls pauseApplications() so the queue won't be flooded.

When a P2PApplication needs to establish a direct connection (a MsnDirectConnection class), it calls addConnection() or addServerConnection(). This class reports back whether a connection attempt succeeded, or all connection attempts failed. Internally, a DirectConnectionPool is used to handle multiple connection attempts.

The "in-between role" of this class appeared to be a must for peer-to-peer applications (P2PApplication instances), especially in combination with direct connections. The MSNP2P features pose some difficult design choices:

This protocol logic makes the client implementations heavier, but it's more efficient on network resources (hence MSNC* is about moving protocol logic to the clients).

The method calls to start a P2P data transfer are pretty complex. This happens because each situation needs a fallback to keep the transfer running. The usual path for transfers is:

If the connection attempt or authenticaion fails, the connectionFailed() signal is called. This causes the applications to start their transfer as well with registerDataSendingApplication(). In this case, the transfer takes place over the switchboard. Internally, the slotSwitchboardTestReadyWrite() invokes the calls to the P2PApplication::sendNextDataParts() method.

If the connection is closed in any event, all transfers switch from slotConnectionReadyWrite() to slotSwitchboardTestReadyWrite(). The reverse happens when a different invitation manages to establish a direct connection. This guarantees the transfer continues, or takes advantage of high speed whenever possible.

Author:
Diederik van der Boor

Definition at line 105 of file applicationlist.h.


Public Slots

void sendMessage (const MimeApplication *source, const MimeMessage &messageData)
 Send a message for a MIME application.

Signals

void applicationsAborted (const QString &contact)
 This signal is fired when all applications aborted.
void connectionAuthorized ()
 This signal is fired when the direct connection is authorized.
void connectionClosed ()
 This signal is fired when the direct connection was closed.
void connectionEstablished ()
 This signal is fired when direct connection is established.
void connectionFailed ()
 This signal is fired when all direct connection attempts failed.
void newApplication (Application *application)
 This signal is fired when a new application was created.
void putMsg (const MimeMessage &message, const QString &contactHandle, bool privateChatRequired)
 This signal is fired when the ChatMaster should deliver a message to the switchboard.

Public Member Functions

void addApplication (P2PApplication *application)
 Add a new P2P application to the list.
void addApplication (MimeApplication *application)
 Add a new MIME application to the list.
bool addConnection (const QString &ipAddress, const quint16 port)
 Attempt to establish a direct connection at the given ipaddress/port.
int addServerConnection ()
 Attempt to establish a direct connection by listening at a random port.
 ApplicationList (const QString &contactHandle)
 The constructor.
bool contactLeavingChat (const MsnSwitchboardConnection *connection, bool userInitiated=false)
 Abort all applications, the contact is leaving a chat.
bool contactLeftChat (bool userInitiated=false)
 Abort all applications, the contact left a chat.
ApplicationgetApplicationByCookie (const QString &cookie) const
 Find the application with uses the given cookie.
const QString & getContactHandle () const
 Return the handle of the contact this class manages.
MsnDirectConnectiongetDirectConnection () const
 Return the direct connection, if available.
void gotMessage (const P2PMessage &message)
 Deliver a received P2P message to the correct application instance.
void gotMessage (const MimeMessage &message)
 Deliver a received MIME message to the correct application instance.
bool hasAuthorizedDirectConnection () const
 Return whether the direct connection is connected and authorized. If a direct connection is not authorized, it's not able to send the data transfer.
bool hasDataSendingApplications () const
 Return whether there are applications which need to send data.
bool hasDirectConnection () const
 Return whether there is an active direct connection.
bool hasMsnObjectTransfer (const MsnObject &msnObject) const
 Return whether an MSN object transfer for the given msn object is already running.
bool hasPendingConnectionInvitation () const
 Return whether the transfer invitation has been sent.
bool hasPendingConnections () const
 Return whether there are pending connection attempts.
bool isEmpty () const
 Return whether the application list does not have any applications. Note that there could also be a direct connection.
void pauseApplications ()
 Pause all applications, avoid flooding the switchboard message queue.
void registerDataSendingApplication (P2PApplicationBase *application)
 Register an application which is sending a file.
void resumeApplications (bool isPrivateChat=true)
 Resume all applications, allowing messages to be sent again.
bool sendMessage (const P2PApplicationBase *source, const QByteArray &header, const QByteArray &messageData=0, uint footerCode=0)
 Send a P2P message over one of the available connections/bridges.
void setAddingConnections (bool state)
 Set an application is adding connections, don't send "all failed" signal.
void setPendingConnectionInvitation (bool state)
 Set whether the transfer invitation has been sent.
void unregisterDataSendingApplication (P2PApplicationBase *application)
 Remove the registration of an application which sends a file.
virtual ~ApplicationList ()
 The destructor.

Private Slots

void slotActiveConnectionAuthorized ()
 The direct connection is authorized.
void slotActiveConnectionClosed ()
 The direct connection was closed.
void slotAllConnectionsFailed ()
 All direct connection attempts failed.
void slotConnectionEstablished ()
 The direct connection is established.
void slotConnectionReadyWrite ()
 The direct connection is ready to send more data.
void slotGotDirectConnectionMessage (const QByteArray &messageData)
 A message was received from the direct connection.
void slotSwitchboardTestReadyWrite ()
 The switchboard is ready to send more data.
void slotTerminateApplication (Application *application)
 An application was finished and requested removal.

Private Member Functions

bool abortApplications (const MsnSwitchboardConnection *abortingConnection=0, bool userInitiated=false)
 Abort all applications, the connection is closing or closed.
void connectApplication (Application *app)
 Connect the application object signals.
P2PApplicationcreateApplication (const P2PMessage &message)
 Create the P2P application instance for the given invitation message.
MimeApplicationcreateApplication (const MimeMessage &message)
 Create the MIME application instance for the given invitation message.
P2PApplicationcreateApplicationByEufGuid (const QString &eufGuid)
 Factory method to create a P2P application instance for the given EUF-GUID.
MimeApplicationcreateApplicationByGuid (const QString &applicationGuid)
 Factory method to create a MIME application instance for the given Application-GUID.
P2PApplicationgetApplicationByAckData (const P2PMessage &ackMessage) const
 Find the P2P application which should handle the ACK message.
P2PApplicationgetApplicationByCallId (const QString &callID) const
 Find the P2P application which handles the session for the given Call-ID.
P2PApplicationgetApplicationByLastMessage (unsigned long messageID) const
 Find the P2P application which handled the previous message fragment from the contact.
P2PApplicationgetApplicationByNonce (const QString &nonce) const
 Find the P2P application which authorizes the transfer for the given nonce.
P2PApplicationgetApplicationBySessionId (unsigned long sessionID) const
 Find the P2P application identified with the given session ID.
void initializeDirectConnectionPool ()
 Create the direct connection pool.
void sendMimeRejectMessage (const QString &invitationCookie, bool notInstalled)
 Reject an invitation for a mime-application.

Private Attributes

QList< Application * > abortingApplications_
bool addingConnections_
QString contactHandle_
QList< P2PApplicationBase * > dataSendingApplications_
MsnDirectConnectiondirectConnection_
DirectConnectionPooldirectConnectionPool_
QList< MimeApplication * > mimeApplications_
QList< P2PApplication * > p2pApplications_
bool pauseApplications_
bool pendingConnectionInvitation_
QTimer sbReadyWriteTester_

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index