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: <sea...@us...> - 2006-08-16 17:31:35
|
Revision: 16795 Author: seanegan Date: 2006-08-16 10:31:29 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16795&view=rev Log Message: ----------- Now with 'compiling' feature Modified Paths: -------------- trunk/src/gtkstatusbox.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 17:26:57 UTC (rev 16794) +++ trunk/src/gtkstatusbox.c 2006-08-16 17:31:29 UTC (rev 16795) @@ -953,7 +953,7 @@ } box->buddy_icon_sel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); - gtk_widget_show_all(filesel); + gtk_widget_show_all(box->buddy_icon_sel); return FALSE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-08-16 17:27:00
|
Revision: 16794 Author: seanegan Date: 2006-08-16 10:26:57 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16794&view=rev Log Message: ----------- Only one file selector Modified Paths: -------------- trunk/src/gtkstatusbox.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 17:10:36 UTC (rev 16793) +++ trunk/src/gtkstatusbox.c 2006-08-16 17:26:57 UTC (rev 16794) @@ -947,14 +947,12 @@ static gboolean icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) { - GtkWidget *filesel; - if (box->buddy_icon_sel) { gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); return FALSE; } - filesel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); + box->buddy_icon_sel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); gtk_widget_show_all(filesel); return FALSE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-16 17:10:41
|
Revision: 16793 Author: sadrul Date: 2006-08-16 10:10:36 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16793&view=rev Log Message: ----------- Handle the plugin-pref windows better. Modified Paths: -------------- trunk/console/gntplugin.c Modified: trunk/console/gntplugin.c =================================================================== --- trunk/console/gntplugin.c 2006-08-16 16:56:59 UTC (rev 16792) +++ trunk/console/gntplugin.c 2006-08-16 17:10:36 UTC (rev 16793) @@ -18,6 +18,8 @@ GntWidget *conf; } plugins; +static GHashTable *confwins; + static void decide_conf_button(GaimPlugin *plugin) { @@ -44,8 +46,15 @@ } else { + GntWidget *win; + if (!gaim_plugin_unload(plugin)) gaim_notify_error(NULL, "ERROR", "unloading plugin failed", NULL); + + if ((win = g_hash_table_lookup(confwins, plugin)) != NULL) + { + gnt_widget_destroy(win); + } } decide_conf_button(plugin); gg_plugins_save_loaded(); @@ -111,6 +120,18 @@ } static void +confwin_init() +{ + confwins = g_hash_table_new(g_direct_hash, g_direct_equal); +} + +static void +remove_confwin(GntWidget *window, gpointer plugin) +{ + g_hash_table_remove(confwins, plugin); +} + +static void configure_plugin_cb(GntWidget *button, gpointer null) { GaimPlugin *plugin; @@ -126,6 +147,9 @@ return; } + if (confwins && g_hash_table_lookup(confwins, plugin)) + return; + if (GAIM_IS_GNT_PLUGIN(plugin) && (callback = GAIM_GNT_PLUGIN_UI_INFO(plugin)) != NULL) { @@ -146,8 +170,13 @@ gnt_box_add_widget(GNT_BOX(box), button); g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(remove_confwin), plugin); - gnt_widget_show(window); /* XXX: This window needs to be closed when the plugin is unloaded */ + gnt_widget_show(window); + + if (confwins == NULL) + confwin_init(); + g_hash_table_insert(confwins, plugin, window); } else if (plugin->info->prefs_info && plugin->info->prefs_info->get_plugin_pref_frame) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 16:57:06
|
Revision: 16792 Author: thekingant Date: 2006-08-16 09:56:59 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16792&view=rev Log Message: ----------- Backport SVN revision #16791 from HEAD to v2_0_0 Patch from Henning Nor?\195?\169n Change the DND, extended away and occupied statuses in oscar so that they allow setting a message. Also change another place so that we show messages for people who are in those statuses. ViewCVS Links: ------------- http://svn.sourceforge.net/gaim/?rev=16791&view=rev Modified Paths: -------------- branches/v2_0_0/src/protocols/oscar/oscar.c Modified: branches/v2_0_0/src/protocols/oscar/oscar.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-16 16:53:20 UTC (rev 16791) +++ branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-16 16:56:59 UTC (rev 16792) @@ -4368,7 +4368,8 @@ /* This is needed for us to un-set any previous away message. */ away = g_strdup(""); } - else if (primitive == GAIM_STATUS_AWAY) + else if ((primitive == GAIM_STATUS_AWAY) || + (primitive == GAIM_STATUS_EXTENDED_AWAY)) { htmlaway = gaim_status_get_attr_string(status, "message"); if ((htmlaway == NULL) || (*htmlaway == '\0')) @@ -5608,19 +5609,25 @@ status_types = g_list_append(status_types, type); /* ICQ-specific status types */ - type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, - OSCAR_STATUS_ID_OCCUPIED, - _("Occupied"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, + OSCAR_STATUS_ID_OCCUPIED, + _("Occupied"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); - type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, - OSCAR_STATUS_ID_DND, - _("Do Not Disturb"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, + OSCAR_STATUS_ID_DND, + _("Do Not Disturb"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); - type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, - OSCAR_STATUS_ID_NA, - _("Not Available"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, + OSCAR_STATUS_ID_NA, + _("Not Available"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 16:53:24
|
Revision: 16791 Author: thekingant Date: 2006-08-16 09:53:20 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16791&view=rev Log Message: ----------- Patch from Henning Nor?\195?\169n Change the DND, extended away and occupied statuses in oscar so that they allow setting a message. Also change another place so that we show messages for people who are in those statuses. Modified Paths: -------------- trunk/src/protocols/oscar/oscar.c Modified: trunk/src/protocols/oscar/oscar.c =================================================================== --- trunk/src/protocols/oscar/oscar.c 2006-08-16 16:20:25 UTC (rev 16790) +++ trunk/src/protocols/oscar/oscar.c 2006-08-16 16:53:20 UTC (rev 16791) @@ -4369,7 +4369,8 @@ /* This is needed for us to un-set any previous away message. */ away = g_strdup(""); } - else if (primitive == GAIM_STATUS_AWAY) + else if ((primitive == GAIM_STATUS_AWAY) || + (primitive == GAIM_STATUS_EXTENDED_AWAY)) { htmlaway = gaim_status_get_attr_string(status, "message"); if ((htmlaway == NULL) || (*htmlaway == '\0')) @@ -5609,19 +5610,25 @@ status_types = g_list_append(status_types, type); /* ICQ-specific status types */ - type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, - OSCAR_STATUS_ID_OCCUPIED, - _("Occupied"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, + OSCAR_STATUS_ID_OCCUPIED, + _("Occupied"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); - type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, - OSCAR_STATUS_ID_DND, - _("Do Not Disturb"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, + OSCAR_STATUS_ID_DND, + _("Do Not Disturb"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); - type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, - OSCAR_STATUS_ID_NA, - _("Not Available"), TRUE, is_icq, FALSE); + type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, + OSCAR_STATUS_ID_NA, + _("Not Available"), TRUE, is_icq, FALSE, + "message", _("Message"), + gaim_value_new(GAIM_TYPE_STRING), NULL); status_types = g_list_append(status_types, type); type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-16 16:20:34
|
Revision: 16790 Author: mayuan2006 Date: 2006-08-16 09:20:25 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16790&view=rev Log Message: ----------- SOAP implementation rewrite. use Queue to buffer the SOAP request. Warning:Middle stage,Never Use it committed by Ma Yuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/contact.c 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 Modified: branches/soc-2006-msnp13/src/protocols/msn/contact.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-16 14:18:58 UTC (rev 16789) +++ branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-16 16:20:25 UTC (rev 16790) @@ -210,10 +210,14 @@ void msn_get_contact_list(MsnContact * contact) { - 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_get_contact_written_cb); + MsnSoapReq *soap_request; + + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_GET_CONTACT_POST_URL,MSN_GET_CONTACT_SOAP_ACTION, + MSN_GET_CONTACT_TEMPLATE, + msn_get_contact_list_cb, + msn_get_contact_written_cb); + msn_soap_post(contact->soapconn,soap_request); } static void @@ -424,11 +428,16 @@ void msn_get_address_book(MsnContact *contact) { + MsnSoapReq *soap_request; + gaim_debug_info("MaYuan","msn_get_address_book()...\n"); /*build SOAP and POST it*/ - contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); - contact->soapconn->soap_action = g_strdup(MSN_GET_ADDRESS_SOAP_ACTION); - msn_soap_post(contact->soapconn,MSN_GET_ADDRESS_TEMPLATE,msn_address_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,MSN_GET_ADDRESS_SOAP_ACTION, + MSN_GET_ADDRESS_TEMPLATE, + msn_get_address_cb, + msn_address_written_cb); + msn_soap_post(contact->soapconn,soap_request); } static void @@ -451,8 +460,10 @@ void msn_add_contact(MsnContact *contact,const char *passport,char *groupId) { + MsnSoapReq *soap_request; char *body = NULL; char *contact_xml = NULL; + char *soap_action; gaim_debug_info("MaYuan","msn add a contact...\n"); contact_xml = g_strdup_printf(MSN_CONTACT_XML,passport); @@ -460,17 +471,21 @@ 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); + 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); + soap_action = g_strdup(MSN_ADD_CONTACT_GROUP_SOAP_ACTION); } - msn_soap_post(contact->soapconn,body,msn_add_contact_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,soap_action, + body, + msn_add_contact_read_cb, + msn_add_contact_written_cb); + msn_soap_post(contact->soapconn,soap_request); + g_free(soap_action); g_free(body); } @@ -496,15 +511,20 @@ { char *body = NULL; char *contact_xml = NULL ; + MsnSoapReq *soap_request; 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_delete_contact_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,MSN_CONTACT_DEL_SOAP_ACTION, + body, + msn_delete_contact_read_cb, + msn_delete_contact_written_cb); + msn_soap_post(contact->soapconn,soap_request); + g_free(body); } @@ -528,14 +548,19 @@ void msn_block_contact(MsnContact *contact,const char* membership_id) { + MsnSoapReq *soap_request; char *body = NULL; gaim_debug_info("MaYuan","msn block a contact...\n"); body = g_strdup_printf(MSN_CONTACT_DELECT_FROM_ALLOW_TEMPLATE,membership_id); /*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_block_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_SHARE_POST_URL,MSN_CONTACT_BLOCK_SOAP_ACTION, + body, + msn_block_read_cb, + msn_block_written_cb); + msn_soap_post(contact->soapconn,soap_request); + g_free(body); } @@ -559,15 +584,20 @@ void msn_unblock_contact(MsnContact *contact,const char* passport) { + MsnSoapReq *soap_request; char *body = NULL; gaim_debug_info("MaYuan","msn unblock a contact...\n"); body = g_strdup_printf(MSN_UNBLOCK_CONTACT_TEMPLATE,passport); /*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_unblock_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_SHARE_POST_URL,MSN_CONTACT_UNBLOCK_SOAP_ACTION, + body, + msn_unblock_read_cb, + msn_unblock_written_cb); + msn_soap_post(contact->soapconn,soap_request); + g_free(body); } @@ -591,11 +621,16 @@ void msn_get_gleams(MsnContact *contact) { + MsnSoapReq *soap_request; + gaim_debug_info("MaYuan","msn get gleams info...\n"); /*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_gleams_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,MSN_GET_GLEAMS_SOAP_ACTION, + MSN_GLEAMS_TEMPLATE, + msn_gleams_read_cb, + msn_gleams_written_cb); + msn_soap_post(contact->soapconn,soap_request); } /*************************************************************** @@ -620,8 +655,9 @@ /*add group*/ void msn_add_group(MsnSession *session,const char* group_name) { + MsnSoapReq *soap_request; + MsnContact *contact ; char *body = NULL; - MsnContact *contact ; g_return_if_fail(session != NULL); contact = session->contact; @@ -629,15 +665,18 @@ body = g_strdup_printf(MSN_GROUP_ADD_TEMPLATE,group_name); /*build SOAP and POST it*/ - contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); - contact->soapconn->soap_action = g_strdup(MSN_GROUP_ADD_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_group_written_cb); - g_free(body); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,MSN_GROUP_ADD_SOAP_ACTION, + body, + msn_group_read_cb, + msn_group_written_cb); + msn_soap_post(contact->soapconn,soap_request); } /*delete a group*/ void msn_del_group(MsnSession *session,const char *guid) { + MsnSoapReq *soap_request; MsnContact *contact; char *body = NULL; @@ -647,9 +686,13 @@ body = g_strdup_printf(MSN_GROUP_DEL_TEMPLATE,guid); /*build SOAP and POST it*/ - contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL); - contact->soapconn->soap_action = g_strdup(MSN_GROUP_DEL_SOAP_ACTION); - msn_soap_post(contact->soapconn,body,msn_group_written_cb); + soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, + MSN_ADDRESS_BOOK_POST_URL,MSN_GROUP_DEL_SOAP_ACTION, + body, + msn_group_read_cb, + msn_group_written_cb); + msn_soap_post(contact->soapconn,soap_request); + g_free(body); } Modified: branches/soc-2006-msnp13/src/protocols/msn/oim.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-16 14:18:58 UTC (rev 16789) +++ branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-16 16:20:25 UTC (rev 16790) @@ -109,7 +109,8 @@ void msn_oim_send_single_msg(MsnOim *oim,char * msg) { - const char *oimsoapbody,*t,*p; + MsnSoapReq *soap_request; + const char *soap_body,*t,*p; gaim_debug_info("MaYuan","send single OIM Message\n"); oim->sendconn->login_path = g_strdup(MSN_OIM_SEND_URL); @@ -128,8 +129,12 @@ msg ); #endif - msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_send_written_cb); - + soap_request = msn_soap_request_new(MSN_OIM_SEND_HOST, + MSN_OIM_SEND_URL,MSN_OIM_SEND_SOAP_ACTION, + soap_body, + msn_oim_send_read_cb, + msn_oim_send_written_cb); + msn_soap_post(oim->sendconn,soap_request); } void msn_oim_send_msg(MsnOim *oim,char *msg) @@ -234,7 +239,8 @@ static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) { - const char *oimsoapbody,*t,*p; + MsnSoapReq *soap_request; + const char *soap_body,*t,*p; gaim_debug_info("MaYuan","Get single OIM Message\n"); oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL); @@ -242,12 +248,17 @@ t = oim->session->passport_info.t; p = oim->session->passport_info.p; - oimsoapbody = g_strdup_printf(MSN_OIM_GET_TEMPLATE, + soap_body = g_strdup_printf(MSN_OIM_GET_TEMPLATE, t, p, msgid ); - msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb); + soap_request = msn_soap_request_new(MSN_OIM_SEND_HOST, + MSN_OIM_SEND_URL,MSN_OIM_SEND_SOAP_ACTION, + soap_body, + msn_oim_get_read_cb, + msn_oim_get_written_cb); + msn_soap_post(oim->retrieveconn,soap_request); } /*MSN OIM get SOAP request*/ Modified: branches/soc-2006-msnp13/src/protocols/msn/soap.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/soap.c 2006-08-16 14:18:58 UTC (rev 16789) +++ branches/soc-2006-msnp13/src/protocols/msn/soap.c 2006-08-16 16:20:25 UTC (rev 16790) @@ -41,6 +41,8 @@ soapconn->gsc = NULL; soapconn->input_handler = -1; soapconn->output_handler = -1; + + soapconn->soap_queue = g_queue_new(); return soapconn; } @@ -65,6 +67,9 @@ if(soapconn->connect_cb != NULL){ soapconn->connect_cb(data,gsc,cond); } + + /*we do the SOAP request here*/ + msn_soap_post_head_request(soapconn); } /*ssl soap error callback*/ @@ -90,6 +95,11 @@ soapconn->ssl_conn = ssl; soapconn->connect_cb = connect_cb; soapconn->error_cb = error_cb; +} + +void +msn_soap_connect(MsnSoapConn *soapconn) +{ if(soapconn->ssl_conn){ gaim_ssl_connect(soapconn->session->account, soapconn->login_host, GAIM_SSL_DEFAULT_PORT, msn_soap_connect_cb, msn_soap_error_cb, @@ -98,10 +108,24 @@ } } +void +msn_soap_close(MsnSoapConn *soapconn) +{ + if(soapconn->ssl_conn){ + if(soapconn->gsc != NULL){ + gaim_ssl_close(soapconn->gsc); + soapconn->gsc = NULL; + } + }else{ + } +} + /*destroy the soap connection*/ void msn_soap_destroy(MsnSoapConn *soapconn) { + MsnSoapReq *request; + if(soapconn->login_host) g_free(soapconn->login_host); @@ -120,11 +144,12 @@ msn_soap_free_write_buf(soapconn); /*close ssl connection*/ - if(soapconn->gsc != NULL){ - gaim_ssl_close(soapconn->gsc); + msn_soap_close(soapconn); + + while ((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){ + msn_soap_request_free(request); } - soapconn->gsc = NULL; - + g_queue_free(soapconn->soap_queue); g_free(soapconn); } @@ -290,7 +315,7 @@ 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 + soapconn->body_len){ - return; + return; } g_free(body_len); @@ -302,8 +327,12 @@ /*call the read callback*/ if(soapconn->read_cb != NULL){ - soapconn->read_cb(soapconn,source,0); + soapconn->read_cb(soapconn,source,0); } + + /*Process the next queued SOAP request*/ + msn_soap_post_head_request(soapconn); + #if 0 /*clear the read buffer*/ msn_soap_free_read_buf(soapconn); @@ -404,16 +433,78 @@ msn_soap_write_cb(soapconn, soapconn->gsc->fd, GAIM_INPUT_WRITE); } -/*Post the soap action*/ +/* New a soap request*/ +MsnSoapReq * +msn_soap_request_new(const char *host,const char *post_url,const char *soap_action, + const char *body, + GaimInputFunction read_cb,GaimInputFunction written_cb) +{ + MsnSoapReq *request; + + request = g_new0(MsnSoapReq, 1); + request->id = 0; + + request->login_host = g_strdup(host); + request->login_path = g_strdup(post_url); + request->soap_action = g_strdup(soap_action); + request->body = g_strdup(body); + request->read_cb = read_cb; + request->written_cb = written_cb; + + return request; +} + +/*free a soap request*/ void -msn_soap_post(MsnSoapConn *soapconn,const char * body,GaimInputFunction written_cb) +msn_soap_request_free(MsnSoapReq *request) { + g_return_if_fail(request != NULL); + + g_free(request->login_host); + g_free(request->login_path); + g_free(request->soap_action); + g_free(request->body); + request->read_cb = NULL; + request->written_cb = NULL; + + g_free(request); +} + +void +msn_soap_post_head_request(MsnSoapConn *soapconn) +{ + if(!g_queue_is_empty(soapconn->soap_queue)){ + MsnSoapReq *request; + + if((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){ + msn_soap_post_request(soapconn,request); + } + } +} + +void +msn_soap_post(MsnSoapConn *soapconn,MsnSoapReq *request) +{ + g_queue_push_tail(soapconn->soap_queue, request); + if(!msn_soap_connected(soapconn)){ + /*not connected?connect it first*/ + msn_soap_connect(soapconn); + return; + } + /*if connected, what we only needed to do is to queue the request, + * when SOAP request in the queue processed done, will do this command. + * we just waiting... + */ +} + +/*Post the soap request action*/ +void +msn_soap_post_request(MsnSoapConn *soapconn,MsnSoapReq *request) +{ char * soap_head = NULL; - char * soap_body = NULL; char * request_str = NULL; gaim_debug_info("MaYuan","msn_soap_post()...\n"); - soap_body = g_strdup_printf(body); soap_head = g_strdup_printf( "POST %s HTTP/1.1\r\n" "SOAPAction: %s\r\n" @@ -425,21 +516,18 @@ "Content-Length: %d\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n\r\n", - soapconn->login_path, - soapconn->soap_action, + request->login_path, + request->soap_action, soapconn->session->passport_info.mspauth, - soapconn->login_host, - strlen(soap_body) + request->login_host, + strlen(request->body) ); - request_str = g_strdup_printf("%s%s", soap_head,soap_body); - g_free(soapconn->login_path); - g_free(soapconn->soap_action); + request_str = g_strdup_printf("%s%s", soap_head,request->body); g_free(soap_head); - g_free(soap_body); /*free read buffer*/ msn_soap_free_read_buf(soapconn); gaim_debug_info("MaYuan","send to server{%s}\n",request_str); - msn_soap_write(soapconn,request_str,written_cb); + msn_soap_write(soapconn,request_str,request->written_cb); } Modified: branches/soc-2006-msnp13/src/protocols/msn/soap.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/soap.h 2006-08-16 14:18:58 UTC (rev 16789) +++ branches/soc-2006-msnp13/src/protocols/msn/soap.h 2006-08-16 16:20:25 UTC (rev 16790) @@ -28,9 +28,26 @@ #define MSN_SOAP_READ_BUFF_SIZE 8192 +/*MSN SoapRequest structure*/ +typedef struct _MsnSoapReq MsnSoapReq; + /*MSN Https connection structure*/ typedef struct _MsnSoapConn MsnSoapConn; +struct _MsnSoapReq{ + /*request sequence*/ + int id; + + char *login_host; + char *login_path; + char *soap_action; + + char *body; + + GaimInputFunction read_cb; + GaimInputFunction written_cb; +}; + struct _MsnSoapConn{ MsnSession *session; gpointer parent; @@ -55,6 +72,10 @@ /*write handler*/ guint output_handler; + /*Queue of SOAP request to send*/ + int soap_id; + GQueue *soap_queue; + /*write buffer*/ char *write_buf; gsize written_len; @@ -71,6 +92,15 @@ }; /*Function Prototype*/ +/*Soap Request Function */ +MsnSoapReq * +msn_soap_request_new(const char *host,const char *post_url,const char *soap_action, + const char *body, + GaimInputFunction read_cb,GaimInputFunction written_cb); +void msn_soap_request_free(MsnSoapReq *request); +void msn_soap_post_request(MsnSoapConn *soapconn,MsnSoapReq *request); +void msn_soap_post_head_request(MsnSoapConn *soapconn); + /*new a soap conneciton */ MsnSoapConn *msn_soap_new(MsnSession *session,gpointer data,int sslconn); @@ -82,7 +112,7 @@ /*write to soap*/ void msn_soap_write(MsnSoapConn * soapconn, char *write_buf, GaimInputFunction written_cb); -void msn_soap_post(MsnSoapConn *soapconn,const char * body,GaimInputFunction written_cb); +void msn_soap_post(MsnSoapConn *soapconn,MsnSoapReq *request); void msn_soap_free_read_buf(MsnSoapConn *soapconn); void msn_soap_free_write_buf(MsnSoapConn *soapconn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-16 14:19:07
|
Revision: 16789 Author: sadrul Date: 2006-08-16 07:18:58 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16789&view=rev Log Message: ----------- Update gntgf to work for nick-said messages in chats. Modified Paths: -------------- trunk/console/plugins/gntgf.c Modified: trunk/console/plugins/gntgf.c =================================================================== --- trunk/console/plugins/gntgf.c 2006-08-16 11:13:19 UTC (rev 16788) +++ trunk/console/plugins/gntgf.c 2006-08-16 14:18:58 UTC (rev 16789) @@ -34,6 +34,7 @@ #include <version.h> #include <blist.h> #include <conversation.h> +#include <util.h> #include <gnt.h> #include <gntbox.h> @@ -144,7 +145,18 @@ received_chat_msg(GaimAccount *account, const char *sender, const char *msg, GaimConversation *conv, GaimMessageFlags flags, gpointer null) { - if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_NICK) && (flags & GAIM_MESSAGE_NICK)) + const char *nick; + + if (flags & GAIM_MESSAGE_WHISPER) + return; + + nick = GAIM_CONV_CHAT(conv)->nick; + + if (g_utf8_collate(sender, nick) == 0) + return; + + if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_NICK) && + (gaim_utf8_has_word(msg, nick))) notify(_("%s said your nick in %s"), sender, gaim_conversation_get_name(conv)); else if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_MSG)) notify(_("%s sent a message in %s"), sender, gaim_conversation_get_name(conv)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-16 11:14:56
|
Revision: 16788 Author: datallah Date: 2006-08-16 04:13:19 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16788&view=rev Log Message: ----------- gdk_threads_init() is causing problems on win32 for some reason. Modified Paths: -------------- trunk/src/gtkmain.c Modified: trunk/src/gtkmain.c =================================================================== --- trunk/src/gtkmain.c 2006-08-16 07:37:42 UTC (rev 16787) +++ trunk/src/gtkmain.c 2006-08-16 11:13:19 UTC (rev 16788) @@ -650,7 +650,9 @@ * threadify dbus when that gets initialized. Ugh. */ if (!g_thread_supported()) g_thread_init(NULL); +#ifndef _WIN32 gdk_threads_init(); +#endif #endif /* Glib has threads */ gui_check = gtk_init_check(&argc, &argv); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 07:37:51
|
Revision: 16787 Author: thekingant Date: 2006-08-16 00:37:42 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16787&view=rev Log Message: ----------- Backport the following SVN revisions from HEAD to v2_0_0 16774-16779 16781-16786 This includes Sean's global icon thing and the fix for the MSN crash Modified Paths: -------------- branches/v2_0_0/src/dbus-server.c branches/v2_0_0/src/gtkaccount.c branches/v2_0_0/src/gtkblist.c branches/v2_0_0/src/gtkstatusbox.c branches/v2_0_0/src/gtkstatusbox.h branches/v2_0_0/src/gtkutils.c branches/v2_0_0/src/gtkutils.h branches/v2_0_0/src/prefs.c branches/v2_0_0/src/protocols/msn/nexus.c branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c Modified: branches/v2_0_0/src/dbus-server.c =================================================================== --- branches/v2_0_0/src/dbus-server.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/dbus-server.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -48,7 +48,7 @@ /* * Here we include the list of #GAIM_DBUS_DEFINE_TYPE statements for * all structs defined in gaim. This file has been generated by the - * #dbus-analize-types.py script. + * #dbus-analyze-types.py script. */ #include "dbus-types.c" Modified: branches/v2_0_0/src/gtkaccount.c =================================================================== --- branches/v2_0_0/src/gtkaccount.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkaccount.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -115,6 +115,7 @@ GtkWidget *user_frame; GtkWidget *new_mail_check; GtkWidget *icon_hbox; + GtkWidget *icon_check; GtkWidget *icon_entry; char *icon_path; GtkWidget *icon_filesel; @@ -153,8 +154,6 @@ static void add_account_to_liststore(GaimAccount *account, gpointer user_data); static void set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account); -static char* -convert_buddy_icon(GaimPlugin *plugin, const char *path); /************************************************************************** * Add/Modify Account dialog @@ -271,210 +270,28 @@ } } -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ static void -icon_filesel_choose_cb(GtkWidget *widget, gint response, AccountPrefsDialog *dialog) +icon_filesel_choose_cb(const char *filename, gpointer data) { - char *filename, *current_folder; + AccountPrefsDialog *dialog; - if (response != GTK_RESPONSE_ACCEPT) { - if (response == GTK_RESPONSE_CANCEL) - gtk_widget_destroy(dialog->icon_filesel); - dialog->icon_filesel = NULL; - return; - } + dialog = data; - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); - current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); - if (current_folder != NULL) { - gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); - g_free(current_folder); + if (filename) { + g_free(dialog->icon_path); + dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, filename); + set_dialog_icon(dialog); + gtk_widget_show(dialog->icon_entry); } -#else /* FILECHOOSER */ -static void -icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) -{ - char *filename, *current_folder; - - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); - - /* If they typed in a directory, change there */ - if (gaim_gtk_check_if_dir(filename, - GTK_FILE_SELECTION(dialog->icon_filesel))) - { - g_free(filename); - return; - } - - current_folder = g_path_get_dirname(filename); - if (current_folder != NULL) { - gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); - g_free(current_folder); - } - -#endif /* FILECHOOSER */ - - g_free(dialog->icon_path); - dialog->icon_path = convert_buddy_icon(dialog->plugin, filename); - set_dialog_icon(dialog); - gtk_widget_show(dialog->icon_entry); - - gtk_widget_destroy(dialog->icon_filesel); dialog->icon_filesel = NULL; - g_free(filename); - } - -static void -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ -icon_preview_change_cb(GtkFileChooser *widget, AccountPrefsDialog *dialog) -#else /* FILECHOOSER */ -icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog) -#endif /* FILECHOOSER */ -{ - GdkPixbuf *pixbuf, *scale; - int height, width; - char *basename, *markup, *size; - struct stat st; - char *filename; - -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - filename = gtk_file_chooser_get_preview_filename( - GTK_FILE_CHOOSER(dialog->icon_filesel)); -#else /* FILECHOOSER */ - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); -#endif /* FILECHOOSER */ - - if (!filename || g_stat(filename, &st)) - { - g_free(filename); - return; - } - - pixbuf = gdk_pixbuf_new_from_file(filename, NULL); - if (!pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); - gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - gtk_file_chooser_set_preview_widget_active( - GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE); -#endif /* FILECHOOSER */ - g_free(filename); - return; - } - - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - basename = g_path_get_basename(filename); - size = gaim_str_size_to_units(st.st_size); - markup = g_strdup_printf(_("<b>File:</b> %s\n" - "<b>File size:</b> %s\n" - "<b>Image size:</b> %dx%d"), - basename, size, width, height); - - scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, - 50, GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - gtk_file_chooser_set_preview_widget_active( - GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE); -#endif /* FILECHOOSER */ - gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); - - g_object_unref(G_OBJECT(pixbuf)); - g_object_unref(G_OBJECT(scale)); - g_free(filename); - g_free(basename); - g_free(size); - g_free(markup); } -#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ static void -icon_filesel_delete_cb(GtkWidget *w, AccountPrefsDialog *dialog) -{ - if (dialog->icon_filesel != NULL) - gtk_widget_destroy(dialog->icon_filesel); - - dialog->icon_filesel = NULL; -} -#endif /* FILECHOOSER */ - -static void icon_select_cb(GtkWidget *button, AccountPrefsDialog *dialog) { -#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - GtkWidget *hbox; - GtkWidget *tv; - GtkTreeSelection *sel; -#endif /* FILECHOOSER */ - const char *current_folder; - - if (dialog->icon_filesel != NULL) { - gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); - return; - } - - current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), - GTK_WINDOW(dialog->window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); - if ((current_folder != NULL) && (*current_folder != '\0')) - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), - current_folder); - - dialog->icon_preview = gtk_image_new(); - dialog->icon_text = gtk_label_new(NULL); - gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); - gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), - GTK_WIDGET(dialog->icon_preview)); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", - G_CALLBACK(icon_preview_change_cb), dialog); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", - G_CALLBACK(icon_filesel_choose_cb), dialog); - icon_preview_change_cb(NULL, dialog); -#else /* FILECHOOSER */ - dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); - dialog->icon_preview = gtk_image_new(); - dialog->icon_text = gtk_label_new(NULL); - if ((current_folder != NULL) && (*current_folder != '\0')) - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), - current_folder); - - gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_box_pack_start( - GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), - hbox, FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, - FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); - - tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); - - g_signal_connect(G_OBJECT(sel), "changed", - G_CALLBACK(icon_preview_change_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), - "clicked", - G_CALLBACK(icon_filesel_choose_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), - "clicked", - G_CALLBACK(icon_filesel_delete_cb), dialog); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", - G_CALLBACK(icon_filesel_delete_cb), dialog); -#endif /* FILECHOOSER */ - - gtk_widget_show_all(GTK_WIDGET(dialog->icon_filesel)); + dialog->icon_filesel = gaim_gtk_buddy_icon_chooser_new(GTK_WINDOW(dialog->window), icon_filesel_choose_cb, dialog); + gtk_widget_show_all(dialog->icon_filesel); } static void @@ -510,7 +327,8 @@ if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) *rtmp = '\0'; g_free(dialog->icon_path); - dialog->icon_path = convert_buddy_icon(dialog->plugin, tmp); + + dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, tmp); set_dialog_icon(dialog); gtk_widget_show(dialog->icon_entry); g_free(tmp); @@ -520,207 +338,6 @@ gtk_drag_finish(dc, FALSE, FALSE, t); } - -#if GTK_CHECK_VERSION(2,2,0) -static gboolean -str_array_match(char **a, char **b) -{ - int i, j; - - if (!a || !b) - return FALSE; - for (i = 0; a[i] != NULL; i++) - for (j = 0; b[j] != NULL; j++) - if (!g_ascii_strcasecmp(a[i], b[j])) - return TRUE; - return FALSE; -} -#endif - -static char* -convert_buddy_icon(GaimPlugin *plugin, const char *path) -{ -#if GTK_CHECK_VERSION(2,2,0) - int width, height; - char **pixbuf_formats = NULL; - GdkPixbufFormat *format; - GdkPixbuf *pixbuf; - GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); - char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0); -#if !GTK_CHECK_VERSION(2,4,0) - GdkPixbufLoader *loader; - FILE *file; - struct stat st; - void *data = NULL; -#endif -#endif - const char *dirname = gaim_buddy_icons_get_cache_dir(); - char *random = g_strdup_printf("%x", g_random_int()); - char *filename = g_build_filename(dirname, random, NULL); - - if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { - gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); - - if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { - gaim_debug_error("buddyicon", - "Unable to create directory %s: %s\n", - dirname, strerror(errno)); -#if GTK_CHECK_VERSION(2,2,0) - g_strfreev(prpl_formats); -#endif - g_free(random); - g_free(filename); - return NULL; - } - } - -#if GTK_CHECK_VERSION(2,2,0) -#if GTK_CHECK_VERSION(2,4,0) - format = gdk_pixbuf_get_file_info (path, &width, &height); -#else - loader = gdk_pixbuf_loader_new(); - if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) { - data = g_malloc(st.st_size); - fread(data, 1, st.st_size, file); - fclose(file); - gdk_pixbuf_loader_write(loader, data, st.st_size, NULL); - g_free(data); - } - gdk_pixbuf_loader_close(loader, NULL); - pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - format = gdk_pixbuf_loader_get_format(loader); - g_object_unref(G_OBJECT(loader)); -#endif - pixbuf_formats = gdk_pixbuf_format_get_extensions(format); - - if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ - (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ - (prpl_info->icon_spec.min_width <= width && - prpl_info->icon_spec.max_width >= width && - prpl_info->icon_spec.min_height <= height && - prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ -#endif - { - gchar *contents; - gsize length; - FILE *image; - -#if GTK_CHECK_VERSION(2,2,0) - g_strfreev(prpl_formats); - g_strfreev(pixbuf_formats); -#endif - - /* Copy the image to the cache folder as "filename". */ - - if (!g_file_get_contents(path, &contents, &length, NULL) || - (image = g_fopen(filename, "wb")) == NULL) - { - g_free(random); - g_free(filename); -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - return NULL; - } - - if (fwrite(contents, 1, length, image) != length) - { - fclose(image); - g_unlink(filename); - - g_free(random); - g_free(filename); -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - return NULL; - } - fclose(image); - -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - - g_free(filename); - return random; - } -#if GTK_CHECK_VERSION(2,2,0) - else - { - int i; - GError *error = NULL; - GdkPixbuf *scale; - pixbuf = gdk_pixbuf_new_from_file(path, &error); - g_strfreev(pixbuf_formats); - if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) && - (width < prpl_info->icon_spec.min_width || - width > prpl_info->icon_spec.max_width || - height < prpl_info->icon_spec.min_height || - height > prpl_info->icon_spec.max_height)) - { - int new_width = width; - int new_height = height; - - if(new_width > prpl_info->icon_spec.max_width) - new_width = prpl_info->icon_spec.max_width; - else if(new_width < prpl_info->icon_spec.min_width) - new_width = prpl_info->icon_spec.min_width; - if(new_height > prpl_info->icon_spec.max_height) - new_height = prpl_info->icon_spec.max_height; - else if(new_height < prpl_info->icon_spec.min_height) - new_height = prpl_info->icon_spec.min_height; - - /* preserve aspect ratio */ - if ((double)height * (double)new_width > - (double)width * (double)new_height) { - new_width = 0.5 + (double)width * (double)new_height / (double)height; - } else { - new_height = 0.5 + (double)height * (double)new_width / (double)width; - } - - scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height, - GDK_INTERP_HYPER); - g_object_unref(G_OBJECT(pixbuf)); - pixbuf = scale; - } - if (error) { - g_free(random); - g_free(filename); - gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); - g_error_free(error); - g_strfreev(prpl_formats); - return NULL; - } - - for (i = 0; prpl_formats[i]; i++) { - gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); - /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful, - * FALSE if an error was set. */ - if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE) - break; - gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message); - g_error_free(error); - error = NULL; - } - g_strfreev(prpl_formats); - if (!error) { - g_object_unref(G_OBJECT(pixbuf)); - g_free(filename); - return random; - } else { - gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message); - g_error_free(error); - } - g_free(random); - g_free(filename); - g_object_unref(G_OBJECT(pixbuf)); - } - return NULL; -#endif -} - static void update_editable(GaimConnection *gc, AccountPrefsDialog *dialog) { @@ -898,6 +515,12 @@ } static void +icon_check_cb(GtkWidget *checkbox, AccountPrefsDialog *dialog) +{ + gtk_widget_set_sensitive(dialog->icon_hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); +} + +static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent) { GtkWidget *frame; @@ -930,12 +553,17 @@ gtk_widget_show(dialog->new_mail_check); /* Buddy icon */ + dialog->icon_check = gtk_check_button_new_with_label(_("Use this buddy icon for this account:")); + g_signal_connect(G_OBJECT(dialog->icon_check), "toggled", G_CALLBACK(icon_check_cb), dialog); + gtk_widget_show(dialog->icon_check); + gtk_box_pack_start(GTK_BOX(vbox), dialog->icon_check, FALSE, FALSE, 0); + dialog->icon_hbox = hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtk_widget_set_sensitive(hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); - label = gtk_label_new(_("Buddy icon:")); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); + label = gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); @@ -976,12 +604,14 @@ if (dialog->account != NULL) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->new_mail_check), - gaim_account_get_check_mail(dialog->account)); + gaim_account_get_check_mail(dialog->account)); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check), + !gaim_account_get_ui_bool(dialog->account, GAIM_GTK_UI, "use-global-buddyicon", + TRUE)); - if (gaim_account_get_buddy_icon(dialog->account) != NULL) { - dialog->icon_path = g_strdup(gaim_account_get_buddy_icon(dialog->account)); - set_dialog_icon(dialog); - } + dialog->icon_path = g_strdup(gaim_account_get_ui_string(dialog->account, GAIM_GTK_UI, "non-global-buddyicon", NULL)); + set_dialog_icon(dialog); } if (!dialog->prpl_info || @@ -1425,12 +1055,13 @@ if (dialog->icon_path != NULL) { - const char *icon = gaim_account_get_buddy_icon(dialog->account); + const char *icon = gaim_account_get_ui_string(dialog->account, GAIM_GTK_UI, "non-global-buddyicon", NULL); if (dialog->icon_path != NULL && (icon == NULL || strcmp(dialog->icon_path, icon))) { /* The user set an icon, which would've been cached by convert_buddy_icon, * but didn't save the changes. Delete the cache file. */ char *filename = g_build_filename(gaim_buddy_icons_get_cache_dir(), dialog->icon_path, NULL); + printf("Deleting\n"); g_unlink(filename); g_free(filename); } @@ -1460,7 +1091,7 @@ const char *value; char *username; char *tmp; - gboolean new = FALSE; + gboolean new = FALSE, icon_change = FALSE; GaimAccount *account; if (dialog->account == NULL) @@ -1488,7 +1119,20 @@ gaim_account_set_alias(account, NULL); /* Buddy Icon */ - gaim_account_set_buddy_icon(account, dialog->icon_path); + if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", TRUE) == + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) { + icon_change = TRUE; + } + gaim_account_set_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); + gaim_account_set_ui_string(account, GAIM_GTK_UI, "non-global-buddyicon", dialog->icon_path); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) { + gaim_account_set_buddy_icon(account, dialog->icon_path); + } else if (gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon") && icon_change) { + char *icon = gaim_gtk_convert_buddy_icon(dialog->plugin, gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon")); + gaim_account_set_buddy_icon(account, icon); + g_free(icon); + } + /* Remember Password */ gaim_account_set_remember_password(account, @@ -2672,6 +2316,7 @@ gaim_prefs_add_none("/gaim/gtk/accounts/dialog"); gaim_prefs_add_int("/gaim/gtk/accounts/dialog/width", 520); gaim_prefs_add_int("/gaim/gtk/accounts/dialog/height", 321); + gaim_prefs_add_string("/gaim/gtk/accounts/buddyicon", NULL); gaim_signal_register(gaim_gtk_account_get_handle(), "account-modified", gaim_marshal_VOID__POINTER, NULL, 1, Modified: branches/v2_0_0/src/gtkblist.c =================================================================== --- branches/v2_0_0/src/gtkblist.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkblist.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -3798,12 +3798,11 @@ /* Add the statusbox */ gtkblist->statusbox = gtk_gaim_status_box_new(); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); - + gtk_gaim_status_box_set_buddy_icon(gtkblist->statusbox, gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon")); gtk_widget_show(gtkblist->statusbox); - gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); - - + /* set the Show Offline Buddies option. must be done * after the treeview or faceprint gets mad. -Robot101 */ Modified: branches/v2_0_0/src/gtkstatusbox.c =================================================================== --- branches/v2_0_0/src/gtkstatusbox.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkstatusbox.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -77,6 +77,8 @@ static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); +static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); + static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); @@ -260,6 +262,17 @@ gaim_signals_disconnect_by_handle(statusbox); gaim_prefs_disconnect_by_handle(statusbox); + gdk_cursor_unref(statusbox->hand_cursor); + gdk_cursor_unref(statusbox->arrow_cursor); + + g_object_unref(G_OBJECT(statusbox->buddy_icon)); + g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); + + if (statusbox->buddy_icon_sel) + gtk_widget_destroy(statusbox->buddy_icon_sel); + + g_free(statusbox->buddy_icon_path); + G_OBJECT_CLASS(parent_class)->finalize(obj); } @@ -903,6 +916,62 @@ } static void +icon_choose_cb(const char *filename, gpointer data) +{ + GtkGaimStatusBox *box; + + box = data; + + if (filename) { + GList *accounts; + for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { + GaimAccount *account = accounts->data; + if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddy-icon", TRUE) && + GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account)))->icon_spec.format) { + char *icon = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), + filename); + gaim_account_set_buddy_icon(account, icon); + g_free(icon); + } + } + gtk_gaim_status_box_set_buddy_icon(box, filename); + } + + box->buddy_icon_sel = NULL; +} + +static gboolean +icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) +{ + GtkWidget *filesel; + + if (box->buddy_icon_sel) { + gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); + return FALSE; + } + + filesel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); + gtk_widget_show_all(filesel); + return FALSE; +} + +static gboolean +icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) +{ + gdk_window_set_cursor(widget->window, box->hand_cursor); + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon_hover); + return FALSE; +} + +static gboolean +icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) +{ + gdk_window_set_cursor(widget->window, box->arrow_cursor); + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon) ; + return FALSE; +} + +static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) { GtkCellRenderer *text_rend; @@ -918,6 +987,18 @@ status_box->vsep = gtk_vseparator_new(); status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + status_box->buddy_icon = gdk_pixbuf_new_from_file("/home/seanegan/p1120233.jpg", NULL); + status_box->icon = gtk_image_new_from_pixbuf(status_box->buddy_icon); + status_box->icon_box = gtk_event_box_new(); + status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); + status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); + + g_signal_connect(G_OBJECT(status_box->icon_box), "enter-notify-event", G_CALLBACK(icon_box_enter_cb), status_box); + g_signal_connect(G_OBJECT(status_box->icon_box), "leave-notify-event", G_CALLBACK(icon_box_leave_cb), status_box); + g_signal_connect(G_OBJECT(status_box->icon_box), "button-press-event", G_CALLBACK(icon_box_press_cb), status_box); + + gtk_container_add(GTK_CONTAINER(status_box->icon_box), status_box->icon); + status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); @@ -930,6 +1011,7 @@ gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); gtk_widget_show_all(status_box->toggle_button); + gtk_widget_show_all(status_box->icon_box); #if GTK_CHECK_VERSION(2,4,0) gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); #endif @@ -980,6 +1062,7 @@ #endif gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); + gtk_widget_set_parent(status_box->icon_box, GTK_WIDGET(status_box)); GTK_BIN(status_box)->child = status_box->toggle_button; gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); @@ -1020,14 +1103,58 @@ requisition->height += box_req.height + 3; requisition->width = 1; + + } +/* From gnome-panel */ static void +do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift) +{ + gint i, j; + gint width, height, has_alpha, srcrowstride, destrowstride; + guchar *target_pixels; + guchar *original_pixels; + guchar *pixsrc; + guchar *pixdest; + int val; + guchar r,g,b; + + has_alpha = gdk_pixbuf_get_has_alpha (src); + width = gdk_pixbuf_get_width (src); + height = gdk_pixbuf_get_height (src); + srcrowstride = gdk_pixbuf_get_rowstride (src); + destrowstride = gdk_pixbuf_get_rowstride (dest); + target_pixels = gdk_pixbuf_get_pixels (dest); + original_pixels = gdk_pixbuf_get_pixels (src); + + for (i = 0; i < height; i++) { + pixdest = target_pixels + i*destrowstride; + pixsrc = original_pixels + i*srcrowstride; + for (j = 0; j < width; j++) { + r = *(pixsrc++); + g = *(pixsrc++); + b = *(pixsrc++); + val = r + shift; + *(pixdest++) = CLAMP(val, 0, 255); + val = g + shift; + *(pixdest++) = CLAMP(val, 0, 255); + val = b + shift; + *(pixdest++) = CLAMP(val, 0, 255); + if (has_alpha) + *(pixdest++) = *(pixsrc++); + } + } +} + +static void gtk_gaim_status_box_size_allocate(GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { + GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); GtkRequisition req = {0,0}; - GtkAllocation parent_alc, box_alc; + GtkAllocation parent_alc, box_alc, icon_alc; + GdkPixbuf *scaled; combo_box_size_request(widget, &req); @@ -1039,7 +1166,33 @@ parent_alc = *allocation; parent_alc.height = MAX(1,req.height); parent_alc.y += 3; + parent_alc.width -= (parent_alc.height + 3); combo_box_size_allocate(widget, &parent_alc); + + icon_alc = *allocation; + icon_alc.height = MAX(1,req.height); + icon_alc.width = icon_alc.height; + icon_alc.x = allocation->width - icon_alc.width; + icon_alc.y += 3; + + if (status_box->icon_size != icon_alc.height) + { + if ((status_box->buddy_icon_path != NULL) && + (*status_box->buddy_icon_path != '\0')) + { + scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, + icon_alc.height, icon_alc.width, FALSE, NULL); + status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); + g_object_unref(status_box->buddy_icon); + status_box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); + } + status_box->icon_size = icon_alc.height; + } + gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->icon_box, &icon_alc); + + gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->toggle_button, &parent_alc); widget->allocation = *allocation; } @@ -1051,6 +1204,7 @@ GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); + gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); return FALSE; } @@ -1067,6 +1221,7 @@ (* callback) (status_box->vbox, callback_data); (* callback) (status_box->toggle_button, callback_data); (* callback) (status_box->arrow, callback_data); + (* callback) (status_box->icon_box, callback_data); } combo_box_forall(container, include_internals, callback, callback_data); @@ -1175,6 +1330,37 @@ } void +gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *box, const char *filename) +{ + GdkPixbuf *scaled; + g_free(box->buddy_icon_path); + box->buddy_icon_path = g_strdup(filename); + + if ((filename != NULL) && (*filename != '\0')) + { + if (box->buddy_icon != NULL) + g_object_unref(box->buddy_icon); + scaled = gdk_pixbuf_new_from_file_at_scale(filename, + box->icon_size, box->icon_size, FALSE, NULL); + if (scaled != NULL) + { + box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); + box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + } + } + + gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); +} + +const char* +gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *box) +{ + return box->buddy_icon_path; +} + +void gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) { if (!status_box) Modified: branches/v2_0_0/src/gtkstatusbox.h =================================================================== --- branches/v2_0_0/src/gtkstatusbox.h 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkstatusbox.h 2006-08-16 07:37:42 UTC (rev 16787) @@ -83,6 +83,17 @@ GtkWidget *vbox, *sw; GtkWidget *imhtml; + + char *buddy_icon_path; + GdkPixbuf *buddy_icon; + GdkPixbuf *buddy_icon_hover; + GtkWidget *buddy_icon_sel; + GtkWidget *icon; + GtkWidget *icon_box; + GdkCursor *hand_cursor; + GdkCursor *arrow_cursor; + int icon_size; + gboolean imhtml_visible; GtkWidget *cell_view; @@ -117,16 +128,16 @@ struct _GtkGaimStatusBoxClass { - GtkComboBoxClass parent_class; + GtkComboBoxClass parent_class; - /* signals */ - void (* changed) (GtkComboBox *combo_box); + /* signals */ + void (* changed) (GtkComboBox *combo_box); - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); + /* Padding for future expansion */ + void (*_gtk_reserved0) (void); + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); }; @@ -146,6 +157,12 @@ void gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box); +void +gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *status_box, const char *filename); + +const char * +gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *status_box); + char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box); G_END_DECLS Modified: branches/v2_0_0/src/gtkutils.c =================================================================== --- branches/v2_0_0/src/gtkutils.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkutils.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -2211,3 +2211,439 @@ gdk_window_set_cursor(widget->window, NULL); } +struct _icon_chooser { + GtkWidget *icon_filesel; + GtkWidget *icon_preview; + GtkWidget *icon_text; + + void (*callback)(const char*,gpointer); + gpointer data; +}; + +#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +static void +icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog) +{ + if (dialog->icon_filesel != NULL) + gtk_widget_destroy(dialog->icon_filesel); + + if (dialog->callback) + dialog->callback(NULL, data); + + g_free(dialog); +} +#endif /* FILECHOOSER */ + + + +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +static void +icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog) +{ + char *filename, *current_folder; + + if (response != GTK_RESPONSE_ACCEPT) { + if (response == GTK_RESPONSE_CANCEL) { + gtk_widget_destroy(dialog->icon_filesel); + } + dialog->icon_filesel = NULL; + if (dialog->callback) + dialog->callback(NULL, dialog->data); + g_free(dialog); + return; + } + + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); + current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); + if (current_folder != NULL) { + gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); + g_free(current_folder); + } + +#else /* FILECHOOSER */ +static void +icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) +{ + char *filename, *current_folder; + + filename = g_strdup(gtk_file_selection_get_filename( + GTK_FILE_SELECTION(dialog->icon_filesel))); + + /* If they typed in a directory, change there */ + if (gaim_gtk_check_if_dir(filename, + GTK_FILE_SELECTION(dialog->icon_filesel))) + { + g_free(filename); + return; + } + + current_folder = g_path_get_dirname(filename); + if (current_folder != NULL) { + gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); + g_free(current_folder); + } + +#endif /* FILECHOOSER */ + if (dialog->callback) + dialog->callback(filename, dialog->data); + gtk_widget_destroy(dialog->icon_filesel); + g_free(filename); + g_free(dialog); + } + + +static void +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog) +#else /* FILECHOOSER */ +icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog) +#endif /* FILECHOOSER */ +{ + GdkPixbuf *pixbuf, *scale; + int height, width; + char *basename, *markup, *size; + struct stat st; + char *filename; + +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + filename = gtk_file_chooser_get_preview_filename( + GTK_FILE_CHOOSER(dialog->icon_filesel)); +#else /* FILECHOOSER */ + filename = g_strdup(gtk_file_selection_get_filename( + GTK_FILE_SELECTION(dialog->icon_filesel))); +#endif /* FILECHOOSER */ + + if (!filename || g_stat(filename, &st)) + { + g_free(filename); + return; + } + + pixbuf = gdk_pixbuf_new_from_file(filename, NULL); + if (!pixbuf) { + gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); + gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + gtk_file_chooser_set_preview_widget_active( + GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE); +#endif /* FILECHOOSER */ + g_free(filename); + return; + } + + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + basename = g_path_get_basename(filename); + size = gaim_str_size_to_units(st.st_size); + markup = g_strdup_printf(_("<b>File:</b> %s\n" + "<b>File size:</b> %s\n" + "<b>Image size:</b> %dx%d"), + basename, size, width, height); + + scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, + 50, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + gtk_file_chooser_set_preview_widget_active( + GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE); +#endif /* FILECHOOSER */ + gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); + + g_object_unref(G_OBJECT(pixbuf)); + g_object_unref(G_OBJECT(scale)); + g_free(filename); + g_free(basename); + g_free(size); + g_free(markup); +} + + +GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { + struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); + +#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + GtkWidget *hbox; + GtkWidget *tv; + GtkTreeSelection *sel; +#endif /* FILECHOOSER */ + const char *current_folder; + + dialog->callback = callback; + dialog->data = data; + + if (dialog->icon_filesel != NULL) { + gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); + return NULL; + } + + current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + + dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), + parent, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); + if ((current_folder != NULL) && (*current_folder != '\0')) + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), + current_folder); + + dialog->icon_preview = gtk_image_new(); + dialog->icon_text = gtk_label_new(NULL); + gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); + gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), + GTK_WIDGET(dialog->icon_preview)); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", + G_CALLBACK(icon_preview_change_cb), dialog); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", + G_CALLBACK(icon_filesel_choose_cb), dialog); + icon_preview_change_cb(NULL, dialog); +#else /* FILECHOOSER */ + dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); + dialog->icon_preview = gtk_image_new(); + dialog->icon_text = gtk_label_new(NULL); + if ((current_folder != NULL) && (*current_folder != '\0')) + gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), + current_folder); + + gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start( + GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), + hbox, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, + FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); + + tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); + + g_signal_connect(G_OBJECT(sel), "changed", + G_CALLBACK(icon_preview_change_cb), dialog); + g_signal_connect( + G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), + "clicked", + G_CALLBACK(icon_filesel_choose_cb), dialog); + g_signal_connect( + G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), + "clicked", + G_CALLBACK(icon_filesel_delete_cb), dialog); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", + G_CALLBACK(icon_filesel_delete_cb), dialog); +#endif /* FILECHOOSER */ + return dialog->icon_filesel; +} + + +#if GTK_CHECK_VERSION(2,2,0) +static gboolean +str_array_match(char **a, char **b) +{ + int i, j; + + if (!a || !b) + return FALSE; + for (i = 0; a[i] != NULL; i++) + for (j = 0; b[j] != NULL; j++) + if (!g_ascii_strcasecmp(a[i], b[j])) + return TRUE; + return FALSE; +} +#endif + +char * +gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) +{ +#if GTK_CHECK_VERSION(2,2,0) + int width, height; + char **pixbuf_formats = NULL; + GdkPixbufFormat *format; + GdkPixbuf *pixbuf; + GaimPluginProtocolInfo *prpl_info; + char **prpl_formats; +#if !GTK_CHECK_VERSION(2,4,0) + GdkPixbufLoader *loader; + FILE *file; + struct stat st; + void *data = NULL; +#endif +#endif + const char *dirname; + char *random; + char *filename; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL); + + prpl_formats = g_strsplit(prpl_info->icon_spec.format,",",0); + dirname = gaim_buddy_icons_get_cache_dir(); + random = g_strdup_printf("%x", g_random_int()); + filename = g_build_filename(dirname, random, NULL); + + if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { + gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); + + if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { + gaim_debug_error("buddyicon", + "Unable to create directory %s: %s\n", + dirname, strerror(errno)); +#if GTK_CHECK_VERSION(2,2,0) + g_strfreev(prpl_formats); +#endif + g_free(random); + g_free(filename); + return NULL; + } + } + +#if GTK_CHECK_VERSION(2,2,0) +#if GTK_CHECK_VERSION(2,4,0) + format = gdk_pixbuf_get_file_info (path, &width, &height); +#else + loader = gdk_pixbuf_loader_new(); + if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) { + data = g_malloc(st.st_size); + fread(data, 1, st.st_size, file); + fclose(file); + gdk_pixbuf_loader_write(loader, data, st.st_size, NULL); + g_free(data); + } + gdk_pixbuf_loader_close(loader, NULL); + pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + format = gdk_pixbuf_loader_get_format(loader); + g_object_unref(G_OBJECT(loader)); +#endif + if (format == NULL) + return NULL; + pixbuf_formats = gdk_pixbuf_format_get_extensions(format); + + if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ + (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ + (prpl_info->icon_spec.min_width <= width && + prpl_info->icon_spec.max_width >= width && + prpl_info->icon_spec.min_height <= height && + prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ +#endif + { + gchar *contents; + gsize length; + FILE *image; + +#if GTK_CHECK_VERSION(2,2,0) + g_strfreev(prpl_formats); + g_strfreev(pixbuf_formats); +#endif + + /* Copy the image to the cache folder as "filename". */ + + if (!g_file_get_contents(path, &contents, &length, NULL) || + (image = g_fopen(filename, "wb")) == NULL) + { + g_free(random); + g_free(filename); +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + return NULL; + } + + if (fwrite(contents, 1, length, image) != length) + { + fclose(image); + g_unlink(filename); + + g_free(random); + g_free(filename); +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + return NULL; + } + fclose(image); + +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + + g_free(filename); + return random; + } +#if GTK_CHECK_VERSION(2,2,0) + else + { + int i; + GError *error = NULL; + GdkPixbuf *scale; + pixbuf = gdk_pixbuf_new_from_file(path, &error); + g_strfreev(pixbuf_formats); + if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) && + (width < prpl_info->icon_spec.min_width || + width > prpl_info->icon_spec.max_width || + height < prpl_info->icon_spec.min_height || + height > prpl_info->icon_spec.max_height)) + { + int new_width = width; + int new_height = height; + + if(new_width > prpl_info->icon_spec.max_width) + new_width = prpl_info->icon_spec.max_width; + else if(new_width < prpl_info->icon_spec.min_width) + new_width = prpl_info->icon_spec.min_width; + if(new_height > prpl_info->icon_spec.max_height) + new_height = prpl_info->icon_spec.max_height; + else if(new_height < prpl_info->icon_spec.min_height) + new_height = prpl_info->icon_spec.min_height; + + /* preserve aspect ratio */ + if ((double)height * (double)new_width > + (double)width * (double)new_height) { + new_width = 0.5 + (double)width * (double)new_height / (double)height; + } else { + new_height = 0.5 + (double)height * (double)new_width / (double)width; + } + + scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height, + GDK_INTERP_HYPER); + g_object_unref(G_OBJECT(pixbuf)); + pixbuf = scale; + } + if (error) { + g_free(random); + g_free(filename); + gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); + g_error_free(error); + g_strfreev(prpl_formats); + return NULL; + } + + for (i = 0; prpl_formats[i]; i++) { + gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); + /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful, + * FALSE if an error was set. */ + if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE) + break; + gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message); + g_error_free(error); + error = NULL; + } + g_strfreev(prpl_formats); + if (!error) { + g_object_unref(G_OBJECT(pixbuf)); + g_free(filename); + return random; + } else { + gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message); + g_error_free(error); + } + g_free(random); + g_free(filename); + g_object_unref(G_OBJECT(pixbuf)); + } + return NULL; +#endif +} Modified: branches/v2_0_0/src/gtkutils.h =================================================================== --- branches/v2_0_0/src/gtkutils.h 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/gtkutils.h 2006-08-16 07:37:42 UTC (rev 16787) @@ -462,4 +462,23 @@ */ void gaim_gtk_clear_cursor(GtkWidget *widget); +/** + * Creates a File Selection widget for choosing a buddy icon + * + * @param parent The parent window + * @param callback The callback to call when the window is closed. If the user chose an icon, the char* argument will point to its path + * @param data Data to pass to @callback + * @return The file dialog + */ +GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data); + +/** + * Converts a buddy icon to the required size and format + * + * @param plugin The prpl to conver the icon + * @param path The path of a buddy icon to convert + * @return The path of a new buddy icon + */ +char* gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path); + #endif /* _GAIM_GTKUTILS_H_ */ Modified: branches/v2_0_0/src/prefs.c =================================================================== --- branches/v2_0_0/src/prefs.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/prefs.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -124,14 +124,14 @@ } else if (pref->type == GAIM_PREF_STRING) { xmlnode_set_attrib(node, "type", "string"); - xmlnode_set_attrib(node, "value", pref->value.string); + xmlnode_set_attrib(node, "value", pref->value.string ? pref->value.string : ""); } else if (pref->type == GAIM_PREF_STRING_LIST) { xmlnode_set_attrib(node, "type", "stringlist"); for (cur = pref->value.stringlist; cur != NULL; cur = cur->next) { childnode = xmlnode_new_child(node, "item"); - xmlnode_set_attrib(childnode, "value", cur->data); + xmlnode_set_attrib(childnode, "value", cur->data ? cur->data : ""); } } else if (pref->type == GAIM_PREF_BOOLEAN) { Modified: branches/v2_0_0/src/protocols/msn/nexus.c =================================================================== --- branches/v2_0_0/src/protocols/msn/nexus.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/protocols/msn/nexus.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -293,7 +293,16 @@ } +/* this guards against missing hash entries */ +static char * +nexus_challenge_data_lookup(GHashTable *challenge_data, const char *key) +{ + char *entry; + return (entry = (char *)g_hash_table_lookup(challenge_data, key)) ? + entry : "(null)"; +} + void login_connect_cb(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond) @@ -336,16 +345,16 @@ "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n", - (char *)g_hash_table_lookup(nexus->challenge_data, "lc"), - (char *)g_hash_table_lookup(nexus->challenge_data, "id"), - (char *)g_hash_table_lookup(nexus->challenge_data, "tw"), - (char *)g_hash_table_lookup(nexus->challenge_data, "fs"), - (char *)g_hash_table_lookup(nexus->challenge_data, "ru"), + nexus_challenge_data_lookup(nexus->challenge_data, "lc"), + nexus_challenge_data_lookup(nexus->challenge_data, "id"), + nexus_challenge_data_lookup(nexus->challenge_data, "tw"), + nexus_challenge_data_lookup(nexus->challenge_data, "fs"), + nexus_challenge_data_lookup(nexus->challenge_data, "ru"), ctint, - (char *)g_hash_table_lookup(nexus->challenge_data, "kpp"), - (char *)g_hash_table_lookup(nexus->challenge_data, "kv"), - (char *)g_hash_table_lookup(nexus->challenge_data, "ver"), - (char *)g_hash_table_lookup(nexus->challenge_data, "tpf"), + nexus_challenge_data_lookup(nexus->challenge_data, "kpp"), + nexus_challenge_data_lookup(nexus->challenge_data, "kv"), + nexus_challenge_data_lookup(nexus->challenge_data, "ver"), + nexus_challenge_data_lookup(nexus->challenge_data, "tpf"), nexus->login_host); buffer = g_strdup_printf("%s,pwd=XXXXXXXX,%s\r\n", head, tail); Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c 2006-08-16 07:19:41 UTC (rev 16786) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c 2006-08-16 07:37:42 UTC (rev 16787) @@ -40,7 +40,11 @@ void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) { - struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + struct yahoo_pair *pair; + + g_return_if_fail(value != NULL); + + pair = g_new0(struct yahoo_pair, 1); pair->key = key; pair->value = g_strdup(value); pkt->hash = g_slist_prepend(pkt->hash, pair); @@ -48,8 +52,9 @@ void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) { - struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + struct yahoo_pair *pair; + pair = g_new0(struct yahoo_pair, 1); pair->key = key; pair->value = g_strdup_printf("%d", value); pkt->hash = g_slist_prepend(pkt->hash, pair); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 07:19:46
|
Revision: 16786 Author: thekingant Date: 2006-08-16 00:19:41 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16786&view=rev Log Message: ----------- More/better assertion fixes. Especially when starting Gaim with an account that doesn't have the global buddy icon preference set, or when trying to set an icon using a file that is not an image. Modified Paths: -------------- trunk/src/gtkstatusbox.c trunk/src/gtkutils.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 07:02:26 UTC (rev 16785) +++ trunk/src/gtkstatusbox.c 2006-08-16 07:19:41 UTC (rev 16786) @@ -1179,16 +1179,19 @@ icon_alc.x = allocation->width - icon_alc.width; icon_alc.y += 3; - if ((status_box->buddy_icon_path != NULL) && - (status_box->icon_size != icon_alc.height)) + if (status_box->icon_size != icon_alc.height) { - scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, - icon_alc.height, icon_alc.width, FALSE, NULL); - status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); - do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); - g_object_unref(status_box->buddy_icon); - status_box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); + if ((status_box->buddy_icon_path != NULL) && + (*status_box->buddy_icon_path != '\0')) + { + scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, + icon_alc.height, icon_alc.width, FALSE, NULL); + status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); + g_object_unref(status_box->buddy_icon); + status_box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); + } status_box->icon_size = icon_alc.height; } gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->icon_box, &icon_alc); @@ -1337,15 +1340,19 @@ g_free(box->buddy_icon_path); box->buddy_icon_path = g_strdup(filename); - if (filename != NULL) + if ((filename != NULL) && (*filename != '\0')) { + if (box->buddy_icon != NULL) + g_object_unref(box->buddy_icon); scaled = gdk_pixbuf_new_from_file_at_scale(filename, box->icon_size, box->icon_size, FALSE, NULL); - box->buddy_icon_hover = gdk_pixbuf_copy(scaled); - do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); - g_object_unref(box->buddy_icon); - box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + if (scaled != NULL) + { + box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); + box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + } } gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-16 07:02:26 UTC (rev 16785) +++ trunk/src/gtkutils.c 2006-08-16 07:19:41 UTC (rev 16786) @@ -2453,7 +2453,7 @@ } #endif -char* +char * gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) { #if GTK_CHECK_VERSION(2,2,0) @@ -2518,6 +2518,8 @@ format = gdk_pixbuf_loader_get_format(loader); g_object_unref(G_OBJECT(loader)); #endif + if (format == NULL) + return NULL; pixbuf_formats = gdk_pixbuf_format_get_extensions(format); if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 07:02:30
|
Revision: 16785 Author: thekingant Date: 2006-08-16 00:02:26 -0700 (Wed, 16 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16785&view=rev Log Message: ----------- Fix some assertion failures Modified Paths: -------------- trunk/src/gtkstatusbox.c trunk/src/prefs.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 06:58:59 UTC (rev 16784) +++ trunk/src/gtkstatusbox.c 2006-08-16 07:02:26 UTC (rev 16785) @@ -1179,7 +1179,9 @@ icon_alc.x = allocation->width - icon_alc.width; icon_alc.y += 3; - if (status_box->icon_size != icon_alc.height) { + if ((status_box->buddy_icon_path != NULL) && + (status_box->icon_size != icon_alc.height)) + { scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, icon_alc.height, icon_alc.width, FALSE, NULL); status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); @@ -1335,13 +1337,16 @@ g_free(box->buddy_icon_path); box->buddy_icon_path = g_strdup(filename); - scaled = gdk_pixbuf_new_from_file_at_scale(filename, - box->icon_size, box->icon_size, FALSE, NULL); - box->buddy_icon_hover = gdk_pixbuf_copy(scaled); - do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); - g_object_unref(box->buddy_icon); - box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + if (filename != NULL) + { + scaled = gdk_pixbuf_new_from_file_at_scale(filename, + box->icon_size, box->icon_size, FALSE, NULL); + box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); + g_object_unref(box->buddy_icon); + box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + } gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); } Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2006-08-16 06:58:59 UTC (rev 16784) +++ trunk/src/prefs.c 2006-08-16 07:02:26 UTC (rev 16785) @@ -124,14 +124,14 @@ } else if (pref->type == GAIM_PREF_STRING) { xmlnode_set_attrib(node, "type", "string"); - xmlnode_set_attrib(node, "value", pref->value.string); + xmlnode_set_attrib(node, "value", pref->value.string ? pref->value.string : ""); } else if (pref->type == GAIM_PREF_STRING_LIST) { xmlnode_set_attrib(node, "type", "stringlist"); for (cur = pref->value.stringlist; cur != NULL; cur = cur->next) { childnode = xmlnode_new_child(node, "item"); - xmlnode_set_attrib(childnode, "value", cur->data); + xmlnode_set_attrib(childnode, "value", cur->data ? cur->data : ""); } } else if (pref->type == GAIM_PREF_BOOLEAN) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 06:59:04
|
Revision: 16784 Author: thekingant Date: 2006-08-15 23:58:59 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16784&view=rev Log Message: ----------- Never allow Yahoo! to insert a NULL value into the outgoing packet hash. This fixes some random crashes when the packet gets sent, and yahoo_packet_length() is called, which eventually calls strlen(NULL), which crashes Modified Paths: -------------- trunk/src/protocols/yahoo/yahoo_packet.c Modified: trunk/src/protocols/yahoo/yahoo_packet.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_packet.c 2006-08-16 06:31:59 UTC (rev 16783) +++ trunk/src/protocols/yahoo/yahoo_packet.c 2006-08-16 06:58:59 UTC (rev 16784) @@ -40,7 +40,11 @@ void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) { - struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + struct yahoo_pair *pair; + + g_return_if_fail(value != NULL); + + pair = g_new0(struct yahoo_pair, 1); pair->key = key; pair->value = g_strdup(value); pkt->hash = g_slist_prepend(pkt->hash, pair); @@ -48,8 +52,9 @@ void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) { - struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + struct yahoo_pair *pair; + pair = g_new0(struct yahoo_pair, 1); pair->key = key; pair->value = g_strdup_printf("%d", value); pkt->hash = g_slist_prepend(pkt->hash, pair); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 06:32:08
|
Revision: 16783 Author: thekingant Date: 2006-08-15 23:31:59 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16783&view=rev Log Message: ----------- Whitespace and warning fixes: gtkaccount.c: In function ?\226?\128?\152icon_select_cb?\226?\128?\153: gtkaccount.c:289: warning: passing argument 1 of ?\226?\128?\152gaim_gtk_buddy_icon_chooser_new?\226?\128?\153 from incompatible pointer type gtkaccount.c:289: warning: passing argument 2 of ?\226?\128?\152gaim_gtk_buddy_icon_chooser_new?\226?\128?\153 from incompatible pointer type gtkstatusbox.c: In function ?\226?\128?\152icon_box_press_cb?\226?\128?\153: gtkstatusbox.c:951: warning: passing argument 2 of ?\226?\128?\152gaim_gtk_buddy_icon_chooser_new?\226?\128?\153 from incompatible pointer type gtkstatusbox.c:951: warning: ISO C90 forbids mixed declarations and code gtkstatusbox.c: In function ?\226?\128?\152icon_box_enter_cb?\226?\128?\153: gtkstatusbox.c:960: warning: passing argument 1 of ?\226?\128?\152gtk_image_set_from_pixbuf?\226?\128?\153 from incompatible pointer type gtkstatusbox.c: In function ?\226?\128?\152icon_box_leave_cb?\226?\128?\153: gtkstatusbox.c:968: warning: passing argument 1 of ?\226?\128?\152gtk_image_set_from_pixbuf?\226?\128?\153 from incompatible pointer type gtkstatusbox.c: In function ?\226?\128?\152gtk_gaim_status_box_size_allocate?\226?\128?\153: gtkstatusbox.c:1183: warning: passing argument 1 of ?\226?\128?\152gtk_image_set_from_pixbuf?\226?\128?\153 from incompatible pointer type gtkstatusbox.c: In function ?\226?\128?\152gtk_gaim_status_box_set_buddy_icon?\226?\128?\153: gtkstatusbox.c:1338: warning: passing argument 1 of ?\226?\128?\152gtk_image_set_from_pixbuf?\226?\128?\153 from incompatible pointer type gtkutils.c: In function ?\226?\128?\152gaim_gtk_convert_buddy_icon?\226?\128?\153: gtkutils.c:2463: warning: ISO C90 forbids mixed declarations and code Modified Paths: -------------- trunk/src/gtkaccount.c trunk/src/gtkstatusbox.c trunk/src/gtkstatusbox.h trunk/src/gtkutils.c Modified: trunk/src/gtkaccount.c =================================================================== --- trunk/src/gtkaccount.c 2006-08-16 06:11:10 UTC (rev 16782) +++ trunk/src/gtkaccount.c 2006-08-16 06:31:59 UTC (rev 16783) @@ -271,22 +271,26 @@ } static void -icon_filesel_choose_cb(const char *filename, AccountPrefsDialog *dialog) +icon_filesel_choose_cb(const char *filename, gpointer data) { + AccountPrefsDialog *dialog; + + dialog = data; + if (filename) { g_free(dialog->icon_path); dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, filename); set_dialog_icon(dialog); gtk_widget_show(dialog->icon_entry); } - + dialog->icon_filesel = NULL; } static void icon_select_cb(GtkWidget *button, AccountPrefsDialog *dialog) { - dialog->icon_filesel = gaim_gtk_buddy_icon_chooser_new(dialog->window, icon_filesel_choose_cb, dialog); + dialog->icon_filesel = gaim_gtk_buddy_icon_chooser_new(GTK_WINDOW(dialog->window), icon_filesel_choose_cb, dialog); gtk_widget_show_all(dialog->icon_filesel); } Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-16 06:11:10 UTC (rev 16782) +++ trunk/src/gtkstatusbox.c 2006-08-16 06:31:59 UTC (rev 16783) @@ -267,10 +267,10 @@ g_object_unref(G_OBJECT(statusbox->buddy_icon)); g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); - + if (statusbox->buddy_icon_sel) gtk_widget_destroy(statusbox->buddy_icon_sel); - + g_free(statusbox->buddy_icon_path); G_OBJECT_CLASS(parent_class)->finalize(obj); @@ -920,8 +920,12 @@ } static void -icon_choose_cb(const char *filename, GtkGaimStatusBox *box) +icon_choose_cb(const char *filename, gpointer data) { + GtkGaimStatusBox *box; + + box = data; + if (filename) { GList *accounts; for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { @@ -936,19 +940,21 @@ } gtk_gaim_status_box_set_buddy_icon(box, filename); } - + box->buddy_icon_sel = NULL; } static gboolean icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) { + GtkWidget *filesel; + if (box->buddy_icon_sel) { gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); return FALSE; } - GtkWidget *filesel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); + filesel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); gtk_widget_show_all(filesel); return FALSE; } @@ -957,7 +963,7 @@ icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) { gdk_window_set_cursor(widget->window, box->hand_cursor); - gtk_image_set_from_pixbuf(box->icon, box->buddy_icon_hover); + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon_hover); return FALSE; } @@ -965,7 +971,7 @@ icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) { gdk_window_set_cursor(widget->window, box->arrow_cursor); - gtk_image_set_from_pixbuf(box->icon, box->buddy_icon) ; + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon) ; return FALSE; } @@ -1172,15 +1178,15 @@ icon_alc.width = icon_alc.height; icon_alc.x = allocation->width - icon_alc.width; icon_alc.y += 3; - + if (status_box->icon_size != icon_alc.height) { - scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, + scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, icon_alc.height, icon_alc.width, FALSE, NULL); status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); g_object_unref(status_box->buddy_icon); status_box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(status_box->icon, status_box->buddy_icon); + gtk_image_set_from_pixbuf(GTK_IMAGE(status_box->icon), status_box->buddy_icon); status_box->icon_size = icon_alc.height; } gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->icon_box, &icon_alc); @@ -1329,14 +1335,14 @@ g_free(box->buddy_icon_path); box->buddy_icon_path = g_strdup(filename); - scaled = gdk_pixbuf_new_from_file_at_scale(filename, + scaled = gdk_pixbuf_new_from_file_at_scale(filename, box->icon_size, box->icon_size, FALSE, NULL); box->buddy_icon_hover = gdk_pixbuf_copy(scaled); do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); g_object_unref(box->buddy_icon); box->buddy_icon = scaled; - gtk_image_set_from_pixbuf(box->icon, box->buddy_icon); - + gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon); + gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); } Modified: trunk/src/gtkstatusbox.h =================================================================== --- trunk/src/gtkstatusbox.h 2006-08-16 06:11:10 UTC (rev 16782) +++ trunk/src/gtkstatusbox.h 2006-08-16 06:31:59 UTC (rev 16783) @@ -85,14 +85,14 @@ GtkWidget *imhtml; char *buddy_icon_path; - GdkPixbuf *buddy_icon; - GdkPixbuf *buddy_icon_hover; + GdkPixbuf *buddy_icon; + GdkPixbuf *buddy_icon_hover; GtkWidget *buddy_icon_sel; - GtkWidget *icon; + GtkWidget *icon; GtkWidget *icon_box; GdkCursor *hand_cursor; GdkCursor *arrow_cursor; - int icon_size; + int icon_size; gboolean imhtml_visible; @@ -128,16 +128,16 @@ struct _GtkGaimStatusBoxClass { - GtkComboBoxClass parent_class; + GtkComboBoxClass parent_class; - /* signals */ - void (* changed) (GtkComboBox *combo_box); + /* signals */ + void (* changed) (GtkComboBox *combo_box); - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); + /* Padding for future expansion */ + void (*_gtk_reserved0) (void); + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); }; Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-16 06:11:10 UTC (rev 16782) +++ trunk/src/gtkutils.c 2006-08-16 06:31:59 UTC (rev 16783) @@ -2358,14 +2358,13 @@ } -GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data) { +GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ GtkWidget *hbox; GtkWidget *tv; GtkTreeSelection *sel; - #endif /* FILECHOOSER */ const char *current_folder; @@ -2457,15 +2456,13 @@ char* gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) { - g_return_val_if_fail(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->icon_spec.format != NULL, NULL); - #if GTK_CHECK_VERSION(2,2,0) int width, height; char **pixbuf_formats = NULL; GdkPixbufFormat *format; GdkPixbuf *pixbuf; - GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); - char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0); + GaimPluginProtocolInfo *prpl_info; + char **prpl_formats; #if !GTK_CHECK_VERSION(2,4,0) GdkPixbufLoader *loader; FILE *file; @@ -2473,10 +2470,19 @@ void *data = NULL; #endif #endif - const char *dirname = gaim_buddy_icons_get_cache_dir(); - char *random = g_strdup_printf("%x", g_random_int()); - char *filename = g_build_filename(dirname, random, NULL); + const char *dirname; + char *random; + char *filename; + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL); + + prpl_formats = g_strsplit(prpl_info->icon_spec.format,",",0); + dirname = gaim_buddy_icons_get_cache_dir(); + random = g_strdup_printf("%x", g_random_int()); + filename = g_build_filename(dirname, random, NULL); + if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-16 06:11:14
|
Revision: 16782 Author: thekingant Date: 2006-08-15 23:11:10 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16782&view=rev Log Message: ----------- Fix a warning: nexus.c:299: warning: no previous prototype for 'nexus_challenge_data_lookup' And change this code to use tab indentation Modified Paths: -------------- trunk/src/protocols/msn/nexus.c Modified: trunk/src/protocols/msn/nexus.c =================================================================== --- trunk/src/protocols/msn/nexus.c 2006-08-16 05:12:48 UTC (rev 16781) +++ trunk/src/protocols/msn/nexus.c 2006-08-16 06:11:10 UTC (rev 16782) @@ -294,13 +294,13 @@ } /* this guards against missing hash entries */ -char * +static char * nexus_challenge_data_lookup(GHashTable *challenge_data, const char *key) { - char *entry; + char *entry; - return (entry = (char *)g_hash_table_lookup(challenge_data, key)) ? - entry : "(null)"; + return (entry = (char *)g_hash_table_lookup(challenge_data, key)) ? + entry : "(null)"; } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-16 05:13:06
|
Revision: 16781 Author: sadrul Date: 2006-08-15 22:12:48 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16781&view=rev Log Message: ----------- Allow setting the preferences for gnt-plugins. Add a guifications-like plugin for gntgaim. You can set its preferences. The preferences for core plugins are still not accessible. The makefile-foo will require changes once the split is complete. I am now just committing whatever works for me. Modified Paths: -------------- trunk/console/gntplugin.c trunk/console/gntplugin.h trunk/console/libgnt/gnt.h trunk/console/libgnt/gntmain.c Added Paths: ----------- trunk/console/plugins/ trunk/console/plugins/Makefile.am trunk/console/plugins/gntgf.c Modified: trunk/console/gntplugin.c =================================================================== --- trunk/console/gntplugin.c 2006-08-16 04:50:27 UTC (rev 16780) +++ trunk/console/gntplugin.c 2006-08-16 05:12:48 UTC (rev 16781) @@ -1,5 +1,6 @@ #include <gnt.h> #include <gntbox.h> +#include <gntbutton.h> #include <gntlabel.h> #include <gntline.h> #include <gnttree.h> @@ -14,9 +15,26 @@ GntWidget *tree; GntWidget *window; GntWidget *aboot; + GntWidget *conf; } plugins; static void +decide_conf_button(GaimPlugin *plugin) +{ + if (gaim_plugin_is_loaded(plugin) && + ((GAIM_IS_GNT_PLUGIN(plugin) && + GAIM_GNT_PLUGIN_UI_INFO(plugin) != NULL) || + (plugin->info->prefs_info && + plugin->info->prefs_info->get_plugin_pref_frame))) + gnt_widget_set_visible(plugins.conf, TRUE); + else + gnt_widget_set_visible(plugins.conf, FALSE); + + gnt_box_readjust(GNT_BOX(plugins.window)); + gnt_widget_draw(plugins.window); +} + +static void plugin_toggled_cb(GntWidget *tree, GaimPlugin *plugin, gpointer null) { if (gnt_tree_get_choice(GNT_TREE(tree), plugin)) @@ -29,6 +47,7 @@ if (!gaim_plugin_unload(plugin)) gaim_notify_error(NULL, "ERROR", "unloading plugin failed", NULL); } + decide_conf_button(plugin); gg_plugins_save_loaded(); } @@ -69,6 +88,7 @@ text, GNT_TEXT_FLAG_NORMAL); gnt_text_view_scroll(GNT_TEXT_VIEW(plugins.aboot), 0); g_free(text); + decide_conf_button(plugin); } static void @@ -90,9 +110,63 @@ return ret; } +static void +configure_plugin_cb(GntWidget *button, gpointer null) +{ + GaimPlugin *plugin; + GGPluginFrame callback; + + g_return_if_fail(plugins.tree != NULL); + + plugin = gnt_tree_get_selection_data(GNT_TREE(plugins.tree)); + if (!gaim_plugin_is_loaded(plugin)) + { + gaim_notify_error(plugin, _("Error"), + _("Plugin need to be loaded before you can configure it."), NULL); + return; + } + + if (GAIM_IS_GNT_PLUGIN(plugin) && + (callback = GAIM_GNT_PLUGIN_UI_INFO(plugin)) != NULL) + { + GntWidget *window = gnt_vbox_new(FALSE); + GntWidget *box, *button; + + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), plugin->info->name); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + + box = callback(); + gnt_box_add_widget(GNT_BOX(window), box); + + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + + button = gnt_button_new(_("Close")); + gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(gnt_widget_destroy), window); + + gnt_widget_show(window); /* XXX: This window needs to be closed when the plugin is unloaded */ + } + else if (plugin->info->prefs_info && + plugin->info->prefs_info->get_plugin_pref_frame) + { + gaim_notify_info(plugin, _("..."), + _("Still need to do something about this."), NULL); + return; + } + else + { + gaim_notify_info(plugin, _("Error"), + _("No configuration options for this plugin."), NULL); + return; + } +} + void gg_plugins_show_all() { - GntWidget *window, *tree, *box, *aboot; + GntWidget *window, *tree, *box, *aboot, *button; GList *iter; if (plugins.window) return; @@ -103,6 +177,7 @@ gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_title(GNT_BOX(window), _("Plugins")); gnt_box_set_pad(GNT_BOX(window), 0); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("You can (un)load plugins from the following list."))); @@ -139,8 +214,23 @@ gnt_tree_set_col_width(GNT_TREE(tree), 0, 30); g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(plugin_toggled_cb), NULL); g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL); + + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + + button = gnt_button_new(_("Close")); + gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(gnt_widget_destroy), window); + + plugins.conf = button = gnt_button_new(_("Configure Plugin")); + gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(configure_plugin_cb), NULL); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(reset_plugin_window), NULL); gnt_widget_show(window); + + decide_conf_button(gnt_tree_get_selection_data(GNT_TREE(tree))); } Modified: trunk/console/gntplugin.h =================================================================== --- trunk/console/gntplugin.h 2006-08-16 04:50:27 UTC (rev 16780) +++ trunk/console/gntplugin.h 2006-08-16 05:12:48 UTC (rev 16781) @@ -1,5 +1,21 @@ +#include <gnt.h> + #include <plugin.h> +#include <string.h> + +typedef GntWidget* (*GGPluginFrame) (); + +/* Guess where these came from */ +#define GAIM_GNT_PLUGIN_TYPE "gnt" + +#define GAIM_IS_GNT_PLUGIN(plugin) \ + ((plugin)->info != NULL && (plugin)->info->ui_info != NULL && \ + !strcmp((plugin)->info->ui_requirement, GAIM_GNT_PLUGIN_TYPE)) + +#define GAIM_GNT_PLUGIN_UI_INFO(plugin) \ + (GGPluginFrame)((plugin)->info->ui_info) + void gg_plugins_show_all(); void gg_plugins_save_loaded(); Modified: trunk/console/libgnt/gnt.h =================================================================== --- trunk/console/libgnt/gnt.h 2006-08-16 04:50:27 UTC (rev 16780) +++ trunk/console/libgnt/gnt.h 2006-08-16 05:12:48 UTC (rev 16781) @@ -19,6 +19,8 @@ void gnt_screen_resize_widget(GntWidget *widget, int width, int height); +void gnt_screen_move_widget(GntWidget *widget, int x, int y); + gboolean gnt_widget_has_focus(GntWidget *widget); void gnt_widget_set_urgent(GntWidget *widget); Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-16 04:50:27 UTC (rev 16780) +++ trunk/console/libgnt/gntmain.c 2006-08-16 05:12:48 UTC (rev 16781) @@ -586,10 +586,7 @@ if (changed) { - GntNode *node = g_hash_table_lookup(nodes, widget); - gnt_widget_set_position(widget, x, y); - move_panel(node->panel, y, x); - update_screen(NULL); + gnt_screen_move_widget(widget, x, y); } } else if (*buffer == '\r') @@ -879,3 +876,11 @@ } } +void gnt_screen_move_widget(GntWidget *widget, int x, int y) +{ + GntNode *node = g_hash_table_lookup(nodes, widget); + gnt_widget_set_position(widget, x, y); + move_panel(node->panel, y, x); + update_screen(NULL); +} + Added: trunk/console/plugins/Makefile.am =================================================================== --- trunk/console/plugins/Makefile.am (rev 0) +++ trunk/console/plugins/Makefile.am 2006-08-16 05:12:48 UTC (rev 16781) @@ -0,0 +1,38 @@ +gntgf_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) + +if PLUGINS + +plugin_LTLIBRARIES = \ + gntgf.la + +plugindir = $(libdir)/gaim + +gntgf_la_SOURCES = gntgf.c + +endif # PLUGINS + +EXTRA_DIST = + +GNT_CFLAGS = `pkg-config --cflags gnt` -I.. + +AM_CPPFLAGS = \ + -DDATADIR=\"$(datadir)\" \ + -DVERSION=\"$(VERSION)\" \ + -I$(top_builddir)/src \ + -I$(top_srcdir)/src \ + $(DEBUG_CFLAGS) \ + $(GNT_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(PLUGIN_CFLAGS) + +# +# This part allows people to build their own plugins in here. +# Yes, it's a mess. +# +SUFFIXES = .c .so +.c.so: + $(LIBTOOL) --mode=compile $(CC) -DHAVE_CONFIG_H -I$(top_srcdir) $(AM_CPPFLAGS) $(CFLAGS) -c $< -o tmp$@.lo $(PLUGIN_CFLAGS) + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o libtmp$@.la -rpath $(plugindir) tmp$@.lo $(LIBS) $(LDFLAGS) -module -avoid-version $(PLUGIN_LIBS) + @rm -f tmp$@.lo tmp$@.o libtmp$@.la + @cp .libs/libtmp$@.so* $@ + @rm -f .libs/libtmp$@.* Property changes on: trunk/console/plugins/Makefile.am ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/console/plugins/gntgf.c =================================================================== --- trunk/console/plugins/gntgf.c (rev 0) +++ trunk/console/plugins/gntgf.c 2006-08-16 05:12:48 UTC (rev 16781) @@ -0,0 +1,271 @@ +/** + * @file gntgf.c Minimal toaster plugin in Gnt. + * + * Copyright (C) 2006 Sadrul Habib Chowdhury <sa...@us...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define GAIM_PLUGINS + +#define PLUGIN_STATIC_NAME "GntGf" + +#define PREFS_EVENT "/plugins/gnt/gntgf/events" +#define PREFS_EVENT_SIGNONF PREFS_EVENT "/signonf" +#define PREFS_EVENT_IM_MSG PREFS_EVENT "/immsg" +#define PREFS_EVENT_CHAT_MSG PREFS_EVENT "/chatmsg" +#define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick" + +#include <glib.h> + +#include <plugin.h> +#include <version.h> +#include <blist.h> +#include <conversation.h> + +#include <gnt.h> +#include <gntbox.h> +#include <gntbutton.h> +#include <gntlabel.h> +#include <gnttree.h> + +#include <gntplugin.h> + +#define _(X) X + +typedef struct +{ + GntWidget *window; + int timer; +} GntToast; + +static GList *toasters; +static int gpsy; + +static void +destroy_toaster(GntToast *toast) +{ + toasters = g_list_remove(toasters, toast); + gnt_widget_destroy(toast->window); + g_source_remove(toast->timer); + g_free(toast); +} + +static gboolean +remove_toaster(GntToast *toast) +{ + GList *iter; + int h; + + gnt_widget_get_size(toast->window, NULL, &h); + gpsy -= h; + + destroy_toaster(toast); + + for (iter = toasters; iter; iter = iter->next) + { + int x, y; + toast = iter->data; + gnt_widget_get_position(toast->window, &x, &y); + y += h; + gnt_screen_move_widget(toast->window, x, y); + } + + return FALSE; +} + +static void +notify(const char *fmt, ...) +{ + GntWidget *window; + GntToast *toast = g_new0(GntToast, 1); + char *str; + int h, w; + va_list args; + + toast->window = window = gnt_vbox_new(FALSE); + GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); + GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER); + + va_start(args, fmt); + str = g_strdup_vprintf(fmt, args); + va_end(args); + + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(str, GNT_TEXT_FLAG_HIGHLIGHT)); + + g_free(str); + gnt_widget_size_request(window); + gnt_widget_get_size(window, &w, &h); + gpsy += h; + gnt_widget_set_position(window, getmaxx(stdscr) - w - 1, + getmaxy(stdscr) - gpsy - 1); + gnt_widget_draw(window); + + toast->timer = g_timeout_add(4000, (GSourceFunc)remove_toaster, toast); + toasters = g_list_prepend(toasters, toast); +} + +static void +buddy_signed_on(GaimBuddy *buddy, gpointer null) +{ + if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF)) + notify(_("%s just signed on"), gaim_buddy_get_alias(buddy)); +} + +static void +buddy_signed_off(GaimBuddy *buddy, gpointer null) +{ + if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF)) + notify(_("%s just signed off"), gaim_buddy_get_alias(buddy)); +} + +static void +received_im_msg(GaimAccount *account, const char *sender, const char *msg, + GaimConversation *conv, GaimMessageFlags flags, gpointer null) +{ + if (gaim_prefs_get_bool(PREFS_EVENT_IM_MSG)) + notify(_("%s sent you a message"), sender); +} + +static void +received_chat_msg(GaimAccount *account, const char *sender, const char *msg, + GaimConversation *conv, GaimMessageFlags flags, gpointer null) +{ + if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_NICK) && (flags & GAIM_MESSAGE_NICK)) + notify(_("%s said your nick in %s"), sender, gaim_conversation_get_name(conv)); + else if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_MSG)) + notify(_("%s sent a message in %s"), sender, gaim_conversation_get_name(conv)); +} + +static gboolean +plugin_load(GaimPlugin *plugin) +{ + gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", plugin, + GAIM_CALLBACK(buddy_signed_on), NULL); + gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", plugin, + GAIM_CALLBACK(buddy_signed_off), NULL); + gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", plugin, + GAIM_CALLBACK(received_im_msg), NULL); + gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", plugin, + GAIM_CALLBACK(received_chat_msg), NULL); + + gpsy = 0; + + return TRUE; +} + +static gboolean +plugin_unload(GaimPlugin *plugin) +{ + while (toasters) + { + GntToast *toast = toasters->data; + destroy_toaster(toast); + } + return TRUE; +} + +static struct +{ + char *pref; + char *display; +} prefs[] = +{ + {PREFS_EVENT_SIGNONF, _("Buddy signs on/off")}, + {PREFS_EVENT_IM_MSG, _("You receive an IMs")}, + {PREFS_EVENT_CHAT_MSG, _("Someone speaks in a chat")}, + {PREFS_EVENT_CHAT_NICK, _("Someone says your name in a chat")}, + {NULL, NULL} +}; + +static void +pref_toggled(GntTree *tree, char *key, gpointer null) +{ + gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key)); +} + +static GntWidget * +config_frame() +{ + GntWidget *window, *tree; + int i; + + window = gnt_vbox_new(FALSE); + gnt_box_set_pad(GNT_BOX(window), 0); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + gnt_box_set_fill(GNT_BOX(window), TRUE); + + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new(_("Notify with a toaster when"))); + + tree = gnt_tree_new(); + gnt_box_add_widget(GNT_BOX(window), tree); + + for (i = 0; prefs[i].pref; i++) + { + gnt_tree_add_choice(GNT_TREE(tree), prefs[i].pref, + gnt_tree_create_row(GNT_TREE(tree), prefs[i].display), NULL, NULL); + gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref, + gaim_prefs_get_bool(prefs[i].pref)); + } + gnt_tree_set_col_width(GNT_TREE(tree), 0, 40); + g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL); + + return window; +} + +static GaimPluginInfo info = +{ + GAIM_PLUGIN_MAGIC, + GAIM_MAJOR_VERSION, + GAIM_MINOR_VERSION, + GAIM_PLUGIN_STANDARD, + GAIM_GNT_PLUGIN_TYPE, + 0, + NULL, + GAIM_PRIORITY_DEFAULT, + "gntgf", + N_("GntGf"), + VERSION, + N_("Toaster plugin for GntGaim."), + N_("Toaster plugin for GntGaim."), + "Sadrul H Chowdhury <sa...@us...>", + "http://gaim.sourceforge.net", + plugin_load, + plugin_unload, + NULL, + config_frame, + NULL, + NULL, + NULL +}; + +static void +init_plugin(GaimPlugin *plugin) +{ + gaim_prefs_add_none("/plugins"); + gaim_prefs_add_none("/plugins/gnt"); + + gaim_prefs_add_none("/plugins/gnt/gntgf"); + gaim_prefs_add_none(PREFS_EVENT); + + gaim_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE); + gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE); + gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE); + gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE); +} + +GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) Property changes on: trunk/console/plugins/gntgf.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-08-16 04:50:49
|
Revision: 16780 Author: aaronsheldon Date: 2006-08-15 21:50:27 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16780&view=rev Log Message: ----------- Merges r16472-16568 from blist-efficiency into trunk. Modified Paths: -------------- trunk/src/blist.c trunk/src/gtkblist.c trunk/src/gtkblist.h trunk/src/gtkconv.c trunk/src/privacy.c Modified: trunk/src/blist.c =================================================================== --- trunk/src/blist.c 2006-08-16 03:18:43 UTC (rev 16779) +++ trunk/src/blist.c 2006-08-16 04:50:27 UTC (rev 16780) @@ -2636,6 +2636,11 @@ GAIM_SUBTYPE_STATUS), gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_STATUS)); + gaim_signal_register(handle, "buddy-privacy-changed", + gaim_marshal_VOID__POINTER, NULL, + 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_BLIST_BUDDY)); gaim_signal_register(handle, "buddy-idle-changed", gaim_marshal_VOID__POINTER_INT_INT, NULL, Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-08-16 03:18:43 UTC (rev 16779) +++ trunk/src/gtkblist.c 2006-08-16 04:50:27 UTC (rev 16780) @@ -104,6 +104,7 @@ static guint visibility_manager_count = 0; static gboolean gtk_blist_obscured = FALSE; +GHashTable* status_icon_hash_table = NULL; static GList *gaim_gtk_blist_sort_methods = NULL; static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; @@ -119,14 +120,15 @@ static GaimGtkBuddyList *gtkblist = NULL; static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list); -static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); +static void gaim_gtk_blist_update_buddy_status_icon_key(GaimBlistNode *node, GaimStatusIconSize size); +static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node, gboolean statusChange); static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node); static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full); static const char *item_factory_translate_func (const char *path, gpointer func_data); static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); -static void redo_buddy_list(GaimBuddyList *list, gboolean remove); +static void redo_buddy_list(GaimBuddyList *list, gboolean remove, gboolean rerender); static void gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node); static void gaim_gtk_blist_tooltip_destroy(void); @@ -136,6 +138,7 @@ gboolean contact_expanded; gboolean recent_signonoff; gint recent_signonoff_timer; + GString *status_icon_key; }; @@ -535,6 +538,12 @@ } static void +gaim_gtk_blist_update_privacy_cb(GaimBuddy *buddy) +{ + gaim_gtk_blist_update_buddy(gaim_get_blist(), (GaimBlistNode*)(buddy), TRUE); +} + +static void rebuild_joinchat_entries(GaimGtkJoinChatData *data) { GaimConnection *gc; @@ -2692,12 +2701,112 @@ int y; }; +static void g_string_destroy(GString *destroyable) +{ + g_string_free(destroyable, TRUE); + return; +} + +static void +gaim_gtk_blist_update_buddy_status_icon_key(GaimBlistNode *node, GaimStatusIconSize size) +{ + int i; + GaimAccount *account; + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info; + GString *key = g_string_sized_new(16); + GaimBuddy *buddy; + const char *protoname = NULL; + struct _gaim_gtk_blist_node *gtknode = node->ui_data; + struct _gaim_gtk_blist_node *gtkbuddynode = NULL; + struct _emblem_data emblems[4] = {{NULL, 15, 15}, {NULL, 0, 15}, + {NULL, 0, 0}, {NULL, 15, 0}}; + + buddy = (GaimBuddy*)node; + gtkbuddynode = node->ui_data; + + if (gtkbuddynode && gtkbuddynode->recent_signonoff) { + if (GAIM_BUDDY_IS_ONLINE(buddy)) + g_string_printf(key, "login"); + else + g_string_printf(key, "logout"); + } else { + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, + gaim_buddy_get_name(buddy), + gaim_buddy_get_account(buddy)); + + account = buddy->account; + prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); + + if(!prpl) + return; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if(prpl_info && prpl_info->list_icon) { + protoname = prpl_info->list_icon(account, buddy); + } + if(prpl_info && prpl_info->list_emblems) { + if(gtknode) + prpl_info->list_emblems(buddy, &emblems[0].filename, + &emblems[1].filename, &emblems[2].filename, + &emblems[3].filename); + } + + g_string_assign(key, protoname); + + if(conv != NULL) { + GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); + if(gtkconv != NULL && gaim_gtkconv_is_hidden(gtkconv)) { + /* add pending emblem */ + if(size == GAIM_STATUS_ICON_SMALL) { + emblems[0].filename="pending"; + } + else { + emblems[3].filename=emblems[2].filename; + emblems[2].filename="pending"; + } + } + } + + if(size == GAIM_STATUS_ICON_SMALL) { + /* So that only the se icon will composite */ + emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; + } + + for(i=0; i<4; i++) { + if(emblems[i].filename) { + g_string_append_printf(key, "/%s", emblems[i].filename); + } + } + } + + if (!GAIM_BUDDY_IS_ONLINE(buddy)) { + key = g_string_append(key, "/off"); + } else if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) { + key = g_string_append(key, "/idle"); + } + if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) { + key = g_string_append(key, "/priv"); + } + + if (gtkbuddynode) { + if (gtkbuddynode->status_icon_key) + g_string_free(gtkbuddynode->status_icon_key, TRUE); + gtkbuddynode->status_icon_key = g_string_new(key->str); + } + + g_string_free(key, TRUE); + return; +} + GdkPixbuf * gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) { GdkPixbuf *scale, *status = NULL; int i, scalesize = 30; char *filename; + GString *key = g_string_sized_new(16); const char *protoname = NULL; struct _gaim_gtk_blist_node *gtknode = node->ui_data; struct _gaim_gtk_blist_node *gtkbuddynode = NULL; @@ -2721,6 +2830,28 @@ return NULL; } + if (!status_icon_hash_table) { + status_icon_hash_table = g_hash_table_new_full((GHashFunc)g_string_hash, + (GEqualFunc)g_string_equal, + (GDestroyNotify)g_string_destroy, + (GDestroyNotify)gdk_pixbuf_unref); + + } else if (buddy && gtkbuddynode->status_icon_key && gtkbuddynode->status_icon_key->str) { + key = g_string_new(gtkbuddynode->status_icon_key->str); + + /* Respect the size request given */ + if (size == GAIM_STATUS_ICON_SMALL) { + key = g_string_append(key, "/tiny"); + } + + scale = g_hash_table_lookup(status_icon_hash_table, key); + if (scale) { + gdk_pixbuf_ref(scale); + g_string_free(key, TRUE); + return scale; + } + } + if(buddy || chat) { GaimAccount *account; GaimPlugin *prpl; @@ -2748,24 +2879,93 @@ } } - if(buddy) { - GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, +/* Begin Generating Lookup Key */ + if (buddy) { + gaim_gtk_blist_update_buddy_status_icon_key(node, size); + g_string_printf(key, "%s", strdup(gtkbuddynode->status_icon_key->str)); + } + /* There are only two options for chat or gaimdude - big or small */ + else if (chat) { + GaimAccount *account; + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info; + + account = chat->account; + + prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); + if(!prpl) + return NULL; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if(prpl_info && prpl_info->list_icon) { + protoname = prpl_info->list_icon(account, NULL); + } + g_string_append_printf(key, "%s-chat", protoname); + } + else + key = g_string_append(key, "gaimdude"); + + /* If the icon is small, we do not store this into the status_icon_key + * in the gtkbuddynode. This way we can respect the size value on cache + * lookup. Otherwise, different sized icons could not be stored easily. + */ + if (size == GAIM_STATUS_ICON_SMALL) { + key = g_string_append(key, "/tiny"); + } + +/* End Generating Lookup Key */ + +/* If we already know this icon, just return it */ + scale = g_hash_table_lookup(status_icon_hash_table, key); + if (scale) { + gdk_pixbuf_ref(scale); + g_string_free(key, TRUE); + return scale; + } + +/* Create a new composite icon */ + + if(buddy) { + GaimAccount *account; + GaimPlugin *prpl; + GaimPluginProtocolInfo *prpl_info; + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, gaim_buddy_get_name(buddy), gaim_buddy_get_account(buddy)); - if(conv != NULL) { - GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); - if(gtkconv != NULL && gaim_gtkconv_is_hidden(gtkconv)) { - /* add pending emblem */ - if(size == GAIM_STATUS_ICON_SMALL) { - emblems[0].filename="pending"; + + account = buddy->account; + + prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); + if(!prpl) + return NULL; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + + if(prpl_info && prpl_info->list_icon) { + protoname = prpl_info->list_icon(account, buddy); + } + if(prpl_info && prpl_info->list_emblems) { + if(gtknode && !gtknode->recent_signonoff) + prpl_info->list_emblems(buddy, &emblems[0].filename, + &emblems[1].filename, &emblems[2].filename, + &emblems[3].filename); + } + + if(conv != NULL) { + GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); + if(gtkconv != NULL && gaim_gtkconv_is_hidden(gtkconv)) { + /* add pending emblem */ + if(size == GAIM_STATUS_ICON_SMALL) { + emblems[0].filename="pending"; + } + else { + emblems[3].filename=emblems[2].filename; + emblems[2].filename="pending"; + } } - else { - emblems[3].filename=emblems[2].filename; - emblems[2].filename="pending"; - } } } - } if(size == GAIM_STATUS_ICON_SMALL) { scalesize = 15; @@ -2773,6 +2973,8 @@ emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; } + + if(buddy && GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); } else if(buddy && !GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { @@ -2829,7 +3031,6 @@ if(buddy) { presence = gaim_buddy_get_presence(buddy); - if (!GAIM_BUDDY_IS_ONLINE(buddy)) gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); else if (gaim_presence_is_idle(presence)) @@ -2859,6 +3060,10 @@ } } + /* Insert the new icon into the status icon hash table */ + g_hash_table_insert (status_icon_hash_table, key, scale); + gdk_pixbuf_ref(scale); + return scale; } @@ -3082,7 +3287,7 @@ return TRUE; } -static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node) +static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node, gboolean update) { struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; GtkTreeIter iter; @@ -3092,11 +3297,10 @@ if(gtkblist->selected_node == node) gtkblist->selected_node = NULL; - if (get_iter_from_node(node, &iter)) { gtk_tree_store_remove(gtkblist->treemodel, &iter); - if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) - || GAIM_BLIST_NODE_IS_CHAT(node)) { + if(update && (GAIM_BLIST_NODE_IS_CONTACT(node) || + GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node))) { gaim_gtk_blist_update(list, node->parent); } } @@ -3228,7 +3432,7 @@ if(conv->account != NULL && conv->name != NULL) { GaimBuddy *buddy = gaim_find_buddy(conv->account, conv->name); if(buddy != NULL) - gaim_gtk_blist_update_buddy(NULL, (GaimBlistNode *)buddy); + gaim_gtk_blist_update_buddy(NULL, (GaimBlistNode *)buddy, TRUE); } if (gtkblist->menutrayicon) { @@ -3367,7 +3571,7 @@ gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); } - redo_buddy_list(gaim_get_blist(), TRUE); + redo_buddy_list(gaim_get_blist(), FALSE, FALSE); #if GTK_CHECK_VERSION(2,6,0) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); #endif @@ -3914,23 +4118,36 @@ gaim_signal_emit(handle, "gtkblist-created", list); } -static void redo_buddy_list(GaimBuddyList *list, gboolean remove) +static void redo_buddy_list(GaimBuddyList *list, gboolean remove, gboolean rerender) { GaimBlistNode *node = list->root; while (node) { + /* This is only needed when we're reverting to a non-GTK+ sorted + * status. We shouldn't need to remove otherwise. + */ if (remove && !GAIM_BLIST_NODE_IS_GROUP(node)) - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, FALSE); - gaim_gtk_blist_update(list, node); + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + gaim_gtk_blist_update_buddy(list, node, rerender); + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + gaim_gtk_blist_update(list, node); node = gaim_blist_node_next(node, FALSE); } + + /* There is no hash table if there is nothing in the buddy list to update */ + if (status_icon_hash_table) { + g_hash_table_destroy(status_icon_hash_table); + status_icon_hash_table = NULL; + } + } void gaim_gtk_blist_refresh(GaimBuddyList *list) { - redo_buddy_list(list, FALSE); + redo_buddy_list(list, FALSE, TRUE); } void @@ -3979,7 +4196,7 @@ gaim_request_close_with_handle(node); - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); if(node->parent) gaim_gtk_blist_update(list, node->parent); @@ -4147,7 +4364,7 @@ -1); g_free(mark); } else { - gaim_gtk_blist_hide_node(list, gnode); + gaim_gtk_blist_hide_node(list, gnode, TRUE); } } @@ -4269,13 +4486,13 @@ buddy_node(buddy, &iter, cnode); } } else { - gaim_gtk_blist_hide_node(list, cnode); + gaim_gtk_blist_hide_node(list, cnode, TRUE); } } -static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) +static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node, gboolean statusChange) { GaimBuddy *buddy; struct _gaim_gtk_blist_node *gtkparentnode; @@ -4287,6 +4504,10 @@ buddy = (GaimBuddy*)node; + if (statusChange) + gaim_gtk_blist_update_buddy_status_icon_key(node, (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") + ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); + /* First things first, update the contact */ gaim_gtk_blist_update_contact(list, node); @@ -4302,7 +4523,7 @@ buddy_node(buddy, &iter, node); } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); } } @@ -4342,7 +4563,7 @@ if(status) g_object_unref(status); } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); } } @@ -4362,7 +4583,7 @@ gaim_gtk_blist_update_contact(list, node); break; case GAIM_BLIST_BUDDY_NODE: - gaim_gtk_blist_update_buddy(list, node); + gaim_gtk_blist_update_buddy(list, node, TRUE); break; case GAIM_BLIST_CHAT_NODE: gaim_gtk_blist_update_chat(list, node); @@ -5214,6 +5435,7 @@ gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); + gaim_signal_connect(gaim_blist_get_handle(), "buddy-privacy-changed", gtk_blist_handle, GAIM_CALLBACK(gaim_gtk_blist_update_privacy_cb), NULL); } void @@ -5271,8 +5493,11 @@ gaim_gtk_blist_sort_method_set("none"); return; } - redo_buddy_list(gaim_get_blist(), TRUE); - + if (!strcmp(id, "none")) { + redo_buddy_list(gaim_get_blist(), TRUE, FALSE); + } else { + redo_buddy_list(gaim_get_blist(), FALSE, FALSE); + } } /****************************************** @@ -5837,8 +6062,8 @@ if (gtk_check_menu_item_get_active(checkmenuitem)) { gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); - - gaim_gtk_blist_sort_method_set(id); + /* This is redundant. I think. */ + /* gaim_gtk_blist_sort_method_set(id); */ gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); gaim_gtk_clear_cursor(gtkblist->window); Modified: trunk/src/gtkblist.h =================================================================== --- trunk/src/gtkblist.h 2006-08-16 03:18:43 UTC (rev 16779) +++ trunk/src/gtkblist.h 2006-08-16 04:50:27 UTC (rev 16780) @@ -143,7 +143,7 @@ * Populates a menu with the items shown on the buddy list for a buddy. * * @param menu The menu to populate - * @param buddy The buddy who's menu to get + * @param buddy The buddy whose menu to get * @param sub TRUE if this is a sub-menu, FALSE otherwise */ void gaim_gtk_blist_make_buddy_menu(GtkWidget *menu, GaimBuddy *buddy, gboolean sub); Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-08-16 03:18:43 UTC (rev 16779) +++ trunk/src/gtkconv.c 2006-08-16 04:50:27 UTC (rev 16780) @@ -2185,6 +2185,7 @@ GaimAccount *account = NULL; const char *name = NULL; GdkPixbuf *status = NULL; + GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); g_return_val_if_fail(conv != NULL, NULL); @@ -2198,6 +2199,12 @@ if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { GaimBuddy *b = gaim_find_buddy(account, name); if (b != NULL) { + /* I hate this hack. It fixes a bug where the pending message icon + * displays in the conv tab even though it shouldn't. + * A better solution would be great. */ + if (ops && ops->update) + ops->update(NULL, (GaimBlistNode*)b); + status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); } @@ -6341,6 +6348,20 @@ } static void +update_buddy_privacy_changed(GaimBuddy *buddy) +{ + GaimGtkConversation *gtkconv; + GaimConversation *conv; + + gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); + if (gtkconv) + { + conv = gtkconv->active_conv; + gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); + } +} + +static void update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) { GaimConversation *conv; @@ -6628,6 +6649,8 @@ handle, GAIM_CALLBACK(update_buddy_sign), "off"); gaim_signal_connect(blist_handle, "buddy-status-changed", handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); + gaim_signal_connect(blist_handle, "buddy-privacy-changed", + handle, GAIM_CALLBACK(update_buddy_privacy_changed), NULL); gaim_signal_connect(blist_handle, "buddy-idle-changed", handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); gaim_signal_connect(blist_handle, "buddy-icon-changed", Modified: trunk/src/privacy.c =================================================================== --- trunk/src/privacy.c 2006-08-16 03:18:43 UTC (rev 16779) +++ trunk/src/privacy.c 2006-08-16 04:50:27 UTC (rev 16780) @@ -34,6 +34,7 @@ { GSList *l; char *name; + GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); @@ -41,17 +42,18 @@ name = g_strdup(gaim_normalize(account, who)); for (l = account->permit; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) + if (!gaim_utf8_strcasecmp(name, (char *)l->data)) break; } - g_free(name); + if (l != NULL) + { + g_free(name); + return FALSE; + } - if (l != NULL) - return FALSE; + account->permit = g_slist_append(account->permit, name); - account->permit = g_slist_append(account->permit, g_strdup(who)); - if (!local_only && gaim_account_is_connected(account)) serv_add_permit(gaim_account_get_connection(account), who); @@ -60,6 +62,12 @@ gaim_blist_schedule_save(); + /* This lets the UI know a buddy has had its privacy setting changed */ + buddy = gaim_find_buddy(account, name); + if (buddy != NULL) { + gaim_signal_emit(gaim_blist_get_handle(), + "buddy-privacy-changed", buddy); + } return TRUE; } @@ -69,19 +77,18 @@ { GSList *l; char *name; + GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(account, who)); + name = gaim_normalize(account, who); for (l = account->permit; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) + if (!gaim_utf8_strcasecmp(name, (char *)l->data)) break; } - g_free(name); - if (l == NULL) return FALSE; @@ -96,6 +103,11 @@ gaim_blist_schedule_save(); + buddy = gaim_find_buddy(account, name); + if (buddy != NULL) { + gaim_signal_emit(gaim_blist_get_handle(), + "buddy-privacy-changed", buddy); + } return TRUE; } @@ -105,6 +117,7 @@ { GSList *l; char *name; + GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); @@ -116,12 +129,13 @@ break; } - g_free(name); - if (l != NULL) + { + g_free(name); return FALSE; + } - account->deny = g_slist_append(account->deny, g_strdup(who)); + account->deny = g_slist_append(account->deny, name); if (!local_only && gaim_account_is_connected(account)) serv_add_deny(gaim_account_get_connection(account), who); @@ -131,6 +145,11 @@ gaim_blist_schedule_save(); + buddy = gaim_find_buddy(account, name); + if (buddy != NULL) { + gaim_signal_emit(gaim_blist_get_handle(), + "buddy-privacy-changed", buddy); + } return TRUE; } @@ -140,18 +159,19 @@ { GSList *l; char *name; + GaimBuddy *buddy; g_return_val_if_fail(account != NULL, FALSE); g_return_val_if_fail(who != NULL, FALSE); - name = g_strdup(gaim_normalize(account, who)); + name = gaim_normalize(account, who); for (l = account->deny; l != NULL; l = l->next) { - if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) + if (!gaim_utf8_strcasecmp(name, (char *)l->data)) break; } - g_free(name); + buddy = gaim_find_buddy(account, name); if (l == NULL) return FALSE; @@ -163,8 +183,13 @@ serv_rem_deny(gaim_account_get_connection(account), name); if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) - privacy_ops->deny_removed(account, name); + privacy_ops->deny_removed(account, who); + if (buddy != NULL) { + gaim_signal_emit(gaim_blist_get_handle(), + "buddy-privacy-changed", buddy); + } + g_free(name); gaim_blist_schedule_save(); @@ -184,15 +209,17 @@ return FALSE; case GAIM_PRIVACY_ALLOW_USERS: + who = gaim_normalize(account, who); for (list=account->permit; list!=NULL; list=list->next) { - if (!gaim_utf8_strcasecmp(who, gaim_normalize(account, (char *)list->data))) + if (!gaim_utf8_strcasecmp(who, (char *)list->data)) return TRUE; } return FALSE; case GAIM_PRIVACY_DENY_USERS: + who = gaim_normalize(account, who); for (list=account->deny; list!=NULL; list=list->next) { - if (!gaim_utf8_strcasecmp(who, gaim_normalize( account, (char *)list->data ))) + if (!gaim_utf8_strcasecmp(who, (char *)list->data )) return FALSE; } return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-16 03:18:48
|
Revision: 16779 Author: datallah Date: 2006-08-15 20:18:43 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16779&view=rev Log Message: ----------- It seems like I only got half of CID 261 the first time. Modified Paths: -------------- trunk/src/gtkblist.c Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-08-16 02:44:21 UTC (rev 16778) +++ trunk/src/gtkblist.c 2006-08-16 03:18:43 UTC (rev 16779) @@ -2991,10 +2991,8 @@ text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); else if (!selected && !text) text = g_strdup_printf("<span color='%s'>%s</span>\n" - "<span color='%s' size='smaller'>%s%s%s</span>", + "<span color='%s' size='smaller'>%s</span>", dim_grey(), esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", statustext != NULL ? statustext : ""); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ebl...@us...> - 2006-08-16 02:44:26
|
Revision: 16778 Author: eblanton Date: 2006-08-15 19:44:21 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16778&view=rev Log Message: ----------- Thanks to Josh Blanton for this fix to MSN signon with non-glibc printf. This is a complete hack, but it's no worse than what is there now. Modified Paths: -------------- trunk/src/protocols/msn/nexus.c Modified: trunk/src/protocols/msn/nexus.c =================================================================== --- trunk/src/protocols/msn/nexus.c 2006-08-16 02:37:49 UTC (rev 16777) +++ trunk/src/protocols/msn/nexus.c 2006-08-16 02:44:21 UTC (rev 16778) @@ -293,7 +293,16 @@ } +/* this guards against missing hash entries */ +char * +nexus_challenge_data_lookup(GHashTable *challenge_data, const char *key) +{ + char *entry; + return (entry = (char *)g_hash_table_lookup(challenge_data, key)) ? + entry : "(null)"; +} + void login_connect_cb(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond) @@ -336,16 +345,16 @@ "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n", - (char *)g_hash_table_lookup(nexus->challenge_data, "lc"), - (char *)g_hash_table_lookup(nexus->challenge_data, "id"), - (char *)g_hash_table_lookup(nexus->challenge_data, "tw"), - (char *)g_hash_table_lookup(nexus->challenge_data, "fs"), - (char *)g_hash_table_lookup(nexus->challenge_data, "ru"), + nexus_challenge_data_lookup(nexus->challenge_data, "lc"), + nexus_challenge_data_lookup(nexus->challenge_data, "id"), + nexus_challenge_data_lookup(nexus->challenge_data, "tw"), + nexus_challenge_data_lookup(nexus->challenge_data, "fs"), + nexus_challenge_data_lookup(nexus->challenge_data, "ru"), ctint, - (char *)g_hash_table_lookup(nexus->challenge_data, "kpp"), - (char *)g_hash_table_lookup(nexus->challenge_data, "kv"), - (char *)g_hash_table_lookup(nexus->challenge_data, "ver"), - (char *)g_hash_table_lookup(nexus->challenge_data, "tpf"), + nexus_challenge_data_lookup(nexus->challenge_data, "kpp"), + nexus_challenge_data_lookup(nexus->challenge_data, "kv"), + nexus_challenge_data_lookup(nexus->challenge_data, "ver"), + nexus_challenge_data_lookup(nexus->challenge_data, "tpf"), nexus->login_host); buffer = g_strdup_printf("%s,pwd=XXXXXXXX,%s\r\n", head, tail); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-08-16 02:37:55
|
Revision: 16777 Author: evands Date: 2006-08-15 19:37:49 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16777&view=rev Log Message: ----------- Typo fix Modified Paths: -------------- trunk/src/dbus-server.c Modified: trunk/src/dbus-server.c =================================================================== --- trunk/src/dbus-server.c 2006-08-16 01:32:12 UTC (rev 16776) +++ trunk/src/dbus-server.c 2006-08-16 02:37:49 UTC (rev 16777) @@ -48,7 +48,7 @@ /* * Here we include the list of #GAIM_DBUS_DEFINE_TYPE statements for * all structs defined in gaim. This file has been generated by the - * #dbus-analize-types.py script. + * #dbus-analyze-types.py script. */ #include "dbus-types.c" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-08-16 01:32:18
|
Revision: 16776 Author: seanegan Date: 2006-08-15 18:32:12 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16776&view=rev Log Message: ----------- Fix segfault when using non-buddy-icon'ed accounts Modified Paths: -------------- trunk/src/gtkstatusbox.c trunk/src/gtkutils.c Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-15 23:25:29 UTC (rev 16775) +++ trunk/src/gtkstatusbox.c 2006-08-16 01:32:12 UTC (rev 16776) @@ -926,7 +926,8 @@ GList *accounts; for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { GaimAccount *account = accounts->data; - if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddy-icon", TRUE)) { + if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddy-icon", TRUE) && + GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account)))->icon_spec.format) { char *icon = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), filename); gaim_account_set_buddy_icon(account, icon); Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-15 23:25:29 UTC (rev 16775) +++ trunk/src/gtkutils.c 2006-08-16 01:32:12 UTC (rev 16776) @@ -2457,6 +2457,8 @@ char* gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) { + g_return_val_if_fail(GAIM_PLUGIN_PROTOCOL_INFO(plugin)->icon_spec.format != NULL, NULL); + #if GTK_CHECK_VERSION(2,2,0) int width, height; char **pixbuf_formats = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-08-15 23:25:40
|
Revision: 16775 Author: seanegan Date: 2006-08-15 16:25:29 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16775&view=rev Log Message: ----------- A global buddy icon selector in the statusbox. This is done totally in the GTK+ UI; the core still sees a buddy icon as belonging to an account. Per-account icons can override the global one in Modify Account. There are some caching issues to work out, still. Modified Paths: -------------- trunk/src/gtkaccount.c trunk/src/gtkblist.c trunk/src/gtkstatusbox.c trunk/src/gtkstatusbox.h trunk/src/gtkutils.c trunk/src/gtkutils.h Modified: trunk/src/gtkaccount.c =================================================================== --- trunk/src/gtkaccount.c 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkaccount.c 2006-08-15 23:25:29 UTC (rev 16775) @@ -115,6 +115,7 @@ GtkWidget *user_frame; GtkWidget *new_mail_check; GtkWidget *icon_hbox; + GtkWidget *icon_check; GtkWidget *icon_entry; char *icon_path; GtkWidget *icon_filesel; @@ -153,8 +154,6 @@ static void add_account_to_liststore(GaimAccount *account, gpointer user_data); static void set_account(GtkListStore *store, GtkTreeIter *iter, GaimAccount *account); -static char* -convert_buddy_icon(GaimPlugin *plugin, const char *path); /************************************************************************** * Add/Modify Account dialog @@ -271,210 +270,24 @@ } } -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ static void -icon_filesel_choose_cb(GtkWidget *widget, gint response, AccountPrefsDialog *dialog) +icon_filesel_choose_cb(const char *filename, AccountPrefsDialog *dialog) { - char *filename, *current_folder; - - if (response != GTK_RESPONSE_ACCEPT) { - if (response == GTK_RESPONSE_CANCEL) - gtk_widget_destroy(dialog->icon_filesel); - dialog->icon_filesel = NULL; - return; + if (filename) { + g_free(dialog->icon_path); + dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, filename); + set_dialog_icon(dialog); + gtk_widget_show(dialog->icon_entry); } - - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); - current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); - if (current_folder != NULL) { - gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); - g_free(current_folder); - } - -#else /* FILECHOOSER */ -static void -icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) -{ - char *filename, *current_folder; - - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); - - /* If they typed in a directory, change there */ - if (gaim_gtk_check_if_dir(filename, - GTK_FILE_SELECTION(dialog->icon_filesel))) - { - g_free(filename); - return; - } - - current_folder = g_path_get_dirname(filename); - if (current_folder != NULL) { - gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); - g_free(current_folder); - } - -#endif /* FILECHOOSER */ - - g_free(dialog->icon_path); - dialog->icon_path = convert_buddy_icon(dialog->plugin, filename); - set_dialog_icon(dialog); - gtk_widget_show(dialog->icon_entry); - - gtk_widget_destroy(dialog->icon_filesel); + dialog->icon_filesel = NULL; - g_free(filename); - } - -static void -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ -icon_preview_change_cb(GtkFileChooser *widget, AccountPrefsDialog *dialog) -#else /* FILECHOOSER */ -icon_preview_change_cb(GtkTreeSelection *sel, AccountPrefsDialog *dialog) -#endif /* FILECHOOSER */ -{ - GdkPixbuf *pixbuf, *scale; - int height, width; - char *basename, *markup, *size; - struct stat st; - char *filename; - -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - filename = gtk_file_chooser_get_preview_filename( - GTK_FILE_CHOOSER(dialog->icon_filesel)); -#else /* FILECHOOSER */ - filename = g_strdup(gtk_file_selection_get_filename( - GTK_FILE_SELECTION(dialog->icon_filesel))); -#endif /* FILECHOOSER */ - - if (!filename || g_stat(filename, &st)) - { - g_free(filename); - return; - } - - pixbuf = gdk_pixbuf_new_from_file(filename, NULL); - if (!pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); - gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - gtk_file_chooser_set_preview_widget_active( - GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE); -#endif /* FILECHOOSER */ - g_free(filename); - return; - } - - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - basename = g_path_get_basename(filename); - size = gaim_str_size_to_units(st.st_size); - markup = g_strdup_printf(_("<b>File:</b> %s\n" - "<b>File size:</b> %s\n" - "<b>Image size:</b> %dx%d"), - basename, size, width, height); - - scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, - 50, GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - gtk_file_chooser_set_preview_widget_active( - GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE); -#endif /* FILECHOOSER */ - gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); - - g_object_unref(G_OBJECT(pixbuf)); - g_object_unref(G_OBJECT(scale)); - g_free(filename); - g_free(basename); - g_free(size); - g_free(markup); } -#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ static void -icon_filesel_delete_cb(GtkWidget *w, AccountPrefsDialog *dialog) -{ - if (dialog->icon_filesel != NULL) - gtk_widget_destroy(dialog->icon_filesel); - - dialog->icon_filesel = NULL; -} -#endif /* FILECHOOSER */ - -static void icon_select_cb(GtkWidget *button, AccountPrefsDialog *dialog) { -#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - GtkWidget *hbox; - GtkWidget *tv; - GtkTreeSelection *sel; -#endif /* FILECHOOSER */ - const char *current_folder; - - if (dialog->icon_filesel != NULL) { - gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); - return; - } - - current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); -#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ - dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), - GTK_WINDOW(dialog->window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); - if ((current_folder != NULL) && (*current_folder != '\0')) - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), - current_folder); - - dialog->icon_preview = gtk_image_new(); - dialog->icon_text = gtk_label_new(NULL); - gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); - gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), - GTK_WIDGET(dialog->icon_preview)); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", - G_CALLBACK(icon_preview_change_cb), dialog); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", - G_CALLBACK(icon_filesel_choose_cb), dialog); - icon_preview_change_cb(NULL, dialog); -#else /* FILECHOOSER */ - dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); - dialog->icon_preview = gtk_image_new(); - dialog->icon_text = gtk_label_new(NULL); - if ((current_folder != NULL) && (*current_folder != '\0')) - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), - current_folder); - - gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); - hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); - gtk_box_pack_start( - GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), - hbox, FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, - FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); - - tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); - - g_signal_connect(G_OBJECT(sel), "changed", - G_CALLBACK(icon_preview_change_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), - "clicked", - G_CALLBACK(icon_filesel_choose_cb), dialog); - g_signal_connect( - G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), - "clicked", - G_CALLBACK(icon_filesel_delete_cb), dialog); - g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", - G_CALLBACK(icon_filesel_delete_cb), dialog); -#endif /* FILECHOOSER */ - - gtk_widget_show_all(GTK_WIDGET(dialog->icon_filesel)); + dialog->icon_filesel = gaim_gtk_buddy_icon_chooser_new(dialog->window, icon_filesel_choose_cb, dialog); + gtk_widget_show_all(dialog->icon_filesel); } static void @@ -510,7 +323,8 @@ if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) *rtmp = '\0'; g_free(dialog->icon_path); - dialog->icon_path = convert_buddy_icon(dialog->plugin, tmp); + + dialog->icon_path = gaim_gtk_convert_buddy_icon(dialog->plugin, tmp); set_dialog_icon(dialog); gtk_widget_show(dialog->icon_entry); g_free(tmp); @@ -520,207 +334,6 @@ gtk_drag_finish(dc, FALSE, FALSE, t); } - -#if GTK_CHECK_VERSION(2,2,0) -static gboolean -str_array_match(char **a, char **b) -{ - int i, j; - - if (!a || !b) - return FALSE; - for (i = 0; a[i] != NULL; i++) - for (j = 0; b[j] != NULL; j++) - if (!g_ascii_strcasecmp(a[i], b[j])) - return TRUE; - return FALSE; -} -#endif - -static char* -convert_buddy_icon(GaimPlugin *plugin, const char *path) -{ -#if GTK_CHECK_VERSION(2,2,0) - int width, height; - char **pixbuf_formats = NULL; - GdkPixbufFormat *format; - GdkPixbuf *pixbuf; - GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); - char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0); -#if !GTK_CHECK_VERSION(2,4,0) - GdkPixbufLoader *loader; - FILE *file; - struct stat st; - void *data = NULL; -#endif -#endif - const char *dirname = gaim_buddy_icons_get_cache_dir(); - char *random = g_strdup_printf("%x", g_random_int()); - char *filename = g_build_filename(dirname, random, NULL); - - if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { - gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); - - if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { - gaim_debug_error("buddyicon", - "Unable to create directory %s: %s\n", - dirname, strerror(errno)); -#if GTK_CHECK_VERSION(2,2,0) - g_strfreev(prpl_formats); -#endif - g_free(random); - g_free(filename); - return NULL; - } - } - -#if GTK_CHECK_VERSION(2,2,0) -#if GTK_CHECK_VERSION(2,4,0) - format = gdk_pixbuf_get_file_info (path, &width, &height); -#else - loader = gdk_pixbuf_loader_new(); - if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) { - data = g_malloc(st.st_size); - fread(data, 1, st.st_size, file); - fclose(file); - gdk_pixbuf_loader_write(loader, data, st.st_size, NULL); - g_free(data); - } - gdk_pixbuf_loader_close(loader, NULL); - pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); - width = gdk_pixbuf_get_width(pixbuf); - height = gdk_pixbuf_get_height(pixbuf); - format = gdk_pixbuf_loader_get_format(loader); - g_object_unref(G_OBJECT(loader)); -#endif - pixbuf_formats = gdk_pixbuf_format_get_extensions(format); - - if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ - (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ - (prpl_info->icon_spec.min_width <= width && - prpl_info->icon_spec.max_width >= width && - prpl_info->icon_spec.min_height <= height && - prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ -#endif - { - gchar *contents; - gsize length; - FILE *image; - -#if GTK_CHECK_VERSION(2,2,0) - g_strfreev(prpl_formats); - g_strfreev(pixbuf_formats); -#endif - - /* Copy the image to the cache folder as "filename". */ - - if (!g_file_get_contents(path, &contents, &length, NULL) || - (image = g_fopen(filename, "wb")) == NULL) - { - g_free(random); - g_free(filename); -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - return NULL; - } - - if (fwrite(contents, 1, length, image) != length) - { - fclose(image); - g_unlink(filename); - - g_free(random); - g_free(filename); -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - return NULL; - } - fclose(image); - -#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) - g_object_unref(G_OBJECT(pixbuf)); -#endif - - g_free(filename); - return random; - } -#if GTK_CHECK_VERSION(2,2,0) - else - { - int i; - GError *error = NULL; - GdkPixbuf *scale; - pixbuf = gdk_pixbuf_new_from_file(path, &error); - g_strfreev(pixbuf_formats); - if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) && - (width < prpl_info->icon_spec.min_width || - width > prpl_info->icon_spec.max_width || - height < prpl_info->icon_spec.min_height || - height > prpl_info->icon_spec.max_height)) - { - int new_width = width; - int new_height = height; - - if(new_width > prpl_info->icon_spec.max_width) - new_width = prpl_info->icon_spec.max_width; - else if(new_width < prpl_info->icon_spec.min_width) - new_width = prpl_info->icon_spec.min_width; - if(new_height > prpl_info->icon_spec.max_height) - new_height = prpl_info->icon_spec.max_height; - else if(new_height < prpl_info->icon_spec.min_height) - new_height = prpl_info->icon_spec.min_height; - - /* preserve aspect ratio */ - if ((double)height * (double)new_width > - (double)width * (double)new_height) { - new_width = 0.5 + (double)width * (double)new_height / (double)height; - } else { - new_height = 0.5 + (double)height * (double)new_width / (double)width; - } - - scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height, - GDK_INTERP_HYPER); - g_object_unref(G_OBJECT(pixbuf)); - pixbuf = scale; - } - if (error) { - g_free(random); - g_free(filename); - gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); - g_error_free(error); - g_strfreev(prpl_formats); - return NULL; - } - - for (i = 0; prpl_formats[i]; i++) { - gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); - /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful, - * FALSE if an error was set. */ - if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE) - break; - gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message); - g_error_free(error); - error = NULL; - } - g_strfreev(prpl_formats); - if (!error) { - g_object_unref(G_OBJECT(pixbuf)); - g_free(filename); - return random; - } else { - gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message); - g_error_free(error); - } - g_free(random); - g_free(filename); - g_object_unref(G_OBJECT(pixbuf)); - } - return NULL; -#endif -} - static void update_editable(GaimConnection *gc, AccountPrefsDialog *dialog) { @@ -898,6 +511,12 @@ } static void +icon_check_cb(GtkWidget *checkbox, AccountPrefsDialog *dialog) +{ + gtk_widget_set_sensitive(dialog->icon_hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); +} + +static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent) { GtkWidget *frame; @@ -930,12 +549,17 @@ gtk_widget_show(dialog->new_mail_check); /* Buddy icon */ + dialog->icon_check = gtk_check_button_new_with_label(_("Use this buddy icon for this account:")); + g_signal_connect(G_OBJECT(dialog->icon_check), "toggled", G_CALLBACK(icon_check_cb), dialog); + gtk_widget_show(dialog->icon_check); + gtk_box_pack_start(GTK_BOX(vbox), dialog->icon_check, FALSE, FALSE, 0); + dialog->icon_hbox = hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtk_widget_set_sensitive(hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); - label = gtk_label_new(_("Buddy icon:")); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); + label = gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); @@ -976,12 +600,14 @@ if (dialog->account != NULL) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->new_mail_check), - gaim_account_get_check_mail(dialog->account)); + gaim_account_get_check_mail(dialog->account)); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->icon_check), + !gaim_account_get_ui_bool(dialog->account, GAIM_GTK_UI, "use-global-buddyicon", + TRUE)); - if (gaim_account_get_buddy_icon(dialog->account) != NULL) { - dialog->icon_path = g_strdup(gaim_account_get_buddy_icon(dialog->account)); - set_dialog_icon(dialog); - } + dialog->icon_path = g_strdup(gaim_account_get_ui_string(dialog->account, GAIM_GTK_UI, "non-global-buddyicon", NULL)); + set_dialog_icon(dialog); } if (!dialog->prpl_info || @@ -1425,12 +1051,13 @@ if (dialog->icon_path != NULL) { - const char *icon = gaim_account_get_buddy_icon(dialog->account); + const char *icon = gaim_account_get_ui_string(dialog->account, GAIM_GTK_UI, "non-global-buddyicon", NULL); if (dialog->icon_path != NULL && (icon == NULL || strcmp(dialog->icon_path, icon))) { /* The user set an icon, which would've been cached by convert_buddy_icon, * but didn't save the changes. Delete the cache file. */ char *filename = g_build_filename(gaim_buddy_icons_get_cache_dir(), dialog->icon_path, NULL); + printf("Deleting\n"); g_unlink(filename); g_free(filename); } @@ -1460,7 +1087,7 @@ const char *value; char *username; char *tmp; - gboolean new = FALSE; + gboolean new = FALSE, icon_change = FALSE; GaimAccount *account; if (dialog->account == NULL) @@ -1488,7 +1115,20 @@ gaim_account_set_alias(account, NULL); /* Buddy Icon */ - gaim_account_set_buddy_icon(account, dialog->icon_path); + if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", TRUE) == + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) { + icon_change = TRUE; + } + gaim_account_set_ui_bool(account, GAIM_GTK_UI, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); + gaim_account_set_ui_string(account, GAIM_GTK_UI, "non-global-buddyicon", dialog->icon_path); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) { + gaim_account_set_buddy_icon(account, dialog->icon_path); + } else if (gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon") && icon_change) { + char *icon = gaim_gtk_convert_buddy_icon(dialog->plugin, gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon")); + gaim_account_set_buddy_icon(account, icon); + g_free(icon); + } + /* Remember Password */ gaim_account_set_remember_password(account, @@ -2672,6 +2312,7 @@ gaim_prefs_add_none("/gaim/gtk/accounts/dialog"); gaim_prefs_add_int("/gaim/gtk/accounts/dialog/width", 520); gaim_prefs_add_int("/gaim/gtk/accounts/dialog/height", 321); + gaim_prefs_add_string("/gaim/gtk/accounts/buddyicon", NULL); gaim_signal_register(gaim_gtk_account_get_handle(), "account-modified", gaim_marshal_VOID__POINTER, NULL, 1, Modified: trunk/src/gtkblist.c =================================================================== --- trunk/src/gtkblist.c 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkblist.c 2006-08-15 23:25:29 UTC (rev 16775) @@ -3814,12 +3814,11 @@ /* Add the statusbox */ gtkblist->statusbox = gtk_gaim_status_box_new(); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); gtk_widget_set_name(gtkblist->statusbox, "gaim_gtkblist_statusbox"); - + gtk_gaim_status_box_set_buddy_icon(gtkblist->statusbox, gaim_prefs_get_string("/gaim/gtk/accounts/buddyicon")); gtk_widget_show(gtkblist->statusbox); - gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); - - + /* set the Show Offline Buddies option. must be done * after the treeview or faceprint gets mad. -Robot101 */ Modified: trunk/src/gtkstatusbox.c =================================================================== --- trunk/src/gtkstatusbox.c 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkstatusbox.c 2006-08-15 23:25:29 UTC (rev 16775) @@ -77,6 +77,8 @@ static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); +static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); + static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); @@ -260,6 +262,17 @@ gaim_signals_disconnect_by_handle(statusbox); gaim_prefs_disconnect_by_handle(statusbox); + gdk_cursor_unref(statusbox->hand_cursor); + gdk_cursor_unref(statusbox->arrow_cursor); + + g_object_unref(G_OBJECT(statusbox->buddy_icon)); + g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); + + if (statusbox->buddy_icon_sel) + gtk_widget_destroy(statusbox->buddy_icon_sel); + + g_free(statusbox->buddy_icon_path); + G_OBJECT_CLASS(parent_class)->finalize(obj); } @@ -907,6 +920,55 @@ } static void +icon_choose_cb(const char *filename, GtkGaimStatusBox *box) +{ + if (filename) { + GList *accounts; + for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { + GaimAccount *account = accounts->data; + if (gaim_account_get_ui_bool(account, GAIM_GTK_UI, "use-global-buddy-icon", TRUE)) { + char *icon = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), + filename); + gaim_account_set_buddy_icon(account, icon); + g_free(icon); + } + } + gtk_gaim_status_box_set_buddy_icon(box, filename); + } + + box->buddy_icon_sel = NULL; +} + +static gboolean +icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) +{ + if (box->buddy_icon_sel) { + gtk_window_present(GTK_WINDOW(box->buddy_icon_sel)); + return FALSE; + } + + GtkWidget *filesel = gaim_gtk_buddy_icon_chooser_new(NULL, icon_choose_cb, box); + gtk_widget_show_all(filesel); + return FALSE; +} + +static gboolean +icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) +{ + gdk_window_set_cursor(widget->window, box->hand_cursor); + gtk_image_set_from_pixbuf(box->icon, box->buddy_icon_hover); + return FALSE; +} + +static gboolean +icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) +{ + gdk_window_set_cursor(widget->window, box->arrow_cursor); + gtk_image_set_from_pixbuf(box->icon, box->buddy_icon) ; + return FALSE; +} + +static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) { GtkCellRenderer *text_rend; @@ -922,6 +984,18 @@ status_box->vsep = gtk_vseparator_new(); status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + status_box->buddy_icon = gdk_pixbuf_new_from_file("/home/seanegan/p1120233.jpg", NULL); + status_box->icon = gtk_image_new_from_pixbuf(status_box->buddy_icon); + status_box->icon_box = gtk_event_box_new(); + status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); + status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); + + g_signal_connect(G_OBJECT(status_box->icon_box), "enter-notify-event", G_CALLBACK(icon_box_enter_cb), status_box); + g_signal_connect(G_OBJECT(status_box->icon_box), "leave-notify-event", G_CALLBACK(icon_box_leave_cb), status_box); + g_signal_connect(G_OBJECT(status_box->icon_box), "button-press-event", G_CALLBACK(icon_box_press_cb), status_box); + + gtk_container_add(GTK_CONTAINER(status_box->icon_box), status_box->icon); + status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); @@ -934,6 +1008,7 @@ gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->arrow, FALSE, FALSE, 0); gtk_widget_show_all(status_box->toggle_button); + gtk_widget_show_all(status_box->icon_box); #if GTK_CHECK_VERSION(2,4,0) gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); #endif @@ -984,6 +1059,7 @@ #endif gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); gtk_widget_set_parent(status_box->toggle_button, GTK_WIDGET(status_box)); + gtk_widget_set_parent(status_box->icon_box, GTK_WIDGET(status_box)); GTK_BIN(status_box)->child = status_box->toggle_button; gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); @@ -1024,14 +1100,58 @@ requisition->height += box_req.height + 3; requisition->width = 1; + + } +/* From gnome-panel */ static void +do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift) +{ + gint i, j; + gint width, height, has_alpha, srcrowstride, destrowstride; + guchar *target_pixels; + guchar *original_pixels; + guchar *pixsrc; + guchar *pixdest; + int val; + guchar r,g,b; + + has_alpha = gdk_pixbuf_get_has_alpha (src); + width = gdk_pixbuf_get_width (src); + height = gdk_pixbuf_get_height (src); + srcrowstride = gdk_pixbuf_get_rowstride (src); + destrowstride = gdk_pixbuf_get_rowstride (dest); + target_pixels = gdk_pixbuf_get_pixels (dest); + original_pixels = gdk_pixbuf_get_pixels (src); + + for (i = 0; i < height; i++) { + pixdest = target_pixels + i*destrowstride; + pixsrc = original_pixels + i*srcrowstride; + for (j = 0; j < width; j++) { + r = *(pixsrc++); + g = *(pixsrc++); + b = *(pixsrc++); + val = r + shift; + *(pixdest++) = CLAMP(val, 0, 255); + val = g + shift; + *(pixdest++) = CLAMP(val, 0, 255); + val = b + shift; + *(pixdest++) = CLAMP(val, 0, 255); + if (has_alpha) + *(pixdest++) = *(pixsrc++); + } + } +} + +static void gtk_gaim_status_box_size_allocate(GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { + GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); GtkRequisition req = {0,0}; - GtkAllocation parent_alc, box_alc; + GtkAllocation parent_alc, box_alc, icon_alc; + GdkPixbuf *scaled; combo_box_size_request(widget, &req); @@ -1043,7 +1163,28 @@ parent_alc = *allocation; parent_alc.height = MAX(1,req.height); parent_alc.y += 3; + parent_alc.width -= (parent_alc.height + 3); combo_box_size_allocate(widget, &parent_alc); + + icon_alc = *allocation; + icon_alc.height = MAX(1,req.height); + icon_alc.width = icon_alc.height; + icon_alc.x = allocation->width - icon_alc.width; + icon_alc.y += 3; + + if (status_box->icon_size != icon_alc.height) { + scaled = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, + icon_alc.height, icon_alc.width, FALSE, NULL); + status_box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(status_box->buddy_icon_hover, status_box->buddy_icon_hover, 30); + g_object_unref(status_box->buddy_icon); + status_box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(status_box->icon, status_box->buddy_icon); + status_box->icon_size = icon_alc.height; + } + gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->icon_box, &icon_alc); + + gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->toggle_button, &parent_alc); widget->allocation = *allocation; } @@ -1055,6 +1196,7 @@ GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); + gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->icon_box, event); return FALSE; } @@ -1071,6 +1213,7 @@ (* callback) (status_box->vbox, callback_data); (* callback) (status_box->toggle_button, callback_data); (* callback) (status_box->arrow, callback_data); + (* callback) (status_box->icon_box, callback_data); } combo_box_forall(container, include_internals, callback, callback_data); @@ -1179,6 +1322,30 @@ } void +gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *box, const char *filename) +{ + GdkPixbuf *scaled; + g_free(box->buddy_icon_path); + box->buddy_icon_path = g_strdup(filename); + + scaled = gdk_pixbuf_new_from_file_at_scale(filename, + box->icon_size, box->icon_size, FALSE, NULL); + box->buddy_icon_hover = gdk_pixbuf_copy(scaled); + do_colorshift(box->buddy_icon_hover, box->buddy_icon_hover, 30); + g_object_unref(box->buddy_icon); + box->buddy_icon = scaled; + gtk_image_set_from_pixbuf(box->icon, box->buddy_icon); + + gaim_prefs_set_string("/gaim/gtk/accounts/buddyicon", filename); +} + +const char* +gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *box) +{ + return box->buddy_icon_path; +} + +void gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) { if (!status_box) Modified: trunk/src/gtkstatusbox.h =================================================================== --- trunk/src/gtkstatusbox.h 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkstatusbox.h 2006-08-15 23:25:29 UTC (rev 16775) @@ -83,6 +83,17 @@ GtkWidget *vbox, *sw; GtkWidget *imhtml; + + char *buddy_icon_path; + GdkPixbuf *buddy_icon; + GdkPixbuf *buddy_icon_hover; + GtkWidget *buddy_icon_sel; + GtkWidget *icon; + GtkWidget *icon_box; + GdkCursor *hand_cursor; + GdkCursor *arrow_cursor; + int icon_size; + gboolean imhtml_visible; GtkWidget *cell_view; @@ -146,6 +157,12 @@ void gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box); +void +gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *status_box, const char *filename); + +const char * +gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *status_box); + char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box); G_END_DECLS Modified: trunk/src/gtkutils.c =================================================================== --- trunk/src/gtkutils.c 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkutils.c 2006-08-15 23:25:29 UTC (rev 16775) @@ -2211,3 +2211,429 @@ gdk_window_set_cursor(widget->window, NULL); } +struct _icon_chooser { + GtkWidget *icon_filesel; + GtkWidget *icon_preview; + GtkWidget *icon_text; + + void (*callback)(const char*,gpointer); + gpointer data; +}; + +#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +static void +icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog) +{ + if (dialog->icon_filesel != NULL) + gtk_widget_destroy(dialog->icon_filesel); + + if (dialog->callback) + dialog->callback(NULL, data); + + g_free(dialog); +} +#endif /* FILECHOOSER */ + + + +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +static void +icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog) +{ + char *filename, *current_folder; + + if (response != GTK_RESPONSE_ACCEPT) { + if (response == GTK_RESPONSE_CANCEL) { + gtk_widget_destroy(dialog->icon_filesel); + } + dialog->icon_filesel = NULL; + if (dialog->callback) + dialog->callback(NULL, dialog->data); + g_free(dialog); + return; + } + + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); + current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); + if (current_folder != NULL) { + gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); + g_free(current_folder); + } + +#else /* FILECHOOSER */ +static void +icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) +{ + char *filename, *current_folder; + + filename = g_strdup(gtk_file_selection_get_filename( + GTK_FILE_SELECTION(dialog->icon_filesel))); + + /* If they typed in a directory, change there */ + if (gaim_gtk_check_if_dir(filename, + GTK_FILE_SELECTION(dialog->icon_filesel))) + { + g_free(filename); + return; + } + + current_folder = g_path_get_dirname(filename); + if (current_folder != NULL) { + gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); + g_free(current_folder); + } + +#endif /* FILECHOOSER */ + if (dialog->callback) + dialog->callback(filename, dialog->data); + gtk_widget_destroy(dialog->icon_filesel); + g_free(filename); + g_free(dialog); + } + + +static void +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ +icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog) +#else /* FILECHOOSER */ +icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog) +#endif /* FILECHOOSER */ +{ + GdkPixbuf *pixbuf, *scale; + int height, width; + char *basename, *markup, *size; + struct stat st; + char *filename; + +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + filename = gtk_file_chooser_get_preview_filename( + GTK_FILE_CHOOSER(dialog->icon_filesel)); +#else /* FILECHOOSER */ + filename = g_strdup(gtk_file_selection_get_filename( + GTK_FILE_SELECTION(dialog->icon_filesel))); +#endif /* FILECHOOSER */ + + if (!filename || g_stat(filename, &st)) + { + g_free(filename); + return; + } + + pixbuf = gdk_pixbuf_new_from_file(filename, NULL); + if (!pixbuf) { + gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); + gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + gtk_file_chooser_set_preview_widget_active( + GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE); +#endif /* FILECHOOSER */ + g_free(filename); + return; + } + + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + basename = g_path_get_basename(filename); + size = gaim_str_size_to_units(st.st_size); + markup = g_strdup_printf(_("<b>File:</b> %s\n" + "<b>File size:</b> %s\n" + "<b>Image size:</b> %dx%d"), + basename, size, width, height); + + scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, + 50, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + gtk_file_chooser_set_preview_widget_active( + GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE); +#endif /* FILECHOOSER */ + gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); + + g_object_unref(G_OBJECT(pixbuf)); + g_object_unref(G_OBJECT(scale)); + g_free(filename); + g_free(basename); + g_free(size); + g_free(markup); +} + + +GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data) { + struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); + +#if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + GtkWidget *hbox; + GtkWidget *tv; + GtkTreeSelection *sel; + +#endif /* FILECHOOSER */ + const char *current_folder; + + dialog->callback = callback; + dialog->data = data; + + if (dialog->icon_filesel != NULL) { + gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); + return NULL; + } + + current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); +#if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ + + dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), + parent, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); + if ((current_folder != NULL) && (*current_folder != '\0')) + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), + current_folder); + + dialog->icon_preview = gtk_image_new(); + dialog->icon_text = gtk_label_new(NULL); + gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); + gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), + GTK_WIDGET(dialog->icon_preview)); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", + G_CALLBACK(icon_preview_change_cb), dialog); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", + G_CALLBACK(icon_filesel_choose_cb), dialog); + icon_preview_change_cb(NULL, dialog); +#else /* FILECHOOSER */ + dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); + dialog->icon_preview = gtk_image_new(); + dialog->icon_text = gtk_label_new(NULL); + if ((current_folder != NULL) && (*current_folder != '\0')) + gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), + current_folder); + + gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); + hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); + gtk_box_pack_start( + GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), + hbox, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, + FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); + + tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); + + g_signal_connect(G_OBJECT(sel), "changed", + G_CALLBACK(icon_preview_change_cb), dialog); + g_signal_connect( + G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), + "clicked", + G_CALLBACK(icon_filesel_choose_cb), dialog); + g_signal_connect( + G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), + "clicked", + G_CALLBACK(icon_filesel_delete_cb), dialog); + g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", + G_CALLBACK(icon_filesel_delete_cb), dialog); +#endif /* FILECHOOSER */ + return dialog->icon_filesel; +} + + +#if GTK_CHECK_VERSION(2,2,0) +static gboolean +str_array_match(char **a, char **b) +{ + int i, j; + + if (!a || !b) + return FALSE; + for (i = 0; a[i] != NULL; i++) + for (j = 0; b[j] != NULL; j++) + if (!g_ascii_strcasecmp(a[i], b[j])) + return TRUE; + return FALSE; +} +#endif + +char* +gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) +{ +#if GTK_CHECK_VERSION(2,2,0) + int width, height; + char **pixbuf_formats = NULL; + GdkPixbufFormat *format; + GdkPixbuf *pixbuf; + GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + char **prpl_formats = g_strsplit (prpl_info->icon_spec.format,",",0); +#if !GTK_CHECK_VERSION(2,4,0) + GdkPixbufLoader *loader; + FILE *file; + struct stat st; + void *data = NULL; +#endif +#endif + const char *dirname = gaim_buddy_icons_get_cache_dir(); + char *random = g_strdup_printf("%x", g_random_int()); + char *filename = g_build_filename(dirname, random, NULL); + + if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { + gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); + + if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { + gaim_debug_error("buddyicon", + "Unable to create directory %s: %s\n", + dirname, strerror(errno)); +#if GTK_CHECK_VERSION(2,2,0) + g_strfreev(prpl_formats); +#endif + g_free(random); + g_free(filename); + return NULL; + } + } + +#if GTK_CHECK_VERSION(2,2,0) +#if GTK_CHECK_VERSION(2,4,0) + format = gdk_pixbuf_get_file_info (path, &width, &height); +#else + loader = gdk_pixbuf_loader_new(); + if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) { + data = g_malloc(st.st_size); + fread(data, 1, st.st_size, file); + fclose(file); + gdk_pixbuf_loader_write(loader, data, st.st_size, NULL); + g_free(data); + } + gdk_pixbuf_loader_close(loader, NULL); + pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + format = gdk_pixbuf_loader_get_format(loader); + g_object_unref(G_OBJECT(loader)); +#endif + pixbuf_formats = gdk_pixbuf_format_get_extensions(format); + + if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ + (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ + (prpl_info->icon_spec.min_width <= width && + prpl_info->icon_spec.max_width >= width && + prpl_info->icon_spec.min_height <= height && + prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ +#endif + { + gchar *contents; + gsize length; + FILE *image; + +#if GTK_CHECK_VERSION(2,2,0) + g_strfreev(prpl_formats); + g_strfreev(pixbuf_formats); +#endif + + /* Copy the image to the cache folder as "filename". */ + + if (!g_file_get_contents(path, &contents, &length, NULL) || + (image = g_fopen(filename, "wb")) == NULL) + { + g_free(random); + g_free(filename); +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + return NULL; + } + + if (fwrite(contents, 1, length, image) != length) + { + fclose(image); + g_unlink(filename); + + g_free(random); + g_free(filename); +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + return NULL; + } + fclose(image); + +#if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) + g_object_unref(G_OBJECT(pixbuf)); +#endif + + g_free(filename); + return random; + } +#if GTK_CHECK_VERSION(2,2,0) + else + { + int i; + GError *error = NULL; + GdkPixbuf *scale; + pixbuf = gdk_pixbuf_new_from_file(path, &error); + g_strfreev(pixbuf_formats); + if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) && + (width < prpl_info->icon_spec.min_width || + width > prpl_info->icon_spec.max_width || + height < prpl_info->icon_spec.min_height || + height > prpl_info->icon_spec.max_height)) + { + int new_width = width; + int new_height = height; + + if(new_width > prpl_info->icon_spec.max_width) + new_width = prpl_info->icon_spec.max_width; + else if(new_width < prpl_info->icon_spec.min_width) + new_width = prpl_info->icon_spec.min_width; + if(new_height > prpl_info->icon_spec.max_height) + new_height = prpl_info->icon_spec.max_height; + else if(new_height < prpl_info->icon_spec.min_height) + new_height = prpl_info->icon_spec.min_height; + + /* preserve aspect ratio */ + if ((double)height * (double)new_width > + (double)width * (double)new_height) { + new_width = 0.5 + (double)width * (double)new_height / (double)height; + } else { + new_height = 0.5 + (double)height * (double)new_width / (double)width; + } + + scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height, + GDK_INTERP_HYPER); + g_object_unref(G_OBJECT(pixbuf)); + pixbuf = scale; + } + if (error) { + g_free(random); + g_free(filename); + gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); + g_error_free(error); + g_strfreev(prpl_formats); + return NULL; + } + + for (i = 0; prpl_formats[i]; i++) { + gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); + /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful, + * FALSE if an error was set. */ + if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE) + break; + gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message); + g_error_free(error); + error = NULL; + } + g_strfreev(prpl_formats); + if (!error) { + g_object_unref(G_OBJECT(pixbuf)); + g_free(filename); + return random; + } else { + gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message); + g_error_free(error); + } + g_free(random); + g_free(filename); + g_object_unref(G_OBJECT(pixbuf)); + } + return NULL; +#endif +} Modified: trunk/src/gtkutils.h =================================================================== --- trunk/src/gtkutils.h 2006-08-15 20:23:58 UTC (rev 16774) +++ trunk/src/gtkutils.h 2006-08-15 23:25:29 UTC (rev 16775) @@ -460,4 +460,23 @@ */ void gaim_gtk_clear_cursor(GtkWidget *widget); +/** + * Creates a File Selection widget for choosing a buddy icon + * + * @param parent The parent window + * @param callback The callback to call when the window is closed. If the user chose an icon, the char* argument will point to its path + * @param data Data to pass to @callback + * @return The file dialog + */ +GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data); + +/** + * Converts a buddy icon to the required size and format + * + * @param plugin The prpl to conver the icon + * @param path The path of a buddy icon to convert + * @return The path of a new buddy icon + */ +char* gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path); + #endif /* _GAIM_GTKUTILS_H_ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-15 20:24:09
|
Revision: 16774 Author: sadrul Date: 2006-08-15 13:23:58 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16774&view=rev Log Message: ----------- Add a new custom status dialog, and a corresponding entry in the status-selector in the buddylist. But you cannot set any per-account status yet. Modified Paths: -------------- trunk/console/gntblist.c trunk/console/gntstatus.c trunk/console/libgnt/gntcombobox.c Modified: trunk/console/gntblist.c =================================================================== --- trunk/console/gntblist.c 2006-08-15 18:05:14 UTC (rev 16773) +++ trunk/console/gntblist.c 2006-08-15 20:23:58 UTC (rev 16774) @@ -45,6 +45,7 @@ STATUS_PRIMITIVE = 0, STATUS_SAVED_POPULAR, STATUS_SAVED_ALL, + STATUS_SAVED_NEW } StatusType; typedef struct @@ -1065,6 +1066,13 @@ gaim_savedstatus_get_title(iter->data)); } + /* New savedstatus */ + item = g_new0(StatusBoxItem, 1); + item->type = STATUS_SAVED_NEW; + items = g_list_prepend(items, item); + gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, + _("New...")); + /* More savedstatuses */ item = g_new0(StatusBoxItem, 1); item->type = STATUS_SAVED_ALL; @@ -1156,6 +1164,12 @@ gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); gg_savedstatus_show_all(); } + else if (now->type == STATUS_SAVED_NEW) + { + savedstatus_changed(gaim_savedstatus_get_current(), NULL); + gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); + gg_savedstatus_edit(NULL); + } else g_return_if_reached(); } Modified: trunk/console/gntstatus.c =================================================================== --- trunk/console/gntstatus.c 2006-08-15 18:05:14 UTC (rev 16773) +++ trunk/console/gntstatus.c 2006-08-15 20:23:58 UTC (rev 16774) @@ -1,10 +1,12 @@ #include <gnt.h> #include <gntbox.h> #include <gntbutton.h> +#include <gntcombobox.h> #include <gntentry.h> #include <gntlabel.h> #include <gnttree.h> +#include <notify.h> #include <request.h> #include "gntgaim.h" @@ -16,6 +18,18 @@ GntWidget *tree; } statuses; +typedef struct +{ + GaimSavedStatus *saved; + GntWidget *window; + GntWidget *title; + GntWidget *type; + GntWidget *message; + /* XXX: Stuff needed for per-account statuses */ +} EditStatus; + +static GList *edits; /* List of opened edit-status dialogs */ + static void reset_status_window(GntWidget *widget, gpointer null) { @@ -48,7 +62,18 @@ static void really_delete_status(GaimSavedStatus *saved) { - /* XXX: Close any modify dialog opened for the savedstatus */ + GList *iter; + + for (iter = edits; iter; iter = iter->next) + { + EditStatus *edit = iter->data; + if (edit->saved == saved) + { + gnt_widget_destroy(edit->window); + break; + } + } + if (statuses.tree) gnt_tree_remove(GNT_TREE(statuses.tree), saved); @@ -80,6 +105,14 @@ gaim_savedstatus_activate(gnt_tree_get_selection_data(GNT_TREE(statuses.tree))); } +static void +edit_savedstatus_cb(GntWidget *widget, gpointer null) +{ + g_return_if_fail(statuses.tree != NULL); + + gg_savedstatus_edit(gnt_tree_get_selection_data(GNT_TREE(statuses.tree))); +} + void gg_savedstatus_show_all() { GntWidget *window, *tree, *box, *button; @@ -114,9 +147,13 @@ button = gnt_button_new(_("Add")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(gg_savedstatus_edit), NULL); button = gnt_button_new(_("Edit")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", + G_CALLBACK(edit_savedstatus_cb), NULL); button = gnt_button_new(_("Delete")); gnt_box_add_widget(GNT_BOX(box), button); @@ -133,7 +170,159 @@ gnt_widget_show(window); } +static void +update_edit_list(GntWidget *widget, EditStatus *edit) +{ + edits = g_list_remove(edits, edit); + gaim_notify_close_with_handle(edit); + g_free(edit); +} + +static void +save_savedstatus_cb(GntWidget *button, EditStatus *edit) +{ + const char *title, *message; + GaimStatusPrimitive prim; + GaimSavedStatus *find; + + title = gnt_entry_get_text(GNT_ENTRY(edit->title)); + message = gnt_entry_get_text(GNT_ENTRY(edit->message)); + if (!message || !*message) + message = NULL; + + prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type))); + + if (!title || !*title) + { + gaim_notify_error(edit, _("Error"), _("Invalid title"), + _("Please enter a non-empty title for the status.")); + return; + } + + find = gaim_savedstatus_find(title); + if (find && find != edit->saved) + { + gaim_notify_error(edit, _("Error"), _("Duplicate title"), + _("Please enter a different title for the status.")); + return; + } + + if (edit->saved == NULL) + { + edit->saved = gaim_savedstatus_new(title, prim); + gaim_savedstatus_set_message(edit->saved, message); + if (statuses.tree) + gnt_tree_add_row_last(GNT_TREE(statuses.tree), edit->saved, + gnt_tree_create_row(GNT_TREE(statuses.tree), title, + gaim_primitive_get_name_from_type(prim), message), NULL); + } + else + { + gaim_savedstatus_set_title(edit->saved, title); + gaim_savedstatus_set_type(edit->saved, prim); + gaim_savedstatus_set_message(edit->saved, message); + if (statuses.tree) + { + gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 0, title); + gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 1, + gaim_primitive_get_name_from_type(prim)); + gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 2, message); + } + } + + if (g_object_get_data(G_OBJECT(button), "use")) + gaim_savedstatus_activate(edit->saved); + + gnt_widget_destroy(edit->window); +} + void gg_savedstatus_edit(GaimSavedStatus *saved) { + EditStatus *edit; + GntWidget *window, *box, *button, *entry, *combo, *label; + GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY, + GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET}, current; + int i; + + if (saved) + { + GList *iter; + for (iter = edits; iter; iter = iter->next) + { + edit = iter->data; + if (edit->saved == saved) + return; + } + } + + edit = g_new0(EditStatus, 1); + edit->saved = saved; + edit->window = window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), _("Edit Status")); + gnt_box_set_fill(GNT_BOX(window), TRUE); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT); + gnt_box_set_pad(GNT_BOX(window), 0); + + edits = g_list_append(edits, edit); + + /* Title */ + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Title"))); + + edit->title = entry = gnt_entry_new(saved ? gaim_savedstatus_get_title(saved) : NULL); + gnt_box_add_widget(GNT_BOX(box), entry); + + /* Type */ + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + gnt_box_add_widget(GNT_BOX(box), label = gnt_label_new(_("Status"))); + gnt_widget_set_size(label, 0, 1); + + edit->type = combo = gnt_combo_box_new(); + gnt_box_add_widget(GNT_BOX(box), combo); + current = saved ? gaim_savedstatus_get_type(saved) : GAIM_STATUS_UNSET; + for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++) + { + gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(prims[i]), + gaim_primitive_get_name_from_type(prims[i])); + if (prims[i] == current) + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(current)); + } + + /* Message */ + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Message"))); + + edit->message = entry = gnt_entry_new(saved ? gaim_savedstatus_get_message(saved) : NULL); + gnt_box_add_widget(GNT_BOX(box), entry); + + /* The buttons */ + box = gnt_hbox_new(FALSE); + gnt_box_add_widget(GNT_BOX(window), box); + + /* Save */ + button = gnt_button_new(_("Save")); + gnt_box_add_widget(GNT_BOX(box), button); + g_object_set_data(G_OBJECT(button), "use", NULL); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit); + + /* Save & Use */ + button = gnt_button_new(_("Save & Use")); + gnt_box_add_widget(GNT_BOX(box), button); + g_object_set_data(G_OBJECT(button), "use", GINT_TO_POINTER(TRUE)); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit); + + /* Cancel */ + button = gnt_button_new(_("Cancel")); + gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(gnt_widget_destroy), window); + + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(update_edit_list), edit); + + gnt_widget_show(window); } Modified: trunk/console/libgnt/gntcombobox.c =================================================================== --- trunk/console/libgnt/gntcombobox.c 2006-08-15 18:05:14 UTC (rev 16773) +++ trunk/console/libgnt/gntcombobox.c 2006-08-15 20:23:58 UTC (rev 16774) @@ -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 + 4); + widget->priv.width = MAX(10, dd->priv.width + 4); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-15 18:05:25
|
Revision: 16773 Author: sadrul Date: 2006-08-15 11:05:14 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16773&view=rev Log Message: ----------- Some adjustment to the scrollbars. Deal with dialogs with NULL title. Status-selector in the buddylist should always show the active status. Modified Paths: -------------- trunk/console/gntblist.c trunk/console/libgnt/gntmain.c trunk/console/libgnt/gnttextview.c trunk/console/libgnt/gnttree.c trunk/console/libgnt/test/multiwin.c Modified: trunk/console/gntblist.c =================================================================== --- trunk/console/gntblist.c 2006-08-15 16:48:32 UTC (rev 16772) +++ trunk/console/gntblist.c 2006-08-15 18:05:14 UTC (rev 16773) @@ -67,6 +67,7 @@ static gboolean remove_typing_cb(gpointer null); static void remove_peripherals(GGBlist *ggblist); static const char * get_display_name(GaimBlistNode *node); +static void savedstatus_changed(GaimSavedStatus *now, GaimSavedStatus *old); static void new_node(GaimBlistNode *node) @@ -1150,6 +1151,9 @@ } else if (now->type == STATUS_SAVED_ALL) { + /* Restore the selection to reflect current status. */ + savedstatus_changed(gaim_savedstatus_get_current(), NULL); + gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); gg_savedstatus_show_all(); } else Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-15 16:48:32 UTC (rev 16772) +++ trunk/console/libgnt/gntmain.c 2006-08-15 18:05:14 UTC (rev 16773) @@ -16,6 +16,8 @@ /** * Notes: Interesting functions to look at: * scr_dump, scr_init, scr_restore: for workspaces + * + * Need to wattrset for colors to use with PDCurses. */ static int lock_focus_list; @@ -176,6 +178,7 @@ { GntWidget *w = iter->data; int color; + const char *title; if (w == focus_list->data) { @@ -194,7 +197,8 @@ } wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); - mvwprintw(taskbar, 0, width * i, "%s", GNT_BOX(w)->title); + title = GNT_BOX(w)->title; + mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>"); update_window_in_list(w); } Modified: trunk/console/libgnt/gnttextview.c =================================================================== --- trunk/console/libgnt/gnttextview.c 2006-08-15 16:48:32 UTC (rev 16772) +++ trunk/console/libgnt/gnttextview.c 2006-08-15 18:05:14 UTC (rev 16773) @@ -26,7 +26,7 @@ GntTextView *view = GNT_TEXT_VIEW(widget); int i = 0; GList *lines; - int showing, position, rows, scrcol; + int rows, scrcol; werase(widget->window); @@ -51,11 +51,17 @@ rows = widget->priv.height - 2; if (rows > 0) { + int total = g_list_length(g_list_first(view->list)); + int showing, position, up, down; - showing = rows * rows / g_list_length(g_list_first(view->list)) + 1; + showing = rows * rows / total + 1; showing = MIN(rows, showing); - position = showing * g_list_length(view->list) / rows; + total -= rows; + up = g_list_length(lines); + down = total - up; + + position = (rows - showing) * up / MAX(1, up + down); position = MAX((lines != NULL), position); if (showing + position > rows) Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-08-15 16:48:32 UTC (rev 16772) +++ trunk/console/libgnt/gnttree.c 2006-08-15 18:05:14 UTC (rev 16773) @@ -250,7 +250,7 @@ GntWidget *widget = GNT_WIDGET(tree); GntTreeRow *row; int pos, up, down; - int showing, position, rows, scrcol; + int rows, scrcol; if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) return; @@ -371,11 +371,18 @@ rows--; if (rows > 0) { - get_next_n_opt(tree->root, g_list_length(tree->list), &i); - showing = rows * rows / MAX(i, 1) + 1; + int total; + int showing, position; + + get_next_n_opt(tree->root, g_list_length(tree->list), &total); + showing = rows * rows / MAX(total, 1) + 1; showing = MIN(rows, showing); - position = showing * get_distance(tree->root, tree->top) / rows; + total -= rows; + up = get_distance(tree->root, tree->top); + down = total - up; + + position = (rows - showing) * up / MAX(1, up + down); position = MAX((tree->top != tree->root), position); if (showing + position > rows) Modified: trunk/console/libgnt/test/multiwin.c =================================================================== --- trunk/console/libgnt/test/multiwin.c 2006-08-15 16:48:32 UTC (rev 16772) +++ trunk/console/libgnt/test/multiwin.c 2006-08-15 18:05:14 UTC (rev 16773) @@ -63,7 +63,7 @@ gnt_tree_add_row_after(GNT_TREE(tree), "6", gnt_tree_create_row(GNT_TREE(tree), "6", " long text", "a2"), "4", NULL); int i; - for (i = 110; i < 130; i++) + for (i = 110; i < 430; i++) { char *s; s = g_strdup_printf("%d", i); /* XXX: yes, leaking */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-15 16:48:43
|
Revision: 16772 Author: mayuan2006 Date: 2006-08-15 09:48:32 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16772&view=rev Log Message: ----------- change the UUX and FQY command procedure comitted by MaYuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/command.c branches/soc-2006-msnp13/src/protocols/msn/notification.c Modified: branches/soc-2006-msnp13/src/protocols/msn/command.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/command.c 2006-08-15 15:57:07 UTC (rev 16771) +++ branches/soc-2006-msnp13/src/protocols/msn/command.c 2006-08-15 16:48:32 UTC (rev 16772) @@ -53,6 +53,7 @@ (!strcmp(str,"UBN")) || (!strcmp(str,"UUM")) || (!strcmp(str,"UBM")) || + (!strcmp(str,"FQY")) || (!strcmp(str,"UUN")) || (!strcmp(str,"UUX"))){ return TRUE; Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-15 15:57:07 UTC (rev 16771) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-15 16:48:32 UTC (rev 16772) @@ -37,6 +37,8 @@ /**************************************************************************** * Local Function Prototype ****************************************************************************/ +void msn_notification_post_adl(MsnCmdProc *cmdproc,char *payload ,int payload_len); + void msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type); /************************************************************************** @@ -447,7 +449,7 @@ const char *body; char *body_str; char *body_enc; - char *body_final; + char *body_final = NULL; size_t body_len; body = msn_message_get_bin_data(msg, &body_len); @@ -614,14 +616,25 @@ g_free(type_str); #endif xmlnode_insert_child(d_node, c_node); + + g_free(tokens); } +void +msn_notification_post_adl(MsnCmdProc *cmdproc,char *payload, int payload_len) +{ + MsnTransaction *trans; + + gaim_debug_info("MaYuan","Send 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); +} + /*dump contact info to NS*/ void msn_notification_dump_contact(MsnSession *session) { - MsnCmdProc *cmdproc; - MsnTransaction *trans; MsnUserList *userlist; MsnUser *user; GList *l; @@ -629,7 +642,6 @@ char *payload; int payload_len; - cmdproc = session->notification->cmdproc; userlist = session->userlist; adl_node = xmlnode_new("ml"); adl_node->child = NULL; @@ -644,10 +656,31 @@ 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_notification_post_adl(session->notification->cmdproc,payload,payload_len); +} + +/*Post FQY to NS,Inform add a Yahoo User*/ +void +msn_notification_fqy_yahoo(MsnSession *session,char *passport) +{ + MsnTransaction *trans; + MsnCmdProc *cmdproc; + char* email,*domain,*payload; + char **tokens; + + cmdproc = session->notification->cmdproc; + + tokens = g_strsplit(passport, "@", 2); + email = tokens[0]; + domain = tokens[1]; + + payload = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>",domain,email); + trans = msn_transaction_new(cmdproc, "FQY","%d",strlen(payload)); msn_transaction_set_payload(trans, payload, strlen(payload)); msn_cmdproc_send_trans(cmdproc, trans); + + g_free(payload); + g_free(tokens); } static void @@ -663,6 +696,21 @@ } static void +fqy_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) +{ + gaim_debug_info("MaYuan","FQY payload{%s}\n",payload); + msn_notification_post_adl(cmdproc,payload,len); +} + +static void +fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) +{ + gaim_debug_info("MaYuan","Process FQY\n"); + cmdproc->last_cmd->payload_cb = fqy_cmd_post; +} + +static void rml_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnTransaction *trans; @@ -1344,9 +1392,21 @@ } static void +ubx_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) +{ + /*get the payload content*/ + gaim_debug_info("MaYuan","ubx{%s}\n",cmd->payload); +} + +static void ubx_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { gaim_debug_info("MaYuan","UBX... \n"); + if(cmd->payload_len == 0){ + return; + } + cmdproc->last_cmd->payload_cb = ubx_cmd_post; } static void @@ -1653,10 +1713,8 @@ 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); + msn_notification_post_adl(notification->servconn->cmdproc, + payload,payload_len); } void @@ -1727,6 +1785,7 @@ msn_table_add_cmd(cbs_table, NULL, "CHL", chl_cmd); msn_table_add_cmd(cbs_table, NULL, "RML", rml_cmd); msn_table_add_cmd(cbs_table, NULL, "ADL", adl_cmd); + msn_table_add_cmd(cbs_table, NULL, "FQY", fqy_cmd); msn_table_add_cmd(cbs_table, NULL, "QRY", NULL); msn_table_add_cmd(cbs_table, NULL, "QNG", NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-15 15:57:15
|
Revision: 16771 Author: mayuan2006 Date: 2006-08-15 08:57:07 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16771&view=rev Log Message: ----------- add README file comitted by Ma Yuan<may...@gm...> Added Paths: ----------- branches/soc-2006-msnp13/src/protocols/msn/README Added: branches/soc-2006-msnp13/src/protocols/msn/README =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/README (rev 0) +++ branches/soc-2006-msnp13/src/protocols/msn/README 2006-08-15 15:57:07 UTC (rev 16771) @@ -0,0 +1,39 @@ +MSNP14 Implementation +by Ma Yuan<may...@gm...> + +1. Introduction + +MSNP14 Protocol, proposed by Windows Live Messenger, is new, and there is no available implementation except the official one on Windows Platform. + +It has introduced many new features attractable to many users, such as: +* Offline Instant Message +You can send the offline Message to the offline User, + The message will be posted to that user the next time when he is online. + + * Communicate with Yahoo User + U can chat with the Yahoo User in MSN, That's Fantastic! Till now , + you can send text/Nudge to Yahoo User. + + * Windows Live ID authentition + WLM use the Window Live ID Authentication process,Known as Passport 3.0, + The procedure is totally different to the previous Passport 2.0 + + * Video/Audio Conversation + U can communicate with other's via Video/Audio. +(Though very interesting, not implemented in this version) + +2.New Features Added + +till Now, This project has implemented the following Feature: +* Windows Live ID authentication. + +* Offline Instant Message +Now can send and receive the Offline Instant Message. + +* Communicate with Yahoo User +Can send/receive Message/Nudge to Yahoo User. + +3. Changes to made to fit MSNP14 Protocol + +4. Reference +The very useful sites of MSN Protocol: Property changes on: branches/soc-2006-msnp13/src/protocols/msn/README ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |