libpurple/protocols/qq/buddy_info.c

changeset 24301
af1ac5f7ced8
parent 24299
b3ebedfac7cb
child 24302
0130b3e3ba4c
child 24311
73d95441cd4c
equal deleted inserted replaced
24299:b3ebedfac7cb 24301:af1ac5f7ced8
282 282
283 g_return_if_fail(uid != 0); 283 g_return_if_fail(uid != 0);
284 284
285 qd = (qq_data *) gc->proto_data; 285 qd = (qq_data *) gc->proto_data;
286 g_snprintf(uid_str, sizeof(uid_str), "%d", uid); 286 g_snprintf(uid_str, sizeof(uid_str), "%d", uid);
287 qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, (guint8 *) uid_str, strlen(uid_str)); 287 qq_send_cmd(gc, QQ_CMD_GET_BUDDY_INFO, (guint8 *) uid_str, strlen(uid_str));
288 288
289 query = g_new0(qq_info_query, 1); 289 query = g_new0(qq_info_query, 1);
290 query->uid = uid; 290 query->uid = uid;
291 query->show_window = show_window; 291 query->show_window = show_window;
292 query->modify_info = FALSE; 292 query->modify_info = FALSE;
301 301
302 g_return_if_fail(uid != 0); 302 g_return_if_fail(uid != 0);
303 303
304 qd = (qq_data *) gc->proto_data; 304 qd = (qq_data *) gc->proto_data;
305 g_snprintf(raw_data, sizeof(raw_data), "%d", uid); 305 g_snprintf(raw_data, sizeof(raw_data), "%d", uid);
306 qq_send_cmd_mess(gc, QQ_CMD_GET_USER_INFO, (guint8 *) raw_data, strlen(raw_data), 306 qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDY_INFO, (guint8 *) raw_data, strlen(raw_data),
307 update_class, ship32); 307 update_class, ship32);
308 } 308 }
309 309
310 /* set up the fields requesting personal information and send a get_info packet 310 /* set up the fields requesting personal information and send a get_info packet
311 * for myself */ 311 * for myself */
688 mid->info->is_open_hp = g_strdup(info->is_open_hp); 688 mid->info->is_open_hp = g_strdup(info->is_open_hp);
689 mid->info->is_open_contact = g_strdup(info->is_open_contact); 689 mid->info->is_open_contact = g_strdup(info->is_open_contact);
690 mid->info->qq_show = g_strdup(info->qq_show); 690 mid->info->qq_show = g_strdup(info->qq_show);
691 mid->info->unknown6 = g_strdup(info->unknown6); 691 mid->info->unknown6 = g_strdup(info->unknown6);
692 692
693 purple_request_fields(gc, _("Modify my information"), 693 purple_request_fields(gc, _("Modify information"),
694 _("Modify my information"), NULL, fields, 694 _("Modify information"), NULL, fields,
695 _("Update my information"), G_CALLBACK(modify_info_ok_cb), 695 _("Update information"), G_CALLBACK(modify_info_ok_cb),
696 _("Cancel"), G_CALLBACK(modify_info_cancel_cb), 696 _("Cancel"), G_CALLBACK(modify_info_cancel_cb),
697 purple_connection_get_account(gc), NULL, NULL, 697 purple_connection_get_account(gc), NULL, NULL,
698 mid); 698 mid);
699 } 699 }
700 } 700 }
757 PurpleAccount *account = purple_connection_get_account(gc); 757 PurpleAccount *account = purple_connection_get_account(gc);
758 const gchar *icon_path = purple_account_get_buddy_icon_path(account); 758 const gchar *icon_path = purple_account_get_buddy_icon_path(account);
759 const gchar *buddy_icon_dir = qq_buddy_icon_dir(); 759 const gchar *buddy_icon_dir = qq_buddy_icon_dir();
760 gint prefix_len = strlen(QQ_ICON_PREFIX); 760 gint prefix_len = strlen(QQ_ICON_PREFIX);
761 gint suffix_len = strlen(QQ_ICON_SUFFIX); 761 gint suffix_len = strlen(QQ_ICON_SUFFIX);
762 gint dir_len = strlen(buddy_icon_dir); 762 gint dir_len = buddy_icon_dir ? strlen(buddy_icon_dir) : 0;
763 gchar *errmsg = g_strdup_printf(_("Setting custom faces is not currently supported. Please choose an image from %s."), buddy_icon_dir); 763 gchar *errmsg = g_strdup_printf(_("Setting custom faces is not currently supported. Please choose an image from %s."), buddy_icon_dir ? buddy_icon_dir : "(null)");
764 gboolean icon_global = purple_account_get_bool(gc->account, "use-global-buddyicon", TRUE); 764 gboolean icon_global = purple_account_get_bool(gc->account, "use-global-buddyicon", TRUE);
765 765
766 if (!icon_path) 766 if (!icon_path)
767 icon_path = ""; 767 icon_path = "";
768 768
769 icon_len = strlen(icon_path) - dir_len - 1 - prefix_len - suffix_len; 769 icon_len = strlen(icon_path) - dir_len - 1 - prefix_len - suffix_len;
770 770
771 /* make sure we're using an appropriate icon */ 771 /* make sure we're using an appropriate icon */
772 if (!(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0 772 if (buddy_icon_dir && !(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0
773 && icon_path[dir_len] == G_DIR_SEPARATOR 773 && icon_path[dir_len] == G_DIR_SEPARATOR
774 && g_ascii_strncasecmp(icon_path + dir_len + 1, QQ_ICON_PREFIX, prefix_len) == 0 774 && g_ascii_strncasecmp(icon_path + dir_len + 1, QQ_ICON_PREFIX, prefix_len) == 0
775 && g_ascii_strncasecmp(icon_path + dir_len + 1 + prefix_len + icon_len, QQ_ICON_SUFFIX, suffix_len) == 0 775 && g_ascii_strncasecmp(icon_path + dir_len + 1 + prefix_len + icon_len, QQ_ICON_SUFFIX, suffix_len) == 0
776 && icon_len <= 3)) { 776 && icon_len <= 3)) {
777 if (icon_global) 777 if (icon_global)
809 const gchar *old_icon_num = NULL; 809 const gchar *old_icon_num = NULL;
810 810
811 if ((buddy = purple_find_buddy(account, name))) 811 if ((buddy = purple_find_buddy(account, name)))
812 old_icon_num = purple_buddy_icons_get_checksum_for_user(buddy); 812 old_icon_num = purple_buddy_icons_get_checksum_for_user(buddy);
813 813
814 if (old_icon_num == NULL || 814 if ((old_icon_num == NULL ||
815 strcmp(icon_num_str, old_icon_num)) 815 strcmp(icon_num_str, old_icon_num)) && (qq_buddy_icon_dir() != NULL))
816 { 816 {
817 gchar *icon_path; 817 gchar *icon_path;
818 818
819 icon_path = g_strconcat(qq_buddy_icon_dir(), G_DIR_SEPARATOR_S, 819 icon_path = g_strconcat(qq_buddy_icon_dir(), G_DIR_SEPARATOR_S,
820 QQ_ICON_PREFIX, icon_num_str, 820 QQ_ICON_PREFIX, icon_num_str,
860 g_free(purple_name); 860 g_free(purple_name);
861 g_free(alias_utf8); 861 g_free(alias_utf8);
862 } 862 }
863 863
864 /* process reply to get_info packet */ 864 /* process reply to get_info packet */
865 void qq_process_get_info_reply(guint8 *data, gint data_len, PurpleConnection *gc) 865 void qq_process_get_buddy_info(guint8 *data, gint data_len, PurpleConnection *gc)
866 { 866 {
867 gchar **segments; 867 gchar **segments;
868 qq_info_query *query; 868 qq_info_query *query;
869 qq_data *qd; 869 qq_data *qd;
870 contact_info *info; 870 contact_info *info;
930 if (count > 0) { 930 if (count > 0) {
931 purple_debug_info("QQ", "%d info queries are freed!\n", count); 931 purple_debug_info("QQ", "%d info queries are freed!\n", count);
932 } 932 }
933 } 933 }
934 934
935 void qq_send_packet_get_level(PurpleConnection *gc, guint32 uid) 935 void qq_request_get_level(PurpleConnection *gc, guint32 uid)
936 { 936 {
937 qq_data *qd = (qq_data *) gc->proto_data; 937 qq_data *qd = (qq_data *) gc->proto_data;
938 guint8 buf[16] = {0}; 938 guint8 buf[16] = {0};
939 gint bytes = 0; 939 gint bytes = 0;
940 940
943 943
944 qd = (qq_data *) gc->proto_data; 944 qd = (qq_data *) gc->proto_data;
945 qq_send_cmd(gc, QQ_CMD_GET_LEVEL, buf, bytes); 945 qq_send_cmd(gc, QQ_CMD_GET_LEVEL, buf, bytes);
946 } 946 }
947 947
948 void qq_request_get_buddies_levels(PurpleConnection *gc, gint update_class) 948 void qq_request_get_buddies_level(PurpleConnection *gc, gint update_class)
949 { 949 {
950 guint8 *buf; 950 guint8 *buf;
951 guint16 size; 951 guint16 size;
952 qq_buddy *q_bud; 952 qq_buddy *q_bud;
953 qq_data *qd = (qq_data *) gc->proto_data; 953 qq_data *qd = (qq_data *) gc->proto_data;

mercurial