Ask: Gloox for Symbian C++
From: Harapan Rachman <harapanrachman@xxxxxxxxx>
Date: Fri, 8 Jan 2010 07:29:10 +0100 (CET)
Dear all.

First, let me introduce myself. I am Harapan. I am currently developing Symbian 
C++ 
simple chat bot application connected to Google Talk Service. I've read 
carefully the documentation of Gloox. Now I have several questions and i would 
be thank you if you want to spare a moment answering my questions.

1. As per Google Talk Service requirement, instead of Gloox example of bot 
Class, i modify it a  little and the result is shown below.

// ---------------------------------------
#include <gloox/client.h>
#include <gloox/messagehandler.h>
#include <gloox/connectionlistener.h> //is it correct?

using namespace gloox;
class Bot : public MessageHandler,
ConnectionListener //required by google
{
public:

virtual bool onTLSConnect(const CertInfo& info) //required by google talk
{
//since i'd like to trust the google server,
return True;
}
Bot()
{
JID jid( "myaccount@xxxxxxxxx" );
j = new Client( jid, "mypassword", 5222);
j->setServer("talk.google.com"); //google host name
j->registerMessageHandler( this );
j->registerConnectionListener( this ); //required by google talk
j->connect();
}

virtual void handleMessage( const Message& stanza,
MessageSession* session = 0 )
{
// Do something with the stanza content and sender
}
private:
Client* j;
};
// ------------------------------------------

Is the above coding correct?

2. For this question, I include three files that may be handy. In Symbian, as 
you might 
have known, to read/write a certain amount of data, we need to first open a 
socket and 
initiate connection as shown below.

// ------------------------
// Open a TCP socket
User::LeaveIfError( iSocket.Open( iSocketServ,
KAfInet,
KSockStream,
KProtocolInetTcp, iConnection ) );

// Set up address information
iAddress.SetPort( KDefaultPortNumber );
iAddress.SetAddress( aAddr );

// Initiate socket connection
iSocket.Connect( iAddress, iStatus );
SetActive();
// ------------------------

then we read/write the data from/to socket as shown below.

// ---------------------------------------------------------------------------
// CIAPConnectDemoEngine::WriteL()
// Writes data to socket.
// ---------------------------------------------------------------------------
//
void CIAPConnectDemoEngine::WriteL( const TDesC8& aData )
{
if ( iEngineStatus == EConnected )
{
iSocketsWriter->IssueWriteL( aData );
}
}

// ---------------------------------------------------------------------------
// CIAPConnectDemoEngine::ReadL()
// Initiates read of data from socket.
// ---------------------------------------------------------------------------
//
void CIAPConnectDemoEngine::ReadL()
{
if ( ( iEngineStatus == EConnected ) && ( !iSocketsReader->IsActive() ) )
{
iSocketsReader->StartL();
}
}
// --------------------------

So my question is, Does the code below require that my symbian chat app has 
already 
been connected to internet?
                                                 j->connect();

After j->connect(), do I need to open socket and do symbian socket 
reading/writing? In 
other words, do I need to provide internet connection only and let j->connect 
handle 
the rest of it?

3. the virtual handleMessage(...), as shown above is called when there is 
incoming 
message regardless the sender. Now, i need to put a lot of piece of code in 
virtual 
handleMessage(...). If by any chance, there is incoming message and my 
handleMessage(...) have not finished the job, what will then happen? what if 
there are 
tenth incoming messages altogether? can the incoming message wait? or my app 
crash? I
need a shed of light here ^_^7

4. When I install GNUTLS and GNUIDN, should i let the installer to choose the 
default 
installation path?

5. Is there anything that i should know about how to build Symbian chat bot app 
using 
your Gloox library?

6. In the gloox.mmp, i found the following code;

        library         libstdcpp.lib libssl.lib
        library         libcrypto.lib libz.lib

i can not find in the gloox 1.0 file downloaded from camaya.net. where can i 
find it?
7. Recently, i try compiling the code. But it yields error, i.e.:

        can not find <string>,<map> and <list>.

so i downloaded the stl-port 5.2.1. from stlport.org. yet, the errors still 
occured. it said; undefined identifier std. OMG, i think the stl is not 
compatible with Symbian C++ compiler (S60 2nd FP3 SDK), isn't it? um... how can 
i solve it?

I think that's all. I am sorry for hasking so many questions. And i really 
thank you for spending your time reading my email.

Sincerely,
Harapan Rachman.