You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(106) |
Oct
(334) |
Nov
(246) |
Dec
(145) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(42) |
Feb
(53) |
Mar
(232) |
Apr
(109) |
May
(137) |
Jun
(63) |
Jul
(26) |
Aug
(263) |
Sep
(193) |
Oct
(507) |
Nov
(440) |
Dec
(241) |
2003 |
Jan
(567) |
Feb
(195) |
Mar
(504) |
Apr
(481) |
May
(524) |
Jun
(522) |
Jul
(594) |
Aug
(502) |
Sep
(643) |
Oct
(508) |
Nov
(430) |
Dec
(377) |
2004 |
Jan
(361) |
Feb
(251) |
Mar
(219) |
Apr
(499) |
May
(461) |
Jun
(419) |
Jul
(314) |
Aug
(519) |
Sep
(416) |
Oct
(247) |
Nov
(305) |
Dec
(382) |
2005 |
Jan
(267) |
Feb
(282) |
Mar
(327) |
Apr
(338) |
May
(189) |
Jun
(400) |
Jul
(462) |
Aug
(530) |
Sep
(316) |
Oct
(523) |
Nov
(481) |
Dec
(650) |
2006 |
Jan
(536) |
Feb
(361) |
Mar
(287) |
Apr
(146) |
May
(101) |
Jun
(169) |
Jul
(221) |
Aug
(498) |
Sep
(300) |
Oct
(236) |
Nov
(209) |
Dec
(205) |
2007 |
Jan
(30) |
Feb
(23) |
Mar
(26) |
Apr
(15) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <the...@us...> - 2006-08-12 11:16:55
|
Revision: 16720 Author: thekingant Date: 2006-08-12 04:16:53 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16720&view=rev Log Message: ----------- Backport SVN revision #16719 from HEAD to v2_0_0 Original commit message: Get rid of two assertion failures and an accidentally double colon. I found all three of these when getting the jabber info of quser.alpha.qunu.com while trying to figure out http://trac.adiumx.com/ticket/4686 ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16719&view=rev Modified Paths: -------------- branches/v2_0_0/src/protocols/jabber/buddy.c Modified: branches/v2_0_0/src/protocols/jabber/buddy.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-12 11:15:23 UTC (rev 16719) +++ branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-12 11:16:53 UTC (rev 16720) @@ -674,7 +674,7 @@ } if(jbr->client.name) { g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", - _("Client:"), jbr->client.name, + _("Client"), jbr->client.name, jbr->client.version ? jbr->client.version : ""); if(jbr->client.os) { g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", @@ -688,7 +688,8 @@ g_free(resource_name); - info_text = g_string_append(info_text, jbi->vcard_text); + if (jbi->vcard_text != NULL) + info_text = g_string_append(info_text, jbi->vcard_text); gaim_notify_userinfo(jbi->js->gc, jbi->jid, info_text->str, NULL, NULL); @@ -699,7 +700,9 @@ g_string_free(info_text, TRUE); - gaim_timeout_remove(jbi->timeout_handle); + if (jbi->timeout_handle > 0) + gaim_timeout_remove(jbi->timeout_handle); + g_free(jbi->jid); g_hash_table_destroy(jbi->resources); g_free(jbi->vcard_text); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 11:15:25
|
Revision: 16719 Author: thekingant Date: 2006-08-12 04:15:23 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16719&view=rev Log Message: ----------- Get rid of two assertion failures and an accidentally double colon. I found all three of these when getting the jabber info of quser.alpha.qunu.com while trying to figure out http://trac.adiumx.com/ticket/4686 Modified Paths: -------------- trunk/src/protocols/jabber/buddy.c Modified: trunk/src/protocols/jabber/buddy.c =================================================================== --- trunk/src/protocols/jabber/buddy.c 2006-08-12 11:00:39 UTC (rev 16718) +++ trunk/src/protocols/jabber/buddy.c 2006-08-12 11:15:23 UTC (rev 16719) @@ -674,7 +674,7 @@ } if(jbr->client.name) { g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", - _("Client:"), jbr->client.name, + _("Client"), jbr->client.name, jbr->client.version ? jbr->client.version : ""); if(jbr->client.os) { g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", @@ -688,7 +688,8 @@ g_free(resource_name); - info_text = g_string_append(info_text, jbi->vcard_text); + if (jbi->vcard_text != NULL) + info_text = g_string_append(info_text, jbi->vcard_text); gaim_notify_userinfo(jbi->js->gc, jbi->jid, info_text->str, NULL, NULL); @@ -699,7 +700,9 @@ g_string_free(info_text, TRUE); - gaim_timeout_remove(jbi->timeout_handle); + if (jbi->timeout_handle > 0) + gaim_timeout_remove(jbi->timeout_handle); + g_free(jbi->jid); g_hash_table_destroy(jbi->resources); g_free(jbi->vcard_text); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 11:00:42
|
Revision: 16718 Author: thekingant Date: 2006-08-12 04:00:39 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16718&view=rev Log Message: ----------- Backport SVN revision #16717 from HEAD to v2_0_0 Original commit message: Fix a bug reported by Jon Oberheide. If there is an extra either 1 or 3 bytes on an incoming oscar message then our ICBM parser gets into an infinite loop. This could open be caused by a malicious server or a man-in-the-middle. ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16717&view=rev Modified Paths: -------------- branches/v2_0_0/src/protocols/oscar/family_icbm.c Modified: branches/v2_0_0/src/protocols/oscar/family_icbm.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/family_icbm.c 2006-08-12 10:59:13 UTC (rev 16717) +++ branches/v2_0_0/src/protocols/oscar/family_icbm.c 2006-08-12 11:00:39 UTC (rev 16718) @@ -1588,7 +1588,7 @@ * I've changed it to process the TLVs in-place. This avoids lots * of per-IM memory allocations. */ - while (byte_stream_empty(bs)) + while (byte_stream_empty(bs) >= 4) { type = byte_stream_get16(bs); length = byte_stream_get16(bs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 10:59:16
|
Revision: 16717 Author: thekingant Date: 2006-08-12 03:59:13 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16717&view=rev Log Message: ----------- Fix a bug reported by Jon Oberheide. If there is an extra either 1 or 3 bytes on an incoming oscar message then our ICBM parser gets into an infinite loop. This could open be caused by a malicious server or a man-in-the-middle. Modified Paths: -------------- trunk/src/protocols/oscar/family_icbm.c Modified: trunk/src/protocols/oscar/family_icbm.c =================================================================== --- trunk/src/protocols/oscar/family_icbm.c 2006-08-12 10:30:30 UTC (rev 16716) +++ trunk/src/protocols/oscar/family_icbm.c 2006-08-12 10:59:13 UTC (rev 16717) @@ -1588,7 +1588,7 @@ * I've changed it to process the TLVs in-place. This avoids lots * of per-IM memory allocations. */ - while (byte_stream_empty(bs)) + while (byte_stream_empty(bs) >= 4) { type = byte_stream_get16(bs); length = byte_stream_get16(bs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-12 10:30:45
|
Revision: 16716 Author: mayuan2006 Date: 2006-08-12 03:30:30 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16716&view=rev Log Message: ----------- add/delete contact function OK committed by MaYuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/contact.c branches/soc-2006-msnp13/src/protocols/msn/contact.h branches/soc-2006-msnp13/src/protocols/msn/msn.c branches/soc-2006-msnp13/src/protocols/msn/notification.c branches/soc-2006-msnp13/src/protocols/msn/notification.h branches/soc-2006-msnp13/src/protocols/msn/oim.c branches/soc-2006-msnp13/src/protocols/msn/soap.c branches/soc-2006-msnp13/src/protocols/msn/soap.h branches/soc-2006-msnp13/src/protocols/msn/state.c branches/soc-2006-msnp13/src/protocols/msn/userlist.c Modified: branches/soc-2006-msnp13/src/protocols/msn/contact.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -195,7 +195,7 @@ } static void -msn_contact_written_cb(gpointer data, gint source, GaimInputCondition cond) +msn_get_contact_written_cb(gpointer data, gint source, GaimInputCondition cond) { MsnSoapConn * soapconn = data; @@ -210,7 +210,7 @@ gaim_debug_info("MaYuan","msn_get_contact_list()...\n"); contact->soapconn->login_path = g_strdup(MSN_GET_CONTACT_POST_URL); contact->soapconn->soap_action = g_strdup(MSN_GET_CONTACT_SOAP_ACTION); - msn_soap_post(contact->soapconn,MSN_GET_CONTACT_TEMPLATE,msn_contact_written_cb); + msn_soap_post(contact->soapconn,MSN_GET_CONTACT_TEMPLATE,msn_get_contact_written_cb); } static void @@ -372,7 +372,7 @@ xmlnode_free(node); msn_soap_free_read_buf(contact->soapconn); - dump_adl_cmd(session); + msn_notification_dump_contact(session); msn_set_psm(session); msn_session_finish_login(session); } @@ -415,44 +415,99 @@ msn_soap_post(contact->soapconn,MSN_GET_ADDRESS_TEMPLATE,msn_address_written_cb); } +static void +msn_add_contact_read_cb(gpointer data, gint source, GaimInputCondition cond) +{ + gaim_debug_info("MaYuan","block read done\n"); +} + +static void +msn_add_contact_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + gaim_debug_info("MaYuan","finish unblock written\n"); + soapconn->read_cb = msn_add_contact_read_cb; + msn_soap_read_cb(data,source,cond); +} + /*add a Contact */ void -msn_add_contact(MsnContact *contact,const char *passport) +msn_add_contact(MsnContact *contact,const char *passport,char *groupId) { char *body = NULL; char *contact_xml = NULL; gaim_debug_info("MaYuan","msn add a contact...\n"); contact_xml = g_strdup_printf(MSN_CONTACT_XML,passport); - body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml); - g_free(contact_xml); + if(groupId == NULL){ + body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml); + g_free(contact_xml); + /*build SOAP and POST it*/ + contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); + contact->soapconn->soap_action = g_strdup(MSN_CONTACT_ADD_SOAP_ACTION); + }else{ + body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE,groupId,contact_xml); + g_free(contact_xml); + /*build SOAP and POST it*/ + contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); + contact->soapconn->soap_action = g_strdup(MSN_ADD_CONTACT_GROUP_SOAP_ACTION); + } + msn_soap_post(contact->soapconn,body,msn_add_contact_written_cb); - /*build SOAP and POST it*/ - contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); - contact->soapconn->soap_action = g_strdup(MSN_CONTACT_ADD_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_address_written_cb); - g_free(body); } +static void +msn_delete_contact_read_cb(gpointer data, gint source, GaimInputCondition cond) +{ + gaim_debug_info("MaYuan","delete contact read done\n"); +} + +static void +msn_delete_contact_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + gaim_debug_info("MaYuan","delete contact written\n"); + soapconn->read_cb = msn_delete_contact_read_cb; + msn_soap_read_cb(data,source,cond); +} + /*delete a Contact*/ void -msn_delete_contact(MsnContact *contact,const char *passport_id) +msn_delete_contact(MsnContact *contact,const char *contactId) { char *body = NULL; char *contact_xml = NULL ; - gaim_debug_info("MaYuan","msn delete a contact...\n"); - contact_xml = g_strdup_printf(MSN_CONTACTS_DEL_XML,passport_id); + gaim_debug_info("MaYuan","msn delete a contact,contactId:{%s}...\n",contactId); + contact_xml = g_strdup_printf(MSN_CONTACTS_DEL_XML,contactId); body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE,contact_xml); g_free(contact_xml); /*build SOAP and POST it*/ contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); contact->soapconn->soap_action = g_strdup(MSN_CONTACT_DEL_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_address_written_cb); + msn_soap_post(contact->soapconn,body,msn_delete_contact_written_cb); g_free(body); } +static void +msn_block_read_cb(gpointer data, gint source, GaimInputCondition cond) +{ + gaim_debug_info("MaYuan","block read done\n"); +} + +static void +msn_block_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + gaim_debug_info("MaYuan","finish unblock written\n"); + soapconn->read_cb = msn_block_read_cb; + msn_soap_read_cb(data,source,cond); +} + /*block a Contact*/ void msn_block_contact(MsnContact *contact,const char* membership_id) @@ -464,10 +519,26 @@ /*build SOAP and POST it*/ contact->soapconn->login_path = g_strdup(MSN_SHARE_POST_URL); contact->soapconn->soap_action = g_strdup(MSN_CONTACT_BLOCK_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_address_written_cb); + msn_soap_post(contact->soapconn,body,msn_block_written_cb); g_free(body); } +static void +msn_unblock_read_cb(gpointer data, gint source, GaimInputCondition cond) +{ + gaim_debug_info("MaYuan","unblock read done\n"); +} + +static void +msn_unblock_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + gaim_debug_info("MaYuan","finish unblock written\n"); + soapconn->read_cb = msn_unblock_read_cb; + msn_soap_read_cb(data,source,cond); +} + /*unblock a contact*/ void msn_unblock_contact(MsnContact *contact,const char* passport) @@ -480,10 +551,26 @@ /*build SOAP and POST it*/ contact->soapconn->login_path = g_strdup(MSN_SHARE_POST_URL); contact->soapconn->soap_action = g_strdup(MSN_CONTACT_UNBLOCK_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_address_written_cb); + msn_soap_post(contact->soapconn,body,msn_unblock_written_cb); g_free(body); } +static void +msn_gleams_read_cb(gpointer data, gint source, GaimInputCondition cond) +{ + gaim_debug_info("MaYuan","Gleams read done\n"); +} + +static void +msn_gleams_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + gaim_debug_info("MaYuan","finish Group written\n"); + soapconn->read_cb = msn_gleams_read_cb; + msn_soap_read_cb(data,source,cond); +} + /*get the gleams info*/ void msn_get_gleams(MsnContact *contact) @@ -492,7 +579,7 @@ /*build SOAP and POST it*/ contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); contact->soapconn->soap_action = g_strdup(MSN_GET_GLEAMS_SOAP_ACTION); - msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_address_written_cb); + msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_gleams_written_cb); } /*************************************************************** Modified: branches/soc-2006-msnp13/src/protocols/msn/contact.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/contact.h 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/contact.h 2006-08-12 10:30:30 UTC (rev 16716) @@ -25,7 +25,7 @@ #ifndef _MSN_CONTACT_H_ #define _MSN_CONTACT_H_ -#define MSN_CONTACT_SERVER "contacts.msn.com" +#define MSN_CONTACT_SERVER "omega.contacts.msn.com" /*get contact list soap request template*/ #define MSN_GET_CONTACT_POST_URL "/abservice/SharingService.asmx" @@ -116,6 +116,10 @@ #define MSN_ADD_CONTACT_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>ContactSave</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><contacts>%s</contacts><options><EnableAllowListManagement>true</EnableAllowListManagement></options></ABContactAdd></soap:Body></soap:Envelope>" +/*Contact Group Add*/ +#define MSN_ADD_CONTACT_GROUP_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABGroupContactAdd" +#define MSN_ADD_CONTACT_GROUP_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>ContactSave</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABGroupContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><groupFilter><groupIds><guid>%s</guid></groupIds></groupFilter><contacts>%s</contacts><groupContactAddOptions><fGenerateMissingQuickName>true</fGenerateMissingQuickName><EnableAllowListManagement>true</EnableAllowListManagement></groupContactAddOptions></ABGroupContactAdd></soap:Body></soap:Envelope>" + /*delete contact from contact list soap request template*/ #define MSN_CONTACT_DEL_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABContactDelete" #define MSN_CONTACTS_DEL_XML "<Contact><contactId>%s</contactId></Contact>" @@ -168,6 +172,11 @@ void msn_get_contact_list(MsnContact * contact); void msn_get_address_book(MsnContact *contact); +/*contact SOAP Operation*/ +void msn_add_contact(MsnContact *contact,const char *passport,char *groupId); +void msn_delete_contact(MsnContact *contact,const char *contactId); + + /*group operation*/ void msn_add_group(MsnSession *session,const char* group_name); void msn_del_group(MsnSession *session,const char *guid); Modified: branches/soc-2006-msnp13/src/protocols/msn/msn.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -972,6 +972,7 @@ userlist = session->userlist; who = msn_normalize(gc->account, buddy->name); + gaim_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name); if (!session->logged_in) { #if 0 Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -34,6 +34,11 @@ static MsnTable *cbs_table; +/**************************************************************************** + * Local Function Prototype + ****************************************************************************/ +void msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type); + /************************************************************************** * Main **************************************************************************/ @@ -434,19 +439,70 @@ /************************************************************************** * Buddy Lists **************************************************************************/ +/* add contact to xmlnode */ +void +msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type) +{ + xmlnode *d_node,*c_node; + char **tokens; + char *email,*domain; + char *list_op_str,*type_str; + + gaim_debug_info("MaYuan","passport:%s\n",passport); + tokens = g_strsplit(passport, "@", 2); + email = tokens[0]; + domain = tokens[1]; + + /*find a domain Node*/ + for(d_node = xmlnode_get_child(mlNode,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)){ + const char * attr = NULL; + gaim_debug_info("MaYuan","d_node:%s\n",d_node->name); + attr = xmlnode_get_attrib(d_node,"n"); + if(attr == NULL){ + continue; + } + if(!strcmp(attr,domain)){ + break; + } + } + if(d_node == NULL){ + /*domain not found, create a new domain Node*/ + gaim_debug_info("MaYuan","get No d_node\n"); + d_node = xmlnode_new("d"); + xmlnode_set_attrib(d_node,"n",domain); + xmlnode_insert_child(mlNode,d_node); + } + + /*create contact node*/ + c_node = xmlnode_new("c"); + xmlnode_set_attrib(c_node,"n",email); + + list_op_str = g_strdup_printf("%d",list_op); + gaim_debug_info("MaYuan","list_op:%d\n",list_op_str); + xmlnode_set_attrib(c_node,"l",list_op_str); + g_free(list_op_str); +#if 0 + type_str = g_strdup_printf("%d",type); + xmlnode_set_attrib(c_node,"t",type_str); +#else + type_str = g_strdup_printf("1"); + xmlnode_set_attrib(c_node,"t",type_str); + g_free(type_str); +#endif + xmlnode_insert_child(d_node, c_node); +} + +/*dump contact info to NS*/ void -dump_adl_cmd(MsnSession *session) +msn_notification_dump_contact(MsnSession *session) { MsnCmdProc *cmdproc; MsnTransaction *trans; MsnUserList *userlist; MsnUser *user; GList *l; - xmlnode *adl_node,*d_node,*c_node; - char **tokens; - char *email,*domain; + xmlnode *adl_node; char *payload; - char *list_op,*type; int payload_len; cmdproc = session->notification->cmdproc; @@ -458,58 +514,15 @@ /*get the userlist*/ for (l = userlist->users; l != NULL; l = l->next){ user = l->data; - - gaim_debug_info("MaYuan","passport:%s\n",user->passport); - tokens = g_strsplit(user->passport, "@", 2); - email = tokens[0]; - domain = tokens[1]; - - /*find a domain node*/ - for(d_node = xmlnode_get_child(adl_node,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)){ - const char * attr = NULL; - gaim_debug_info("MaYuan","d_node:%s\n",d_node->name); - attr = xmlnode_get_attrib(d_node,"n"); - if(attr == NULL){ - continue; - } - if(!strcmp(attr,domain)){ - break; - } - } - if(d_node == NULL){ - gaim_debug_info("MaYuan","get No d_node\n"); - d_node = xmlnode_new("d"); - xmlnode_set_attrib(d_node,"n",domain); - xmlnode_insert_child(adl_node,d_node); - } - - /*create contact node*/ - c_node = xmlnode_new("c"); - xmlnode_set_attrib(c_node,"n",email); - - list_op = g_strdup_printf("%d",user->list_op); - gaim_debug_info("MaYuan","list_op:%d\n",user->list_op); - xmlnode_set_attrib(c_node,"l",list_op); -#if 0 - type = g_strdup_printf("%d",user->type); - xmlnode_set_attrib(c_node,"t",type); -#else - type = g_strdup_printf("1"); - xmlnode_set_attrib(c_node,"t",type); -#endif - xmlnode_insert_child(d_node, c_node); - - g_free(list_op); - g_free(type); + msn_add_contact_xml(adl_node,user->passport,user->list_op,user->type); } payload = xmlnode_to_str(adl_node,&payload_len); + xmlnode_free(adl_node); gaim_debug_info("MaYuan","ADL{%s}\n",payload); trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload)); - msn_transaction_set_payload(trans, payload, strlen(payload)); - msn_cmdproc_send_trans(cmdproc, trans); } @@ -1530,16 +1543,29 @@ const char *group_id) { MsnCmdProc *cmdproc; + MsnTransaction *trans; + xmlnode *adl_node; + char *payload; + int payload_len; + cmdproc = notification->servconn->cmdproc; - if (group_id != NULL && !strcmp(list, "FL")) + if (strcmp(list, "FL") != 0){ + } - if (group_id >= 0){ - msn_cmdproc_send(cmdproc, "ADD", "%s %s %s %d", - list, who, store_name, group_id); - }else{ - msn_cmdproc_send(cmdproc, "ADD", "%s %s %s", list, who, store_name); - } + adl_node = xmlnode_new("ml"); + adl_node->child = NULL; + xmlnode_set_attrib(adl_node, "l", "1"); + + msn_add_contact_xml(adl_node,who,3,1); + + payload = xmlnode_to_str(adl_node,&payload_len); + xmlnode_free(adl_node); + + gaim_debug_info("MaYuan","ADL{%s}\n",payload); + trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload)); + msn_transaction_set_payload(trans, payload, strlen(payload)); + msn_cmdproc_send_trans(cmdproc, trans); } void @@ -1547,19 +1573,31 @@ const char *who, const char *group_id) { MsnCmdProc *cmdproc; + MsnTransaction *trans; + xmlnode *rml_node; + char *payload; + int payload_len; + cmdproc = notification->servconn->cmdproc; - if (group_id != NULL){ - msn_cmdproc_send(cmdproc, "REM", "%s %s %d", list, who, group_id); - }else{ - msn_cmdproc_send(cmdproc, "REM", "%s %s", list, who); - } + rml_node = xmlnode_new("ml"); + rml_node->child = NULL; + xmlnode_set_attrib(rml_node, "l", "1"); + + msn_add_contact_xml(rml_node,who,3,1); + + payload = xmlnode_to_str(rml_node,&payload_len); + xmlnode_free(rml_node); + + gaim_debug_info("MaYuan","RML{%s}\n",payload); + trans = msn_transaction_new(cmdproc, "RML","%d",strlen(payload)); + msn_transaction_set_payload(trans, payload, strlen(payload)); + msn_cmdproc_send_trans(cmdproc, trans); } /************************************************************************** * Init **************************************************************************/ - void msn_notification_init(void) { Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.h 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.h 2006-08-12 10:30:30 UTC (rev 16716) @@ -63,7 +63,7 @@ gboolean msn_notification_connect(MsnNotification *notification, const char *host, int port); void msn_notification_disconnect(MsnNotification *notification); -void dump_adl_cmd(MsnSession *session); +void msn_notification_dump_contact(MsnSession *session); /** * Closes a notification. Modified: branches/soc-2006-msnp13/src/protocols/msn/oim.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -106,7 +106,8 @@ } /*pose single message to oim server*/ -void msn_oim_send_single_msg(MsnOim *oim,char * msg) +void +msn_oim_send_single_msg(MsnOim *oim,char * msg) { const char *oimsoapbody,*t,*p; @@ -139,6 +140,10 @@ } /**************************************** + * OIM delete SOAP request + * **************************************/ + +/**************************************** * OIM get SOAP request * **************************************/ /*oim SOAP server login error*/ @@ -179,9 +184,13 @@ GaimInputCondition cond) { MsnSoapConn * soapconn = data; - MsnOim * msnoim; + MsnOim * oim = soapconn->session->oim; gaim_debug_info("MaYuan","OIM get read buffer:{%s}\n",soapconn->body); + + /*get next single Offline Message*/ + oim->oim_list = g_list_remove(oim->oim_list, oim->oim_list->data); +// msn_oim_get_msg(oim); } static void @@ -220,7 +229,6 @@ if ((conv = msn_oim_get_conv(oim,passport)) != NULL){ gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); } - } /*parse the oim XML data*/ @@ -269,19 +277,15 @@ msgid ); msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb); - } /*MSN OIM get SOAP request*/ void msn_oim_get_msg(MsnOim *oim) { - GList *list; - gaim_debug_info("MaYuan","Get OIM with SOAP \n"); // gaim_debug_info("MaYuan","oim->oim_list:%p,data:%s \n",oim->oim_list,oim->oim_list->data); - for(list = oim->oim_list; list!= NULL;list = g_list_next(list)){ - msn_oim_post_single_get_msg(oim,list->data); - oim->oim_list = g_list_remove(oim->oim_list, list->data); + if(oim->oim_list !=NULL){ + msn_oim_post_single_get_msg(oim,oim->oim_list->data); } } Modified: branches/soc-2006-msnp13/src/protocols/msn/soap.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/soap.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/soap.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -146,12 +146,12 @@ { gssize len; gssize total_len = 0; - char temp_buf[10240]; + char temp_buf[MSN_SOAP_READ_BUFF_SIZE]; if(soapconn->ssl_conn){ - len = gaim_ssl_read(soapconn->gsc, temp_buf,sizeof(temp_buf)); + len = gaim_ssl_read(soapconn->gsc, temp_buf,MSN_SOAP_READ_BUFF_SIZE); }else{ - len = read(soapconn->fd, temp_buf,sizeof(temp_buf)); + len = read(soapconn->fd, temp_buf,MSN_SOAP_READ_BUFF_SIZE); } if(len >0){ total_len += len; @@ -162,6 +162,7 @@ soapconn->read_len += len; soapconn->read_buf[soapconn->read_len] = '\0'; } + gaim_debug_info("MaYuan","++soap ssl read:{%d}\n",total_len); // gaim_debug_info("MaYuan","nexus ssl read:{%s}\n",soapconn->read_buf); return total_len; } @@ -209,6 +210,7 @@ /* Redirect. */ char *location, *c; + gaim_debug_error("MaYuan", "soap redirect\n"); location = strstr(soapconn->read_buf, "Location: "); if (location == NULL) { @@ -244,6 +246,7 @@ { const char *error; + gaim_debug_error("MaYuan", "soap 401\n"); if ((error = strstr(soapconn->read_buf, "WWW-Authenticate")) != NULL) { if ((error = strstr(error, "cbtxt=")) != NULL) @@ -284,12 +287,11 @@ /*setup the conn body */ soapconn->body = body_start; soapconn->body_len = atoi(body_len); - // gaim_debug_misc("MaYuan","content length :%d",soapconn->body_len); + gaim_debug_misc("MaYuan","SOAP Read length :%d,body len:%d\n",soapconn->read_len,soapconn->body_len); - if(soapconn->read_len < body_start - soapconn->read_buf + atoi(body_len)){ + if(soapconn->read_len < body_start - soapconn->read_buf + soapconn->body_len){ return; } - g_free(body_len); #if 1 @@ -313,6 +315,7 @@ // soapconn->gsc = NULL; #endif } + return; } void @@ -342,6 +345,13 @@ MsnSoapConn *soapconn = data; int len, total_len; + g_return_if_fail(soapconn != NULL); + if(soapconn->write_buf == NULL){ + gaim_debug_error("MaYuan","soap buffer is NULL\n"); + gaim_input_remove(soapconn->output_handler); + soapconn->output_handler = -1; + return; + } total_len = strlen(soapconn->write_buf); /* Modified: branches/soc-2006-msnp13/src/protocols/msn/soap.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/soap.h 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/soap.h 2006-08-12 10:30:30 UTC (rev 16716) @@ -26,6 +26,8 @@ #ifndef _MSN_SOAP_H_ #define _MSN_SOAP_H_ +#define MSN_SOAP_READ_BUFF_SIZE 8192 + /*MSN Https connection structure*/ typedef struct _MsnSoapConn MsnSoapConn; Modified: branches/soc-2006-msnp13/src/protocols/msn/state.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/state.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/state.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -38,6 +38,17 @@ N_("Available") }; +/* Local Function Prototype*/ +char * msn_build_psm(char * psmstr,char *mediastr,char * guidstr); + +/* + * WLM media PSM info build prcedure + * + * Result can like: + * <CurrentMedia>\0Music\01\0{0} - {1}\0 Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\ + * <CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\ + * <CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>" + */ char * msn_build_psm(char * psmstr,char *mediastr,char * guidstr) { @@ -53,10 +64,6 @@ } xmlnode_insert_child(dataNode,psmNode); -//"<CurrentMedia>\0Music\01\0{0} - {1}\0 Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\ -<CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\ -<CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>" - mediaNode = xmlnode_new("CurrentMedia"); if(mediastr != NULL){ xmlnode_insert_data(psmNode,mediastr,strlen(mediastr)); Modified: branches/soc-2006-msnp13/src/protocols/msn/userlist.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-12 10:27:29 UTC (rev 16715) +++ branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-12 10:30:30 UTC (rev 16716) @@ -591,6 +591,10 @@ const char *list; user = msn_userlist_find_user(userlist, who); + + /*delete the contact from address book via soap action*/ + msn_delete_contact(userlist->session->contact,user->uid); + group_id = NULL; if (group_name != NULL){ @@ -614,7 +618,7 @@ /* Then request the rem to the server. */ list = lists[list_id]; - msn_notification_rem_buddy(userlist->session->notification, list, who, group_id); +// msn_notification_rem_buddy(userlist->session->notification, list, who, group_id); } /*add buddy*/ @@ -628,6 +632,7 @@ const char *list; const char *store_name; + gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); group_id = NULL; if (!gaim_email_is_valid(who)){ @@ -668,8 +673,11 @@ /* Then request the add to the server. */ list = lists[list_id]; - msn_notification_add_buddy(userlist->session->notification, list, who, + gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); + msn_add_contact(userlist->session->contact,who,group_id); +/* msn_notification_add_buddy(userlist->session->notification, list, who, store_name, group_id); + */ } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-12 10:27:40
|
Revision: 16715 Author: sadrul Date: 2006-08-12 03:27:29 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16715&view=rev Log Message: ----------- Add support for tab-completion and save-history in GntEntry. Also, the keyboard-commands should now work for Xterms. Modified Paths: -------------- trunk/console/gntconv.c trunk/console/libgnt/Makefile.am trunk/console/libgnt/gntcombobox.c trunk/console/libgnt/gntentry.c trunk/console/libgnt/gntentry.h trunk/console/libgnt/gntkeys.h trunk/console/libgnt/gntmain.c trunk/console/libgnt/gnttree.c trunk/console/libgnt/gnttree.h trunk/console/libgnt/gntwidget.c trunk/console/libgnt/test/tv.c Added Paths: ----------- trunk/console/libgnt/gntkeys.c Modified: trunk/console/gntconv.c =================================================================== --- trunk/console/gntconv.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/gntconv.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -123,6 +123,7 @@ } g_free(escape); } + gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); gnt_entry_clear(GNT_ENTRY(ggconv->entry)); return TRUE; } @@ -198,8 +199,11 @@ ggc->entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); gnt_widget_set_name(ggc->entry, "conversation-window-entry"); + gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); + gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); + gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); - g_signal_connect(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); + g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); gnt_widget_set_position(ggc->window, gaim_prefs_get_int(PREF_ROOT "/position/x"), @@ -315,6 +319,9 @@ static void gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals) { + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + if (!new_arrivals) { /* Print the list of users in the room */ @@ -335,25 +342,39 @@ GAIM_MESSAGE_SYSTEM, time(NULL)); g_string_free(string, TRUE); } - /* XXX: Add the names for string completion */ + + for (; users; users = users->next) + { + GaimConvChatBuddy *cbuddy = users->data; + gnt_entry_add_suggest(entry, cbuddy->name); + gnt_entry_add_suggest(entry, cbuddy->alias); + } } static void gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a) { /* XXX: Update the name for string completion */ + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + gnt_entry_remove_suggest(entry, old); + gnt_entry_add_suggest(entry, new_n); + gnt_entry_add_suggest(entry, new_a); } static void gg_chat_remove_user(GaimConversation *conv, GList *list) { /* XXX: Remove the name from string completion */ + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + for (; list; list = list->next) + gnt_entry_remove_suggest(entry, list->data); } static void gg_chat_update_user(GaimConversation *conv, const char *user) { - /* XXX: This probably will not require updating the string completion */ } static GaimConversationUiOps conv_ui_ops = Modified: trunk/console/libgnt/Makefile.am =================================================================== --- trunk/console/libgnt/Makefile.am 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/Makefile.am 2006-08-12 10:27:29 UTC (rev 16715) @@ -11,6 +11,7 @@ gntcolors.c \ gntcombobox.c \ gntentry.c \ + gntkeys.c \ gntlabel.c \ gntline.c \ gntmarshal.c \ Modified: trunk/console/libgnt/gntcombobox.c =================================================================== --- trunk/console/libgnt/gntcombobox.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntcombobox.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -79,7 +79,7 @@ GntWidget *dd = GNT_COMBO_BOX(widget)->dropdown; gnt_widget_size_request(dd); widget->priv.height = 3; /* For now, a combobox will have border */ - widget->priv.width = MIN(10, dd->priv.width); + widget->priv.width = MIN(10, dd->priv.width + 4); } } Modified: trunk/console/libgnt/gntentry.c =================================================================== --- trunk/console/libgnt/gntentry.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntentry.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -1,7 +1,9 @@ #include <ctype.h> #include <string.h> +#include "gntbox.h" #include "gntentry.h" +#include "gnttree.h" enum { @@ -12,6 +14,92 @@ static guint signals[SIGS] = { 0 }; static void +destroy_suggest(GntEntry *entry) +{ + if (entry->ddown) + { + gnt_widget_destroy(entry->ddown->parent); + entry->ddown = NULL; + } +} + +static char * +get_beginning_of_word(GntEntry *entry) +{ + char *s = entry->cursor; + while (s > entry->start) + { + char *t = g_utf8_find_prev_char(entry->start, s); + if ((*t < 'A' || *t > 'Z') && (*t < 'a' || *t > 'z')) + break; + s = t; + } + return s; +} + +static gboolean +show_suggest_dropdown(GntEntry *entry) +{ + char *suggest = NULL; + int len; + int offset = 0, x, y; + int count = 0; + GList *iter; + + if (entry->word) + { + char *s = get_beginning_of_word(entry); + suggest = g_strndup(s, entry->cursor - s); + if (entry->scroll < s) + offset = g_utf8_pointer_to_offset(entry->scroll, s); + } + else + suggest = g_strdup(entry->start); + len = strlen(suggest); /* Don't need to use the utf8-function here */ + + if (entry->ddown == NULL) + { + GntWidget *box = gnt_vbox_new(FALSE); + entry->ddown = gnt_tree_new(); + gnt_box_add_widget(GNT_BOX(box), entry->ddown); + + GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); + + gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); + x += offset; + y++; + if (y + 10 >= getmaxy(stdscr)) + y -= 11; + gnt_widget_set_position(box, x, y); + + gnt_widget_draw(box); + } + else + gnt_tree_remove_all(GNT_TREE(entry->ddown)); + + for (count = 0, iter = entry->suggests; iter; iter = iter->next) + { + const char *text = iter->data; + if (strncmp(suggest, text, len) == 0 && strlen(text) >= len) + { + gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, + gnt_tree_create_row(GNT_TREE(entry->ddown), text), + NULL, NULL); + count++; + } + } + g_free(suggest); + + if (count == 0) + { + destroy_suggest(entry); + return FALSE; + } + + return TRUE; +} + +static void gnt_entry_draw(GntWidget *widget) { GntEntry *entry = GNT_ENTRY(widget); @@ -80,6 +168,11 @@ memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1); entry->end -= len; entry_redraw(widget); + + if (entry->ddown) + show_suggest_dropdown(entry); + + return TRUE; } else if (strcmp(text + 1, GNT_KEY_LEFT) == 0 && entry->cursor > entry->start) { @@ -87,6 +180,8 @@ if (entry->cursor < entry->scroll) entry->scroll = entry->cursor; entry_redraw(widget); + + return TRUE; } else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0 && entry->cursor < entry->end) { @@ -94,15 +189,90 @@ if (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); entry_redraw(widget); + + return TRUE; } + else if (strcmp(text + 1, GNT_KEY_CTRL_DOWN) == 0 && entry->histlength) + { + if (entry->history->prev) + { + entry->history = entry->history->prev; + gnt_entry_set_text(entry, entry->history->data); + destroy_suggest(entry); + + return TRUE; + } + } + else if (strcmp(text + 1, GNT_KEY_UP) == 0 || + strcmp(text + 1, GNT_KEY_DOWN) == 0) + { + if (entry->ddown) + { + gnt_widget_key_pressed(entry->ddown, text); + return TRUE; + } + } + else if (strcmp(text + 1, GNT_KEY_CTRL_UP) == 0 && entry->histlength) + { + if (entry->history->next) + { + if (entry->history->prev == NULL) + { + /* Save the current contents */ + char *text = g_strdup(gnt_entry_get_text(entry)); + g_free(entry->history->data); + entry->history->data = text; + } + + entry->history = entry->history->next; + gnt_entry_set_text(entry, entry->history->data); + destroy_suggest(entry); + + return TRUE; + } + } /* XXX: handle other keys, like home/end, and ctrl+ goodness */ - else - return FALSE; + else if (text[1] == 0) + { + destroy_suggest(entry); + } - return TRUE; + return FALSE; } else { + if (text[0] == '\t') + { + if (entry->ddown) + destroy_suggest(entry); + else if (entry->suggests) + return show_suggest_dropdown(entry); + + return FALSE; + } + else if (text[0] == '\r' && entry->ddown) + { + char *text = g_strdup(gnt_tree_get_selection_data(GNT_TREE(entry->ddown))); + destroy_suggest(entry); + if (entry->word) + { + char *s = get_beginning_of_word(entry); + char *iter = text; + while (*s == *iter) + { + s++; + iter++; + } + gnt_entry_key_pressed(widget, iter); + } + else + { + gnt_entry_set_text(entry, text); + } + g_free(text); + return TRUE; + } + if (!iscntrl(text[0])) { const char *str, *next; @@ -143,6 +313,9 @@ while (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); + + if (entry->ddown) + show_suggest_dropdown(entry); } entry_redraw(widget); return TRUE; @@ -161,6 +334,8 @@ entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll); entry_redraw(widget); + if (entry->ddown) + show_suggest_dropdown(entry); return TRUE; } } @@ -174,9 +349,35 @@ { GntEntry *entry = GNT_ENTRY(widget); g_free(entry->start); + + if (entry->history) + { + entry->history = g_list_first(entry->history); + g_list_foreach(entry->history, (GFunc)g_free, NULL); + g_list_free(entry->history); + } + + if (entry->suggests) + { + g_list_foreach(entry->suggests, (GFunc)g_free, NULL); + g_list_free(entry->suggests); + } + + if (entry->ddown) + { + gnt_widget_destroy(entry->ddown->parent); + } } static void +gnt_entry_lost_focus(GntWidget *widget) +{ + GntEntry *entry = GNT_ENTRY(widget); + destroy_suggest(entry); + entry_redraw(widget); +} + +static void gnt_entry_class_init(GntEntryClass *klass) { parent_class = GNT_WIDGET_CLASS(klass); @@ -185,6 +386,7 @@ parent_class->map = gnt_entry_map; parent_class->size_request = gnt_entry_size_request; parent_class->key_pressed = gnt_entry_key_pressed; + parent_class->lost_focus = gnt_entry_lost_focus; DEBUG; } @@ -197,7 +399,14 @@ entry->flag = GNT_ENTRY_FLAG_ALL; entry->max = 0; + + entry->histlength = 0; + entry->history = NULL; + entry->word = TRUE; + entry->always = FALSE; + entry->suggests = NULL; + GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS); GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_GROW_X); @@ -302,6 +511,7 @@ gnt_entry_set_text(entry, NULL); entry->scroll = entry->cursor = entry->end = entry->start; entry_redraw(GNT_WIDGET(entry)); + destroy_suggest(entry); } void gnt_entry_set_masked(GntEntry *entry, gboolean set) @@ -309,3 +519,90 @@ entry->masked = set; } +void gnt_entry_add_to_history(GntEntry *entry, const char *text) +{ + g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */ + + if (g_list_length(entry->history) >= entry->histlength) + return; + + entry->history = g_list_first(entry->history); + g_free(entry->history->data); + entry->history->data = g_strdup(text); + entry->history = g_list_prepend(entry->history, NULL); +} + +void gnt_entry_set_history_length(GntEntry *entry, int num) +{ + if (num == 0) + { + entry->histlength = num; + if (entry->history) + { + entry->history = g_list_first(entry->history); + g_list_foreach(entry->history, (GFunc)g_free, NULL); + g_list_free(entry->history); + entry->history = NULL; + } + return; + } + + if (entry->histlength == 0) + { + entry->histlength = num; + entry->history = g_list_append(NULL, NULL); + return; + } + + if (num > 0 && num < entry->histlength) + { + GList *first, *iter; + int index = 0; + for (first = entry->history, index = 0; first->prev; first = first->prev, index++); + while ((iter = g_list_nth(first, num)) != NULL) + { + g_free(iter->data); + first = g_list_delete_link(first, iter); + } + entry->histlength = num; + if (index >= num) + entry->history = g_list_last(first); + return; + } + + entry->histlength = num; +} + +void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) +{ + entry->word = word; +} + +void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) +{ + entry->always = always; +} + +void gnt_entry_add_suggest(GntEntry *entry, const char *text) +{ + GList *find; + + if (!text || !*text) + return; + + find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); + if (find) + return; + entry->suggests = g_list_append(entry->suggests, g_strdup(text)); +} + +void gnt_entry_remove_suggest(GntEntry *entry, const char *text) +{ + GList *find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); + if (find) + { + g_free(find->data); + entry->suggests = g_list_delete_link(entry->suggests, find); + } +} + Modified: trunk/console/libgnt/gntentry.h =================================================================== --- trunk/console/libgnt/gntentry.h 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntentry.h 2006-08-12 10:27:29 UTC (rev 16715) @@ -50,6 +50,14 @@ int max; /* 0 means infinite */ gboolean masked; + + GList *history; /* History of the strings. User can use this by pressing ctrl+up/down */ + int histlength; /* How long can the history be? */ + + GList *suggests; /* List of suggestions */ + gboolean word; /* Are the suggestions for only a word, or for the whole thing? */ + gboolean always; /* Should the list of suggestions show at all times, or only on tab-press? */ + GntWidget *ddown; /* The dropdown with the suggested list */ }; struct _GnEntryClass @@ -70,7 +78,6 @@ void gnt_entry_set_max(GntEntry *entry, int max); -/* XXX: For now, call gnt_entry_clear before calling this */ void gnt_entry_set_text(GntEntry *entry, const char *text); void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag); @@ -81,6 +88,18 @@ void gnt_entry_set_masked(GntEntry *entry, gboolean set); +void gnt_entry_add_to_history(GntEntry *entry, const char *text); + +void gnt_entry_set_history_length(GntEntry *entry, int num); + +void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word); + +void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always); + +void gnt_entry_add_suggest(GntEntry *entry, const char *text); + +void gnt_entry_remove_suggest(GntEntry *entry, const char *text); + G_END_DECLS #endif /* GNT_ENTRY_H */ Added: trunk/console/libgnt/gntkeys.c =================================================================== --- trunk/console/libgnt/gntkeys.c (rev 0) +++ trunk/console/libgnt/gntkeys.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -0,0 +1,29 @@ +#include "gntkeys.h" + +#include <string.h> + +void gnt_keys_refine(char *text) +{ + if (text[0] == 27) + { + /* These are for urxvt */ + if (strcmp(text + 1, "Oa") == 0) + { + strcpy(text + 1, GNT_KEY_CTRL_UP); + } + else if (strcmp(text + 1, "Ob") == 0) + { + strcpy(text + 1, GNT_KEY_CTRL_DOWN); + } + } + else if ((unsigned char)text[0] == 195) + { + /* These for xterm */ + if (text[2] == 0) + { + text[0] = 27; + text[1] -= 64; + } + } +} + Property changes on: trunk/console/libgnt/gntkeys.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/console/libgnt/gntkeys.h =================================================================== --- trunk/console/libgnt/gntkeys.h 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntkeys.h 2006-08-12 10:27:29 UTC (rev 16715) @@ -9,6 +9,11 @@ #define GNT_KEY_UP "[A" #define GNT_KEY_DOWN "[B" +#define GNT_KEY_CTRL_UP "[1;5A" +#define GNT_KEY_CTRL_DOWN "[1;5B" +#define GNT_KEY_CTRL_RIGHT "[1;5C" +#define GNT_KEY_CTRL_LEFT "[1;5D" + #define GNT_KEY_PGUP "[5~" #define GNT_KEY_PGDOWN "[6~" @@ -17,4 +22,9 @@ #define GNT_KEY_BACKSPACE "\177" #define GNT_KEY_DEL "[3~" +/** + * This will do stuff with the terminal settings and stuff. + */ +void gnt_keys_refine(char *text); + #endif Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntmain.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -13,6 +13,11 @@ #include <unistd.h> #include <string.h> +/** + * Notes: Interesting functions to look at: + * scr_dump, scr_init, scr_restore: for workspaces + */ + static int lock_focus_list; static GList *focus_list; @@ -52,6 +57,14 @@ static void draw_taskbar(); static void bring_on_top(GntWidget *widget); +static gboolean +update_screen(gpointer null) +{ + update_panels(); + doupdate(); + return TRUE; +} + void gnt_screen_take_focus(GntWidget *widget) { GntWidget *w = NULL; @@ -119,8 +132,7 @@ GntNode *nd = g_hash_table_lookup(nodes, window_list.window); top_panel(nd->panel); } - update_panels(); - doupdate(); + update_screen(NULL); draw_taskbar(); } @@ -437,6 +449,8 @@ dump_screen(); } + gnt_keys_refine(buffer); + if (mode == GNT_KP_MODE_NORMAL) { if (focus_list) @@ -499,6 +513,14 @@ { shift_window(focus_list->data, 1); } + else if (strcmp(buffer + 1, "l") == 0) + { + touchwin(stdscr); + touchwin(newscr); + wrefresh(newscr); + update_screen(NULL); + draw_taskbar(); + } } } } @@ -557,8 +579,7 @@ GntNode *node = g_hash_table_lookup(nodes, widget); gnt_widget_set_position(widget, x, y); move_panel(node->panel, y, x); - update_panels(); - doupdate(); + update_screen(NULL); } } else if (*buffer == '\r') @@ -656,6 +677,10 @@ ascii_only = TRUE; initscr(); + typeahead(-1); + noecho(); + curs_set(0); + gnt_init_colors(); gnt_init_styles(); @@ -671,7 +696,6 @@ nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); - noecho(); refresh(); #if 0 mousemask(NCURSES_BUTTON_PRESSED | NCURSES_BUTTON_RELEASED | REPORT_MOUSE_POSITION, NULL); @@ -729,8 +753,7 @@ } } - update_panels(); - doupdate(); + update_screen(NULL); } void gnt_screen_release(GntWidget *widget) @@ -750,8 +773,7 @@ gnt_tree_remove(GNT_TREE(window_list.tree), widget); } - update_panels(); - doupdate(); + update_screen(NULL); } void gnt_screen_update(GntWidget *widget) @@ -779,8 +801,7 @@ top_panel(nd->panel); } - update_panels(); - doupdate(); + update_screen(NULL); } gboolean gnt_widget_has_focus(GntWidget *widget) @@ -844,8 +865,7 @@ gnt_widget_draw(widget); replace_panel(node->panel, widget->window); show_panel(node->panel); - update_panels(); - doupdate(); + update_screen(NULL); } } Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gnttree.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -770,6 +770,15 @@ } } +void gnt_tree_remove_all(GntTree *tree) +{ + tree->root = NULL; + g_hash_table_remove_all(tree->hash); + g_list_free(tree->list); + tree->list = NULL; + tree->current = tree->top = tree->bottom = NULL; +} + int gnt_tree_get_selection_visible_line(GntTree *tree) { return get_distance(tree->top, tree->current) + Modified: trunk/console/libgnt/gnttree.h =================================================================== --- trunk/console/libgnt/gnttree.h 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gnttree.h 2006-08-12 10:27:29 UTC (rev 16715) @@ -85,6 +85,8 @@ void gnt_tree_remove(GntTree *tree, gpointer key); +void gnt_tree_remove_all(GntTree *tree); + /* Returns the visible line number of the selected row */ int gnt_tree_get_selection_visible_line(GntTree *tree); Modified: trunk/console/libgnt/gntwidget.c =================================================================== --- trunk/console/libgnt/gntwidget.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/gntwidget.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -80,6 +80,23 @@ return TRUE; } +static gboolean +gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy) +{ + gboolean continue_emission; + gboolean signal_handled; + + signal_handled = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, signal_handled); + continue_emission = !signal_handled; + + return continue_emission; +} + + static void gnt_widget_class_init(GntWidgetClass *klass) { @@ -194,7 +211,7 @@ G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(GntWidgetClass, key_pressed), - NULL, NULL, + gnt_boolean_handled_accumulator, NULL, gnt_closure_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1, G_TYPE_STRING); DEBUG; Modified: trunk/console/libgnt/test/tv.c =================================================================== --- trunk/console/libgnt/test/tv.c 2006-08-12 10:26:45 UTC (rev 16714) +++ trunk/console/libgnt/test/tv.c 2006-08-12 10:27:29 UTC (rev 16715) @@ -14,19 +14,24 @@ gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), gnt_entry_get_text(GNT_ENTRY(w)), GNT_TEXT_FLAG_HIGHLIGHT); + gnt_entry_add_to_history(GNT_ENTRY(w), gnt_entry_get_text(GNT_ENTRY(w))); gnt_text_view_next_line(GNT_TEXT_VIEW(view)); gnt_entry_clear(GNT_ENTRY(w)); if (gnt_text_view_get_lines_below(GNT_TEXT_VIEW(view)) <= 1) gnt_text_view_scroll(GNT_TEXT_VIEW(view), 0); + gnt_entry_remove_suggest(GNT_ENTRY(w), "acb"); return TRUE; } else if (key[0] == 27) { - if (strcmp(key+1, GNT_KEY_UP)) + if (strcmp(key+1, GNT_KEY_UP) == 0) + gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); + else if (strcmp(key+1, GNT_KEY_DOWN) == 0) gnt_text_view_scroll(GNT_TEXT_VIEW(view), 1); - else if (strcmp(key+1, GNT_KEY_DOWN)) - gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); + else + return FALSE; + return TRUE; } return FALSE; @@ -53,6 +58,15 @@ gnt_widget_set_name(entry, "entry"); GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS); + gnt_entry_set_word_suggest(GNT_ENTRY(entry), TRUE); + gnt_entry_set_always_suggest(GNT_ENTRY(entry), FALSE); + gnt_entry_add_suggest(GNT_ENTRY(entry), "a"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "ab"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abc"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abcd"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abcde"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "acb"); + view = gnt_text_view_new(); gnt_widget_set_name(view, "view"); @@ -65,7 +79,8 @@ gnt_widget_show(hbox); - g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); + gnt_entry_set_history_length(GNT_ENTRY(entry), -1); + g_signal_connect_after(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); #ifdef STANDALONE gnt_main(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 10:26:53
|
Revision: 16714 Author: thekingant Date: 2006-08-12 03:26:45 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16714&view=rev Log Message: ----------- Backport SVN revisions 16711 to 16713 from HEAD to v2_0_0 Original commit messages: 16711: Get rid of an assert when editing an account that has no icon 16712: Pretty large commit here. Basically I got sick of having to verify that gc is still valid on all the callback functions for gaim_proxy_connect(). The fix for this for gaim_proxy_connect() to return something that allows the connection attempt to be canceled. It's not quite there yet, but this is a good first step. I changed gaim_proxy_connect() to return a reference to a new GaimProxyConnectInfo (this used to be called PHB). Eventually this can be passed to a function that'll cancel the connection attempt. I also decided to add an error_cb instead of using connect_cb and passing a file descriptor of -1. And proxy.c will also pass an error message to callers which should explain the reason that the connection attempt failed. Oh, and proxy.c now never calls gaim_connection_error() 16713: Rename struct PHB to struct _GaimProxyConnectInfo Modified Paths: -------------- branches/v2_0_0/src/ft.c branches/v2_0_0/src/gtkaccount.c branches/v2_0_0/src/protocols/irc/irc.c branches/v2_0_0/src/protocols/jabber/jabber.c branches/v2_0_0/src/protocols/jabber/si.c branches/v2_0_0/src/protocols/msn/directconn.c branches/v2_0_0/src/protocols/msn/httpconn.c branches/v2_0_0/src/protocols/msn/servconn.c branches/v2_0_0/src/protocols/oscar/oscar.c branches/v2_0_0/src/protocols/oscar/peer.c branches/v2_0_0/src/protocols/oscar/peer.h branches/v2_0_0/src/protocols/oscar/peer_proxy.c branches/v2_0_0/src/protocols/sametime/sametime.c branches/v2_0_0/src/protocols/silc/silc.c branches/v2_0_0/src/protocols/simple/simple.c branches/v2_0_0/src/protocols/yahoo/yahoo.c branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c branches/v2_0_0/src/protocols/yahoo/yahoochat.c branches/v2_0_0/src/protocols/yahoo/ycht.c branches/v2_0_0/src/proxy.c branches/v2_0_0/src/proxy.h branches/v2_0_0/src/sslconn.c branches/v2_0_0/src/upnp.c branches/v2_0_0/src/util.c Modified: branches/v2_0_0/src/ft.c =================================================================== --- branches/v2_0_0/src/ft.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/ft.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -911,13 +911,13 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition condition) +connect_cb(gpointer data, gint source) { GaimXfer *xfer = (GaimXfer *)data; xfer->fd = source; - begin_transfer(xfer, condition); + begin_transfer(xfer, GAIM_INPUT_READ); } void @@ -946,7 +946,7 @@ /* Establish a file descriptor. */ gaim_proxy_connect(xfer->account, xfer->remote_ip, - xfer->remote_port, connect_cb, xfer); + xfer->remote_port, connect_cb, NULL, xfer); return; } Modified: branches/v2_0_0/src/gtkaccount.c =================================================================== --- branches/v2_0_0/src/gtkaccount.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/gtkaccount.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -210,7 +210,8 @@ } gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_entry), pixbuf); - g_object_unref(G_OBJECT(pixbuf)); + if (pixbuf != NULL) + g_object_unref(G_OBJECT(pixbuf)); g_free(filename); } Modified: branches/v2_0_0/src/protocols/irc/irc.c =================================================================== --- branches/v2_0_0/src/protocols/irc/irc.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/irc/irc.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -46,7 +46,7 @@ /* static GList *irc_chat_info(GaimConnection *gc); */ static void irc_login(GaimAccount *account); static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); -static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond); +static void irc_login_cb(gpointer data, gint source); static void irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, gpointer data); static void irc_close(GaimConnection *gc); static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags); @@ -283,7 +283,7 @@ struct irc_conn *irc; char **userparts; const char *username = gaim_account_get_username(account); - int err; + GaimProxyConnectInfo *connect_info; gc = gaim_account_get_connection(account); gc->flags |= GAIM_CONNECTION_NO_NEWLINES; @@ -325,11 +325,11 @@ if (!irc->gsc) { - err = gaim_proxy_connect(account, irc->server, + connect_info = gaim_proxy_connect(account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), - irc_login_cb, gc); + irc_login_cb, NULL, gc); - if (err || !gaim_account_get_connection(account)) { + if (!connect_info || !gaim_account_get_connection(account)) { gaim_connection_error(gc, _("Couldn't create socket")); return; } @@ -394,7 +394,7 @@ } } -static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond) +static void irc_login_cb(gpointer data, gint source) { GaimConnection *gc = data; struct irc_conn *irc = gc->proto_data; Modified: branches/v2_0_0/src/protocols/jabber/jabber.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -418,7 +418,7 @@ static void -jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) +jabber_login_callback(gpointer data, gint source) { GaimConnection *gc = data; JabberStream *js = gc->proto_data; @@ -471,12 +471,12 @@ static void jabber_login_connect(JabberStream *js, const char *server, int port) { - int rc; + GaimProxyConnectInfo *connect_info; - rc = gaim_proxy_connect(js->gc->account, server, - port, jabber_login_callback, js->gc); + connect_info = gaim_proxy_connect(js->gc->account, server, + port, jabber_login_callback, NULL, js->gc); - if (rc != 0) + if (connect_info == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); } @@ -859,7 +859,7 @@ const char *connect_server = gaim_account_get_string(account, "connect_server", ""); const char *server; - int rc; + GaimProxyConnectInfo *connect_info; js = gc->proto_data = g_new0(JabberStream, 1); js->gc = gc; @@ -909,11 +909,11 @@ } if(!js->gsc) { - rc = gaim_proxy_connect(account, server, + connect_info = gaim_proxy_connect(account, server, gaim_account_get_int(account, "port", 5222), - jabber_login_callback, gc); + jabber_login_callback, NULL, gc); - if (rc != 0) + if (connect_info == NULL) gaim_connection_error(gc, _("Unable to create socket")); } } Modified: branches/v2_0_0/src/protocols/jabber/si.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/si.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/jabber/si.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -88,7 +88,7 @@ static void jabber_si_bytestreams_attempt_connect(GaimXfer *xfer); -static void jabber_si_bytestreams_connect_cb(gpointer data, gint source, GaimInputCondition cond) +static void jabber_si_bytestreams_connect_cb(gpointer data, gint source) { GaimXfer *xfer = data; JabberSIXfer *jsx = xfer->data; @@ -167,7 +167,7 @@ for(i=0; i<20; i++, p+=2) snprintf(p, 3, "%02x", hashval[i]); - gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); + gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, NULL, xfer); g_free(dstaddr); } Modified: branches/v2_0_0/src/protocols/msn/directconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -368,12 +368,12 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnDirectConn* directconn; int fd; - gaim_debug_misc("msn", "directconn: connect_cb: %d, %d.\n", source, cond); + gaim_debug_misc("msn", "directconn: connect_cb: %d\n", source); directconn = data; @@ -423,7 +423,7 @@ msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port) { MsnSession *session; - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(directconn != NULL, FALSE); g_return_val_if_fail(host != NULL, TRUE); @@ -438,10 +438,10 @@ } #endif - r = gaim_proxy_connect(session->account, host, port, connect_cb, - directconn); + connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, NULL, directconn); - if (r == 0) + if (connect_info != NULL) { return TRUE; } Modified: branches/v2_0_0/src/protocols/msn/httpconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/httpconn.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/msn/httpconn.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -693,7 +693,7 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnHttpConn *httpconn = data; @@ -729,7 +729,7 @@ gboolean msn_httpconn_connect(MsnHttpConn *httpconn, const char *host, int port) { - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(httpconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); @@ -738,10 +738,10 @@ if (httpconn->connected) msn_httpconn_disconnect(httpconn); - r = gaim_proxy_connect(httpconn->session->account, - "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); + connect_info = gaim_proxy_connect(httpconn->session->account, + "gateway.messenger.hotmail.com", 80, connect_cb, NULL, httpconn); - if (r == 0) + if (connect_info != NULL) { httpconn->waiting_response = TRUE; httpconn->connected = TRUE; Modified: branches/v2_0_0/src/protocols/msn/servconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/servconn.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/msn/servconn.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -166,7 +166,7 @@ **************************************************************************/ static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnServConn *servconn = data; @@ -199,7 +199,7 @@ msn_servconn_connect(MsnServConn *servconn, const char *host, int port) { MsnSession *session; - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(servconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); @@ -232,10 +232,10 @@ return TRUE; } - r = gaim_proxy_connect(session->account, host, port, connect_cb, - servconn); + connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, NULL, servconn); - if (r == 0) + if (connect_info != NULL) { servconn->processing = TRUE; return TRUE; Modified: branches/v2_0_0/src/protocols/oscar/oscar.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -943,7 +943,7 @@ * on the type of host, we do a few different things here. */ static void -connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +connection_established_cb(gpointer data, gint source) { NewFlapConnectionData *new_conn_data; GaimConnection *gc; @@ -1250,7 +1250,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), - connection_established_cb, new_conn_data) < 0) + connection_established_cb, NULL, new_conn_data) == NULL) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -1294,7 +1294,8 @@ GaimConnection *gc = od->gc; GaimAccount *account = gc->account; char *host; int port; - int i, rc; + int i; + GaimProxyConnectInfo *connect_info; NewFlapConnectionData *new_conn_data; va_list ap; struct aim_authresp_info *info; @@ -1366,9 +1367,10 @@ new_conn_data->cookielen = info->cookielen; new_conn_data->cookie = g_memdup(info->cookie, info->cookielen); new_conn_data->data = NULL; - rc = gaim_proxy_connect(gc->account, host, port, connection_established_cb, new_conn_data); + connect_info = gaim_proxy_connect(gc->account, host, port, + connection_established_cb, NULL, new_conn_data); g_free(host); - if (rc < 0) { + if (connect_info == NULL) { gaim_connection_error(gc, _("Could Not Connect")); od->killme = TRUE; return 0; @@ -1479,7 +1481,9 @@ g_free(pos); } -static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { +static void +straight_to_hell(gpointer data, gint source) +{ struct pieceofcrap *pos = data; gchar *buf; @@ -1569,7 +1573,8 @@ pos->len = len; pos->modname = g_strdup(modname); - if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) + if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, + straight_to_hell, NULL, pos) == NULL) { char buf[256]; if (pos->modname) @@ -1660,7 +1665,7 @@ new_conn_data->data = NULL; } - if (gaim_proxy_connect(account, host, port, connection_established_cb, new_conn_data) != 0) + if (gaim_proxy_connect(account, host, port, connection_established_cb, NULL, new_conn_data) == NULL) { flap_connection_schedule_destroy(new_conn_data->conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); Modified: branches/v2_0_0/src/protocols/oscar/peer.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -470,7 +470,7 @@ * either connected or failed to connect. */ static void -peer_connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +peer_connection_established_cb(gpointer data, gint source) { NewPeerConnectionData *new_conn_data; GaimConnection *gc; @@ -668,7 +668,7 @@ } if (gaim_proxy_connect(account, conn->verifiedip, conn->port, - peer_connection_established_cb, new_conn_data) == 0) + peer_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; @@ -699,7 +699,7 @@ } if (gaim_proxy_connect(account, conn->clientip, conn->port, - peer_connection_established_cb, new_conn_data) == 0) + peer_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; @@ -760,7 +760,7 @@ if (gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, - peer_proxy_connection_established_cb, new_conn_data) == 0) + peer_proxy_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; Modified: branches/v2_0_0/src/protocols/oscar/peer.h =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-12 10:26:45 UTC (rev 16714) @@ -254,7 +254,7 @@ /* * For peer proxying */ -void peer_proxy_connection_established_cb(gpointer data, gint source, GaimInputCondition cond); +void peer_proxy_connection_established_cb(gpointer data, gint source); #if 0 int peer_oft_sendheader(OscarData *od, guint16 type, PeerConnection *peer_connection); Modified: branches/v2_0_0/src/protocols/oscar/peer_proxy.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -326,7 +326,7 @@ * either connected or failed to connect. */ void -peer_proxy_connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +peer_proxy_connection_established_cb(gpointer data, gint source) { NewPeerConnectionData *new_conn_data; GaimConnection *gc; Modified: branches/v2_0_0/src/protocols/sametime/sametime.c =================================================================== --- branches/v2_0_0/src/protocols/sametime/sametime.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/sametime/sametime.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -310,7 +310,7 @@ /* connection functions */ -static void connect_cb(gpointer data, gint source, GaimInputCondition cond); +static void connect_cb(gpointer data, gint source); /* ----- session ------ */ @@ -1409,7 +1409,7 @@ port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) || - gaim_proxy_connect(account, host, port, connect_cb, pd)) { + (gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL)) { mwSession_forceLogin(session); } @@ -1669,8 +1669,7 @@ /** Callback passed to gaim_proxy_connect when an account is logged in, and if the session logging in receives a redirect message */ -static void connect_cb(gpointer data, gint source, - GaimInputCondition cond) { +static void connect_cb(gpointer data, gint source) { struct mwGaimPluginData *pd = data; GaimConnection *gc = pd->gc; @@ -3684,7 +3683,7 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - if(gaim_proxy_connect(account, host, port, connect_cb, pd)) { + if(gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } Modified: branches/v2_0_0/src/protocols/silc/silc.c =================================================================== --- branches/v2_0_0/src/protocols/silc/silc.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/silc/silc.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -141,7 +141,7 @@ } static void -silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond) +silcgaim_login_connected(gpointer data, gint source) { GaimConnection *gc = data; SilcGaim sg; @@ -367,7 +367,8 @@ gaim_account_get_string(account, "server", "silc.silcnet.org"), gaim_account_get_int(account, "port", 706), - silcgaim_login_connected, gc)) { + silcgaim_login_connected, NULL, gc) == NULL) + { gaim_connection_error(gc, _("Unable to create connection")); return; } Modified: branches/v2_0_0/src/protocols/simple/simple.c =================================================================== --- branches/v2_0_0/src/protocols/simple/simple.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/simple/simple.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -421,7 +421,7 @@ static void simple_input_cb(gpointer data, gint source, GaimInputCondition cond); -static void send_later_cb(gpointer data, gint source, GaimInputCondition cond) { +static void send_later_cb(gpointer data, gint source) { GaimConnection *gc = data; struct simple_account_data *sip = gc->proto_data; struct sip_connection *conn; @@ -448,11 +448,12 @@ static void sendlater(GaimConnection *gc, const char *buf) { struct simple_account_data *sip = gc->proto_data; - int error = 0; + GaimProxyConnectInfo *connect_info; + if(!sip->connecting) { gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); - error = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); - if(error) { + connect_info = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, NULL, gc); + if(connect_info == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); } sip->connecting = TRUE; @@ -1452,7 +1453,7 @@ conn->inputhandler = gaim_input_add(newfd, GAIM_INPUT_READ, simple_input_cb, gc); } -static void login_cb(gpointer data, gint source, GaimInputCondition cond) { +static void login_cb(gpointer data, gint source) { GaimConnection *gc = data; struct simple_account_data *sip = gc->proto_data; struct sip_connection *conn; @@ -1536,7 +1537,7 @@ static void simple_tcp_connect_listen_cb(int listenfd, gpointer data) { struct simple_account_data *sip = (struct simple_account_data*) data; - int error = 0; + GaimProxyConnectInfo *connect_info; sip->listenfd = listenfd; if(sip->listenfd == -1) { @@ -1551,9 +1552,9 @@ gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname, sip->realport); /* open tcp connection to the server */ - error = gaim_proxy_connect(sip->account, sip->realhostname, - sip->realport, login_cb, sip->gc); - if(error) { + connect_info = gaim_proxy_connect(sip->account, sip->realhostname, + sip->realport, login_cb, NULL, sip->gc); + if(connect_info == NULL) { gaim_connection_error(sip->gc, _("Couldn't create socket")); } } Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -2239,7 +2239,7 @@ } } -static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_connected(gpointer data, gint source) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2266,7 +2266,7 @@ gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); } -static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_web_connected(gpointer data, gint source) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2348,7 +2348,7 @@ /* Now we have our cookies to login with. I'll go get the milk. */ if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_web_connected, gc) != 0) { + yahoo_got_web_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2390,7 +2390,7 @@ gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); } -static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_cookies(gpointer data, gint source) { GaimConnection *gc = data; @@ -2516,7 +2516,7 @@ "Host: login.yahoo.com\r\n\r\n"); g_hash_table_destroy(hash); yd->auth = g_string_free(url, FALSE); - if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { + if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2618,7 +2618,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, gc) != 0) + yahoo_got_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; @@ -2628,7 +2628,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, gc) != 0) + yahoo_got_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -92,7 +92,7 @@ } -static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_receivefile_connected(gpointer data, gint source) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -162,7 +162,7 @@ gaim_xfer_start(xfer, source, NULL, 0); } -static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_sendfile_connected(gpointer data, gint source) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -263,7 +263,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) + yahoo_sendfile_connected, NULL, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -272,7 +272,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) + yahoo_sendfile_connected, NULL, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -280,8 +280,12 @@ } } } else { - xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port, - yahoo_receivefile_connected, xfer); + /* TODO: Using xfer->fd like this is probably a bad thing... */ + if (gaim_proxy_connect(account, xfer_data->host, xfer_data->port, + yahoo_receivefile_connected, NULL, xfer) == NULL) + xfer->fd = -1; + else + xfer->fd = 0; if (xfer->fd == -1) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -406,7 +406,7 @@ } } -static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_buddy_icon_upload_connected(gpointer data, gint source) { struct yahoo_buddy_icon_upload_data *d = data; struct yahoo_packet *pkt; @@ -484,7 +484,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, d) == -1) + yahoo_buddy_icon_upload_connected, NULL, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); @@ -492,7 +492,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, d) == -1) + yahoo_buddy_icon_upload_connected, NULL, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); Modified: branches/v2_0_0/src/protocols/yahoo/yahoochat.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -1373,7 +1373,7 @@ } -static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_roomlist_got_connected(gpointer data, gint source) { struct yahoo_roomlist *yrl = data; GaimRoomlist *list = yrl->list; @@ -1449,8 +1449,8 @@ gaim_roomlist_set_fields(rl, fields); - if (gaim_proxy_connect(gaim_connection_get_account(gc), - yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0) + if (gaim_proxy_connect(gaim_connection_get_account(gc), yrl->host, 80, + yahoo_roomlist_got_connected, NULL, yrl) == NULL) { gaim_notify_error(gc, NULL, _("Connection problem"), _("Unable to fetch room list.")); yahoo_roomlist_cleanup(rl, yrl); @@ -1518,8 +1518,8 @@ yrl->ucat = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat); gaim_roomlist_room_add(list, yrl->ucat); - if (gaim_proxy_connect(list->account, - yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0) + if (gaim_proxy_connect(list->account, yrl->host, 80, + yahoo_roomlist_got_connected, NULL, yrl) == NULL) { gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Connection problem"), _("Unable to fetch room list.")); Modified: branches/v2_0_0/src/protocols/yahoo/ycht.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/ycht.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/protocols/yahoo/ycht.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -528,7 +528,7 @@ } } -static void ycht_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void ycht_got_connected(gpointer data, gint source) { YchtConn *ycht = data; GaimConnection *gc = ycht->gc; @@ -571,7 +571,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "ycht-server", YAHOO_YCHT_HOST), gaim_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT), - ycht_got_connected, ycht) != 0) + ycht_got_connected, NULL, ycht) == NULL) { ycht_connection_error(ycht, _("Connection problem")); return; Modified: branches/v2_0_0/src/proxy.c =================================================================== --- branches/v2_0_0/src/proxy.c 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/proxy.c 2006-08-12 10:26:45 UTC (rev 16714) @@ -38,16 +38,15 @@ #include "proxy.h" #include "util.h" -static GaimProxyInfo *global_proxy_info = NULL; - -struct PHB { - GaimInputFunction func; +/* Does anyone know what PHB stands for? */ +struct _GaimProxyConnectInfo { + GaimProxyConnectFunction connect_cb; + GaimProxyErrorFunction error_cb; gpointer data; char *host; int port; - gint inpa; + guint inpa; GaimProxyInfo *gpi; - GaimAccount *account; GSList *hosts; guchar *write_buffer; gsize write_buf_len; @@ -58,8 +57,6 @@ gsize read_len; }; -static void try_connect(struct PHB *); - static const char *socks5errors[] = { "succeeded\n", "general SOCKS server failure\n", @@ -72,6 +69,11 @@ "Address type not supported\n" }; +static GaimProxyInfo *global_proxy_info = NULL; +static GSList *phbs = NULL; + +static void try_connect(struct _GaimProxyConnectInfo *); + /************************************************************************** * Proxy structure API **************************************************************************/ @@ -255,6 +257,63 @@ * Proxy API **************************************************************************/ +static void +gaim_proxy_phb_destroy(struct _GaimProxyConnectInfo *phb) +{ + phbs = g_slist_remove(phbs, phb); + + if (phb->inpa > 0) + gaim_input_remove(phb->inpa); + + while (phb->hosts != NULL) + { + /* Discard the length... */ + phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + /* Free the address... */ + g_free(phb->hosts->data); + phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + } + + g_free(phb->host); + g_free(phb->write_buffer); + g_free(phb->read_buffer); + g_free(phb); +} + +static void +gaim_proxy_phb_connected(struct _GaimProxyConnectInfo *phb, int fd) +{ + phb->connect_cb(phb->data, fd); + gaim_proxy_phb_destroy(phb); +} + +/** + * @param error An error message explaining why the connection + * failed. This will be passed to the callback function + * specified in the call to gaim_proxy_connect(). + */ +static void +gaim_proxy_phb_error(struct _GaimProxyConnectInfo *phb, const gchar *error_message) +{ + if (phb->error_cb == NULL) + { + /* + * TODO + * While we're transitioning to the new gaim_proxy_connect() + * code, not all callers supply an error_cb. If this is the + * case then they're expecting connect_cb to be called with + * an fd of -1 in the case of an error. Once all callers have + * been changed this whole if statement should be removed. + */ + phb->connect_cb(phb->data, -1); + gaim_proxy_phb_destroy(phb); + return; + } + + phb->error_cb(phb->data, error_message); + gaim_proxy_phb_destroy(phb); +} + #if defined(__unix__) || defined(__APPLE__) /* @@ -264,9 +323,9 @@ typedef struct { char *host; int port; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; - gint inpa; + guint inpa; int fd_in, fd_out; pid_t dns_pid; } pending_dns_request_t; @@ -285,7 +344,7 @@ typedef struct { dns_params_t params; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; } queued_dns_request_t; @@ -694,7 +753,7 @@ */ int -gaim_gethostbyname_async(const char *hostname, int port, dns_callback_t callback, gpointer data) +gaim_gethostbyname_async(const char *hostname, int port, GaimProxyDnsConnectFunction callback, gpointer data) { pending_dns_request_t *req = NULL; dns_params_t dns_params; @@ -767,7 +826,7 @@ typedef struct _dns_tdata { char *hostname; int port; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; GSList *hosts; char *errmsg; @@ -843,7 +902,7 @@ int gaim_gethostbyname_async(const char *hostname, int port, - dns_callback_t callback, gpointer data) + GaimProxyDnsConnectFunction callback, gpointer data) { dns_tdata *td; struct sockaddr_in sin; @@ -882,7 +941,7 @@ gpointer data; size_t addrlen; struct sockaddr *addr; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; } pending_dns_request_t; static gboolean host_resolved(gpointer data) @@ -898,7 +957,7 @@ int gaim_gethostbyname_async(const char *hostname, int port, - dns_callback_t callback, gpointer data) + GaimProxyDnsConnectFunction callback, gpointer data) { struct sockaddr_in sin; pending_dns_request_t *req; @@ -932,7 +991,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error=0, ret; @@ -955,9 +1014,11 @@ if (ret == 0 && error == EINPROGRESS) return; /* we'll be called again later */ if (ret < 0 || error != 0) { - if(ret!=0) error = errno; + if (ret!=0) + error = errno; close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); @@ -967,36 +1028,23 @@ } gaim_input_remove(phb->inpa); + phb->inpa = 0; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); } static gboolean clean_connect(gpointer data) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { + gaim_proxy_phb_connected(phb, phb->port); - phb->func(phb->data, phb->port, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); - return FALSE; } static int -proxy_connect_none(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1015,8 +1063,9 @@ if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("proxy", - "Connect would have blocked.\n"); + /* This just confuses people. */ + /* gaim_debug_warning("proxy", + "Connect would have blocked.\n"); */ phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); } else { @@ -1036,8 +1085,9 @@ close(fd); return -1; } + /* TODO: Why is the following line so strange? */ phb->port = fd; /* bleh */ - gaim_timeout_add(50, clean_connect, phb); /* we do this because we never + gaim_timeout_add(10, clean_connect, phb); /* we do this because we never want to call our callback before we return. */ } @@ -1048,7 +1098,7 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; const guchar *request = phb->write_buffer + phb->written_len; gsize request_len = phb->write_buf_len - phb->written_len; @@ -1058,6 +1108,7 @@ return; else if(ret < 0) { gaim_input_remove(phb->inpa); + phb->inpa = 0; close(source); g_free(phb->write_buffer); phb->write_buffer = NULL; @@ -1079,27 +1130,16 @@ #define HTTP_GOODSTRING "HTTP/1.0 200" #define HTTP_GOODSTRING2 "HTTP/1.1 200" -static void -http_complete(struct PHB *phb, gint source) -{ - gaim_debug_info("http proxy", "proxy connection established\n"); - if(!phb->account || phb->account->gc) { - phb->func(phb->data, source, GAIM_INPUT_READ); - } - g_free(phb->host); - g_free(phb); -} - - /* read the response to the CONNECT request, if we are requesting a non-port-80 tunnel */ static void http_canread(gpointer data, gint source, GaimInputCondition cond) { int len, headers_len, status = 0; gboolean error; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; guchar *p; gsize max_read; + gchar *msg; if(phb->read_buffer == NULL) { phb->read_buf_len = 8192; @@ -1115,12 +1155,7 @@ return; else if(len <= 0) { close(source); - source = -1; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - gaim_input_remove(phb->inpa); - phb->inpa = 0; - http_complete(phb, source); + gaim_proxy_phb_error(phb, _("Lost connection with server for an unknown reason.")); return; } else { phb->read_len += len; @@ -1136,7 +1171,8 @@ return; error = strncmp((const char *)phb->read_buffer, "HTTP/", 5) != 0; - if(!error) { + if (!error) + { int major; p = phb->read_buffer + 5; major = strtol((const char *)p, (char **)&p, 10); @@ -1156,7 +1192,8 @@ /* Read the contents */ p = (guchar *)g_strrstr((const gchar *)phb->read_buffer, "Content-Length: "); - if(p != NULL) { + if (p != NULL) + { gchar *tmp; int len = 0; char tmpc; @@ -1179,25 +1216,22 @@ } } - if(error) { - gaim_debug_error("proxy", - "Unable to parse proxy's response: %s\n", + if (error) + { + close(source); + msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", phb->read_buffer); - close(source); - source = -1; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - gaim_input_remove(phb->inpa); - phb->inpa = 0; - http_complete(phb, source); + gaim_proxy_phb_error(phb, msg); + g_free(msg); return; - } else if(status != 200) { + } + else if (status != 200) + { gaim_debug_error("proxy", "Proxy server replied with:\n%s\n", phb->read_buffer); - /* XXX: why in the hell are we calling gaim_connection_error() here? */ if(status == 407 /* Proxy Auth */) { gchar *ntlm; if((ntlm = g_strrstr((const gchar *)phb->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ @@ -1207,19 +1241,13 @@ gchar *username; gchar *request; gchar *response; - if(!(username = strchr(domain, '\\'))) { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); + username = strchr(domain, '\\'); + if (username == NULL) + { close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } *username = '\0'; @@ -1263,19 +1291,13 @@ gchar *domain = (gchar*) gaim_proxy_info_get_username(phb->gpi); gchar *username; int request_len; - if(!(username = strchr(domain, '\\'))) { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); + username = strchr(domain, '\\'); + if (username == NULL) + { close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } *username = '\0'; @@ -1312,49 +1334,29 @@ proxy_do_write(phb, source, cond); return; } else { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } } if(status == 403 /* Forbidden */ ) { - gchar *msg = g_strdup_printf(_("Access denied: proxy server forbids port %d tunnelling."), phb->port); - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), phb->port); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); } else { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); } } else { gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; - http_complete(phb, source); + gaim_debug_info("proxy", "HTTP proxy connection established\n"); + gaim_proxy_phb_connected(phb, source); return; } } @@ -1366,14 +1368,17 @@ { char request[8192]; int request_len = 0; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("http proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); @@ -1426,7 +1431,7 @@ } static int -proxy_connect_http(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1455,7 +1460,8 @@ phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, http_canwrite, phb); } else { - http_complete(phb, fd); + gaim_debug_info("proxy", "HTTP proxy connection established\n"); + gaim_proxy_phb_connected(phb, fd); } } else { close(fd); @@ -1484,7 +1490,7 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; guchar *buf; int len, max_read; @@ -1506,21 +1512,13 @@ return; else if (len + phb->read_len >= 4) { if (phb->read_buffer[1] == 90) { - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); return; } } gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; @@ -1534,14 +1532,17 @@ { unsigned char packet[9]; struct hostent *hp; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks4 proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); @@ -1588,7 +1589,7 @@ } static int -proxy_connect_socks4(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1640,7 +1641,7 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -1661,6 +1662,7 @@ gaim_debug_warning("socks5 proxy", "or not...\n"); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1678,6 +1680,7 @@ gaim_debug_error("socks5 proxy", "Bad data.\n"); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1714,22 +1717,13 @@ /* Skip past BND.PORT */ buf += 2; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); } static void -s5_sendconnect(gpointer data, gint source) +s5_sendconnect(gpointer data, int source) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int hlen = strlen(phb->host); phb->write_buf_len = 5 + hlen + 2; phb->write_buffer = g_malloc(phb->write_buf_len); @@ -1748,13 +1742,12 @@ phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); proxy_do_write(phb, source, GAIM_INPUT_WRITE); - } static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -1772,6 +1765,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1783,6 +1777,7 @@ return; gaim_input_remove(phb->inpa); + phb->inpa = 0; if ((phb->read_buffer[0] != 0x01) || (phb->read_buffer[1] != 0x00)) { close(source); @@ -1845,7 +1840,7 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); @@ -1864,6 +1859,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1879,6 +1875,7 @@ if (*cmdbuf != 0x01) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1900,6 +1897,7 @@ /* Did auth work? */ if (buf[0] == 0x00) { gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; /* Success */ @@ -1912,6 +1910,7 @@ "failed. Disconnecting..."); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1956,6 +1955,7 @@ "Disconnecting..."); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1973,7 +1973,7 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -1991,6 +1991,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -2002,6 +2003,7 @@ return; gaim_input_remove(phb->inpa); + phb->inpa = 0; if ((phb->read_buffer[0] != 0x05) || (phb->read_buffer[1] == 0xff)) { close(source); @@ -2086,14 +2088,17 @@ { unsigned char buf[5]; int i; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks5 proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { @@ -2130,7 +2135,7 @@ } static int -proxy_connect_socks5(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -2180,7 +2185,7 @@ return fd; } -static void try_connect(struct PHB *phb) +static void try_connect(struct _GaimProxyConnectInfo *phb) { size_t addrlen; struct sockaddr *addr; @@ -2224,14 +2229,7 @@ } if (ret < 0) { - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, -1, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_error(phb, _("TODO")); } } @@ -2239,7 +2237,7 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct PHB *phb = (struct PHB*)data; + struct _GaimProxyConnectInfo *phb = (struct _GaimProxyConnectInfo*)data; phb->hosts = hosts; @@ -2312,31 +2310,26 @@ return gpi; } -/* - * TODO: It would be really good if this returned some sort of handle - * that we could use to cancel the connection. As it is now, - * each callback has to check to make sure gc is still valid. - * And that is ugly. - */ -int +GaimProxyConnectInfo * gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimInputFunction func, gpointer data) + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data) { const char *connecthost = host; int connectport = port; - struct PHB *phb; + struct _GaimProxyConnectInfo *phb; - g_return_val_if_fail(host != NULL, -1); - g_return_val_if_fail(port != 0 && port != -1, -1); - g_return_val_if_fail(func != NULL, -1); + g_return_val_if_fail(host != NULL, NULL); + g_return_val_if_fail(port > 0, NULL); + g_return_val_if_fail(connect_cb != NULL, NULL); + /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ - phb = g_new0(struct PHB, 1); - - phb->func = func; + phb = g_new0(struct _GaimProxyConnectInfo, 1); + phb->connect_cb = connect_cb; + phb->error_cb = error_cb; phb->data = data; phb->host = g_strdup(host); phb->port = port; - phb->account = account; phb->gpi = gaim_proxy_get_setup(account); if ((gaim_proxy_info_get_type(phb->gpi) != GAIM_PROXY_NONE) && @@ -2344,9 +2337,8 @@ gaim_proxy_info_get_port(phb->gpi) <= 0)) { gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); - g_free(phb->host); - g_free(phb); - return -1; + gaim_proxy_phb_destroy(phb); + return NULL; } switch (gaim_proxy_info_get_type(phb->gpi)) @@ -2363,30 +2355,55 @@ break; default: - g_free(phb->host); - g_free(phb); - return -1; + gaim_proxy_phb_destroy(phb); + return NULL; } - return gaim_gethostbyname_async(connecthost, connectport, - connection_host_resolved, phb); + if (gaim_gethostbyname_async(connecthost, + connectport, connection_host_resolved, phb) != 0) + { + gaim_proxy_phb_destroy(phb); + return NULL; + } + + phbs = g_slist_prepend(phbs, phb); + + return phb; } -int +/* + * Combine some of this code with gaim_proxy_connect() + */ +GaimProxyConnectInfo * gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimInputFunction func, gpointer data) + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data) { - struct PHB *phb; + struct _GaimProxyConnectInfo *phb; - phb = g_new0(struct PHB, 1); - phb->gpi = gpi; - phb->func = func; + g_return_val_if_fail(host != NULL, NULL); + g_return_val_if_fail(port > 0, NULL); + g_return_val_if_fail(connect_cb != NULL, NULL); + /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ + + phb = g_new0(struct _GaimProxyConnectInfo, 1); + phb->connect_cb = connect_cb; + phb->error_cb = error_cb; phb->data = data; phb->host = g_strdup(host); phb->port = port; + phb->gpi = gpi; - return gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), - gaim_proxy_info_get_port(gpi), connection_host_resolved, phb); + if (gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), + gaim_proxy_info_get_port(gpi), connection_host_resolved, phb) != 0) + { + gaim_proxy_phb_destroy(phb); + return NULL; + } + + phbs = g_slist_prepend(phbs, phb); + + return phb; } @@ -2424,6 +2441,14 @@ gaim_proxy_info_set_password(info, value); } +void * +gaim_proxy_get_handle() +{ + static int handle; + + return &handle; +} + void gaim_proxy_init(void) { @@ -2458,10 +2483,9 @@ #endif } -void * -gaim_proxy_get_handle() +void +gaim_proxy_uninit(void) { - static int handle; - - return &handle; + while (phbs != NULL) + gaim_proxy_phb_destroy(phbs->data); } Modified: branches/v2_0_0/src/proxy.h =================================================================== --- branches/v2_0_0/src/proxy.h 2006-08-12 10:20:19 UTC (rev 16713) +++ branches/v2_0_0/src/proxy.h 2006-08-12 10:26:45 UTC (rev 16714) @@ -56,7 +56,18 @@ } GaimProxyInfo; +typedef struct _GaimProxyConnectInfo GaimProxyConnectInfo; +typedef void (*GaimProxyConnectFunction)(gpointer data, gint source); +typedef void (*GaimProxyErrorFunction)(gpointer dat, const gchar *error_message); + +/** + * The "hosts" parameter is a linked list containing pairs of + * one size_t addrlen and one struct sockaddr *addr. + */ +typedef void (*GaimProxyDnsConnectFunction)(GSList *hosts, gpointer data, const char *error_message); + + #include "account.h" #ifdef __cplusplus @@ -69,13 +80,6 @@ /*@{*/ /** - * Get the handle for the proxy system. - * - * @return the handle to the proxy system - */ -void *gaim_proxy_get_handle(void); - -/** * Creates a proxy information structure. * * @return The proxy information structure. @@ -196,11 +200,23 @@ /*@{*/ /** + * Returns the proxy subsystem handle. + * + * @return The proxy subsystem handle. + */ +void *gaim_proxy_get_handle(void); + +/** * Initializes the proxy subsystem. */ void gaim_proxy_init(void); /** + * Uninitializes the proxy subsystem. + */ +void gaim_proxy_uninit(void); + +/** * Returns configuration of a proxy. * * @param account The account for which the configuration is needed. @@ -210,35 +226,50 @@ GaimProxyInfo *gaim_proxy_get_setup(GaimAccount *account); /** - * Makes a connection to the specified host and port. + * Makes a connection to the specified host and port. Note that this + * function name can be misleading--although it is called "proxy + * connect," it is used for establishing any outgoing TCP connection, + * whether through a proxy or not. * - * @param account The account making the connection. - * @param host The destination host. - * @param port The destination port. - * @param func The input handler function. - * @param data User-defined data. + * @param account The account making the connection. + * @param host The destination host. + * @param port The destination port. + * @param connect_cb The function to call when the connection is + * established. + * @param error_cb The function to call if there is an error while + * establishing the connection. + * @param data User-defined data. * - * @return Zero indicates the connection is pending. Any other value indicates failure. + * @return NULL if there was an error, or a reference to a data + * structure that can be used to cancel the pending + * connection, if needed. */ -int gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimInputFunction func, gpointer data); +GaimProxyConnectInfo *gaim_proxy_connect(GaimAccount *account, + const char *host, int port, + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data); /** * Makes a connection through a SOCKS5 proxy. * - * @param gpi The GaimProxyInfo specifying the proxy settings - * @param host The destination host. - * @param port The destination port. - * @param func The input handler function. - * @param data User-defined data. + * @param gpi The GaimProxyInfo specifying the proxy settings + * @param host The destination host. + * @param port The destination port. + * @param connect_cb The function to call when the connection is + * established. + * @param error_cb The function to call if there is an error while + * establishing the connection. + * @param data User-defined data. * - * @return Zero indicates the connection is pending. Any other value indicates failure. + * @return NULL if there was an error, or a reference to a data + * structure that can be used to cancel the pending + * connection, if needed. */ -int gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimInputFunction func, gpointer data); +GaimProxyConnectInfo *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, + const char *host, int port, + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data); -typedef void (*dns_callback_t)(GSList *hosts, gpointer data, - const char *error_message); /** * Do an async dns query * @@ -249,7 +280,7 @@ * * @return Zero indicates the connection is pending. Any other value indicates failure. */ -int gaim_gethostbyname_async(const char *hostname, int port, dns_callback_t callback, gpointer data); +int gaim_gethostbyname_async(const char *hostname, int port, GaimProxyDnsConnectFunction callback, gpointer data); /*@}*/ Modified: branches/v2_0_0/src/sslconn.c =====================================================... [truncated message content] |
From: <the...@us...> - 2006-08-12 10:20:24
|
Revision: 16713 Author: thekingant Date: 2006-08-12 03:20:19 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16713&view=rev Log Message: ----------- Rename struct PHB to struct _GaimProxyConnectInfo Modified Paths: -------------- trunk/src/proxy.c trunk/src/proxy.h Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 10:12:43 UTC (rev 16712) +++ trunk/src/proxy.c 2006-08-12 10:20:19 UTC (rev 16713) @@ -39,7 +39,7 @@ #include "util.h" /* Does anyone know what PHB stands for? */ -struct PHB { +struct _GaimProxyConnectInfo { GaimProxyConnectFunction connect_cb; GaimProxyErrorFunction error_cb; gpointer data; @@ -72,7 +72,7 @@ static GaimProxyInfo *global_proxy_info = NULL; static GSList *phbs = NULL; -static void try_connect(struct PHB *); +static void try_connect(struct _GaimProxyConnectInfo *); /************************************************************************** * Proxy structure API @@ -258,7 +258,7 @@ **************************************************************************/ static void -gaim_proxy_phb_destroy(struct PHB *phb) +gaim_proxy_phb_destroy(struct _GaimProxyConnectInfo *phb) { phbs = g_slist_remove(phbs, phb); @@ -281,7 +281,7 @@ } static void -gaim_proxy_phb_connected(struct PHB *phb, int fd) +gaim_proxy_phb_connected(struct _GaimProxyConnectInfo *phb, int fd) { phb->connect_cb(phb->data, fd); gaim_proxy_phb_destroy(phb); @@ -293,7 +293,7 @@ * specified in the call to gaim_proxy_connect(). */ static void -gaim_proxy_phb_error(struct PHB *phb, const gchar *error_message) +gaim_proxy_phb_error(struct _GaimProxyConnectInfo *phb, const gchar *error_message) { if (phb->error_cb == NULL) { @@ -991,7 +991,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error=0, ret; @@ -1035,7 +1035,7 @@ static gboolean clean_connect(gpointer data) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; gaim_proxy_phb_connected(phb, phb->port); @@ -1044,7 +1044,7 @@ static int -proxy_connect_none(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1098,7 +1098,7 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; const guchar *request = phb->write_buffer + phb->written_len; gsize request_len = phb->write_buf_len - phb->written_len; @@ -1136,7 +1136,7 @@ { int len, headers_len, status = 0; gboolean error; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; guchar *p; gsize max_read; gchar *msg; @@ -1368,7 +1368,7 @@ { char request[8192]; int request_len = 0; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; @@ -1431,7 +1431,7 @@ } static int -proxy_connect_http(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1490,7 +1490,7 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; guchar *buf; int len, max_read; @@ -1532,7 +1532,7 @@ { unsigned char packet[9]; struct hostent *hp; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; @@ -1589,7 +1589,7 @@ } static int -proxy_connect_socks4(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1641,7 +1641,7 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -1723,7 +1723,7 @@ static void s5_sendconnect(gpointer data, int source) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int hlen = strlen(phb->host); phb->write_buf_len = 5 + hlen + 2; phb->write_buffer = g_malloc(phb->write_buf_len); @@ -1747,7 +1747,7 @@ static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -1840,7 +1840,7 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); @@ -1973,7 +1973,7 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; int len; if (phb->read_buffer == NULL) { @@ -2088,7 +2088,7 @@ { unsigned char buf[5]; int i; - struct PHB *phb = data; + struct _GaimProxyConnectInfo *phb = data; socklen_t len; int error = ETIMEDOUT; @@ -2135,7 +2135,7 @@ } static int -proxy_connect_socks5(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -2185,7 +2185,7 @@ return fd; } -static void try_connect(struct PHB *phb) +static void try_connect(struct _GaimProxyConnectInfo *phb) { size_t addrlen; struct sockaddr *addr; @@ -2237,7 +2237,7 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct PHB *phb = (struct PHB*)data; + struct _GaimProxyConnectInfo *phb = (struct _GaimProxyConnectInfo*)data; phb->hosts = hosts; @@ -2317,14 +2317,14 @@ { const char *connecthost = host; int connectport = port; - struct PHB *phb; + struct _GaimProxyConnectInfo *phb; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ - phb = g_new0(struct PHB, 1); + phb = g_new0(struct _GaimProxyConnectInfo, 1); phb->connect_cb = connect_cb; phb->error_cb = error_cb; phb->data = data; @@ -2379,14 +2379,14 @@ GaimProxyConnectFunction connect_cb, GaimProxyErrorFunction error_cb, gpointer data) { - struct PHB *phb; + struct _GaimProxyConnectInfo *phb; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ - phb = g_new0(struct PHB, 1); + phb = g_new0(struct _GaimProxyConnectInfo, 1); phb->connect_cb = connect_cb; phb->error_cb = error_cb; phb->data = data; Modified: trunk/src/proxy.h =================================================================== --- trunk/src/proxy.h 2006-08-12 10:12:43 UTC (rev 16712) +++ trunk/src/proxy.h 2006-08-12 10:20:19 UTC (rev 16713) @@ -56,7 +56,7 @@ } GaimProxyInfo; -typedef struct PBH GaimProxyConnectInfo; +typedef struct _GaimProxyConnectInfo GaimProxyConnectInfo; typedef void (*GaimProxyConnectFunction)(gpointer data, gint source); typedef void (*GaimProxyErrorFunction)(gpointer dat, const gchar *error_message); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 10:12:49
|
Revision: 16712 Author: thekingant Date: 2006-08-12 03:12:43 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16712&view=rev Log Message: ----------- Pretty large commit here. Basically I got sick of having to verify that gc is still valid on all the callback functions for gaim_proxy_connect(). The fix for this for gaim_proxy_connect() to return something that allows the connection attempt to be canceled. It's not quite there yet, but this is a good first step. I changed gaim_proxy_connect() to return a reference to a new GaimProxyConnectInfo (this used to be called PHB). Eventually this can be passed to a function that'll cancel the connection attempt. I also decided to add an error_cb instead of using connect_cb and passing a file descriptor of -1. And proxy.c will also pass an error message to callers which should explain the reason that the connection attempt failed. Oh, and proxy.c now never calls gaim_connection_error() Modified Paths: -------------- trunk/src/ft.c trunk/src/protocols/irc/irc.c trunk/src/protocols/jabber/jabber.c trunk/src/protocols/jabber/si.c trunk/src/protocols/msn/directconn.c trunk/src/protocols/msn/httpconn.c trunk/src/protocols/msn/servconn.c trunk/src/protocols/oscar/oscar.c trunk/src/protocols/oscar/peer.c trunk/src/protocols/oscar/peer.h trunk/src/protocols/oscar/peer_proxy.c trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/sametime/sametime.c trunk/src/protocols/silc/silc.c trunk/src/protocols/simple/simple.c trunk/src/protocols/yahoo/yahoo.c trunk/src/protocols/yahoo/yahoo_filexfer.c trunk/src/protocols/yahoo/yahoo_picture.c trunk/src/protocols/yahoo/yahoochat.c trunk/src/protocols/yahoo/ycht.c trunk/src/proxy.c trunk/src/proxy.h trunk/src/sslconn.c trunk/src/upnp.c trunk/src/util.c Modified: trunk/src/ft.c =================================================================== --- trunk/src/ft.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/ft.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -911,13 +911,13 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition condition) +connect_cb(gpointer data, gint source) { GaimXfer *xfer = (GaimXfer *)data; xfer->fd = source; - begin_transfer(xfer, condition); + begin_transfer(xfer, GAIM_INPUT_READ); } void @@ -946,7 +946,7 @@ /* Establish a file descriptor. */ gaim_proxy_connect(xfer->account, xfer->remote_ip, - xfer->remote_port, connect_cb, xfer); + xfer->remote_port, connect_cb, NULL, xfer); return; } Modified: trunk/src/protocols/irc/irc.c =================================================================== --- trunk/src/protocols/irc/irc.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/irc/irc.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -46,7 +46,7 @@ /* static GList *irc_chat_info(GaimConnection *gc); */ static void irc_login(GaimAccount *account); static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); -static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond); +static void irc_login_cb(gpointer data, gint source); static void irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, gpointer data); static void irc_close(GaimConnection *gc); static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags); @@ -283,7 +283,7 @@ struct irc_conn *irc; char **userparts; const char *username = gaim_account_get_username(account); - int err; + GaimProxyConnectInfo *connect_info; gc = gaim_account_get_connection(account); gc->flags |= GAIM_CONNECTION_NO_NEWLINES; @@ -325,11 +325,11 @@ if (!irc->gsc) { - err = gaim_proxy_connect(account, irc->server, + connect_info = gaim_proxy_connect(account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), - irc_login_cb, gc); + irc_login_cb, NULL, gc); - if (err || !gaim_account_get_connection(account)) { + if (!connect_info || !gaim_account_get_connection(account)) { gaim_connection_error(gc, _("Couldn't create socket")); return; } @@ -394,7 +394,7 @@ } } -static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond) +static void irc_login_cb(gpointer data, gint source) { GaimConnection *gc = data; struct irc_conn *irc = gc->proto_data; Modified: trunk/src/protocols/jabber/jabber.c =================================================================== --- trunk/src/protocols/jabber/jabber.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/jabber/jabber.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -421,7 +421,7 @@ static void -jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) +jabber_login_callback(gpointer data, gint source) { GaimConnection *gc = data; JabberStream *js = gc->proto_data; @@ -474,12 +474,12 @@ static void jabber_login_connect(JabberStream *js, const char *server, int port) { - int rc; + GaimProxyConnectInfo *connect_info; - rc = gaim_proxy_connect(js->gc->account, server, - port, jabber_login_callback, js->gc); + connect_info = gaim_proxy_connect(js->gc->account, server, + port, jabber_login_callback, NULL, js->gc); - if (rc != 0) + if (connect_info == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); } @@ -862,7 +862,7 @@ const char *connect_server = gaim_account_get_string(account, "connect_server", ""); const char *server; - int rc; + GaimProxyConnectInfo *connect_info; js = gc->proto_data = g_new0(JabberStream, 1); js->gc = gc; @@ -912,11 +912,11 @@ } if(!js->gsc) { - rc = gaim_proxy_connect(account, server, + connect_info = gaim_proxy_connect(account, server, gaim_account_get_int(account, "port", 5222), - jabber_login_callback, gc); + jabber_login_callback, NULL, gc); - if (rc != 0) + if (connect_info == NULL) gaim_connection_error(gc, _("Unable to create socket")); } } Modified: trunk/src/protocols/jabber/si.c =================================================================== --- trunk/src/protocols/jabber/si.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/jabber/si.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -88,7 +88,7 @@ static void jabber_si_bytestreams_attempt_connect(GaimXfer *xfer); -static void jabber_si_bytestreams_connect_cb(gpointer data, gint source, GaimInputCondition cond) +static void jabber_si_bytestreams_connect_cb(gpointer data, gint source) { GaimXfer *xfer = data; JabberSIXfer *jsx = xfer->data; @@ -167,7 +167,7 @@ for(i=0; i<20; i++, p+=2) snprintf(p, 3, "%02x", hashval[i]); - gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); + gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, NULL, xfer); g_free(dstaddr); } Modified: trunk/src/protocols/msn/directconn.c =================================================================== --- trunk/src/protocols/msn/directconn.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/msn/directconn.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -368,12 +368,12 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnDirectConn* directconn; int fd; - gaim_debug_misc("msn", "directconn: connect_cb: %d, %d.\n", source, cond); + gaim_debug_misc("msn", "directconn: connect_cb: %d\n", source); directconn = data; @@ -423,7 +423,7 @@ msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port) { MsnSession *session; - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(directconn != NULL, FALSE); g_return_val_if_fail(host != NULL, TRUE); @@ -438,10 +438,10 @@ } #endif - r = gaim_proxy_connect(session->account, host, port, connect_cb, - directconn); + connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, NULL, directconn); - if (r == 0) + if (connect_info != NULL) { return TRUE; } Modified: trunk/src/protocols/msn/httpconn.c =================================================================== --- trunk/src/protocols/msn/httpconn.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/msn/httpconn.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -693,7 +693,7 @@ } static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnHttpConn *httpconn = data; @@ -729,7 +729,7 @@ gboolean msn_httpconn_connect(MsnHttpConn *httpconn, const char *host, int port) { - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(httpconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); @@ -738,10 +738,10 @@ if (httpconn->connected) msn_httpconn_disconnect(httpconn); - r = gaim_proxy_connect(httpconn->session->account, - "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); + connect_info = gaim_proxy_connect(httpconn->session->account, + "gateway.messenger.hotmail.com", 80, connect_cb, NULL, httpconn); - if (r == 0) + if (connect_info != NULL) { httpconn->waiting_response = TRUE; httpconn->connected = TRUE; Modified: trunk/src/protocols/msn/servconn.c =================================================================== --- trunk/src/protocols/msn/servconn.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/msn/servconn.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -166,7 +166,7 @@ **************************************************************************/ static void -connect_cb(gpointer data, gint source, GaimInputCondition cond) +connect_cb(gpointer data, gint source) { MsnServConn *servconn = data; @@ -199,7 +199,7 @@ msn_servconn_connect(MsnServConn *servconn, const char *host, int port) { MsnSession *session; - int r; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(servconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); @@ -232,10 +232,10 @@ return TRUE; } - r = gaim_proxy_connect(session->account, host, port, connect_cb, - servconn); + connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, NULL, servconn); - if (r == 0) + if (connect_info != NULL) { servconn->processing = TRUE; return TRUE; Modified: trunk/src/protocols/oscar/oscar.c =================================================================== --- trunk/src/protocols/oscar/oscar.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/oscar/oscar.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -943,7 +943,7 @@ * on the type of host, we do a few different things here. */ static void -connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +connection_established_cb(gpointer data, gint source) { NewFlapConnectionData *new_conn_data; GaimConnection *gc; @@ -1250,7 +1250,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), - connection_established_cb, new_conn_data) < 0) + connection_established_cb, NULL, new_conn_data) == NULL) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -1294,7 +1294,8 @@ GaimConnection *gc = od->gc; GaimAccount *account = gc->account; char *host; int port; - int i, rc; + int i; + GaimProxyConnectInfo *connect_info; NewFlapConnectionData *new_conn_data; va_list ap; struct aim_authresp_info *info; @@ -1366,9 +1367,10 @@ new_conn_data->cookielen = info->cookielen; new_conn_data->cookie = g_memdup(info->cookie, info->cookielen); new_conn_data->data = NULL; - rc = gaim_proxy_connect(gc->account, host, port, connection_established_cb, new_conn_data); + connect_info = gaim_proxy_connect(gc->account, host, port, + connection_established_cb, NULL, new_conn_data); g_free(host); - if (rc < 0) { + if (connect_info == NULL) { gaim_connection_error(gc, _("Could Not Connect")); od->killme = TRUE; return 0; @@ -1479,7 +1481,9 @@ g_free(pos); } -static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { +static void +straight_to_hell(gpointer data, gint source) +{ struct pieceofcrap *pos = data; gchar *buf; @@ -1569,7 +1573,8 @@ pos->len = len; pos->modname = g_strdup(modname); - if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) + if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, + straight_to_hell, NULL, pos) == NULL) { char buf[256]; if (pos->modname) @@ -1660,7 +1665,7 @@ new_conn_data->data = NULL; } - if (gaim_proxy_connect(account, host, port, connection_established_cb, new_conn_data) != 0) + if (gaim_proxy_connect(account, host, port, connection_established_cb, NULL, new_conn_data) == NULL) { flap_connection_schedule_destroy(new_conn_data->conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); Modified: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/oscar/peer.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -470,7 +470,7 @@ * either connected or failed to connect. */ static void -peer_connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +peer_connection_established_cb(gpointer data, gint source) { NewPeerConnectionData *new_conn_data; GaimConnection *gc; @@ -668,7 +668,7 @@ } if (gaim_proxy_connect(account, conn->verifiedip, conn->port, - peer_connection_established_cb, new_conn_data) == 0) + peer_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; @@ -699,7 +699,7 @@ } if (gaim_proxy_connect(account, conn->clientip, conn->port, - peer_connection_established_cb, new_conn_data) == 0) + peer_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; @@ -760,7 +760,7 @@ if (gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, - peer_proxy_connection_established_cb, new_conn_data) == 0) + peer_proxy_connection_established_cb, NULL, new_conn_data) != NULL) { /* Connecting... */ return; Modified: trunk/src/protocols/oscar/peer.h =================================================================== --- trunk/src/protocols/oscar/peer.h 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/oscar/peer.h 2006-08-12 10:12:43 UTC (rev 16712) @@ -254,7 +254,7 @@ /* * For peer proxying */ -void peer_proxy_connection_established_cb(gpointer data, gint source, GaimInputCondition cond); +void peer_proxy_connection_established_cb(gpointer data, gint source); #if 0 int peer_oft_sendheader(OscarData *od, guint16 type, PeerConnection *peer_connection); Modified: trunk/src/protocols/oscar/peer_proxy.c =================================================================== --- trunk/src/protocols/oscar/peer_proxy.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/oscar/peer_proxy.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -326,7 +326,7 @@ * either connected or failed to connect. */ void -peer_proxy_connection_established_cb(gpointer data, gint source, GaimInputCondition cond) +peer_proxy_connection_established_cb(gpointer data, gint source) { NewPeerConnectionData *new_conn_data; GaimConnection *gc; Modified: trunk/src/protocols/qq/qq_proxy.c =================================================================== --- trunk/src/protocols/qq/qq_proxy.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/qq/qq_proxy.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -119,7 +119,7 @@ /* the callback function after socket is built * we setup the qq protocol related configuration here */ -static void _qq_got_login(gpointer data, gint source, GaimInputCondition cond) +static void _qq_got_login(gpointer data, gint source) { qq_data *qd; GaimConnection *gc; @@ -309,7 +309,7 @@ * and qq_udp_proxy.c to add UDP proxy support (thanks henry) * return the socket handle, -1 means fail */ static gint _proxy_connect_full (GaimAccount *account, const gchar *host, guint16 port, - GaimInputFunction func, gpointer data, gboolean use_tcp) + GaimProxyConnectFunction func, gpointer data, gboolean use_tcp) { GaimConnection *gc; qq_data *qd; @@ -319,8 +319,12 @@ qd->server_ip = g_strdup(host); qd->server_port = port; - return use_tcp ? gaim_proxy_connect(account, host, port, func, data) : /* TCP mode */ - _qq_udp_proxy_connect(account, host, port, func, data); /* UDP mode */ + if (use_tcp) + /* TCP mode */ + return (gaim_proxy_connect(account, host, port, func, NULL, data) == NULL); + else + /* UDP mode */ + return _qq_udp_proxy_connect(account, host, port, func, data); } /* establish a generic QQ connection Modified: trunk/src/protocols/sametime/sametime.c =================================================================== --- trunk/src/protocols/sametime/sametime.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/sametime/sametime.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -310,7 +310,7 @@ /* connection functions */ -static void connect_cb(gpointer data, gint source, GaimInputCondition cond); +static void connect_cb(gpointer data, gint source); /* ----- session ------ */ @@ -1409,7 +1409,7 @@ port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) || - gaim_proxy_connect(account, host, port, connect_cb, pd)) { + (gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL)) { mwSession_forceLogin(session); } @@ -1669,8 +1669,7 @@ /** Callback passed to gaim_proxy_connect when an account is logged in, and if the session logging in receives a redirect message */ -static void connect_cb(gpointer data, gint source, - GaimInputCondition cond) { +static void connect_cb(gpointer data, gint source) { struct mwGaimPluginData *pd = data; GaimConnection *gc = pd->gc; @@ -3684,7 +3683,7 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - if(gaim_proxy_connect(account, host, port, connect_cb, pd)) { + if(gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } Modified: trunk/src/protocols/silc/silc.c =================================================================== --- trunk/src/protocols/silc/silc.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/silc/silc.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -141,7 +141,7 @@ } static void -silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond) +silcgaim_login_connected(gpointer data, gint source) { GaimConnection *gc = data; SilcGaim sg; @@ -367,7 +367,8 @@ gaim_account_get_string(account, "server", "silc.silcnet.org"), gaim_account_get_int(account, "port", 706), - silcgaim_login_connected, gc)) { + silcgaim_login_connected, NULL, gc) == NULL) + { gaim_connection_error(gc, _("Unable to create connection")); return; } Modified: trunk/src/protocols/simple/simple.c =================================================================== --- trunk/src/protocols/simple/simple.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/simple/simple.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -421,7 +421,7 @@ static void simple_input_cb(gpointer data, gint source, GaimInputCondition cond); -static void send_later_cb(gpointer data, gint source, GaimInputCondition cond) { +static void send_later_cb(gpointer data, gint source) { GaimConnection *gc = data; struct simple_account_data *sip = gc->proto_data; struct sip_connection *conn; @@ -448,11 +448,12 @@ static void sendlater(GaimConnection *gc, const char *buf) { struct simple_account_data *sip = gc->proto_data; - int error = 0; + GaimProxyConnectInfo *connect_info; + if(!sip->connecting) { gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); - error = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); - if(error) { + connect_info = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, NULL, gc); + if(connect_info == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); } sip->connecting = TRUE; @@ -1452,7 +1453,7 @@ conn->inputhandler = gaim_input_add(newfd, GAIM_INPUT_READ, simple_input_cb, gc); } -static void login_cb(gpointer data, gint source, GaimInputCondition cond) { +static void login_cb(gpointer data, gint source) { GaimConnection *gc = data; struct simple_account_data *sip = gc->proto_data; struct sip_connection *conn; @@ -1536,7 +1537,7 @@ static void simple_tcp_connect_listen_cb(int listenfd, gpointer data) { struct simple_account_data *sip = (struct simple_account_data*) data; - int error = 0; + GaimProxyConnectInfo *connect_info; sip->listenfd = listenfd; if(sip->listenfd == -1) { @@ -1551,9 +1552,9 @@ gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname, sip->realport); /* open tcp connection to the server */ - error = gaim_proxy_connect(sip->account, sip->realhostname, - sip->realport, login_cb, sip->gc); - if(error) { + connect_info = gaim_proxy_connect(sip->account, sip->realhostname, + sip->realport, login_cb, NULL, sip->gc); + if(connect_info == NULL) { gaim_connection_error(sip->gc, _("Couldn't create socket")); } } Modified: trunk/src/protocols/yahoo/yahoo.c =================================================================== --- trunk/src/protocols/yahoo/yahoo.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/yahoo/yahoo.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -2239,7 +2239,7 @@ } } -static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_connected(gpointer data, gint source) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2266,7 +2266,7 @@ gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); } -static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_web_connected(gpointer data, gint source) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2348,7 +2348,7 @@ /* Now we have our cookies to login with. I'll go get the milk. */ if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_web_connected, gc) != 0) { + yahoo_got_web_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2390,7 +2390,7 @@ gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); } -static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_cookies(gpointer data, gint source) { GaimConnection *gc = data; @@ -2516,7 +2516,7 @@ "Host: login.yahoo.com\r\n\r\n"); g_hash_table_destroy(hash); yd->auth = g_string_free(url, FALSE); - if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { + if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2618,7 +2618,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, gc) != 0) + yahoo_got_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; @@ -2628,7 +2628,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, gc) != 0) + yahoo_got_connected, NULL, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; Modified: trunk/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -92,7 +92,7 @@ } -static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_receivefile_connected(gpointer data, gint source) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -162,7 +162,7 @@ gaim_xfer_start(xfer, source, NULL, 0); } -static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_sendfile_connected(gpointer data, gint source) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -263,7 +263,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) + yahoo_sendfile_connected, NULL, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -272,7 +272,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) + yahoo_sendfile_connected, NULL, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -280,8 +280,12 @@ } } } else { - xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port, - yahoo_receivefile_connected, xfer); + /* TODO: Using xfer->fd like this is probably a bad thing... */ + if (gaim_proxy_connect(account, xfer_data->host, xfer_data->port, + yahoo_receivefile_connected, NULL, xfer) == NULL) + xfer->fd = -1; + else + xfer->fd = 0; if (xfer->fd == -1) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); Modified: trunk/src/protocols/yahoo/yahoo_picture.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_picture.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/yahoo/yahoo_picture.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -406,7 +406,7 @@ } } -static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, GaimInputCondition condition) +static void yahoo_buddy_icon_upload_connected(gpointer data, gint source) { struct yahoo_buddy_icon_upload_data *d = data; struct yahoo_packet *pkt; @@ -484,7 +484,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, d) == -1) + yahoo_buddy_icon_upload_connected, NULL, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); @@ -492,7 +492,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, d) == -1) + yahoo_buddy_icon_upload_connected, NULL, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); Modified: trunk/src/protocols/yahoo/yahoochat.c =================================================================== --- trunk/src/protocols/yahoo/yahoochat.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/yahoo/yahoochat.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -1373,7 +1373,7 @@ } -static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_roomlist_got_connected(gpointer data, gint source) { struct yahoo_roomlist *yrl = data; GaimRoomlist *list = yrl->list; @@ -1449,8 +1449,8 @@ gaim_roomlist_set_fields(rl, fields); - if (gaim_proxy_connect(gaim_connection_get_account(gc), - yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0) + if (gaim_proxy_connect(gaim_connection_get_account(gc), yrl->host, 80, + yahoo_roomlist_got_connected, NULL, yrl) == NULL) { gaim_notify_error(gc, NULL, _("Connection problem"), _("Unable to fetch room list.")); yahoo_roomlist_cleanup(rl, yrl); @@ -1518,8 +1518,8 @@ yrl->ucat = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat); gaim_roomlist_room_add(list, yrl->ucat); - if (gaim_proxy_connect(list->account, - yrl->host, 80, yahoo_roomlist_got_connected, yrl) != 0) + if (gaim_proxy_connect(list->account, yrl->host, 80, + yahoo_roomlist_got_connected, NULL, yrl) == NULL) { gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Connection problem"), _("Unable to fetch room list.")); Modified: trunk/src/protocols/yahoo/ycht.c =================================================================== --- trunk/src/protocols/yahoo/ycht.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/protocols/yahoo/ycht.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -528,7 +528,7 @@ } } -static void ycht_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void ycht_got_connected(gpointer data, gint source) { YchtConn *ycht = data; GaimConnection *gc = ycht->gc; @@ -571,7 +571,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "ycht-server", YAHOO_YCHT_HOST), gaim_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT), - ycht_got_connected, ycht) != 0) + ycht_got_connected, NULL, ycht) == NULL) { ycht_connection_error(ycht, _("Connection problem")); return; Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/proxy.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -38,16 +38,15 @@ #include "proxy.h" #include "util.h" -static GaimProxyInfo *global_proxy_info = NULL; - +/* Does anyone know what PHB stands for? */ struct PHB { - GaimInputFunction func; + GaimProxyConnectFunction connect_cb; + GaimProxyErrorFunction error_cb; gpointer data; char *host; int port; - gint inpa; + guint inpa; GaimProxyInfo *gpi; - GaimAccount *account; GSList *hosts; guchar *write_buffer; gsize write_buf_len; @@ -58,8 +57,6 @@ gsize read_len; }; -static void try_connect(struct PHB *); - static const char *socks5errors[] = { "succeeded\n", "general SOCKS server failure\n", @@ -72,6 +69,11 @@ "Address type not supported\n" }; +static GaimProxyInfo *global_proxy_info = NULL; +static GSList *phbs = NULL; + +static void try_connect(struct PHB *); + /************************************************************************** * Proxy structure API **************************************************************************/ @@ -255,6 +257,63 @@ * Proxy API **************************************************************************/ +static void +gaim_proxy_phb_destroy(struct PHB *phb) +{ + phbs = g_slist_remove(phbs, phb); + + if (phb->inpa > 0) + gaim_input_remove(phb->inpa); + + while (phb->hosts != NULL) + { + /* Discard the length... */ + phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + /* Free the address... */ + g_free(phb->hosts->data); + phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + } + + g_free(phb->host); + g_free(phb->write_buffer); + g_free(phb->read_buffer); + g_free(phb); +} + +static void +gaim_proxy_phb_connected(struct PHB *phb, int fd) +{ + phb->connect_cb(phb->data, fd); + gaim_proxy_phb_destroy(phb); +} + +/** + * @param error An error message explaining why the connection + * failed. This will be passed to the callback function + * specified in the call to gaim_proxy_connect(). + */ +static void +gaim_proxy_phb_error(struct PHB *phb, const gchar *error_message) +{ + if (phb->error_cb == NULL) + { + /* + * TODO + * While we're transitioning to the new gaim_proxy_connect() + * code, not all callers supply an error_cb. If this is the + * case then they're expecting connect_cb to be called with + * an fd of -1 in the case of an error. Once all callers have + * been changed this whole if statement should be removed. + */ + phb->connect_cb(phb->data, -1); + gaim_proxy_phb_destroy(phb); + return; + } + + phb->error_cb(phb->data, error_message); + gaim_proxy_phb_destroy(phb); +} + #if defined(__unix__) || defined(__APPLE__) /* @@ -264,9 +323,9 @@ typedef struct { char *host; int port; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; - gint inpa; + guint inpa; int fd_in, fd_out; pid_t dns_pid; } pending_dns_request_t; @@ -285,7 +344,7 @@ typedef struct { dns_params_t params; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; } queued_dns_request_t; @@ -694,7 +753,7 @@ */ int -gaim_gethostbyname_async(const char *hostname, int port, dns_callback_t callback, gpointer data) +gaim_gethostbyname_async(const char *hostname, int port, GaimProxyDnsConnectFunction callback, gpointer data) { pending_dns_request_t *req = NULL; dns_params_t dns_params; @@ -767,7 +826,7 @@ typedef struct _dns_tdata { char *hostname; int port; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; gpointer data; GSList *hosts; char *errmsg; @@ -843,7 +902,7 @@ int gaim_gethostbyname_async(const char *hostname, int port, - dns_callback_t callback, gpointer data) + GaimProxyDnsConnectFunction callback, gpointer data) { dns_tdata *td; struct sockaddr_in sin; @@ -882,7 +941,7 @@ gpointer data; size_t addrlen; struct sockaddr *addr; - dns_callback_t callback; + GaimProxyDnsConnectFunction callback; } pending_dns_request_t; static gboolean host_resolved(gpointer data) @@ -898,7 +957,7 @@ int gaim_gethostbyname_async(const char *hostname, int port, - dns_callback_t callback, gpointer data) + GaimProxyDnsConnectFunction callback, gpointer data) { struct sockaddr_in sin; pending_dns_request_t *req; @@ -955,9 +1014,11 @@ if (ret == 0 && error == EINPROGRESS) return; /* we'll be called again later */ if (ret < 0 || error != 0) { - if(ret!=0) error = errno; + if (ret!=0) + error = errno; close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); @@ -967,30 +1028,17 @@ } gaim_input_remove(phb->inpa); + phb->inpa = 0; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); } static gboolean clean_connect(gpointer data) { struct PHB *phb = data; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { + gaim_proxy_phb_connected(phb, phb->port); - phb->func(phb->data, phb->port, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); - return FALSE; } @@ -1037,8 +1085,9 @@ close(fd); return -1; } + /* TODO: Why is the following line so strange? */ phb->port = fd; /* bleh */ - gaim_timeout_add(50, clean_connect, phb); /* we do this because we never + gaim_timeout_add(10, clean_connect, phb); /* we do this because we never want to call our callback before we return. */ } @@ -1059,6 +1108,7 @@ return; else if(ret < 0) { gaim_input_remove(phb->inpa); + phb->inpa = 0; close(source); g_free(phb->write_buffer); phb->write_buffer = NULL; @@ -1080,18 +1130,6 @@ #define HTTP_GOODSTRING "HTTP/1.0 200" #define HTTP_GOODSTRING2 "HTTP/1.1 200" -static void -http_complete(struct PHB *phb, gint source) -{ - gaim_debug_info("http proxy", "proxy connection established\n"); - if(!phb->account || phb->account->gc) { - phb->func(phb->data, source, GAIM_INPUT_READ); - } - g_free(phb->host); - g_free(phb); -} - - /* read the response to the CONNECT request, if we are requesting a non-port-80 tunnel */ static void http_canread(gpointer data, gint source, GaimInputCondition cond) @@ -1101,6 +1139,7 @@ struct PHB *phb = data; guchar *p; gsize max_read; + gchar *msg; if(phb->read_buffer == NULL) { phb->read_buf_len = 8192; @@ -1116,12 +1155,7 @@ return; else if(len <= 0) { close(source); - source = -1; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - gaim_input_remove(phb->inpa); - phb->inpa = 0; - http_complete(phb, source); + gaim_proxy_phb_error(phb, _("Lost connection with server for an unknown reason.")); return; } else { phb->read_len += len; @@ -1137,7 +1171,8 @@ return; error = strncmp((const char *)phb->read_buffer, "HTTP/", 5) != 0; - if(!error) { + if (!error) + { int major; p = phb->read_buffer + 5; major = strtol((const char *)p, (char **)&p, 10); @@ -1157,7 +1192,8 @@ /* Read the contents */ p = (guchar *)g_strrstr((const gchar *)phb->read_buffer, "Content-Length: "); - if(p != NULL) { + if (p != NULL) + { gchar *tmp; int len = 0; char tmpc; @@ -1180,25 +1216,22 @@ } } - if(error) { - gaim_debug_error("proxy", - "Unable to parse proxy's response: %s\n", + if (error) + { + close(source); + msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", phb->read_buffer); - close(source); - source = -1; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - gaim_input_remove(phb->inpa); - phb->inpa = 0; - http_complete(phb, source); + gaim_proxy_phb_error(phb, msg); + g_free(msg); return; - } else if(status != 200) { + } + else if (status != 200) + { gaim_debug_error("proxy", "Proxy server replied with:\n%s\n", phb->read_buffer); - /* XXX: why in the hell are we calling gaim_connection_error() here? */ if(status == 407 /* Proxy Auth */) { gchar *ntlm; if((ntlm = g_strrstr((const gchar *)phb->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ @@ -1208,19 +1241,13 @@ gchar *username; gchar *request; gchar *response; - if(!(username = strchr(domain, '\\'))) { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); + username = strchr(domain, '\\'); + if (username == NULL) + { close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } *username = '\0'; @@ -1264,19 +1291,13 @@ gchar *domain = (gchar*) gaim_proxy_info_get_username(phb->gpi); gchar *username; int request_len; - if(!(username = strchr(domain, '\\'))) { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); + username = strchr(domain, '\\'); + if (username == NULL) + { close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } *username = '\0'; @@ -1313,49 +1334,29 @@ proxy_do_write(phb, source, cond); return; } else { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); close(source); - source = -1; - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); return; } } if(status == 403 /* Forbidden */ ) { - gchar *msg = g_strdup_printf(_("Access denied: proxy server forbids port %d tunnelling."), phb->port); - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), phb->port); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); } else { - char *msg = g_strdup_printf(_("Proxy connection error %d"), status); - if(phb->account) - gaim_connection_error(phb->account->gc, msg); - else - gaim_debug_error("http proxy", "%s\n", msg); + msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); + gaim_proxy_phb_error(phb, msg); g_free(msg); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); } } else { gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; - http_complete(phb, source); + gaim_debug_info("proxy", "HTTP proxy connection established\n"); + gaim_proxy_phb_connected(phb, source); return; } } @@ -1374,7 +1375,10 @@ gaim_debug_info("http proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); @@ -1456,7 +1460,8 @@ phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, http_canwrite, phb); } else { - http_complete(phb, fd); + gaim_debug_info("proxy", "HTTP proxy connection established\n"); + gaim_proxy_phb_connected(phb, fd); } } else { close(fd); @@ -1507,21 +1512,13 @@ return; else if (len + phb->read_len >= 4) { if (phb->read_buffer[1] == 90) { - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); return; } } gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; @@ -1542,7 +1539,10 @@ gaim_debug_info("socks4 proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); @@ -1662,6 +1662,7 @@ gaim_debug_warning("socks5 proxy", "or not...\n"); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1679,6 +1680,7 @@ gaim_debug_error("socks5 proxy", "Bad data.\n"); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1715,20 +1717,11 @@ /* Skip past BND.PORT */ buf += 2; - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, source, GAIM_INPUT_READ); - } - - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_connected(phb, source); } static void -s5_sendconnect(gpointer data, gint source) +s5_sendconnect(gpointer data, int source) { struct PHB *phb = data; int hlen = strlen(phb->host); @@ -1749,7 +1742,6 @@ phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); proxy_do_write(phb, source, GAIM_INPUT_WRITE); - } static void @@ -1773,6 +1765,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1784,6 +1777,7 @@ return; gaim_input_remove(phb->inpa); + phb->inpa = 0; if ((phb->read_buffer[0] != 0x01) || (phb->read_buffer[1] != 0x00)) { close(source); @@ -1865,6 +1859,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1880,6 +1875,7 @@ if (*cmdbuf != 0x01) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1901,6 +1897,7 @@ /* Did auth work? */ if (buf[0] == 0x00) { gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; /* Success */ @@ -1913,6 +1910,7 @@ "failed. Disconnecting..."); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1957,6 +1955,7 @@ "Disconnecting..."); close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -1992,6 +1991,7 @@ else if(len <= 0) { close(source); gaim_input_remove(phb->inpa); + phb->inpa = 0; g_free(phb->read_buffer); phb->read_buffer = NULL; try_connect(phb); @@ -2003,6 +2003,7 @@ return; gaim_input_remove(phb->inpa); + phb->inpa = 0; if ((phb->read_buffer[0] != 0x05) || (phb->read_buffer[1] == 0xff)) { close(source); @@ -2094,7 +2095,10 @@ gaim_debug_info("socks5 proxy", "Connected.\n"); if (phb->inpa > 0) + { gaim_input_remove(phb->inpa); + phb->inpa = 0; + } len = sizeof(error); if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { @@ -2225,14 +2229,7 @@ } if (ret < 0) { - if (phb->account == NULL || - gaim_account_get_connection(phb->account) != NULL) { - - phb->func(phb->data, -1, GAIM_INPUT_READ); - } - - g_free(phb->host); - g_free(phb); + gaim_proxy_phb_error(phb, _("TODO")); } } @@ -2313,31 +2310,26 @@ return gpi; } -/* - * TODO: It would be really good if this returned some sort of handle - * that we could use to cancel the connection. As it is now, - * each callback has to check to make sure gc is still valid. - * And that is ugly. - */ -int +GaimProxyConnectInfo * gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimInputFunction func, gpointer data) + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data) { const char *connecthost = host; int connectport = port; struct PHB *phb; - g_return_val_if_fail(host != NULL, -1); - g_return_val_if_fail(port != 0 && port != -1, -1); - g_return_val_if_fail(func != NULL, -1); + g_return_val_if_fail(host != NULL, NULL); + g_return_val_if_fail(port > 0, NULL); + g_return_val_if_fail(connect_cb != NULL, NULL); + /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ phb = g_new0(struct PHB, 1); - - phb->func = func; + phb->connect_cb = connect_cb; + phb->error_cb = error_cb; phb->data = data; phb->host = g_strdup(host); phb->port = port; - phb->account = account; phb->gpi = gaim_proxy_get_setup(account); if ((gaim_proxy_info_get_type(phb->gpi) != GAIM_PROXY_NONE) && @@ -2345,9 +2337,8 @@ gaim_proxy_info_get_port(phb->gpi) <= 0)) { gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); - g_free(phb->host); - g_free(phb); - return -1; + gaim_proxy_phb_destroy(phb); + return NULL; } switch (gaim_proxy_info_get_type(phb->gpi)) @@ -2364,30 +2355,55 @@ break; default: - g_free(phb->host); - g_free(phb); - return -1; + gaim_proxy_phb_destroy(phb); + return NULL; } - return gaim_gethostbyname_async(connecthost, connectport, - connection_host_resolved, phb); + if (gaim_gethostbyname_async(connecthost, + connectport, connection_host_resolved, phb) != 0) + { + gaim_proxy_phb_destroy(phb); + return NULL; + } + + phbs = g_slist_prepend(phbs, phb); + + return phb; } -int +/* + * Combine some of this code with gaim_proxy_connect() + */ +GaimProxyConnectInfo * gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimInputFunction func, gpointer data) + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data) { struct PHB *phb; + g_return_val_if_fail(host != NULL, NULL); + g_return_val_if_fail(port > 0, NULL); + g_return_val_if_fail(connect_cb != NULL, NULL); + /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ + phb = g_new0(struct PHB, 1); - phb->gpi = gpi; - phb->func = func; + phb->connect_cb = connect_cb; + phb->error_cb = error_cb; phb->data = data; phb->host = g_strdup(host); phb->port = port; + phb->gpi = gpi; - return gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), - gaim_proxy_info_get_port(gpi), connection_host_resolved, phb); + if (gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), + gaim_proxy_info_get_port(gpi), connection_host_resolved, phb) != 0) + { + gaim_proxy_phb_destroy(phb); + return NULL; + } + + phbs = g_slist_prepend(phbs, phb); + + return phb; } @@ -2425,6 +2441,14 @@ gaim_proxy_info_set_password(info, value); } +void * +gaim_proxy_get_handle() +{ + static int handle; + + return &handle; +} + void gaim_proxy_init(void) { @@ -2459,10 +2483,9 @@ #endif } -void * -gaim_proxy_get_handle() +void +gaim_proxy_uninit(void) { - static int handle; - - return &handle; + while (phbs != NULL) + gaim_proxy_phb_destroy(phbs->data); } Modified: trunk/src/proxy.h =================================================================== --- trunk/src/proxy.h 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/proxy.h 2006-08-12 10:12:43 UTC (rev 16712) @@ -56,7 +56,18 @@ } GaimProxyInfo; +typedef struct PBH GaimProxyConnectInfo; +typedef void (*GaimProxyConnectFunction)(gpointer data, gint source); +typedef void (*GaimProxyErrorFunction)(gpointer dat, const gchar *error_message); + +/** + * The "hosts" parameter is a linked list containing pairs of + * one size_t addrlen and one struct sockaddr *addr. + */ +typedef void (*GaimProxyDnsConnectFunction)(GSList *hosts, gpointer data, const char *error_message); + + #include "account.h" #ifdef __cplusplus @@ -69,13 +80,6 @@ /*@{*/ /** - * Get the handle for the proxy system. - * - * @return the handle to the proxy system - */ -void *gaim_proxy_get_handle(void); - -/** * Creates a proxy information structure. * * @return The proxy information structure. @@ -196,11 +200,23 @@ /*@{*/ /** + * Returns the proxy subsystem handle. + * + * @return The proxy subsystem handle. + */ +void *gaim_proxy_get_handle(void); + +/** * Initializes the proxy subsystem. */ void gaim_proxy_init(void); /** + * Uninitializes the proxy subsystem. + */ +void gaim_proxy_uninit(void); + +/** * Returns configuration of a proxy. * * @param account The account for which the configuration is needed. @@ -210,35 +226,50 @@ GaimProxyInfo *gaim_proxy_get_setup(GaimAccount *account); /** - * Makes a connection to the specified host and port. + * Makes a connection to the specified host and port. Note that this + * function name can be misleading--although it is called "proxy + * connect," it is used for establishing any outgoing TCP connection, + * whether through a proxy or not. * - * @param account The account making the connection. - * @param host The destination host. - * @param port The destination port. - * @param func The input handler function. - * @param data User-defined data. + * @param account The account making the connection. + * @param host The destination host. + * @param port The destination port. + * @param connect_cb The function to call when the connection is + * established. + * @param error_cb The function to call if there is an error while + * establishing the connection. + * @param data User-defined data. * - * @return Zero indicates the connection is pending. Any other value indicates failure. + * @return NULL if there was an error, or a reference to a data + * structure that can be used to cancel the pending + * connection, if needed. */ -int gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimInputFunction func, gpointer data); +GaimProxyConnectInfo *gaim_proxy_connect(GaimAccount *account, + const char *host, int port, + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data); /** * Makes a connection through a SOCKS5 proxy. * - * @param gpi The GaimProxyInfo specifying the proxy settings - * @param host The destination host. - * @param port The destination port. - * @param func The input handler function. - * @param data User-defined data. + * @param gpi The GaimProxyInfo specifying the proxy settings + * @param host The destination host. + * @param port The destination port. + * @param connect_cb The function to call when the connection is + * established. + * @param error_cb The function to call if there is an error while + * establishing the connection. + * @param data User-defined data. * - * @return Zero indicates the connection is pending. Any other value indicates failure. + * @return NULL if there was an error, or a reference to a data + * structure that can be used to cancel the pending + * connection, if needed. */ -int gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimInputFunction func, gpointer data); +GaimProxyConnectInfo *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, + const char *host, int port, + GaimProxyConnectFunction connect_cb, + GaimProxyErrorFunction error_cb, gpointer data); -typedef void (*dns_callback_t)(GSList *hosts, gpointer data, - const char *error_message); /** * Do an async dns query * @@ -249,7 +280,7 @@ * * @return Zero indicates the connection is pending. Any other value indicates failure. */ -int gaim_gethostbyname_async(const char *hostname, int port, dns_callback_t callback, gpointer data); +int gaim_gethostbyname_async(const char *hostname, int port, GaimProxyDnsConnectFunction callback, gpointer data); /*@}*/ Modified: trunk/src/sslconn.c =================================================================== --- trunk/src/sslconn.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/sslconn.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -69,7 +69,7 @@ { GaimSslConnection *gsc; GaimSslOps *ops; - int i; + GaimProxyConnectInfo *connect_info; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port != 0 && port != -1, NULL); @@ -95,9 +95,9 @@ gsc->connect_cb = func; gsc->error_cb = error_func; - i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); + connect_info = gaim_proxy_connect(account, host, port, ops->connect_cb, NULL, gsc); - if (i < 0) + if (connect_info == NULL) { g_free(gsc->host); g_free(gsc); Modified: trunk/src/upnp.c =================================================================== --- trunk/src/upnp.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/upnp.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -780,15 +780,15 @@ } static void -looked_up_internal_ip_cb(gpointer data, gint sock, GaimInputCondition cond) +looked_up_internal_ip_cb(gpointer data, gint source) { - if (sock) { + if (source) { strncpy(control_info.internalip, - gaim_network_get_local_system_ip(sock), + gaim_network_get_local_system_ip(source), sizeof(control_info.internalip)); gaim_debug_info("upnp", "Local IP: %s\n", control_info.internalip); - close(sock); + close(source); } else gaim_debug_info("upnp", "Unable to look up local IP\n"); @@ -811,8 +811,8 @@ } if(gaim_proxy_connect(NULL, addressOfControl, port, - looked_up_internal_ip_cb, NULL) != 0) { - + looked_up_internal_ip_cb, NULL, NULL) == NULL) + { gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d\n", addressOfControl, port); } Modified: trunk/src/util.c =================================================================== --- trunk/src/util.c 2006-08-12 10:06:15 UTC (rev 16711) +++ trunk/src/util.c 2006-08-12 10:12:43 UTC (rev 16712) @@ -3367,7 +3367,7 @@ } static void -url_fetch_connect_cb(gpointer url_data, gint source, GaimInputCondition cond) +url_fetch_connect_cb(gpointer url_data, gint source) { GaimFetchUrlData *gfud; @@ -3448,7 +3448,8 @@ &gfud->website.page, &gfud->website.user, &gfud->website.passwd); if (gaim_proxy_connect(NULL, gfud->website.address, - gfud->website.port, url_fetch_connect_cb, gfud) != 0) { + gfud->website.port, url_fetch_connect_cb, NULL, gfud) == NULL) + { destroy_fetch_url_data(gfud); cb(user_data, g_strdup(_("g003: Error opening connection.\n")), 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 10:06:22
|
Revision: 16711 Author: thekingant Date: 2006-08-12 03:06:15 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16711&view=rev Log Message: ----------- Get rid of an assert when editing an account that has no icon Modified Paths: -------------- trunk/src/gtkaccount.c Modified: trunk/src/gtkaccount.c =================================================================== --- trunk/src/gtkaccount.c 2006-08-11 19:56:55 UTC (rev 16710) +++ trunk/src/gtkaccount.c 2006-08-12 10:06:15 UTC (rev 16711) @@ -210,7 +210,8 @@ } gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_entry), pixbuf); - g_object_unref(G_OBJECT(pixbuf)); + if (pixbuf != NULL) + g_object_unref(G_OBJECT(pixbuf)); g_free(filename); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 19:57:08
|
Revision: 16710 Author: datallah Date: 2006-08-11 12:56:55 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16710&view=rev Log Message: ----------- Fix CID 101. Also fix the behavior of adding a group to a fields list so that it doesn't matter if you add the group to a fields list before you add fields to the group or not. Modified Paths: -------------- trunk/src/request.c Modified: trunk/src/request.c =================================================================== --- trunk/src/request.c 2006-08-11 19:02:47 UTC (rev 16709) +++ trunk/src/request.c 2006-08-11 19:56:55 UTC (rev 16710) @@ -84,7 +84,13 @@ field = l->data; g_hash_table_insert(fields->fields, - g_strdup(gaim_request_field_get_id(field)), field); + g_strdup(gaim_request_field_get_id(field)), field); + + if (gaim_request_field_is_required(field)) { + fields->required_fields = + g_list_append(fields->required_fields, field); + } + } } @@ -280,15 +286,16 @@ { g_hash_table_insert(group->fields_list->fields, g_strdup(gaim_request_field_get_id(field)), field); + + if (gaim_request_field_is_required(field)) + { + group->fields_list->required_fields = + g_list_append(group->fields_list->required_fields, field); + } } field->group = group; - if (gaim_request_field_is_required(field)) - { - group->fields_list->required_fields = - g_list_append(group->fields_list->required_fields, field); - } } const char * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 19:02:52
|
Revision: 16709 Author: datallah Date: 2006-08-11 12:02:47 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16709&view=rev Log Message: ----------- Deal with inability to create key pair. (CID 139) Modified Paths: -------------- trunk/src/protocols/silc/util.c Modified: trunk/src/protocols/silc/util.c =================================================================== --- trunk/src/protocols/silc/util.c 2006-08-11 18:35:26 UTC (rev 16708) +++ trunk/src/protocols/silc/util.c 2006-08-11 19:02:47 UTC (rev 16709) @@ -205,12 +205,20 @@ /* If file doesn't exist */ if (errno == ENOENT) { gaim_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); - silc_create_key_pair(SILCGAIM_DEF_PKCS, + if (!silc_create_key_pair(SILCGAIM_DEF_PKCS, SILCGAIM_DEF_PKCS_LEN, file_public_key, file_private_key, NULL, (gc->password == NULL) ? "" : gc->password, - NULL, NULL, NULL, FALSE); - g_stat(file_public_key, &st); + NULL, NULL, NULL, FALSE)) { + gaim_debug_error("silc", "Couldn't create key pair\n"); + return FALSE; + } + + if ((g_stat(file_public_key, &st)) == -1) { + gaim_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", + file_public_key, strerror(errno)); + return FALSE; + } } else { gaim_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", file_public_key, strerror(errno)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 18:35:30
|
Revision: 16708 Author: datallah Date: 2006-08-11 11:35:26 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16708&view=rev Log Message: ----------- Fix CID 122 - Avoid an assert when the conversation has been closed before a custom emoticon finishes loading Modified Paths: -------------- trunk/src/protocols/msn/slp.c Modified: trunk/src/protocols/msn/slp.c =================================================================== --- trunk/src/protocols/msn/slp.c 2006-08-11 13:35:26 UTC (rev 16707) +++ trunk/src/protocols/msn/slp.c 2006-08-11 18:35:26 UTC (rev 16708) @@ -768,14 +768,15 @@ gc = slpcall->slplink->session->account->gc; who = slpcall->slplink->remote_user; - conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, gc->account); + if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, gc->account))) { - /* FIXME: it would be better if we wrote the data as we received it - instead of all at once, calling write multiple times and - close once at the very end - */ - gaim_conv_custom_smiley_write(conv, slpcall->data_info, data, size); - gaim_conv_custom_smiley_close(conv, slpcall->data_info ); + /* FIXME: it would be better if we wrote the data as we received it + instead of all at once, calling write multiple times and + close once at the very end + */ + gaim_conv_custom_smiley_write(conv, slpcall->data_info, data, size); + gaim_conv_custom_smiley_close(conv, slpcall->data_info); + } #ifdef MSN_DEBUG_UD gaim_debug_info("msn", "Got smiley: %s\n", slpcall->data_info); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 13:35:52
|
Revision: 16707 Author: datallah Date: 2006-08-11 06:35:26 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16707&view=rev Log Message: ----------- Merge of the changes I made yesterday in trunk (16687:16701) Modified Paths: -------------- branches/v2_0_0/plugins/log_reader.c branches/v2_0_0/src/account.c branches/v2_0_0/src/gtkblist.c branches/v2_0_0/src/plugin.c branches/v2_0_0/src/protocols/jabber/buddy.c branches/v2_0_0/src/protocols/jabber/jabber.c branches/v2_0_0/src/protocols/msn/nexus.c branches/v2_0_0/src/protocols/oscar/family_oservice.c branches/v2_0_0/src/protocols/simple/simple.c branches/v2_0_0/src/protocols/simple/simple.h branches/v2_0_0/src/protocols/simple/sipmsg.c branches/v2_0_0/src/protocols/simple/sipmsg.h branches/v2_0_0/src/protocols/yahoo/yahoo.c Modified: branches/v2_0_0/plugins/log_reader.c =================================================================== --- branches/v2_0_0/plugins/log_reader.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/plugins/log_reader.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -790,6 +790,7 @@ time_t time_unix; struct tm *tm_new; char *timestamp; + char *tmp; const char *style; new_session_id = xmlnode_get_attrib(message, "SessionID"); @@ -900,7 +901,7 @@ !isalnum(*(from_name + alias_length))); - to_name_matches = (gaim_str_has_prefix( + to_name_matches = to_name && (gaim_str_has_prefix( to_name, alias) && !isalnum(*(to_name + alias_length))); @@ -982,16 +983,18 @@ style = xmlnode_get_attrib(text_node, "Style"); + tmp = xmlnode_get_data(text_node); if (style && *style) { text = g_string_append(text, "<span style=\""); text = g_string_append(text, style); text = g_string_append(text, "\">"); - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "</span>\n"); } else { - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "\n"); } + g_free(tmp); } data->text = text; @@ -1462,7 +1465,7 @@ g_string_append(formatted, "<span style=\"color: #ff0000;\">"); - + if (gaim_str_has_prefix(line, "Your previous message has not been sent. " "Reason: Maximum length exceeded.")) { @@ -1682,10 +1685,11 @@ char buffer[1024] = ""; DWORD size = (sizeof(buffer) - 1); DWORD type; + gboolean found = FALSE; path = NULL; /* TODO: Test this after removing the trailing "\\". */ - if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", + if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", 0, KEY_QUERY_VALUE, &hKey)) { if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { @@ -1720,20 +1724,18 @@ if (!path) { char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); - if (folder) + if (folder) { path = g_build_filename(folder, "Trillian", "users", "default", "talk.ini", NULL); g_free(folder); } } - gboolean found = FALSE; - if (path) { /* Read talk.ini file to find the log directory. */ GError *error = NULL; -#if 0 && GTK_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ +#if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ GKeyFile *key_file; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", @@ -1760,9 +1762,9 @@ g_key_file_free(key_file); } -#else /* !GTK_CHECK_VERSION(2,6,0) */ - GError *error = NULL; +#else /* !GLIB_CHECK_VERSION(2,6,0) */ gsize length; + gchar *contents = NULL; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", "Reading %s\n", path); Modified: branches/v2_0_0/src/account.c =================================================================== --- branches/v2_0_0/src/account.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/account.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -696,14 +696,14 @@ if ((protocol_id == NULL) || (name == NULL)) { - free(protocol_id); - free(name); + g_free(protocol_id); + g_free(name); return NULL; } ret = gaim_account_new(name, protocol_id); - free(name); - free(protocol_id); + g_free(name); + g_free(protocol_id); /* Read the password */ child = xmlnode_get_child(node, "password"); Modified: branches/v2_0_0/src/gtkblist.c =================================================================== --- branches/v2_0_0/src/gtkblist.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/gtkblist.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -2989,10 +2989,8 @@ else { text = g_strdup_printf("%s\n" - "<span color='%s' size='smaller'>%s%s%s</span>", + "<span color='%s' size='smaller'>%s</span>", esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", statustext != NULL ? statustext : ""); } } @@ -3584,8 +3582,8 @@ hbox = gtk_hbox_new(FALSE, 0); /* Create the icon */ - status_type = gaim_account_get_status_type_with_primitive(account, - GAIM_STATUS_OFFLINE); + if ((status_type = gaim_account_get_status_type_with_primitive(account, + GAIM_STATUS_OFFLINE))) { pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); if (pixbuf != NULL) { image = gtk_image_new_from_pixbuf(pixbuf); @@ -3594,6 +3592,7 @@ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, GAIM_HIG_BOX_SPACE); } + } /* Create the text */ label = gtk_label_new(""); Modified: branches/v2_0_0/src/plugin.c =================================================================== --- branches/v2_0_0/src/plugin.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/plugin.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -1232,7 +1232,7 @@ plugin->path); gaim_plugin_load(plugin); } - else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL) + else if (basename && (plugin = gaim_plugins_find_with_basename(basename)) != NULL) { gaim_debug_info("plugins", "Loading saved plugin %s\n", plugin->path); Modified: branches/v2_0_0/src/protocols/jabber/buddy.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -532,8 +532,8 @@ GaimRequestFieldGroup *group; GaimRequestField *field; const struct vcard_template *vc_tp; - char *user_info; - char *cdata; + const char *user_info; + char *cdata = NULL; xmlnode *x_vc_data = NULL; fields = gaim_request_fields_new(); @@ -543,10 +543,8 @@ /* * Get existing, XML-formatted, user info */ - if((user_info = g_strdup(gaim_account_get_user_info(gc->account))) != NULL) + if((user_info = gaim_account_get_user_info(gc->account)) != NULL) x_vc_data = xmlnode_from_str(user_info, -1); - else - user_info = g_strdup(""); /* * Set up GSLists for edit with labels from "template," data from user info @@ -555,17 +553,18 @@ xmlnode *data_node; if((vc_tp->label)[0] == '\0') continue; - if(vc_tp->ptag == NULL) { - data_node = xmlnode_get_child(x_vc_data, vc_tp->tag); - } else { - gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); - data_node = xmlnode_get_child(x_vc_data, tag); - g_free(tag); + + if (x_vc_data != NULL) { + if(vc_tp->ptag == NULL) { + data_node = xmlnode_get_child(x_vc_data, vc_tp->tag); + } else { + gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); + data_node = xmlnode_get_child(x_vc_data, tag); + g_free(tag); + } + if(data_node) + cdata = xmlnode_get_data(data_node); } - if(data_node) - cdata = xmlnode_get_data(data_node); - else - cdata = NULL; if(strcmp(vc_tp->tag, "DESC") == 0) { field = gaim_request_field_string_new(vc_tp->tag, @@ -577,14 +576,15 @@ FALSE); } + g_free(cdata); + cdata = NULL; + gaim_request_field_group_add_field(group, field); } if(x_vc_data != NULL) xmlnode_free(x_vc_data); - g_free(user_info); - gaim_request_fields(gc, _("Edit Jabber vCard"), _("Edit Jabber vCard"), _("All items below are optional. Enter only the " @@ -724,8 +724,7 @@ static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) { - const char *type, *id, *from; - JabberBuddy *jb; + const char *id, *from; GString *info_text; char *bare_jid; char *text; @@ -734,18 +733,17 @@ JabberBuddyInfo *jbi = data; from = xmlnode_get_attrib(packet, "from"); - type = xmlnode_get_attrib(packet, "type"); id = xmlnode_get_attrib(packet, "id"); - jabber_buddy_info_remove_id(jbi, id); - if(!jbi) return; + jabber_buddy_info_remove_id(jbi, id); + if(!from) return; - if(!(jb = jabber_buddy_find(js, from, TRUE))) + if(!jabber_buddy_find(js, from, FALSE)) return; /* XXX: handle the error case */ Modified: branches/v2_0_0/src/protocols/jabber/jabber.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -838,6 +838,8 @@ _("Register New Jabber Account"), instructions, fields, _("Register"), G_CALLBACK(jabber_register_cb), _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); + + g_free(instructions); } } Modified: branches/v2_0_0/src/protocols/msn/nexus.c =================================================================== --- branches/v2_0_0/src/protocols/msn/nexus.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/msn/nexus.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -422,8 +422,8 @@ if ((da_login = strstr(base, "DALogin=")) != NULL) { - if ((da_login = strchr(da_login, '=')) != NULL) - da_login++; + /* skip over "DALogin=" */ + da_login += 8; if ((c = strchr(da_login, ',')) != NULL) *c = '\0'; Modified: branches/v2_0_0/src/protocols/oscar/family_oservice.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/family_oservice.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/oscar/family_oservice.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -1028,13 +1028,6 @@ byte_stream_put32(&frame->data, 0xa46d3b39); #endif - } else if ((offset == 0x00001000) && (len == 0x00000000)) { - - byte_stream_put32(&frame->data, 0xd41d8cd9); - byte_stream_put32(&frame->data, 0x8f00b204); - byte_stream_put32(&frame->data, 0xe9800998); - byte_stream_put32(&frame->data, 0xecf8427e); - } else gaim_debug_warning("oscar", "sendmemblock: unknown hash request\n"); Modified: branches/v2_0_0/src/protocols/simple/simple.c =================================================================== --- branches/v2_0_0/src/protocols/simple/simple.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/simple/simple.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -130,7 +130,8 @@ return NULL; } -static struct simple_watcher *watcher_find(struct simple_account_data *sip, gchar *name) { +static struct simple_watcher *watcher_find(struct simple_account_data *sip, + const gchar *name) { struct simple_watcher *watcher; GSList *entry = sip->watcher; while(entry) { @@ -141,7 +142,9 @@ return NULL; } -static struct simple_watcher *watcher_create(struct simple_account_data *sip, gchar *name, gchar *callid, gchar *ourtag, gchar *theirtag, int needsxpidf) { +static struct simple_watcher *watcher_create(struct simple_account_data *sip, + const gchar *name, const gchar *callid, const gchar *ourtag, + const gchar *theirtag, gboolean needsxpidf) { struct simple_watcher *watcher = g_new0(struct simple_watcher, 1); watcher->name = g_strdup(name); watcher->dialog.callid = g_strdup(callid); @@ -152,7 +155,7 @@ return watcher; } -static void watcher_remove(struct simple_account_data *sip, gchar *name) { +static void watcher_remove(struct simple_account_data *sip, const gchar *name) { struct simple_watcher *watcher = watcher_find(sip, name); sip->watcher = g_slist_remove(sip->watcher, watcher); g_free(watcher->name); @@ -299,8 +302,9 @@ return ret; } -static char *parse_attribute(const char *attrname, char *source) { - char *tmp, *tmp2, *retval = NULL; +static char *parse_attribute(const char *attrname, const char *source) { + const char *tmp, *tmp2; + char *retval = NULL; int len = strlen(attrname); if(!strncmp(source, attrname, len)) { @@ -524,7 +528,8 @@ g_string_free(outstr, TRUE); } -static void send_sip_response(GaimConnection *gc, struct sipmsg *msg, int code, char *text, char *body) { +static void send_sip_response(GaimConnection *gc, struct sipmsg *msg, int code, + const char *text, const char *body) { GSList *tmp = msg->headers; gchar *name; gchar *value; @@ -560,7 +565,7 @@ g_free(trans); } -static void transactions_add_buf(struct simple_account_data *sip, gchar *buf, void *callback) { +static void transactions_add_buf(struct simple_account_data *sip, const gchar *buf, void *callback) { struct transaction *trans = g_new0(struct transaction, 1); trans->time = time(NULL); trans->msg = sipmsg_parse_msg(buf); @@ -593,6 +598,7 @@ char *auth = ""; const char *addh = ""; gchar *branch = genbranch(); + gchar *tag = NULL; char *buf; if(!strcmp(method, "REGISTER")) { @@ -618,6 +624,9 @@ gaim_debug(GAIM_DEBUG_MISC, "simple", "header %s", auth); } + if (!dialog) + tag = gentag(); + buf = g_strdup_printf("%s %s SIP/2.0\r\n" "Via: SIP/2.0/%s %s:%d;branch=%s\r\n" /* Don't know what epid is, but LCS wants it */ @@ -637,7 +646,7 @@ branch, sip->username, sip->servername, - dialog ? dialog->ourtag : gentag(), + dialog ? dialog->ourtag : tag, to, dialog ? ";tag=" : "", dialog ? dialog->theirtag : "", @@ -648,6 +657,9 @@ addh, strlen(body), body); + + g_free(tag); + g_free(auth); g_free(branch); g_free(callid); @@ -691,30 +703,30 @@ do_register_exp(sip, sip->registerexpire); } -static gchar *parse_from(gchar *hdr) { - gchar *from = hdr; - gchar *tmp; +static gchar *parse_from(const gchar *hdr) { + gchar *from; + const gchar *tmp, *tmp2 = hdr; - if(!from) return NULL; - gaim_debug_info("simple", "parsing address out of %s\n", from); - tmp = strchr(from, '<'); + if(!hdr) return NULL; + gaim_debug_info("simple", "parsing address out of %s\n", hdr); + tmp = strchr(hdr, '<'); /* i hate the different SIP UA behaviours... */ if(tmp) { /* sip address in <...> */ - from = tmp+1; - tmp = strchr(from, '>'); + tmp2 = tmp + 1; + tmp = strchr(tmp2, '>'); if(tmp) { - from = g_strndup(from, tmp-from); + from = g_strndup(tmp2, tmp - tmp2); } else { gaim_debug_info("simple", "found < without > in From\n"); return NULL; } } else { - tmp = strchr(from, ';'); + tmp = strchr(tmp2, ';'); if(tmp) { - from = g_strndup(from, tmp-from); + from = g_strndup(tmp2, tmp - tmp2); } else { - from = g_strdup(from); + from = g_strdup(tmp2); } } gaim_debug_info("simple", "got %s\n", from); @@ -722,12 +734,14 @@ } static gboolean process_subscribe_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { - gchar *to = parse_from(sipmsg_find_header(tc->msg, "To")); /* cant be NULL since it is our own msg */ + gchar *to; if(msg->response == 200 || msg->response == 202) { return TRUE; } + to = parse_from(sipmsg_find_header(tc->msg, "To")); /* cant be NULL since it is our own msg */ + /* we can not subscribe -> user is offline (TODO unknown status?) */ gaim_prpl_got_user_status(sip->account, to, "offline", NULL); @@ -740,7 +754,7 @@ gchar *to; gchar *tmp; - if(strstr(buddy->name,"sip:")) + if(strstr(buddy->name, "sip:")) to = g_strdup(buddy->name); else to = g_strdup_printf("sip:%s", buddy->name); @@ -768,43 +782,50 @@ xmlnode *item, *group, *isc; const char *name_group; GaimBuddy *b; - GaimGroup *g; + GaimGroup *g = NULL; struct simple_buddy *bs; int len = msg->bodylen; tmp = sipmsg_find_header(msg, "Event"); - if(tmp && !strncmp(tmp,"vnd-microsoft-roaming-contacts",30)){ + if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ - gaim_debug_info("simple","simple_add_lcs_contacts->%s-%d\n",msg->body, len); + gaim_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len); /*Convert the contact from XML to Gaim Buddies*/ - isc = xmlnode_from_str(msg->body, len); + isc = xmlnode_from_str(msg->body, len); /* ToDo. Find for all groups */ - group = xmlnode_get_child(isc, "group"); - name_group = xmlnode_get_attrib(group, "name"); - gaim_debug_info("simple","name_group->%s\n",name_group); - g = gaim_find_group(name_group); - if(!g) { + if ((group = xmlnode_get_child(isc, "group"))) { + name_group = xmlnode_get_attrib(group, "name"); + gaim_debug_info("simple", "name_group->%s\n", name_group); + g = gaim_find_group(name_group); + if(!g) + g = gaim_group_new(name_group); + } + + if (!g) { g = gaim_find_group("Buddies"); - if(!g){ + if(!g) g = gaim_group_new("Buddies"); - } - }else{ - g = gaim_group_new(name_group); } for(item = xmlnode_get_child(isc, "contact"); item; item = xmlnode_get_next_twin(item)) { const char *uri, *name, *groups; + char *buddy_name; uri = xmlnode_get_attrib(item, "uri"); name = xmlnode_get_attrib(item, "name"); groups = xmlnode_get_attrib(item, "groups"); - gaim_debug_info("simple","URI->%s\n",uri); - b = gaim_find_buddy(sip->account, g_strdup_printf("sip:%s",uri)); + gaim_debug_info("simple", "URI->%s\n", uri); + + buddy_name = g_strdup_printf("sip:%s", uri); + + b = gaim_find_buddy(sip->account, buddy_name); if(!b){ - b = gaim_buddy_new(sip->account, g_strdup_printf("sip:%s",uri), uri); + b = gaim_buddy_new(sip->account, buddy_name, uri); } + g_free(buddy_name); + gaim_blist_add_buddy(b, NULL, g, NULL); gaim_blist_alias_buddy(b, uri); bs = g_new0(struct simple_buddy, 1); @@ -821,14 +842,14 @@ gchar *to; gchar *tmp; to = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); - + tmp = get_contact(sip); - + contact = g_strdup_printf("%sContact: %s\r\n", contact, tmp); g_free(tmp); - - send_sip_request(sip->gc, "SUBSCRIBE",to, to, contact, "", NULL, simple_add_lcs_contacts); + send_sip_request(sip->gc, "SUBSCRIBE", to, to, contact, "", NULL, simple_add_lcs_contacts); + g_free(to); g_free(contact); } @@ -946,6 +967,7 @@ if(!state) { gaim_debug_info("simple", "process_incoming_message: no state found\n"); + xmlnode_free(isc); return; } @@ -953,6 +975,8 @@ if(statedata) { if(strstr(statedata, "active")) serv_got_typing(sip->gc, from, 0, GAIM_TYPING); else serv_got_typing_stopped(sip->gc, from); + + g_free(statedata); } xmlnode_free(isc); send_sip_response(sip->gc, msg, 200, "OK", NULL); @@ -984,7 +1008,7 @@ subscribe_timeout(sip); tmp = sipmsg_find_header(msg, "Allow-Events"); - if(tmp && strstr(tmp,"vnd-microsoft-provisioning")){ + if(tmp && strstr(tmp, "vnd-microsoft-provisioning")){ simple_subscribe_buddylist(sip); } @@ -1012,7 +1036,7 @@ gchar *fromhdr; gchar *tmp2; xmlnode *pidf; - xmlnode *basicstatus; + xmlnode *basicstatus = NULL, *tuple, *status; gboolean isonline = FALSE; fromhdr = sipmsg_find_header(msg, "From"); @@ -1026,10 +1050,13 @@ return; } - basicstatus = xmlnode_get_child(xmlnode_get_child(xmlnode_get_child(pidf, "tuple"), "status"), "basic"); + if ((tuple = xmlnode_get_child(pidf, "tuple"))) + if ((status = xmlnode_get_child(tuple, "status"))) + basicstatus = xmlnode_get_child(status, "basic"); if(!basicstatus) { gaim_debug_info("simple", "process_incoming_notify: no basic found\n"); + xmlnode_free(pidf); return; } @@ -1037,6 +1064,7 @@ if(!tmp2) { gaim_debug_info("simple", "process_incoming_notify: no basic data found\n"); + xmlnode_free(pidf); return; } @@ -1044,6 +1072,8 @@ isonline = TRUE; } + g_free(tmp2); + if(isonline) gaim_prpl_got_user_status(sip->account, from, "available", NULL); else gaim_prpl_got_user_status(sip->account, from, "offline", NULL); @@ -1084,16 +1114,13 @@ return 1; } -static gchar *find_tag(gchar *hdr) { - gchar *tmp = strstr(hdr, ";tag="); - gchar *tmp2; +static gchar *find_tag(const gchar *hdr) { + const gchar *tmp = strstr(hdr, ";tag="), *tmp2; + if(!tmp) return NULL; tmp += 5; if((tmp2 = strchr(tmp, ';'))) { - tmp2[0] = '\0'; - tmp = g_strdup(tmp); - tmp2[0] = ';'; - return tmp; + return g_strndup(tmp, tmp2 - tmp); } return g_strdup(tmp); } @@ -1162,12 +1189,14 @@ "Content-Type: application/pidf+xml\r\n", doc, NULL, process_publish_response); sip->republish = time(NULL) + 500; + g_free(uri); g_free(doc); } static void process_incoming_subscribe(struct simple_account_data *sip, struct sipmsg *msg) { - gchar *from = parse_from(sipmsg_find_header(msg, "From")); - gchar *theirtag = find_tag(sipmsg_find_header(msg, "From")); + const char *from_hdr = sipmsg_find_header(msg, "From"); + gchar *from = parse_from(from_hdr); + gchar *theirtag = find_tag(from_hdr); gchar *ourtag = find_tag(sipmsg_find_header(msg, "To")); gboolean tagadded = FALSE; gchar *callid = sipmsg_find_header(msg, "Call-ID"); @@ -1180,22 +1209,22 @@ } if(!watcher) { /* new subscription */ gchar *acceptheader = sipmsg_find_header(msg, "Accept"); - int needsxpidf = 0; + gboolean needsxpidf = FALSE; if(!gaim_privacy_check(sip->account, from)) { send_sip_response(sip->gc, msg, 202, "Ok", NULL); goto privend; } if(acceptheader) { gchar *tmp = acceptheader; - int foundpidf = 0; - int foundxpidf = 0; + gboolean foundpidf = FALSE; + gboolean foundxpidf = FALSE; while(tmp && tmp < acceptheader + strlen(acceptheader)) { gchar *tmp2 = strchr(tmp, ','); if(tmp2) *tmp2 = '\0'; - if(!strcmp("application/pidf+xml",tmp)) - foundpidf = 1; - if(!strcmp("application/xpidf+xml",tmp)) - foundxpidf = 1; + if(!strcmp("application/pidf+xml", tmp)) + foundpidf = TRUE; + if(!strcmp("application/xpidf+xml", tmp)) + foundxpidf = TRUE; if(tmp2) { *tmp2 = ','; tmp = tmp2; @@ -1203,7 +1232,7 @@ } else tmp = 0; } - if(!foundpidf && foundxpidf) needsxpidf = 1; + if(!foundpidf && foundxpidf) needsxpidf = TRUE; g_free(acceptheader); } watcher = watcher_create(sip, from, callid, ourtag, theirtag, needsxpidf); @@ -1212,6 +1241,7 @@ gchar *to = g_strdup_printf("%s;tag=%s", sipmsg_find_header(msg, "To"), ourtag); sipmsg_remove_header(msg, "To"); sipmsg_add_header(msg, "To", to); + g_free(to); } if(expire) watcher->expire = time(NULL) + strtol(expire, NULL, 10); @@ -1221,7 +1251,7 @@ tmp = get_contact(sip); sipmsg_add_header(msg, "Contact", tmp); g_free(tmp); - gaim_debug_info("simple","got subscribe: name %s ourtag %s theirtag %s callid %s\n", watcher->name, watcher->dialog.ourtag, watcher->dialog.theirtag, watcher->dialog.callid); + gaim_debug_info("simple", "got subscribe: name %s ourtag %s theirtag %s callid %s\n", watcher->name, watcher->dialog.ourtag, watcher->dialog.theirtag, watcher->dialog.callid); send_sip_response(sip->gc, msg, 200, "Ok", NULL); send_notify(sip, watcher); privend: @@ -1274,7 +1304,7 @@ gaim_debug_info("simple", "got trying response\n"); } else { sip->proxy.retries = 0; - if(!strcmp(trans->msg->method,"REGISTER")) { + if(!strcmp(trans->msg->method, "REGISTER")) { if(msg->response == 401) sip->registrar.retries++; else sip->registrar.retries = 0; } else { @@ -1327,7 +1357,7 @@ cur++; } if(cur != conn->inbuf) { - memmove(conn->inbuf, cur, conn->inbufused-(cur-conn->inbuf)); + memmove(conn->inbuf, cur, conn->inbufused - (cur - conn->inbuf)); conn->inbufused = strlen(conn->inbuf); } @@ -1340,7 +1370,7 @@ msg = sipmsg_parse_header(conn->inbuf); cur[0] = '\r'; cur += 2; - restlen = conn->inbufused - (cur-conn->inbuf); + restlen = conn->inbufused - (cur - conn->inbuf); if(restlen >= msg->bodylen) { dummy = g_malloc(msg->bodylen + 1); memcpy(dummy, cur, msg->bodylen); Modified: branches/v2_0_0/src/protocols/simple/simple.h =================================================================== --- branches/v2_0_0/src/protocols/simple/simple.h 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/simple/simple.h 2006-08-11 13:35:26 UTC (rev 16707) @@ -44,7 +44,7 @@ gchar *name; time_t expire; struct sip_dialog dialog; - int needsxpidf; + gboolean needsxpidf; }; struct simple_buddy { Modified: branches/v2_0_0/src/protocols/simple/sipmsg.c =================================================================== --- branches/v2_0_0/src/protocols/simple/sipmsg.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/simple/sipmsg.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -35,18 +35,23 @@ #include "simple.h" #include "sipmsg.h" -struct sipmsg *sipmsg_parse_msg(gchar *msg) { - char *tmp = strstr(msg, "\r\n\r\n"); +struct sipmsg *sipmsg_parse_msg(const gchar *msg) { + const char *tmp = strstr(msg, "\r\n\r\n"); + char *line; struct sipmsg *smsg; + if(!tmp) return NULL; - tmp[0]=0; - smsg = sipmsg_parse_header(msg); - tmp[0]='\r'; - smsg->body = g_strdup(tmp+4); + + line = g_strndup(msg, tmp - msg); + + smsg = sipmsg_parse_header(line); + smsg->body = g_strdup(tmp + 4); + + g_free(line); return smsg; } -struct sipmsg *sipmsg_parse_header(gchar *header) { +struct sipmsg *sipmsg_parse_header(const gchar *header) { struct sipmsg *msg = g_new0(struct sipmsg,1); gchar **lines = g_strsplit(header,"\r\n",0); gchar **parts; @@ -110,7 +115,7 @@ return msg; } -void sipmsg_print(struct sipmsg *msg) { +void sipmsg_print(const struct sipmsg *msg) { GSList *cur; struct siphdrelement *elem; gaim_debug(GAIM_DEBUG_MISC, "simple", "SIP MSG\n"); @@ -124,7 +129,7 @@ } } -char *sipmsg_to_string(struct sipmsg *msg) { +char *sipmsg_to_string(const struct sipmsg *msg) { GSList *cur; GString *outstr = g_string_new(""); struct siphdrelement *elem; @@ -148,7 +153,7 @@ return g_string_free(outstr, FALSE); } -void sipmsg_add_header(struct sipmsg *msg, gchar *name, gchar *value) { +void sipmsg_add_header(struct sipmsg *msg, const gchar *name, const gchar *value) { struct siphdrelement *element = g_new0(struct siphdrelement,1); element->name = g_strdup(name); element->value = g_strdup(value); @@ -170,13 +175,16 @@ g_free(msg); } -void sipmsg_remove_header(struct sipmsg *msg, gchar *name) { +void sipmsg_remove_header(struct sipmsg *msg, const gchar *name) { struct siphdrelement *elem; GSList *tmp = msg->headers; while(tmp) { elem = tmp->data; if(strcmp(elem->name, name)==0) { msg->headers = g_slist_remove(msg->headers, elem); + g_free(elem->name); + g_free(elem->value); + g_free(elem); return; } tmp = g_slist_next(tmp); @@ -184,7 +192,7 @@ return; } -gchar *sipmsg_find_header(struct sipmsg *msg, gchar *name) { +gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name) { GSList *tmp; struct siphdrelement *elem; tmp = msg->headers; Modified: branches/v2_0_0/src/protocols/simple/sipmsg.h =================================================================== --- branches/v2_0_0/src/protocols/simple/sipmsg.h 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/simple/sipmsg.h 2006-08-11 13:35:26 UTC (rev 16707) @@ -39,12 +39,12 @@ gchar *value; }; -struct sipmsg *sipmsg_parse_msg(gchar *msg); -struct sipmsg *sipmsg_parse_header(gchar *header); -void sipmsg_add_header(struct sipmsg *msg, gchar *name, gchar *value); +struct sipmsg *sipmsg_parse_msg(const gchar *msg); +struct sipmsg *sipmsg_parse_header(const gchar *header); +void sipmsg_add_header(struct sipmsg *msg, const gchar *name, const gchar *value); void sipmsg_free(struct sipmsg *msg); -gchar *sipmsg_find_header(struct sipmsg *msg, gchar *name); -void sipmsg_remove_header(struct sipmsg *msg, gchar *name); -void sipmsg_print(struct sipmsg *msg); -char *sipmsg_to_string(struct sipmsg *msg); +gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name); +void sipmsg_remove_header(struct sipmsg *msg, const gchar *name); +void sipmsg_print(const struct sipmsg *msg); +char *sipmsg_to_string(const struct sipmsg *msg); #endif /* _GAIM_SIMPLE_H */ Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-11 08:13:38 UTC (rev 16706) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-11 13:35:26 UTC (rev 16707) @@ -350,7 +350,7 @@ break; yahoo_friend_set_buddy_icon_need_request(f, FALSE); - if (cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)) + if (b && cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)) yahoo_send_picture_request(gc, name); break; @@ -3407,7 +3407,7 @@ if (foo) group = foo->name; if (!group) { - g = gaim_buddy_get_group(gaim_find_buddy(gc->account, buddy->name)); + g = gaim_buddy_get_group(buddy); if (g) group = g->name; else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-11 08:13:44
|
Revision: 16706 Author: thekingant Date: 2006-08-11 01:13:38 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16706&view=rev Log Message: ----------- Backport SVN revisions 16703 through 16705 from HEAD to v2_0_0 Original commit messages: Don't use the same callback for both gaim_proxy_connect() and gaim_input_add(). Aside from being a little confusing, it's hindering some changes I want to make to gaim_proxy_connect(). #if 0 some of the MSN listen-for-connection code for file transfers. It wasn't being used Modified Paths: -------------- branches/v2_0_0/src/protocols/msn/directconn.c branches/v2_0_0/src/protocols/msn/directconn.h branches/v2_0_0/src/protocols/yahoo/yahoo.c branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c branches/v2_0_0/src/protocols/yahoo/yahoochat.c branches/v2_0_0/src/util.c Modified: branches/v2_0_0/src/protocols/msn/directconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-11 08:13:38 UTC (rev 16706) @@ -76,6 +76,7 @@ * Connection Functions **************************************************************************/ +#if 0 static int create_listener(int port) { @@ -159,6 +160,7 @@ return fd; } +#endif static size_t msn_directconn_write(MsnDirectConn *directconn, @@ -447,6 +449,7 @@ return FALSE; } +#if 0 void msn_directconn_listen(MsnDirectConn *directconn) { @@ -466,6 +469,7 @@ directconn->port = port; directconn->c = 0; } +#endif MsnDirectConn* msn_directconn_new(MsnSlpLink *slplink) Modified: branches/v2_0_0/src/protocols/msn/directconn.h =================================================================== --- branches/v2_0_0/src/protocols/msn/directconn.h 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/protocols/msn/directconn.h 2006-08-11 08:13:38 UTC (rev 16706) @@ -50,7 +50,9 @@ MsnDirectConn *msn_directconn_new(MsnSlpLink *slplink); gboolean msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port); +#if 0 void msn_directconn_listen(MsnDirectConn *directconn); +#endif void msn_directconn_send_msg(MsnDirectConn *directconn, MsnMessage *msg); void msn_directconn_parse_nonce(MsnDirectConn *directconn, const char *nonce); void msn_directconn_destroy(MsnDirectConn *directconn); Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-11 08:13:38 UTC (rev 16706) @@ -2354,19 +2354,17 @@ } } -static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_cookies_send_cb(gpointer data, gint source, GaimInputCondition cond) { - GaimConnection *gc = data; - struct yahoo_data *yd = gc->proto_data; - int written, total_len; + GaimConnection *gc; + struct yahoo_data *yd; + int written, remaining; - if (source < 0) { - gaim_connection_error(gc, _("Unable to connect.")); - return; - } + gc = data; + yd = gc->proto_data; - total_len = strlen(yd->auth) - yd->auth_written; - written = write(source, yd->auth + yd->auth_written, total_len); + remaining = strlen(yd->auth) - yd->auth_written; + written = write(source, yd->auth + yd->auth_written, remaining); if (written < 0 && errno == EAGAIN) written = 0; @@ -2380,22 +2378,35 @@ return; } - if (written < total_len) { + if (written < remaining) { yd->auth_written += written; - if (!gc->inpa) - gc->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_got_cookies, gc); return; } g_free(yd->auth); yd->auth = NULL; yd->auth_written = 0; - if (gc->inpa) - gaim_input_remove(gc->inpa); + gaim_input_remove(gc->inpa); gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); } +static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +{ + GaimConnection *gc = data; + + if (source < 0) { + gaim_connection_error(gc, _("Unable to connect.")); + return; + } + + if (gc->inpa == 0) + { + gc->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_got_cookies_send_cb, gc); + yahoo_got_cookies_send_cb(gc, source, GAIM_INPUT_WRITE); + } +} + static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) { if (!strcmp(key, "passwd")) Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-11 08:13:38 UTC (rev 16706) @@ -57,11 +57,45 @@ g_free(xd); } +static void yahoo_receivefile_send_cb(gpointer data, gint source, GaimInputCondition condition) +{ + GaimXfer *xfer; + struct yahoo_xfer_data *xd; + int remaining, written; + + xfer = data; + xd = xfer->data; + + remaining = xd->txbuflen - xd->txbuf_written; + written = write(xfer->fd, xd->txbuf + xd->txbuf_written, remaining); + + if (written < 0 && errno == EAGAIN) + written = 0; + else if (written <= 0) { + gaim_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno); + gaim_xfer_cancel_remote(xfer); + return; + } + + if (written < remaining) { + xd->txbuf_written += written; + return; + } + + gaim_input_remove(xd->tx_handler); + xd->tx_handler = 0; + g_free(xd->txbuf); + xd->txbuf = NULL; + xd->txbuflen = 0; + + gaim_xfer_start(xfer, source, NULL, 0); + +} + static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition) { GaimXfer *xfer; struct yahoo_xfer_data *xd; - int total_len, written; gaim_debug(GAIM_DEBUG_INFO, "yahoo", "AAA - in yahoo_receivefile_connected\n"); @@ -76,6 +110,8 @@ return; } + xfer->fd = source; + /* The first time we get here, assemble the tx buffer */ if (xd->txbuflen == 0) { xd->txbuf = g_strdup_printf("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n", @@ -84,12 +120,26 @@ xd->txbuf_written = 0; } - total_len = xd->txbuflen - xd->txbuf_written; + if (!xd->tx_handler) + { + xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_receivefile_send_cb, xfer); + yahoo_receivefile_send_cb(xfer, source, GAIM_INPUT_WRITE); + } +} - xfer->fd = source; +static void yahoo_sendfile_send_cb(gpointer data, gint source, GaimInputCondition condition) +{ + GaimXfer *xfer; + struct yahoo_xfer_data *xd; + int written, remaining; - written = write(xfer->fd, xd->txbuf + xd->txbuf_written, total_len); + xfer = data; + xd = xfer->data; + remaining = xd->txbuflen - xd->txbuf_written; + written = write(xfer->fd, xd->txbuf + xd->txbuf_written, remaining); + if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { @@ -98,31 +148,33 @@ return; } - if (written < total_len) { - if (!xd->tx_handler) - xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_receivefile_connected, xfer); + if (written < remaining) { xd->txbuf_written += written; return; } - if (xd->tx_handler) - gaim_input_remove(xd->tx_handler); + gaim_input_remove(xd->tx_handler); xd->tx_handler = 0; g_free(xd->txbuf); xd->txbuf = NULL; xd->txbuflen = 0; gaim_xfer_start(xfer, source, NULL, 0); - } - static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { GaimXfer *xfer; struct yahoo_xfer_data *xd; - int written, total_len; + struct yahoo_packet *pkt; + gchar *size, *filename, *encoded_filename, *header; + guchar *pkt_buf; + const char *host; + int port; + size_t content_length, header_len, pkt_buf_len; + GaimConnection *gc; + GaimAccount *account; + struct yahoo_data *yd; gaim_debug(GAIM_DEBUG_INFO, "yahoo", "AAA - in yahoo_sendfile_connected\n"); @@ -131,7 +183,6 @@ if (!(xd = xfer->data)) return; - if (source < 0) { gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, _("Unable to connect.")); @@ -139,96 +190,61 @@ return; } - /* The first time we get here, assemble the tx buffer */ - if (xd->txbuflen == 0) { - struct yahoo_packet *pkt; - gchar *size, *filename, *encoded_filename, *header; - guchar *pkt_buf; - const char *host; - int port; - size_t content_length, header_len, pkt_buf_len; - GaimConnection *gc; - GaimAccount *account; - struct yahoo_data *yd; + xfer->fd = source; - gc = xd->gc; - account = gaim_connection_get_account(gc); - yd = gc->proto_data; + /* Assemble the tx buffer */ + gc = xd->gc; + account = gaim_connection_get_account(gc); + yd = gc->proto_data; - pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, - YAHOO_STATUS_AVAILABLE, yd->session_id); + pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, + YAHOO_STATUS_AVAILABLE, yd->session_id); - size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer)); - filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); - encoded_filename = yahoo_string_encode(gc, filename, NULL); + size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer)); + filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); + encoded_filename = yahoo_string_encode(gc, filename, NULL); - yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc), - 5, xfer->who, 14, "", 27, encoded_filename, 28, size); - g_free(size); - g_free(encoded_filename); - g_free(filename); + yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc), + 5, xfer->who, 14, "", 27, encoded_filename, 28, size); + g_free(size); + g_free(encoded_filename); + g_free(filename); - content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); + content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); - pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, &pkt_buf); - yahoo_packet_free(pkt); + pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, &pkt_buf); + yahoo_packet_free(pkt); - host = gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); - port = gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); - header = g_strdup_printf( - "POST http://%s:%d/notifyft HTTP/1.0\r\n" - "Content-length: %" G_GSIZE_FORMAT "\r\n" - "Host: %s:%d\r\n" - "Cookie: Y=%s; T=%s\r\n" - "\r\n", - host, port, content_length + 4 + gaim_xfer_get_size(xfer), - host, port, yd->cookie_y, yd->cookie_t); + host = gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); + port = gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); + header = g_strdup_printf( + "POST http://%s:%d/notifyft HTTP/1.0\r\n" + "Content-length: %" G_GSIZE_FORMAT "\r\n" + "Host: %s:%d\r\n" + "Cookie: Y=%s; T=%s\r\n" + "\r\n", + host, port, content_length + 4 + gaim_xfer_get_size(xfer), + host, port, yd->cookie_y, yd->cookie_t); + header_len = strlen(header); - header_len = strlen(header); + xd->txbuflen = header_len + pkt_buf_len + 4; + xd->txbuf = g_malloc(xd->txbuflen); - xd->txbuflen = header_len + pkt_buf_len + 4; - xd->txbuf = g_malloc(xd->txbuflen); + memcpy(xd->txbuf, header, header_len); + g_free(header); + memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len); + g_free(pkt_buf); + memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4); - memcpy(xd->txbuf, header, header_len); - g_free(header); - memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len); - g_free(pkt_buf); - memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4); + xd->txbuf_written = 0; - xd->txbuf_written = 0; + if (xd->tx_handler == 0) + { + xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_sendfile_send_cb, xfer); + yahoo_sendfile_send_cb(xfer, source, GAIM_INPUT_WRITE); } - - total_len = xd->txbuflen - xd->txbuf_written; - - xfer->fd = source; - - written = write(xfer->fd, xd->txbuf + xd->txbuf_written, total_len); - - if (written < 0 && errno == EAGAIN) - written = 0; - else if (written <= 0) { - gaim_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno); - gaim_xfer_cancel_remote(xfer); - return; - } - - if (written < total_len) { - if (!xd->tx_handler) - xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_sendfile_connected, xfer); - xd->txbuf_written += written; - return; - } - - if (xd->tx_handler) - gaim_input_remove(xd->tx_handler); - xd->tx_handler = 0; - g_free(xd->txbuf); - xd->txbuf = NULL; - xd->txbuflen = 0; - - gaim_xfer_start(xfer, source, NULL, 0); } static void yahoo_xfer_init(GaimXfer *xfer) Modified: branches/v2_0_0/src/protocols/yahoo/yahoochat.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-11 08:13:38 UTC (rev 16706) @@ -1335,38 +1335,22 @@ yrl->rxlen = 0; } -static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_roomlist_send_cb(gpointer data, gint source, GaimInputCondition cond) { - struct yahoo_roomlist *yrl = data; - GaimRoomlist *list = yrl->list; - struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; - int written, total_len; + struct yahoo_roomlist *yrl; + GaimRoomlist *list; + int written, remaining; - if (source < 0) { - gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); - yahoo_roomlist_cleanup(list, yrl); - return; - } + yrl = data; + list = yrl->list; - if (yrl->txbuf == NULL) { - yrl->fd = source; + remaining = strlen(yrl->txbuf) - yrl->tx_written; + written = write(yrl->fd, yrl->txbuf + yrl->tx_written, remaining); - yrl->txbuf = g_strdup_printf( - "GET http://%s/%s HTTP/1.0\r\n" - "Host: %s\r\n" - "Cookie: Y=%s; T=%s\r\n\r\n", - yrl->host, yrl->path, yrl->host, yd->cookie_y, - yd->cookie_t); - } - - total_len = strlen(yrl->txbuf) - yrl->tx_written; - written = write(yrl->fd, yrl->txbuf + yrl->tx_written, total_len); - if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + gaim_input_remove(yrl->inpa); yrl->inpa = 0; g_free(yrl->txbuf); yrl->txbuf = NULL; @@ -1375,24 +1359,47 @@ return; } - if (written < total_len) { - if (!yrl->inpa) - yrl->inpa = gaim_input_add(yrl->fd, - GAIM_INPUT_WRITE, yahoo_roomlist_got_connected, - yrl); + if (written < remaining) { yrl->tx_written += written; return; } g_free(yrl->txbuf); yrl->txbuf = NULL; - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + + gaim_input_remove(yrl->inpa); yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, - yahoo_roomlist_pending, yrl); + yahoo_roomlist_pending, yrl); } +static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +{ + struct yahoo_roomlist *yrl = data; + GaimRoomlist *list = yrl->list; + struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; + + if (source < 0) { + gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); + yahoo_roomlist_cleanup(list, yrl); + return; + } + + yrl->fd = source; + + yrl->txbuf = g_strdup_printf( + "GET http://%s/%s HTTP/1.0\r\n" + "Host: %s\r\n" + "Cookie: Y=%s; T=%s\r\n\r\n", + yrl->host, yrl->path, yrl->host, yd->cookie_y, + yd->cookie_t); + + + yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_WRITE, + yahoo_roomlist_send_cb, yrl); + yahoo_roomlist_send_cb(yrl, yrl->fd, GAIM_INPUT_WRITE); +} + GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc) { struct yahoo_roomlist *yrl; Modified: branches/v2_0_0/src/util.c =================================================================== --- branches/v2_0_0/src/util.c 2006-08-11 08:08:19 UTC (rev 16705) +++ branches/v2_0_0/src/util.c 2006-08-11 08:13:38 UTC (rev 16706) @@ -3202,7 +3202,7 @@ static void -url_fetched_cb(gpointer url_data, gint sock, GaimInputCondition cond) +url_fetch_recv_cb(gpointer url_data, gint source, GaimInputCondition cond) { GaimFetchUrlData *gfud = url_data; int len; @@ -3210,7 +3210,7 @@ char *data_cursor; gboolean got_eof = FALSE; - while((len = read(sock, buf, sizeof(buf))) > 0) { + while((len = read(source, buf, sizeof(buf))) > 0) { /* If we've filled up our butfer, make it bigger */ if((gfud->len + len) >= gfud->data_len) { while((gfud->len + len) >= gfud->data_len) @@ -3240,7 +3240,7 @@ header_len, gfud->webdata); /* See if we can find a redirect. */ - if(parse_redirect(gfud->webdata, header_len, sock, gfud)) + if(parse_redirect(gfud->webdata, header_len, source, gfud)) return; gfud->got_headers = TRUE; @@ -3273,7 +3273,7 @@ gaim_debug_error("gaim_url_fetch", "Failed to allocate %u bytes: %s\n", content_len, strerror(errno)); gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, NULL, 0); destroy_fetch_url_data(gfud); @@ -3310,7 +3310,7 @@ got_eof = TRUE; } else { gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, NULL, 0); @@ -3326,7 +3326,7 @@ /* gaim_debug_misc("gaim_url_fetch", "Received: '%s'\n", gfud->webdata); */ gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, gfud->webdata, gfud->len); destroy_fetch_url_data(gfud); @@ -3334,17 +3334,54 @@ } static void -url_fetch_connect_cb(gpointer url_data, gint sock, GaimInputCondition cond) { - GaimFetchUrlData *gfud = url_data; +url_fetch_send_cb(gpointer data, gint source, GaimInputCondition cond) +{ + GaimFetchUrlData *gfud; int len, total_len; - if(sock == -1) { + gfud = data; + + total_len = strlen(gfud->request); + + len = write(source, gfud->request + gfud->request_written, + total_len - gfud->request_written); + + if(len < 0 && errno == EAGAIN) + return; + else if(len < 0) { + gaim_input_remove(gfud->inpa); + close(source); gfud->callback(gfud->user_data, NULL, 0); destroy_fetch_url_data(gfud); return; } + gfud->request_written += len; - if (!gfud->request) { + if(gfud->request_written != total_len) + return; + + /* We're done writing, now start reading */ + gaim_input_remove(gfud->inpa); + gfud->inpa = gaim_input_add(source, GAIM_INPUT_READ, url_fetch_recv_cb, + gfud); +} + +static void +url_fetch_connect_cb(gpointer url_data, gint source, GaimInputCondition cond) +{ + GaimFetchUrlData *gfud; + + gfud = url_data; + + if (source == -1) + { + gfud->callback(gfud->user_data, NULL, 0); + destroy_fetch_url_data(gfud); + return; + } + + if (!gfud->request) + { if (gfud->user_agent) { /* Host header is not forbidden in HTTP/1.0 requests, and HTTP/1.1 * clients must know how to handle the "chunked" transfer encoding. @@ -3374,33 +3411,9 @@ gaim_debug_misc("gaim_url_fetch", "Request: '%s'\n", gfud->request); - if(!gfud->inpa) - gfud->inpa = gaim_input_add(sock, GAIM_INPUT_WRITE, - url_fetch_connect_cb, gfud); - - total_len = strlen(gfud->request); - - len = write(sock, gfud->request + gfud->request_written, - total_len - gfud->request_written); - - if(len < 0 && errno == EAGAIN) - return; - else if(len < 0) { - gaim_input_remove(gfud->inpa); - close(sock); - gfud->callback(gfud->user_data, NULL, 0); - destroy_fetch_url_data(gfud); - return; - } - gfud->request_written += len; - - if(gfud->request_written != total_len) - return; - - gaim_input_remove(gfud->inpa); - - gfud->inpa = gaim_input_add(sock, GAIM_INPUT_READ, url_fetched_cb, - gfud); + gfud->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + url_fetch_send_cb, gfud); + url_fetch_send_cb(gfud, source, GAIM_INPUT_WRITE); } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-11 08:08:21
|
Revision: 16705 Author: thekingant Date: 2006-08-11 01:08:19 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16705&view=rev Log Message: ----------- Don't use the same callback for both gaim_proxy_connect() and gaim_input_add(). Aside from being a little confusing, it's hindering some changes I want to make to gaim_proxy_connect(). Modified Paths: -------------- trunk/src/protocols/yahoo/yahoo.c trunk/src/protocols/yahoo/yahoo_filexfer.c trunk/src/protocols/yahoo/yahoochat.c Modified: trunk/src/protocols/yahoo/yahoo.c =================================================================== --- trunk/src/protocols/yahoo/yahoo.c 2006-08-11 08:01:16 UTC (rev 16704) +++ trunk/src/protocols/yahoo/yahoo.c 2006-08-11 08:08:19 UTC (rev 16705) @@ -2354,19 +2354,17 @@ } } -static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_got_cookies_send_cb(gpointer data, gint source, GaimInputCondition cond) { - GaimConnection *gc = data; - struct yahoo_data *yd = gc->proto_data; - int written, total_len; + GaimConnection *gc; + struct yahoo_data *yd; + int written, remaining; - if (source < 0) { - gaim_connection_error(gc, _("Unable to connect.")); - return; - } + gc = data; + yd = gc->proto_data; - total_len = strlen(yd->auth) - yd->auth_written; - written = write(source, yd->auth + yd->auth_written, total_len); + remaining = strlen(yd->auth) - yd->auth_written; + written = write(source, yd->auth + yd->auth_written, remaining); if (written < 0 && errno == EAGAIN) written = 0; @@ -2380,22 +2378,35 @@ return; } - if (written < total_len) { + if (written < remaining) { yd->auth_written += written; - if (!gc->inpa) - gc->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_got_cookies, gc); return; } g_free(yd->auth); yd->auth = NULL; yd->auth_written = 0; - if (gc->inpa) - gaim_input_remove(gc->inpa); + gaim_input_remove(gc->inpa); gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); } +static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) +{ + GaimConnection *gc = data; + + if (source < 0) { + gaim_connection_error(gc, _("Unable to connect.")); + return; + } + + if (gc->inpa == 0) + { + gc->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_got_cookies_send_cb, gc); + yahoo_got_cookies_send_cb(gc, source, GAIM_INPUT_WRITE); + } +} + static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) { if (!strcmp(key, "passwd")) Modified: trunk/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-11 08:01:16 UTC (rev 16704) +++ trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-11 08:08:19 UTC (rev 16705) @@ -57,11 +57,45 @@ g_free(xd); } +static void yahoo_receivefile_send_cb(gpointer data, gint source, GaimInputCondition condition) +{ + GaimXfer *xfer; + struct yahoo_xfer_data *xd; + int remaining, written; + + xfer = data; + xd = xfer->data; + + remaining = xd->txbuflen - xd->txbuf_written; + written = write(xfer->fd, xd->txbuf + xd->txbuf_written, remaining); + + if (written < 0 && errno == EAGAIN) + written = 0; + else if (written <= 0) { + gaim_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno); + gaim_xfer_cancel_remote(xfer); + return; + } + + if (written < remaining) { + xd->txbuf_written += written; + return; + } + + gaim_input_remove(xd->tx_handler); + xd->tx_handler = 0; + g_free(xd->txbuf); + xd->txbuf = NULL; + xd->txbuflen = 0; + + gaim_xfer_start(xfer, source, NULL, 0); + +} + static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition) { GaimXfer *xfer; struct yahoo_xfer_data *xd; - int total_len, written; gaim_debug(GAIM_DEBUG_INFO, "yahoo", "AAA - in yahoo_receivefile_connected\n"); @@ -76,6 +110,8 @@ return; } + xfer->fd = source; + /* The first time we get here, assemble the tx buffer */ if (xd->txbuflen == 0) { xd->txbuf = g_strdup_printf("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n", @@ -84,12 +120,26 @@ xd->txbuf_written = 0; } - total_len = xd->txbuflen - xd->txbuf_written; + if (!xd->tx_handler) + { + xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_receivefile_send_cb, xfer); + yahoo_receivefile_send_cb(xfer, source, GAIM_INPUT_WRITE); + } +} - xfer->fd = source; +static void yahoo_sendfile_send_cb(gpointer data, gint source, GaimInputCondition condition) +{ + GaimXfer *xfer; + struct yahoo_xfer_data *xd; + int written, remaining; - written = write(xfer->fd, xd->txbuf + xd->txbuf_written, total_len); + xfer = data; + xd = xfer->data; + remaining = xd->txbuflen - xd->txbuf_written; + written = write(xfer->fd, xd->txbuf + xd->txbuf_written, remaining); + if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { @@ -98,31 +148,33 @@ return; } - if (written < total_len) { - if (!xd->tx_handler) - xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_receivefile_connected, xfer); + if (written < remaining) { xd->txbuf_written += written; return; } - if (xd->tx_handler) - gaim_input_remove(xd->tx_handler); + gaim_input_remove(xd->tx_handler); xd->tx_handler = 0; g_free(xd->txbuf); xd->txbuf = NULL; xd->txbuflen = 0; gaim_xfer_start(xfer, source, NULL, 0); - } - static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { GaimXfer *xfer; struct yahoo_xfer_data *xd; - int written, total_len; + struct yahoo_packet *pkt; + gchar *size, *filename, *encoded_filename, *header; + guchar *pkt_buf; + const char *host; + int port; + size_t content_length, header_len, pkt_buf_len; + GaimConnection *gc; + GaimAccount *account; + struct yahoo_data *yd; gaim_debug(GAIM_DEBUG_INFO, "yahoo", "AAA - in yahoo_sendfile_connected\n"); @@ -131,7 +183,6 @@ if (!(xd = xfer->data)) return; - if (source < 0) { gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, _("Unable to connect.")); @@ -139,96 +190,61 @@ return; } - /* The first time we get here, assemble the tx buffer */ - if (xd->txbuflen == 0) { - struct yahoo_packet *pkt; - gchar *size, *filename, *encoded_filename, *header; - guchar *pkt_buf; - const char *host; - int port; - size_t content_length, header_len, pkt_buf_len; - GaimConnection *gc; - GaimAccount *account; - struct yahoo_data *yd; + xfer->fd = source; - gc = xd->gc; - account = gaim_connection_get_account(gc); - yd = gc->proto_data; + /* Assemble the tx buffer */ + gc = xd->gc; + account = gaim_connection_get_account(gc); + yd = gc->proto_data; - pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, - YAHOO_STATUS_AVAILABLE, yd->session_id); + pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, + YAHOO_STATUS_AVAILABLE, yd->session_id); - size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer)); - filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); - encoded_filename = yahoo_string_encode(gc, filename, NULL); + size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer)); + filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); + encoded_filename = yahoo_string_encode(gc, filename, NULL); - yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc), - 5, xfer->who, 14, "", 27, encoded_filename, 28, size); - g_free(size); - g_free(encoded_filename); - g_free(filename); + yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc), + 5, xfer->who, 14, "", 27, encoded_filename, 28, size); + g_free(size); + g_free(encoded_filename); + g_free(filename); - content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); + content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); - pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, &pkt_buf); - yahoo_packet_free(pkt); + pkt_buf_len = yahoo_packet_build(pkt, 8, FALSE, &pkt_buf); + yahoo_packet_free(pkt); - host = gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); - port = gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); - header = g_strdup_printf( - "POST http://%s:%d/notifyft HTTP/1.0\r\n" - "Content-length: %" G_GSIZE_FORMAT "\r\n" - "Host: %s:%d\r\n" - "Cookie: Y=%s; T=%s\r\n" - "\r\n", - host, port, content_length + 4 + gaim_xfer_get_size(xfer), - host, port, yd->cookie_y, yd->cookie_t); + host = gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST); + port = gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT); + header = g_strdup_printf( + "POST http://%s:%d/notifyft HTTP/1.0\r\n" + "Content-length: %" G_GSIZE_FORMAT "\r\n" + "Host: %s:%d\r\n" + "Cookie: Y=%s; T=%s\r\n" + "\r\n", + host, port, content_length + 4 + gaim_xfer_get_size(xfer), + host, port, yd->cookie_y, yd->cookie_t); + header_len = strlen(header); - header_len = strlen(header); + xd->txbuflen = header_len + pkt_buf_len + 4; + xd->txbuf = g_malloc(xd->txbuflen); - xd->txbuflen = header_len + pkt_buf_len + 4; - xd->txbuf = g_malloc(xd->txbuflen); + memcpy(xd->txbuf, header, header_len); + g_free(header); + memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len); + g_free(pkt_buf); + memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4); - memcpy(xd->txbuf, header, header_len); - g_free(header); - memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len); - g_free(pkt_buf); - memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4); + xd->txbuf_written = 0; - xd->txbuf_written = 0; + if (xd->tx_handler == 0) + { + xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, + yahoo_sendfile_send_cb, xfer); + yahoo_sendfile_send_cb(xfer, source, GAIM_INPUT_WRITE); } - - total_len = xd->txbuflen - xd->txbuf_written; - - xfer->fd = source; - - written = write(xfer->fd, xd->txbuf + xd->txbuf_written, total_len); - - if (written < 0 && errno == EAGAIN) - written = 0; - else if (written <= 0) { - gaim_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno); - gaim_xfer_cancel_remote(xfer); - return; - } - - if (written < total_len) { - if (!xd->tx_handler) - xd->tx_handler = gaim_input_add(source, GAIM_INPUT_WRITE, - yahoo_sendfile_connected, xfer); - xd->txbuf_written += written; - return; - } - - if (xd->tx_handler) - gaim_input_remove(xd->tx_handler); - xd->tx_handler = 0; - g_free(xd->txbuf); - xd->txbuf = NULL; - xd->txbuflen = 0; - - gaim_xfer_start(xfer, source, NULL, 0); } static void yahoo_xfer_init(GaimXfer *xfer) Modified: trunk/src/protocols/yahoo/yahoochat.c =================================================================== --- trunk/src/protocols/yahoo/yahoochat.c 2006-08-11 08:01:16 UTC (rev 16704) +++ trunk/src/protocols/yahoo/yahoochat.c 2006-08-11 08:08:19 UTC (rev 16705) @@ -1335,38 +1335,22 @@ yrl->rxlen = 0; } -static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +static void yahoo_roomlist_send_cb(gpointer data, gint source, GaimInputCondition cond) { - struct yahoo_roomlist *yrl = data; - GaimRoomlist *list = yrl->list; - struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; - int written, total_len; + struct yahoo_roomlist *yrl; + GaimRoomlist *list; + int written, remaining; - if (source < 0) { - gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); - yahoo_roomlist_cleanup(list, yrl); - return; - } + yrl = data; + list = yrl->list; - if (yrl->txbuf == NULL) { - yrl->fd = source; + remaining = strlen(yrl->txbuf) - yrl->tx_written; + written = write(yrl->fd, yrl->txbuf + yrl->tx_written, remaining); - yrl->txbuf = g_strdup_printf( - "GET http://%s/%s HTTP/1.0\r\n" - "Host: %s\r\n" - "Cookie: Y=%s; T=%s\r\n\r\n", - yrl->host, yrl->path, yrl->host, yd->cookie_y, - yd->cookie_t); - } - - total_len = strlen(yrl->txbuf) - yrl->tx_written; - written = write(yrl->fd, yrl->txbuf + yrl->tx_written, total_len); - if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + gaim_input_remove(yrl->inpa); yrl->inpa = 0; g_free(yrl->txbuf); yrl->txbuf = NULL; @@ -1375,24 +1359,47 @@ return; } - if (written < total_len) { - if (!yrl->inpa) - yrl->inpa = gaim_input_add(yrl->fd, - GAIM_INPUT_WRITE, yahoo_roomlist_got_connected, - yrl); + if (written < remaining) { yrl->tx_written += written; return; } g_free(yrl->txbuf); yrl->txbuf = NULL; - if (yrl->inpa) - gaim_input_remove(yrl->inpa); + + gaim_input_remove(yrl->inpa); yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_READ, - yahoo_roomlist_pending, yrl); + yahoo_roomlist_pending, yrl); } +static void yahoo_roomlist_got_connected(gpointer data, gint source, GaimInputCondition cond) +{ + struct yahoo_roomlist *yrl = data; + GaimRoomlist *list = yrl->list; + struct yahoo_data *yd = gaim_account_get_connection(list->account)->proto_data; + + if (source < 0) { + gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Unable to connect"), _("Fetching the room list failed.")); + yahoo_roomlist_cleanup(list, yrl); + return; + } + + yrl->fd = source; + + yrl->txbuf = g_strdup_printf( + "GET http://%s/%s HTTP/1.0\r\n" + "Host: %s\r\n" + "Cookie: Y=%s; T=%s\r\n\r\n", + yrl->host, yrl->path, yrl->host, yd->cookie_y, + yd->cookie_t); + + + yrl->inpa = gaim_input_add(yrl->fd, GAIM_INPUT_WRITE, + yahoo_roomlist_send_cb, yrl); + yahoo_roomlist_send_cb(yrl, yrl->fd, GAIM_INPUT_WRITE); +} + GaimRoomlist *yahoo_roomlist_get_list(GaimConnection *gc) { struct yahoo_roomlist *yrl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-11 08:01:18
|
Revision: 16704 Author: thekingant Date: 2006-08-11 01:01:16 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16704&view=rev Log Message: ----------- #if 0 some of the MSN listen-for-connection code for file transfers. It wasn't being used Modified Paths: -------------- trunk/src/protocols/msn/directconn.c trunk/src/protocols/msn/directconn.h Modified: trunk/src/protocols/msn/directconn.c =================================================================== --- trunk/src/protocols/msn/directconn.c 2006-08-11 07:15:39 UTC (rev 16703) +++ trunk/src/protocols/msn/directconn.c 2006-08-11 08:01:16 UTC (rev 16704) @@ -76,6 +76,7 @@ * Connection Functions **************************************************************************/ +#if 0 static int create_listener(int port) { @@ -159,6 +160,7 @@ return fd; } +#endif static size_t msn_directconn_write(MsnDirectConn *directconn, @@ -447,6 +449,7 @@ return FALSE; } +#if 0 void msn_directconn_listen(MsnDirectConn *directconn) { @@ -466,6 +469,7 @@ directconn->port = port; directconn->c = 0; } +#endif MsnDirectConn* msn_directconn_new(MsnSlpLink *slplink) Modified: trunk/src/protocols/msn/directconn.h =================================================================== --- trunk/src/protocols/msn/directconn.h 2006-08-11 07:15:39 UTC (rev 16703) +++ trunk/src/protocols/msn/directconn.h 2006-08-11 08:01:16 UTC (rev 16704) @@ -50,7 +50,9 @@ MsnDirectConn *msn_directconn_new(MsnSlpLink *slplink); gboolean msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port); +#if 0 void msn_directconn_listen(MsnDirectConn *directconn); +#endif void msn_directconn_send_msg(MsnDirectConn *directconn, MsnMessage *msg); void msn_directconn_parse_nonce(MsnDirectConn *directconn, const char *nonce); void msn_directconn_destroy(MsnDirectConn *directconn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-11 07:15:41
|
Revision: 16703 Author: thekingant Date: 2006-08-11 00:15:39 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16703&view=rev Log Message: ----------- Don't use the same callback for both gaim_proxy_connect() and gaim_input_add(). Aside from being a little confusing, it's hindering some changes I want to make to gaim_proxy_connect(). Modified Paths: -------------- trunk/src/util.c Modified: trunk/src/util.c =================================================================== --- trunk/src/util.c 2006-08-11 06:38:37 UTC (rev 16702) +++ trunk/src/util.c 2006-08-11 07:15:39 UTC (rev 16703) @@ -3202,7 +3202,7 @@ static void -url_fetched_cb(gpointer url_data, gint sock, GaimInputCondition cond) +url_fetch_recv_cb(gpointer url_data, gint source, GaimInputCondition cond) { GaimFetchUrlData *gfud = url_data; int len; @@ -3210,7 +3210,7 @@ char *data_cursor; gboolean got_eof = FALSE; - while((len = read(sock, buf, sizeof(buf))) > 0) { + while((len = read(source, buf, sizeof(buf))) > 0) { /* If we've filled up our butfer, make it bigger */ if((gfud->len + len) >= gfud->data_len) { while((gfud->len + len) >= gfud->data_len) @@ -3240,7 +3240,7 @@ header_len, gfud->webdata); /* See if we can find a redirect. */ - if(parse_redirect(gfud->webdata, header_len, sock, gfud)) + if(parse_redirect(gfud->webdata, header_len, source, gfud)) return; gfud->got_headers = TRUE; @@ -3273,7 +3273,7 @@ gaim_debug_error("gaim_url_fetch", "Failed to allocate %u bytes: %s\n", content_len, strerror(errno)); gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, NULL, 0); destroy_fetch_url_data(gfud); @@ -3310,7 +3310,7 @@ got_eof = TRUE; } else { gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, NULL, 0); @@ -3326,7 +3326,7 @@ /* gaim_debug_misc("gaim_url_fetch", "Received: '%s'\n", gfud->webdata); */ gaim_input_remove(gfud->inpa); - close(sock); + close(source); gfud->callback(gfud->user_data, gfud->webdata, gfud->len); destroy_fetch_url_data(gfud); @@ -3334,17 +3334,54 @@ } static void -url_fetch_connect_cb(gpointer url_data, gint sock, GaimInputCondition cond) { - GaimFetchUrlData *gfud = url_data; +url_fetch_send_cb(gpointer data, gint source, GaimInputCondition cond) +{ + GaimFetchUrlData *gfud; int len, total_len; - if(sock == -1) { + gfud = data; + + total_len = strlen(gfud->request); + + len = write(source, gfud->request + gfud->request_written, + total_len - gfud->request_written); + + if(len < 0 && errno == EAGAIN) + return; + else if(len < 0) { + gaim_input_remove(gfud->inpa); + close(source); gfud->callback(gfud->user_data, NULL, 0); destroy_fetch_url_data(gfud); return; } + gfud->request_written += len; - if (!gfud->request) { + if(gfud->request_written != total_len) + return; + + /* We're done writing, now start reading */ + gaim_input_remove(gfud->inpa); + gfud->inpa = gaim_input_add(source, GAIM_INPUT_READ, url_fetch_recv_cb, + gfud); +} + +static void +url_fetch_connect_cb(gpointer url_data, gint source, GaimInputCondition cond) +{ + GaimFetchUrlData *gfud; + + gfud = url_data; + + if (source == -1) + { + gfud->callback(gfud->user_data, NULL, 0); + destroy_fetch_url_data(gfud); + return; + } + + if (!gfud->request) + { if (gfud->user_agent) { /* Host header is not forbidden in HTTP/1.0 requests, and HTTP/1.1 * clients must know how to handle the "chunked" transfer encoding. @@ -3376,33 +3413,9 @@ gaim_debug_misc("gaim_url_fetch", "Request: '%s'\n", gfud->request); - if(!gfud->inpa) - gfud->inpa = gaim_input_add(sock, GAIM_INPUT_WRITE, - url_fetch_connect_cb, gfud); - - total_len = strlen(gfud->request); - - len = write(sock, gfud->request + gfud->request_written, - total_len - gfud->request_written); - - if(len < 0 && errno == EAGAIN) - return; - else if(len < 0) { - gaim_input_remove(gfud->inpa); - close(sock); - gfud->callback(gfud->user_data, NULL, 0); - destroy_fetch_url_data(gfud); - return; - } - gfud->request_written += len; - - if(gfud->request_written != total_len) - return; - - gaim_input_remove(gfud->inpa); - - gfud->inpa = gaim_input_add(sock, GAIM_INPUT_READ, url_fetched_cb, - gfud); + gfud->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + url_fetch_send_cb, gfud); + url_fetch_send_cb(gfud, source, GAIM_INPUT_WRITE); } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-11 06:38:42
|
Revision: 16702 Author: thekingant Date: 2006-08-10 23:38:37 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16702&view=rev Log Message: ----------- Remove Napster from the description in this file Modified Paths: -------------- trunk/gaim.apspec.in Modified: trunk/gaim.apspec.in =================================================================== --- trunk/gaim.apspec.in 2006-08-11 03:01:14 UTC (rev 16701) +++ trunk/gaim.apspec.in 2006-08-11 06:38:37 UTC (rev 16702) @@ -15,7 +15,7 @@ [Description] Gaim allows you to talk to anyone using a variety of messaging protocols, including AIM (Oscar and TOC), ICQ, IRC, Yahoo!, MSN Messenger, Jabber, -Gadu-Gadu, Napster, and Zephyr. These protocols are implemented using a +Gadu-Gadu, and Zephyr. These protocols are implemented using a modular, easy to use design. To use a protocol, just add an account using the account editor. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 03:01:23
|
Revision: 16701 Author: datallah Date: 2006-08-10 20:01:14 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16701&view=rev Log Message: ----------- leak fix Modified Paths: -------------- trunk/plugins/log_reader.c Modified: trunk/plugins/log_reader.c =================================================================== --- trunk/plugins/log_reader.c 2006-08-11 02:42:13 UTC (rev 16700) +++ trunk/plugins/log_reader.c 2006-08-11 03:01:14 UTC (rev 16701) @@ -790,6 +790,7 @@ time_t time_unix; struct tm *tm_new; char *timestamp; + char *tmp; const char *style; new_session_id = xmlnode_get_attrib(message, "SessionID"); @@ -982,16 +983,18 @@ style = xmlnode_get_attrib(text_node, "Style"); + tmp = xmlnode_get_data(text_node); if (style && *style) { text = g_string_append(text, "<span style=\""); text = g_string_append(text, style); text = g_string_append(text, "\">"); - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "</span>\n"); } else { - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "\n"); } + g_free(tmp); } data->text = text; @@ -1462,7 +1465,7 @@ g_string_append(formatted, "<span style=\"color: #ff0000;\">"); - + if (gaim_str_has_prefix(line, "Your previous message has not been sent. " "Reason: Maximum length exceeded.")) { @@ -1686,7 +1689,7 @@ path = NULL; /* TODO: Test this after removing the trailing "\\". */ - if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", + if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", 0, KEY_QUERY_VALUE, &hKey)) { if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 02:42:16
|
Revision: 16700 Author: datallah Date: 2006-08-10 19:42:13 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16700&view=rev Log Message: ----------- stuff allocated by g_malloc() should be freed with g_free() Modified Paths: -------------- trunk/src/account.c Modified: trunk/src/account.c =================================================================== --- trunk/src/account.c 2006-08-11 02:40:31 UTC (rev 16699) +++ trunk/src/account.c 2006-08-11 02:42:13 UTC (rev 16700) @@ -696,14 +696,14 @@ if ((protocol_id == NULL) || (name == NULL)) { - free(protocol_id); - free(name); + g_free(protocol_id); + g_free(name); return NULL; } ret = gaim_account_new(name, protocol_id); - free(name); - free(protocol_id); + g_free(name); + g_free(protocol_id); /* Read the password */ child = xmlnode_get_child(node, "password"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 02:40:35
|
Revision: 16699 Author: datallah Date: 2006-08-10 19:40:31 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16699&view=rev Log Message: ----------- Leak fix. Modified Paths: -------------- trunk/src/protocols/jabber/jabber.c Modified: trunk/src/protocols/jabber/jabber.c =================================================================== --- trunk/src/protocols/jabber/jabber.c 2006-08-11 02:20:18 UTC (rev 16698) +++ trunk/src/protocols/jabber/jabber.c 2006-08-11 02:40:31 UTC (rev 16699) @@ -841,6 +841,8 @@ _("Register New Jabber Account"), instructions, fields, _("Register"), G_CALLBACK(jabber_register_cb), _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); + + g_free(instructions); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 02:20:23
|
Revision: 16698 Author: datallah Date: 2006-08-10 19:20:18 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16698&view=rev Log Message: ----------- CID 218 Also a win32 compile fix. Modified Paths: -------------- trunk/plugins/log_reader.c Modified: trunk/plugins/log_reader.c =================================================================== --- trunk/plugins/log_reader.c 2006-08-11 02:02:53 UTC (rev 16697) +++ trunk/plugins/log_reader.c 2006-08-11 02:20:18 UTC (rev 16698) @@ -900,7 +900,7 @@ !isalnum(*(from_name + alias_length))); - to_name_matches = (gaim_str_has_prefix( + to_name_matches = to_name && (gaim_str_has_prefix( to_name, alias) && !isalnum(*(to_name + alias_length))); @@ -1682,6 +1682,7 @@ char buffer[1024] = ""; DWORD size = (sizeof(buffer) - 1); DWORD type; + gboolean found = FALSE; path = NULL; /* TODO: Test this after removing the trailing "\\". */ @@ -1720,20 +1721,18 @@ if (!path) { char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); - if (folder) + if (folder) { path = g_build_filename(folder, "Trillian", "users", "default", "talk.ini", NULL); g_free(folder); } } - gboolean found = FALSE; - if (path) { /* Read talk.ini file to find the log directory. */ GError *error = NULL; -#if 0 && GTK_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ +#if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ GKeyFile *key_file; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", @@ -1760,9 +1759,9 @@ g_key_file_free(key_file); } -#else /* !GTK_CHECK_VERSION(2,6,0) */ - GError *error = NULL; +#else /* !GLIB_CHECK_VERSION(2,6,0) */ gsize length; + gchar *contents = NULL; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", "Reading %s\n", path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 02:02:57
|
Revision: 16697 Author: datallah Date: 2006-08-10 19:02:53 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16697&view=rev Log Message: ----------- CID 102 - This would probably take someone messing with prefs.xml manually to be encountered (I don't think there is any way to load plugins with relative paths, but I suppose with libgaim someone might try to do it). Modified Paths: -------------- trunk/src/plugin.c Modified: trunk/src/plugin.c =================================================================== --- trunk/src/plugin.c 2006-08-11 01:30:22 UTC (rev 16696) +++ trunk/src/plugin.c 2006-08-11 02:02:53 UTC (rev 16697) @@ -1232,7 +1232,7 @@ plugin->path); gaim_plugin_load(plugin); } - else if ((plugin = gaim_plugins_find_with_basename(basename)) != NULL) + else if (basename && (plugin = gaim_plugins_find_with_basename(basename)) != NULL) { gaim_debug_info("plugins", "Loading saved plugin %s\n", plugin->path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-11 01:30:27
|
Revision: 16696 Author: datallah Date: 2006-08-10 18:30:22 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16696&view=rev Log Message: ----------- Fix CID 254 - We're assuming that an account has an offline status (perhaps it isn't too bad of an assumption, but lets not make it) Modified Paths: -------------- trunk/src/gtkblist.c Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-08-11 01:14:07 UTC (rev 16695) +++ trunk/src/gtkblist.c 2006-08-11 01:30:22 UTC (rev 16696) @@ -3598,15 +3598,16 @@ hbox = gtk_hbox_new(FALSE, 0); /* Create the icon */ - status_type = gaim_account_get_status_type_with_primitive(account, - GAIM_STATUS_OFFLINE); - pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); - if (pixbuf != NULL) { - image = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); + if ((status_type = gaim_account_get_status_type_with_primitive(account, + GAIM_STATUS_OFFLINE))) { + pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5); + if (pixbuf != NULL) { + image = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); - gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, - GAIM_HIG_BOX_SPACE); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, + GAIM_HIG_BOX_SPACE); + } } /* Create the text */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |