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

MsnSocketHttp Class Reference
[network]

#include <msnsockethttp.h>

Inheritance diagram for MsnSocketHttp:

MsnSocketBase

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:

Author:
Valerio Pilo <valerio@kmess.org>

Definition at line 75 of file msnsockethttp.h.


Public Types

enum  ErrorType {
  ERROR_UNKNOWN = 0, ERROR_CONNECTING, ERROR_PROXY, ERROR_CONNECTING_GATEWAY,
  ERROR_DROP, ERROR_DATA, ERROR_CONNECTION_TIME_LIMIT, ERROR_CONNECTION_OTHER,
  ERROR_AUTH_TIME_LIMIT, ERROR_AUTH_LOGIN, ERROR_AUTH_COMPUTATION, ERROR_USER,
  ERROR_SERVER, ERROR_INTERNAL, ERROR_SOAP_UNKNOWN, ERROR_SOAP_RESPONSE,
  ERROR_SOAP_TIME_LIMIT, ERROR_SOAP_AUTHENTICATION, ERROR_SOAP_TOOMANYREDIRECTS
}
 Types of errors with connection sockets. More...
enum  ServerType { SERVER_NOTIFICATION, SERVER_SWITCHBOARD }
 Type of server that will be connected from this socket. More...

Signals

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_

Classes

struct  RequestInfo

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

Generated by  Doxygen 1.6.0   Back to index