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

MsnSocketHttp Class Reference

#include <msnsockethttp.h>

Inheritance diagram for MsnSocketHttp:


List of all members.

Detailed Description

Basic I/O functionality for the MSN server protocol over a HTTP connection.

This is a low-level class used used by MsnConnection. The class provides the following facilities:

With HTTP the server has no way of contacting the client by itself. Everytime we send a request to the server (the "MSN HTTP Gateway"), it will send along with the answer a full list of messages which we didn't receive yet. So if we've got nothing to send, we're forced to periodically send 'poll' requests. These are bogus calls which exist only to allow the gateway to send any new message back.

In any given moment, there may only be one active message. This means that if we send two subsequent requests, we will be disconnected immediately with a '400 Bad Request' response. Therefore, this class implements a 1-item-wide sending window. It's not necessary to apply it to receiving also, since the server just responds in order.

Data from the server (the "HTTP Gateway") is handled by the slotDataReceived() slot. This method receives responses to HTTP requests made by the class; they contain a list of new undelivered messages. The slotDataReceived() method splits it up to individual commands and forwards the received commands to MsnConnection individually.

Simple scheme of requests/responses:

Valerio Pilo <valerio@kmess.org>

Definition at line 75 of file msnsockethttp.h.

Public Types

enum  ErrorType {
 Types of errors with connection sockets. More...
 Type of server that will be connected from this socket. More...


void connected ()
void dataReceived (const QStringList &commandLine, const QByteArray &payloadData)
void disconnected ()
void error (QString error, MsnSocketBase::ErrorType type)
void pingSent ()
void statusMessage (QString message, bool isError)

Public Member Functions

void connectToServer (const QString &server=QString(), const quint16 port=0)
 Connect to the given server.
void disconnectFromServer (bool isTransfer=false)
 Disconnect from the server.
QStringList getAcceptedPayloadCommands ()
 Return which payload commands are accepted by this connection.
QString getLocalIp () const
 Return the local IP address.
virtual ServerType getServerType () const
 Return the type of server connection managed by the socket.
virtual bool isConnected () const
 Whether or not the connection is active.
bool isErrorCommand (const QString &command) const
 Test whether the given command is an error.
virtual bool isPayloadCommand (const QString &command) const
 Test whether the given command is a payload command.
 MsnSocketHttp (ServerType serverType)
 The constructor.
virtual void setAcceptedPayloadCommands (QStringList commandList)
 Specify which accepted commands carry payload data for this connection.
void setSendPings (bool sendPings)
 Set whether to send pings or not.
qint64 writeBinaryData (const QByteArray &data)
 Write data to the gateway without any conversion.
qint64 writeData (const QString &data)
 Write a string to the gateway.
 ~MsnSocketHttp ()
 The destructor.

Protected Slots

virtual void proxyAuthenticate (const QNetworkProxy &proxy, QAuthenticator *authenticator)

Protected Attributes

QStringList acceptedPayloadCommands_
bool connected_
ServerType serverType_

Private Slots

void slotQueryServer ()
 Send a polling message to the server, to retrieve pending commands.
void slotReplyReceived (QNetworkReply *reply)
 Read received data and pass along the contained commands.

Private Member Functions

void cleanUp ()
 Clean up the connection.
void dump (void *obj, QByteArray data, bool isRequest)
void sendNextRequest ()
 Sends the next queued request.
void setGateway (QString host)
 Change the server connection gateway.

Private Attributes

QString baseServerPath_
bool canSendRequests_
QString gatewayAddress_
QNetworkAccessManager * http_
QDateTime lastPing_
QTime lastRequestTime_
bool lastRequestWasPolling_
bool lastResponseWasEmpty_
QString nextRequestId_
QString nextRequestParameters_
QTimer pollingTimer_
QList< RequestInfo > queuedRequests_
QNetworkRequest requestHeader_
bool sendPings_
QList< QNetworkReply * > unansweredRequests_


struct  RequestInfo

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

Generated by  Doxygen 1.6.0   Back to index