Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QCollectiveMessenger Class Reference
[QtBaseModule]

The QCollectiveMessenger class defines a generic interface to P2P instant messaging. More...

    #include <QCollectiveMessenger>

Inherits QAbstractIpcInterface.

Public Functions

Public Slots

Signals

Additional Inherited Members


Detailed Description

The QCollectiveMessenger class defines a generic interface to P2P instant messaging.

The QCollectiveMessenger class inherits QAbstractIpcInterface which provides client/server communications framework.

The QCollectiveMessenger in Server mode parses the received instant messages from the network and informs the rest of the system. It is also responsible for sending instant messages to the remote peers.

For example, to implement the server mode provider that provides presence interface in "voip" service, create a class that inherits QCollectiveMessenger class and override public slots.

    class IMProvider : public QCollectiveMessenger
    {
        Q_OBJECT
    public:
        IMProvider( QObject *parent=0 )
            : QCollectiveMessenger( "voip", parent, Server )
        {
            ...
        }
    public slots:
        virtual void sendMessage(const QCollectiveSimpleMessage &msg)
        {
            ...
        }
        ...
    };

The QCollectiveMessenger in Client mode is used by client applications to access the incoming and outgoing instant message data.

    QCollectiveMessenger *provider = new QCollectiveMessenger( "voip" );
    provider->registerIncomingHandler("MyIncomingMessageService");

See also QCollectiveSimpleMessage.


Member Function Documentation

QCollectiveMessenger::QCollectiveMessenger ( const QString & service = QString(), QObject * parent = 0, QAbstractIpcInterface::Mode mode = Client )

Constructs a QCollectiveMessenger object for service and attaches it to parent. The object will be created in client mode if mode is Client, or server mode otherwise.

If service is empty, this class will use the first available service that supports the QCollectiveMessenger interface. If there is more than one service that supports this interface, the caller should enumerate them with QCommServiceManager::supports() and create separate QCollectiveMessenger objects for each.

See also QCommServiceManager::supports().

QCollectiveMessenger::~QCollectiveMessenger ()

Destroys the QCollectiveMessenger object.

void QCollectiveMessenger::messageFailed ( const QCollectiveSimpleMessage & message )   [signal]

This signal is emitted whenever message could not be delivered successfully.

See also sendMessage().

void QCollectiveMessenger::messageSent ( const QCollectiveSimpleMessage & message )   [signal]

This signal is emitted whenever a message has been successfully sent.

See also sendMessage().

void QCollectiveMessenger::registerIncomingHandler ( const QString & service )   [virtual slot]

Registers an incoming message handler service.

The service must implement a service method with the following signature:

    void incomingMessages(const QList<QCollectiveSimpleMessage> &);

If multiple handlers are registered, then all registered handlers will be called with the incoming text messages.

If no handlers are registered, then the messages will queue up to a certain implementation defined limit. If that limit is exceeded, then further messages can be lost.

void QCollectiveMessenger::sendMessage ( const QCollectiveSimpleMessage & message )   [virtual slot]

Attempts to send the message to the remote peer specified in the message's to field. The messageSent() signal will be emitted once the message has been sent, and the messageError() signal will be emitted if the message could not be delivered.

void QCollectiveMessenger::unregisterIncomingHandler ( const QString & service )   [virtual slot]

Unregisters an incoming message handler service.


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3