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

P2PApplication Class Reference

#include <p2papplication.h>

Inheritance diagram for P2PApplication:

Application FileTransferP2P PictureTransferP2P WebApplicationP2P

List of all members.


Detailed Description

An Application subclass implementing MSN6 P2P-style conversations. To implement a P2P service, create a derived class which implements the userStarted*, contactStarted* and getAppId() methods.

Each P2P Message received by the switchboard will be passed to the correct P2PApplication instance. The gotMessage() method of that particular P2PApplication will be called to deliver the message.

User-started invitations are handled this way:

Contacted-started invitations are handled this way:

To cancel a running session, call userAborted() or use sendCancelMessage() in combination with endApplication().

Author:
Diederik van der Boor

Definition at line 106 of file p2papplication.h.


Public Types

enum  ApplicationMode { APP_MODE_NORMAL, APP_MODE_BACKGROUND, APP_MODE_ERROR_HANDLER }

Signals

void appInitMessage (QString html)
void appMessage (QString html)
void deleteMe (Application *object)
void fileTransferred (QString filename)
void putMsg (const MimeMessage &message)
void systemMessage (QString message)

Public Member Functions

QString getBranch () const
QString getCallID () const
QString getContactHandle () const
const QString & getCookie () const
unsigned long getLastContactAckMessageID () const
unsigned long getLastContactMessageID () const
unsigned long getLastUserMessageID () const
unsigned long getLastUserUniqueID () const
int getMode () const
unsigned long getSessionID () const
void gotCommand (QString command)
void gotMessage (const MimeMessage &message)
 P2PApplication (const QString &localIP, const QString &contactHandle)
void setMode (ApplicationMode mode)
void start ()
virtual void userAborted ()
virtual ~P2PApplication ()

Protected Types

enum  ApplicationCancelReason {
  CANCEL_INVITATION, CANCEL_SESSION, CANCEL_NOT_INSTALLED, CANCEL_TIMEOUT,
  CANCEL_FAILED, CANCEL_INVALID_SLP_CONTENT_TYPE
}
enum  P2PDataType { P2P_TYPE_NEGOTIATION = 0, P2P_TYPE_PICTURE = 1, P2P_TYPE_FILE = 2 }

Protected Member Functions

void acknowledgePreparation (bool ack=true)
void contactAborted (const QString &message=0)
void contactRejected (const QString &message=0)
virtual void contactStarted1_ContactInvitesUser (const MimeMessage &message)
virtual void contactStarted2_UserAccepts ()
virtual void contactStarted3_ContactConfirmsAccept (const MimeMessage &message)
virtual void contactStarted4_ContactConfirmsPreparation ()
void endApplication (const QString &reason=0)
QString generateCookie () const
virtual QString getCancelMessage () const
const QString & getExternalIp () const
const QString & getInvitationContentType () const
unsigned long getInvitationSessionID () const
const QString & getLocalIp () const
virtual void gotData (const P2PMessage &message)
bool isUserStartedApp () const
bool isWaitingForUser () const
void offerAcceptOrReject (const QString &appHtml)
void offerCancel (const QString &appHtml)
void sendCancelMessage (const ApplicationCancelReason cancelReason)
void sendData (QIODevice *dataSource, const P2PDataType type)
void sendDataPreparation ()
void sendDataPreparationAck ()
void sendSlpInvitation (uint sessionID, const QString &contentType, const MimeMessage &message)
void sendSlpOkMessage (const MimeMessage &message)
void startByInvite (const QString &invitationCookie)
void userRejected ()
virtual void userStarted1_UserInvitesContact ()
virtual void userStarted2_ContactAccepts (const MimeMessage &message)
virtual void userStarted3_UserPrepares ()

Static Protected Member Functions

static void freePort (const int &port)
static unsigned long generateID ()

Private Types

enum  P2PWaitingState {
  P2P_WAIT_DEFAULT = 0, P2P_WAIT_FOR_SLP_OK_ACK = 1, P2P_WAIT_FOR_FILE_DATA = 2, P2P_WAIT_FOR_PREPARE = 3,
  P2P_WAIT_FOR_PREPARE_ACK = 4, P2P_WAIT_FOR_SLP_BYE = 5, P2P_WAIT_FOR_SLP_BYE_ACK = 6, P2P_WAIT_FOR_SLP_ERR_ACK = 7,
  P2P_WAIT_CONTACT_ACCEPT = 8, P2P_WAIT_FOR_CLOSING_ACK = 9
}

Private Slots

void slotCleanup ()
void slotSendData ()

Private Member Functions

void gotAck (const P2PMessage &message)
void gotClosingAck (const P2PMessage &message)
void gotDataFragment (const P2PMessage &message)
void gotDataPreparation (const P2PMessage &message)
void gotErrorAck (const P2PMessage &message)
void gotNegotiationFragment (const P2PMessage &message)
void gotNegotiationMessage (const QString &slpMessage)
void gotSlpBye (const MimeMessage &slpMimeMessage)
void gotSlpInvite (const MimeMessage &slpMimeMessage)
void gotSlpStatus (const MimeMessage &slpMimeMessage, const QString &preamble)
void gotTimeoutAck (const P2PMessage &message)
void sendP2PAck (int ackType=P2PMessage::MSN_FLAG_ACK)
void sendP2PMessage (const QByteArray &messageData, int flagField=0, uint footerCode=0)
void sendSlpBye ()
void sendSlpError (const QString &statusLine, const uint sessionID=0, const QString &messageContentType=0)
void sendSlpMessage (const QString &slpMessage)

Static Private Member Functions

static QString generateGUID ()

Private Attributes

QString branch_
QBuffer * buffer_
QString callID_
QString contactHandle_
QIODevice * dataSource_
P2PDataType dataType_
bool gotSlpMessage_
QString invitationContentType_
int invitationCSeq_
unsigned long invitationSessionID_
unsigned long lastUniqueID_
unsigned long messageID_
unsigned long messageOffset_
unsigned long messageTotalSize_
unsigned long originalAckMessageID_
unsigned long originalDataSize_
unsigned long originalMessageID_
unsigned long originalSessionID_
unsigned long originalTotalSize_
bool sentCancelMessage_
unsigned long sessionID_
bool shouldSendAck_
bool userShouldAcknowledge_
P2PWaitingState waitingState_
QTimer * waitingTimer_

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

Generated by  Doxygen 1.6.0   Back to index