Esempio n. 1
0
IMClient::IMClient(const tstring&	username,
				   const tstring&	resource,
				   const tstring&	password, 
				   const tstring&	server,
				   const tstring&	server_addr,
				   HWND				hWnd,
				   bool				bLog,
				   DWORD			dwIdleTimeout)				  
{
TRY_CATCH

	m_hWnd = hWnd;
	JID jid;

	jid.setUsername( username.c_str() );
	jid.setResource( resource.c_str() );
	jid.setServer(server.c_str());
	m_server = server;

	m_client = new Client(jid, password.c_str());
	m_client->registerConnectionListener(this);
	m_client->setServer( server_addr.c_str());
	
	// Todo we do not want auto presence  - we will need to set presence after 
	// connect due status selected by user 
	// m_client->setAutoPresence(true); 
	// m_client->setInitialPriority(4); removed in gloox 0.9
	m_client->disco()->setVersion( _T("messageTest"), GLOOX_VERSION, _T("Linux") );
	m_client->disco()->setIdentity( _T("client"), _T("bot") );

	//
	//  Our simple client version not requires Sessions
	//  The messages will be handled in the blocked handleMessage() function 
	m_client->registerMessageHandler(this); 

	//
	//  We will log this 
	if( bLog )
	    registerLogHandler();
	
	//
	//	Register this bject to receive updates on roster operations
	//  todo for future versions 
	//  m_client->rosterManager()->registerRosterListener( this ); 
	m_client->setTls(true);

	//
	//
	m_bOnDisconnectCalled = FALSE;

	//
	//
	m_bDisconnected = FALSE;

CATCH_THROW(_T("IMClient::IMClient"))
}