| 145 } |
145 } |
| 146 |
146 |
| 147 /* returns the icon name for a buddy or protocol */ |
147 /* returns the icon name for a buddy or protocol */ |
| 148 static const gchar *_qq_list_icon(GaimAccount *a, GaimBuddy *b) |
148 static const gchar *_qq_list_icon(GaimAccount *a, GaimBuddy *b) |
| 149 { |
149 { |
| 150 /* XXX temp commented out until we figure out what to do with |
|
| 151 * status icons */ |
|
| 152 /* |
|
| 153 gchar *filename; |
150 gchar *filename; |
| 154 qq_buddy *q_bud; |
151 qq_buddy *q_bud; |
| 155 gchar icon_suffix; |
|
| 156 */ |
|
| 157 |
152 |
| 158 /* do not use g_return_val_if_fail, as it is not assertion */ |
153 /* do not use g_return_val_if_fail, as it is not assertion */ |
| 159 if (b == NULL || b->proto_data == NULL) |
154 if (b == NULL || b->proto_data == NULL) |
| 160 return "qq"; |
155 return "qq"; |
| 161 |
156 |
| 162 /* |
|
| 163 q_bud = (qq_buddy *) b->proto_data; |
157 q_bud = (qq_buddy *) b->proto_data; |
| 164 |
158 filename = get_icon_name(q_bud->icon / 3 + 1); |
| 165 icon_suffix = get_suffix_from_status(q_bud->status); |
|
| 166 filename = get_icon_name(q_bud->icon / 3 + 1, icon_suffix); |
|
| 167 |
159 |
| 168 return filename; |
160 return filename; |
| 169 */ |
|
| 170 return "qq"; |
|
| 171 } |
161 } |
| 172 |
162 |
| 173 |
163 |
| 174 /* a short status text beside buddy icon*/ |
164 /* a short status text beside buddy icon*/ |
| 175 static gchar *_qq_status_text(GaimBuddy *b) |
165 static gchar *_qq_status_text(GaimBuddy *b) |
| 280 { |
270 { |
| 281 /* each char ** are refering to filename in pixmaps/gaim/status/default/ *png */ |
271 /* each char ** are refering to filename in pixmaps/gaim/status/default/ *png */ |
| 282 |
272 |
| 283 qq_buddy *q_bud = b->proto_data; |
273 qq_buddy *q_bud = b->proto_data; |
| 284 const char *emblems[4] = { NULL, NULL, NULL, NULL }; |
274 const char *emblems[4] = { NULL, NULL, NULL, NULL }; |
| 285 int i = 0; |
275 int i = 1; |
| 286 |
276 |
| 287 if (q_bud == NULL) { |
277 if (q_bud == NULL) { |
| 288 emblems[0] = "offline"; |
278 emblems[0] = "offline"; |
| 289 } else { |
279 } else { |
| |
280 /* TODO the wireless icon is a bit too big to look good with QQ faces */ |
| |
281 if (q_bud->status == QQ_BUDDY_ONLINE_AWAY || q_bud->status == QQ_SELF_STATUS_AWAY) |
| |
282 emblems[i++] = "away"; |
| 290 if (q_bud->comm_flag & QQ_COMM_FLAG_QQ_MEMBER) |
283 if (q_bud->comm_flag & QQ_COMM_FLAG_QQ_MEMBER) |
| 291 emblems[i++] = "qq_member"; |
284 emblems[i++] = "qq_member"; |
| 292 if (q_bud->comm_flag & QQ_COMM_FLAG_BIND_MOBILE) |
285 if (q_bud->comm_flag & QQ_COMM_FLAG_BIND_MOBILE) |
| 293 emblems[i++] = "wireless"; |
286 emblems[i++] = "wireless"; |
| 294 if (q_bud->comm_flag & QQ_COMM_FLAG_VIDEO) |
287 if (q_bud->comm_flag & QQ_COMM_FLAG_VIDEO) |
| 295 emblems[i++] = "video"; |
288 emblems[i%4] = "video"; |
| 296 |
289 |
| 297 } |
290 } |
| 298 |
291 |
| 299 *se = emblems[0]; |
292 *se = emblems[0]; |
| 300 *sw = emblems[1]; |
293 *sw = emblems[1]; |
| 433 |
426 |
| 434 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
427 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
| 435 |
428 |
| 436 qd = (qq_data *) gc->proto_data; |
429 qd = (qq_data *) gc->proto_data; |
| 437 qq_prepare_modify_info(gc); |
430 qq_prepare_modify_info(gc); |
| |
431 } |
| |
432 |
| |
433 static void _qq_change_face_cb(GaimConnection *gc, GaimRequestFields *fields) |
| |
434 { |
| |
435 qq_data *qd; |
| |
436 GaimRequestField *field; |
| |
437 gint suffix; |
| |
438 |
| |
439 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
| |
440 qd = (qq_data *) gc->proto_data; |
| |
441 |
| |
442 field = gaim_request_fields_get_field(fields, "face_num"); |
| |
443 suffix = get_icon_offset_from_self_status(qd->status); |
| |
444 qd->my_icon = gaim_request_field_choice_get_value(field) * 3 + suffix; |
| |
445 qd->modifying_face = TRUE; |
| |
446 qq_send_packet_get_info(gc, qd->uid, FALSE); |
| |
447 } |
| |
448 |
| |
449 static void _qq_add_face_choice(GaimRequestFieldGroup *group, gint face_num) |
| |
450 { |
| |
451 GaimRequestField *field; |
| |
452 struct stat img_stat; |
| |
453 FILE *file; |
| |
454 gchar *filename, *prefix, *img_data, *face; |
| |
455 gint size; |
| |
456 |
| |
457 face = g_strdup_printf("qq_%i.png", face_num); |
| |
458 prefix = br_extract_prefix(DATADIR); |
| |
459 filename = g_build_filename(prefix, "share","pixmaps", |
| |
460 "gaim","status","default", face, NULL); |
| |
461 g_free(face); |
| |
462 face = g_strdup_printf("%i", face_num); |
| |
463 stat(filename, &img_stat); |
| |
464 file = g_fopen(filename, "rb"); |
| |
465 if (file) { |
| |
466 img_data = g_malloc(img_stat.st_size); |
| |
467 size = fread(img_data, 1, img_stat.st_size, file); |
| |
468 |
| |
469 field = gaim_request_field_image_new(face, face, img_data, size); |
| |
470 gaim_request_field_group_add_field(group, field); |
| |
471 |
| |
472 g_free(img_data); |
| |
473 fclose(file); |
| |
474 } |
| |
475 g_free(face); |
| |
476 g_free(prefix); |
| |
477 } |
| |
478 |
| |
479 static void _qq_menu_change_face(GaimPluginAction *action) |
| |
480 { |
| |
481 GaimConnection *gc = (GaimConnection *) action->context; |
| |
482 qq_data *qd = (qq_data *) gc->proto_data; |
| |
483 GaimRequestFields *fields; |
| |
484 GaimRequestFieldGroup *group; |
| |
485 GaimRequestField *field; |
| |
486 gchar *label; |
| |
487 gint i; |
| |
488 |
| |
489 fields = gaim_request_fields_new(); |
| |
490 group = gaim_request_field_group_new(_("Selection")); |
| |
491 gaim_request_fields_add_group(fields, group); |
| |
492 field = gaim_request_field_choice_new("face_num", |
| |
493 _("Select a number"), qd->my_icon / 3); |
| |
494 for(i = 1; i <= QQ_FACES; i++) { |
| |
495 label = g_strdup_printf("%i", i); |
| |
496 gaim_request_field_choice_add(field, label); |
| |
497 g_free(label); |
| |
498 } |
| |
499 gaim_request_field_group_add_field(group, field); |
| |
500 group = gaim_request_field_group_new(_("Faces")); |
| |
501 gaim_request_fields_add_group(fields, group); |
| |
502 for(i = 1; i <= QQ_FACES; i++) |
| |
503 _qq_add_face_choice(group, i); |
| |
504 |
| |
505 gaim_request_fields(gc, _("Change Your QQ Face"), |
| |
506 _("Change Face"), NULL, fields, |
| |
507 _("Update"), G_CALLBACK(_qq_change_face_cb), |
| |
508 _("Cancel"), NULL, |
| |
509 gc); |
| 438 } |
510 } |
| 439 |
511 |
| 440 static void _qq_menu_change_password(GaimPluginAction *action) |
512 static void _qq_menu_change_password(GaimPluginAction *action) |
| 441 { |
513 { |
| 442 gaim_notify_uri(NULL, "https://password.qq.com"); |
514 gaim_notify_uri(NULL, "https://password.qq.com"); |
| 791 GList *m; |
863 GList *m; |
| 792 GaimPluginAction *act; |
864 GaimPluginAction *act; |
| 793 |
865 |
| 794 m = NULL; |
866 m = NULL; |
| 795 act = gaim_plugin_action_new(_("Modify My Information"), _qq_menu_modify_my_info); |
867 act = gaim_plugin_action_new(_("Modify My Information"), _qq_menu_modify_my_info); |
| |
868 m = g_list_append(m, act); |
| |
869 |
| |
870 act = gaim_plugin_action_new(_("Change My Face"), _qq_menu_change_face); |
| 796 m = g_list_append(m, act); |
871 m = g_list_append(m, act); |
| 797 |
872 |
| 798 act = gaim_plugin_action_new(_("Change Password"), _qq_menu_change_password); |
873 act = gaim_plugin_action_new(_("Change Password"), _qq_menu_change_password); |
| 799 m = g_list_append(m, act); |
874 m = g_list_append(m, act); |
| 800 |
875 |