comparison libgaim/protocols/qq/buddy_info.c @ 15140:63d554c2675d

[gaim-migrate @ 17925] This seems like a reasonable way to tell the prpl if we're using a local or global buddy icon. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Sat, 09 Dec 2006 07:20:46 +0000
parents e952a5fc97b3
children b81e4e44b509
comparison
equal deleted inserted replaced
15139:e952a5fc97b3 15140:63d554c2675d
546 icon = gaim_buddy_icons_find(account, who); 546 icon = gaim_buddy_icons_find(account, who);
547 gaim_buddy_icon_set_path(icon, iconfile); 547 gaim_buddy_icon_set_path(icon, iconfile);
548 } 548 }
549 } 549 }
550 550
551 /* TODO: custom faces */ 551 /* TODO: custom faces for QQ members and users with level >= 16 */
552 void qq_set_my_buddy_icon(GaimConnection *gc, const gchar *iconfile) 552 void qq_set_my_buddy_icon(GaimConnection *gc, const gchar *iconfile)
553 { 553 {
554 gchar *icon; 554 gchar *icon;
555 gint icon_num; 555 gint icon_num;
556 GaimAccount *account = gaim_connection_get_account(gc); 556 GaimAccount *account = gaim_connection_get_account(gc);
559 gint prefix_len = strlen(QQ_ICON_PREFIX); 559 gint prefix_len = strlen(QQ_ICON_PREFIX);
560 gint suffix_len = strlen(QQ_ICON_SUFFIX); 560 gint suffix_len = strlen(QQ_ICON_SUFFIX);
561 gint dir_len = strlen(buddy_icon_dir); 561 gint dir_len = strlen(buddy_icon_dir);
562 gint icon_len = strlen(icon_path) - dir_len - 1 - prefix_len - suffix_len; 562 gint icon_len = strlen(icon_path) - dir_len - 1 - prefix_len - suffix_len;
563 gchar *errmsg = g_strconcat(_("You are attempting to set a custom face. Gaim currently only allows the standard faces. Please choose an image from "), buddy_icon_dir, ".", NULL); 563 gchar *errmsg = g_strconcat(_("You are attempting to set a custom face. Gaim currently only allows the standard faces. Please choose an image from "), buddy_icon_dir, ".", NULL);
564 gboolean icon_global = gaim_account_get_bool(gc->account, "use-global-buddyicon", TRUE);
564 565
565 /* make sure we're using an appropriate icon */ 566 /* make sure we're using an appropriate icon */
566 if (!(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0 567 if (!(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0
567 && icon_path[dir_len] == G_DIR_SEPARATOR 568 && icon_path[dir_len] == G_DIR_SEPARATOR
568 && g_ascii_strncasecmp(icon_path + dir_len + 1, QQ_ICON_PREFIX, prefix_len) == 0 569 && g_ascii_strncasecmp(icon_path + dir_len + 1, QQ_ICON_PREFIX, prefix_len) == 0
569 && g_ascii_strncasecmp(icon_path + dir_len + 1 + prefix_len + icon_len, QQ_ICON_SUFFIX, suffix_len) == 0 570 && g_ascii_strncasecmp(icon_path + dir_len + 1 + prefix_len + icon_len, QQ_ICON_SUFFIX, suffix_len) == 0
570 && icon_len <= 3)) { 571 && icon_len <= 3)) {
571 gaim_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL); 572 if (icon_global)
573 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "%s\n", errmsg);
574 else
575 gaim_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL);
572 g_free(errmsg); 576 g_free(errmsg);
573 return; 577 return;
574 } 578 }
575 /* strip everything but number */ 579 /* strip everything but number */
576 icon = g_strndup(icon_path + dir_len + 1 + prefix_len, icon_len); 580 icon = g_strndup(icon_path + dir_len + 1 + prefix_len, icon_len);
577 icon_num = strtol(icon, NULL, 10); 581 icon_num = strtol(icon, NULL, 10);
578 g_free(icon); 582 g_free(icon);
579 /* ensure face number in proper range */ 583 /* ensure face number in proper range */
580 if (icon_num > QQ_FACES) { 584 if (icon_num > QQ_FACES) {
581 gaim_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL); 585 if (icon_global)
586 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "%s\n", errmsg);
587 else
588 gaim_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL);
582 g_free(errmsg); 589 g_free(errmsg);
583 return; 590 return;
584 } 591 }
585 g_free(errmsg); 592 g_free(errmsg);
586 /* tell server my icon changed */ 593 /* tell server my icon changed */