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

Jump to: navigation, search
(Abstract)
(Explain the class definition)
Line 10: Line 10:
  
 
===The Class Definition===
 
===The Class Definition===
The code below is the class definition for our implementation of the <tt>Decibel::ChannelHandler</tt> interface.
+
Here is the class definition for our implementation of the <tt>Decibel::ChannelHandler</tt> interface. It is explained below.
  
 
<code cppqt>
 
<code cppqt>
Line 32: Line 32:
 
};
 
};
 
</code>
 
</code>
 +
 +
We must inherit from <tt>Decibel::ChannelHandler</tt> which is the interface definition for handling incoming Channels. We reimplement the constructor, Destructor and the <tt>handleChannel()</tt> method as well as adding two slots of our own. We also create the member variables <tt>m_connecion</tt> and <tt>m_channel</tt> which will hold the <tt>QtTapioca::Connection</tt> and <tt>QtTapioca::Channel</tt> objects that are received by the <tt>handleChannel</tt> method.

Revision as of 05:46, 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 simpleclient demo included with Decibel. An explanation of using the simpleclient demo can be found here.

In this tutorial, we only pick out the important parts of the source code to discuss. The complete working source code for this example can be found here in KDE's SVN Repository.

ChannelHandler class

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

The Class Definition

Here is the class definition for our implementation of the Decibel::ChannelHandler interface. It is explained below.

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;

};

We must inherit from Decibel::ChannelHandler which is the interface definition for handling incoming Channels. We reimplement the constructor, Destructor and the handleChannel() method as well as adding two slots of our own. We also create the member variables m_connecion and m_channel which will hold the QtTapioca::Connection and QtTapioca::Channel objects that are received by the handleChannel method.


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