comparison src/protocols/oscar/oscar.c @ 8591:f96795b786d2

[gaim-migrate @ 9342] Alright, I had to get my tooltip construction deuglification on. I removed the \n between the core's tooltip and the prpl's tooltip. prpl's should PREpend a \n to each line they add to the tooltip instead of APpending. This way you don't have to worry about removing trailing newline... it makes a lot more sense to me. I also changed oscar and trepia to use g_strings instead of g_strdup_printf and g_strconcat. G strings are sexy. And I apologize to the translators for changing some strings (separated some html and some text). committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 06 Apr 2004 02:28:01 +0000
parents de3d7eb3fc86
children f0275c2b6281
comparison
equal deleted inserted replaced
8590:de3d7eb3fc86 8591:f96795b786d2
3154 g_free(buf); 3154 g_free(buf);
3155 3155
3156 return 1; 3156 return 1;
3157 } 3157 }
3158 3158
3159 #if 0
3160 static char *images(int flags) {
3161 static char buf[1024];
3162 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s",
3163 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "",
3164 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "",
3165 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "",
3166 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "",
3167 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "",
3168 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "",
3169 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : "");
3170 return buf;
3171 }
3172 #endif
3173
3174 static char *caps_string(guint caps) 3159 static char *caps_string(guint caps)
3175 { 3160 {
3176 static char buf[512], *tmp; 3161 static char buf[512], *tmp;
3177 int count = 0, i = 0; 3162 int count = 0, i = 0;
3178 guint bit = 1; 3163 guint bit = 1;
5693 GaimConnection *gc = b->account->gc; 5678 GaimConnection *gc = b->account->gc;
5694 OscarData *od = gc->proto_data; 5679 OscarData *od = gc->proto_data;
5695 GaimGroup *g = gaim_find_buddys_group(b); 5680 GaimGroup *g = gaim_find_buddys_group(b);
5696 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); 5681 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name));
5697 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); 5682 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name);
5698 gchar *tmp = NULL, *ret = g_strdup(""); 5683 GString *ret = g_string_new("");
5699 5684
5700 if (GAIM_BUDDY_IS_ONLINE(b)) { 5685 if (GAIM_BUDDY_IS_ONLINE(b)) {
5701 if (isdigit(b->name[0])) { 5686 if (isdigit(b->name[0])) {
5702 char *status; 5687 char *status;
5703 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); 5688 status = gaim_icq_status((b->uc & 0xffff0000) >> 16);
5704 tmp = ret; 5689 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), status);
5705 ret = g_strconcat(tmp, _("<b>Status:</b> "), status, "\n", NULL);
5706 g_free(tmp);
5707 g_free(status); 5690 g_free(status);
5708 } 5691 }
5709 5692
5710 if ((bi != NULL) && (bi->ipaddr)) { 5693 if ((bi != NULL) && (bi->ipaddr)) {
5711 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", 5694 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
5712 (bi->ipaddr & 0xff000000) >> 24, 5695 (bi->ipaddr & 0xff000000) >> 24,
5713 (bi->ipaddr & 0x00ff0000) >> 16, 5696 (bi->ipaddr & 0x00ff0000) >> 16,
5714 (bi->ipaddr & 0x0000ff00) >> 8, 5697 (bi->ipaddr & 0x0000ff00) >> 8,
5715 (bi->ipaddr & 0x000000ff)); 5698 (bi->ipaddr & 0x000000ff));
5716 tmp = ret; 5699 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("IP Address"), tstr);
5717 ret = g_strconcat(tmp, _("<b>IP Address:</b> "), tstr, "\n", NULL);
5718 g_free(tmp);
5719 g_free(tstr); 5700 g_free(tstr);
5720 } 5701 }
5721 5702
5722 if ((userinfo != NULL) && (userinfo->capabilities)) { 5703 if ((userinfo != NULL) && (userinfo->capabilities)) {
5723 char *caps = caps_string(userinfo->capabilities); 5704 char *caps = caps_string(userinfo->capabilities);
5724 tmp = ret; 5705 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Capabilities"), caps);
5725 ret = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL);
5726 g_free(tmp);
5727 } 5706 }
5728 5707
5729 if (g && g->name) { 5708 if (g && g->name) {
5730 char *comment = NULL; 5709 char *comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name);
5731 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name);
5732 if (comment != NULL) { 5710 if (comment != NULL) {
5733 tmp = ret; 5711 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Buddy Comment"), comment);
5734 ret = g_strconcat(tmp, _("<b>Buddy Comment:</b> "), comment, "\n", NULL);
5735 free(tmp);
5736 free(comment); 5712 free(comment);
5737 } 5713 }
5738 } 5714 }
5739 5715
5740 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { 5716 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) {
5741 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); 5717 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg));
5742 tmp = ret; 5718 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Available"), escaped);
5743 ret = g_strconcat(tmp, _("<b>Available:</b> "), escaped, "\n", NULL);
5744 g_free(tmp);
5745 g_free(escaped); 5719 g_free(escaped);
5746 } 5720 }
5747 5721
5748 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { 5722 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
5749 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); 5723 gchar *charset = oscar_encoding_extract(userinfo->away_encoding);
5758 g_free(tmp1); 5732 g_free(tmp1);
5759 tmp1 = gaim_escape_html(tmp2); 5733 tmp1 = gaim_escape_html(tmp2);
5760 g_free(tmp2); 5734 g_free(tmp2);
5761 tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); 5735 tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc)));
5762 g_free(tmp1); 5736 g_free(tmp1);
5763 tmp = ret; 5737 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp3);
5764 ret = g_strconcat(tmp, _("<b>Away Message:</b> "), tmp3, "\n", NULL);
5765 g_free(tmp);
5766 } 5738 }
5767 } 5739 }
5768 } else { 5740 } else {
5769 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); 5741 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name);
5770 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { 5742 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))
5771 tmp = ret; 5743 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Not Authorized"));
5772 ret = g_strconcat(tmp, _("<b>Status:</b> Not Authorized"), "\n", NULL); 5744 else
5773 g_free(tmp); 5745 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Offline"));
5774 } else { 5746 }
5775 tmp = ret; 5747
5776 ret = g_strconcat(tmp, _("<b>Status:</b> Offline"), "\n", NULL); 5748 return g_string_free(ret, FALSE);;
5777 g_free(tmp);
5778 }
5779 }
5780
5781 /* remove the trailing newline character */
5782 if (ret && (strlen(ret) > 0))
5783 ret[strlen(ret)-1] = '\0';
5784 return ret;
5785 } 5749 }
5786 5750
5787 static char *oscar_status_text(GaimBuddy *b) { 5751 static char *oscar_status_text(GaimBuddy *b) {
5788 GaimConnection *gc = b->account->gc; 5752 GaimConnection *gc = b->account->gc;
5789 OscarData *od = gc->proto_data; 5753 OscarData *od = gc->proto_data;
6859 pam->label = _("Search for Buddy by Email..."); 6823 pam->label = _("Search for Buddy by Email...");
6860 pam->callback = oscar_show_find_email; 6824 pam->callback = oscar_show_find_email;
6861 pam->gc = gc; 6825 pam->gc = gc;
6862 m = g_list_append(m, pam); 6826 m = g_list_append(m, pam);
6863 6827
6864 /* pam = g_new0(struct proto_actions_menu, 1); 6828 #if 0
6829 pam = g_new0(struct proto_actions_menu, 1);
6865 pam->label = _("Search for Buddy by Information"); 6830 pam->label = _("Search for Buddy by Information");
6866 pam->callback = show_find_info; 6831 pam->callback = show_find_info;
6867 pam->gc = gc; 6832 pam->gc = gc;
6868 m = g_list_append(m, pam); */ 6833 m = g_list_append(m, pam);
6834 #endif
6869 6835
6870 return m; 6836 return m;
6871 } 6837 }
6872 6838
6873 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) 6839 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new)