Difference between revisions of "Development/Tutorials/Decibel/Handling TextChannels"

Jump to: navigation, search
(The Class Definition)
(ChannelHandler class)
Line 5: Line 5:
  
 
==ChannelHandler class==
 
==ChannelHandler class==
The first class we will need to create is an implementation of the Decibel::ChannelHandler interface.
+
The first class we will need to create is an implementation of the <tt>Decibel::ChannelHandler</tt> interface.
  
 
===The Class Definition===
 
===The Class Definition===
Line 16: Line 16:
  
 
public:
 
public:
    /** @brief Constructor. */
 
 
     explicit MyTextChannelHandler(QObject * parent = 0);
 
     explicit MyTextChannelHandler(QObject * parent = 0);
    /** @brief Destructor. */
 
 
     ~MyTextChannelHandler();
 
     ~MyTextChannelHandler();
  
    /** @brief A implementation of the ChannelHandler interface's only method. */
 
 
     bool handleChannel(QtTapioca::Connection *, QtTapioca::Channel *, const bool);
 
     bool handleChannel(QtTapioca::Connection *, QtTapioca::Channel *, const bool);
  
 
public slots:
 
public slots:
 
    /** @brief Called when a new text message was received on our channel. */
 
 
     void onMessageReceived();
 
     void onMessageReceived();
    /** @brief Called when our channel is closed. */
 
 
     void onCloseChannel();
 
     void onCloseChannel();
  
 
private:
 
private:
    /** @brief A pointer to our Connection. */
 
 
     QtTapioca::Connection *  m_connection;
 
     QtTapioca::Connection *  m_connection;
    /** @brief A pointer to our Channel. */
 
 
     QtTapioca::TextChannel * m_channel;
 
     QtTapioca::TextChannel * m_channel;
 
};
 
};
 
</code>
 
</code>

Revision as of 05:34, 12 March 2008

Abstract

This tutorial will walk you through the process of creating a simple application that uses Decibel's TextChannels to communicate via arbitrary instant messaging networks using telepathy. From the result of this tutorial, only a few more lines of code are needed to produce a functioning text based instant messaging client.

This tutorial is based on the source code of the simpleclient demo included in decibel. An explanation of using the simpleclient demo can be found here.

ChannelHandler class

The first class we will need to create is an implementation of the Decibel::ChannelHandler interface.

The Class Definition

The code below is the class definition for our implementation of the Decibel::ChannelHandler interface.

class MyTextChannelHandler : public Decibel::ChannelHandler {

   Q_OBJECT

public:

   explicit MyTextChannelHandler(QObject * parent = 0);
   ~MyTextChannelHandler();
   bool handleChannel(QtTapioca::Connection *, QtTapioca::Channel *, const bool);

public slots:

   void onMessageReceived();
   void onCloseChannel();

private:

   QtTapioca::Connection *  m_connection;
   QtTapioca::TextChannel * m_channel;

};


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal