Problem quitting libpurple core

duncan at berrimans.co.uk duncan at berrimans.co.uk
Fri Jul 20 13:32:23 EDT 2012


I use

msnaccount = purple_account_new(msn_user, "prpl-msn");
purple_account_set_password(msnaccount, msn_password);
purple_accounts_add(msnaccount);
purple_account_set_enabled(msnaccount, UI_ID, TRUE);

GMainLoop *loop = g_main_loop_new(NULL, FALSE);
while (!dostop) {
   g_timeout_add (1000 , timeout_callback , loop);
   g_main_loop_run(loop);

    msn_online = checkconnected(msnaccount, &msn_retry,msn_password);
    ... other code send messages etc 
    ... set dostop if required

}
g_main_loop_unref(loop);

checkconnected function uses purple_account_get_connection and purple_connection_get_state to check the connection and status

If its not connected ( purple_account_get_connection  = NULL or purple_connection_get_state(gc)) != PURPLE_CONNECTED ) then I do a disconnect 

purple_account_disconnect(account);

then to reconnect I do

purple_account_set_password(account, password);
purple_account_connect(account);

It may not be possible to reconnect immediately so I check the return status and retry periodically (not every pass!).

Hope that helps
Duncan

From: Vaibhav Chauhan 
Sent: Friday, July 20, 2012 5:04 PM
To: devel at pidgin.im 
Subject: Problem quitting libpurple core

Hi, 

I am working on a libpurple client which does everything fine, other than reconnecting.  
I connect -> disconnect using purple_account_disconnect( m_pAccount ); -> call connect and am unable to connect.

My connect does following(I am posting main functionalities of code below):

m_pLoop = g_main_loop_new(NULL, FALSE);
m_pAccount = purple_account_new( m_pUserName.c_str(), strProtocol.c_str() ); 
purple_account_set_password( m_pAccount, m_pPassword.c_str() );
purple_account_set_enabled( m_pAccount, m_pUId.c_str(), TRUE ); 
PurpleSavedStatus *pStatus = purple_savedstatus_new( NULL, PURPLE_STATUS_AVAILABLE ); 
purple_savedstatus_activate( pStatus );


I have tried calling:

g_main_loop_quit( m_pLoop );
g_main_loop_unref( m_pLoop );
purple_core_quit(); // I call this when I am done with client and want to start a completely fresh client 


but nothing works.
purple_core_quit(); keeps running and never stops. What is the way to:
1. Quit libpurple client removing all memory gracefully
2. Reconnect after disconnecting

Please help. Quite urgent.




Best Regards
Vaibhav Chauhan 

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 


--------------------------------------------------------------------------------
_______________________________________________
Devel mailing list
Devel at pidgin.im
http://pidgin.im/cgi-bin/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20120720/0c3cbcf0/attachment-0002.html>


More information about the Devel mailing list