comparison libgaim/protocols/qq/qq.c @ 14629:6b8bc59414f0

[gaim-migrate @ 17375] Get rid of these useless checks. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Tue, 26 Sep 2006 22:54:24 +0000
parents 8ed6ef220b2d
children a33d179d5508
comparison
equal deleted inserted replaced
14628:58202142e9ad 14629:6b8bc59414f0
312 { 312 {
313 gint type, to_uid; 313 gint type, to_uid;
314 gchar *msg, *msg_with_qq_smiley; 314 gchar *msg, *msg_with_qq_smiley;
315 qq_data *qd; 315 qq_data *qd;
316 316
317 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, -1); 317 g_return_val_if_fail(who != NULL, -1);
318 318
319 qd = (qq_data *) gc->proto_data; 319 qd = (qq_data *) gc->proto_data;
320 320
321 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG); 321 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
322 322
341 static int _qq_chat_send(GaimConnection *gc, int channel, const char *message, GaimMessageFlags flags) 341 static int _qq_chat_send(GaimConnection *gc, int channel, const char *message, GaimMessageFlags flags)
342 { 342 {
343 gchar *msg, *msg_with_qq_smiley; 343 gchar *msg, *msg_with_qq_smiley;
344 qq_group *group; 344 qq_group *group;
345 345
346 g_return_val_if_fail(gc != NULL && message != NULL, -1); 346 g_return_val_if_fail(message != NULL, -1);
347 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG); 347 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
348 348
349 group = qq_group_find_by_channel(gc, channel); 349 group = qq_group_find_by_channel(gc, channel);
350 g_return_val_if_fail(group != NULL, -1); 350 g_return_val_if_fail(group != NULL, -1);
351 351
362 static void _qq_get_info(GaimConnection *gc, const gchar *who) 362 static void _qq_get_info(GaimConnection *gc, const gchar *who)
363 { 363 {
364 guint32 uid; 364 guint32 uid;
365 qq_data *qd; 365 qq_data *qd;
366 366
367 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
368 qd = gc->proto_data; 367 qd = gc->proto_data;
369 uid = gaim_name_to_uid(who); 368 uid = gaim_name_to_uid(who);
370 369
371 if (uid <= 0) { 370 if (uid <= 0) {
372 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Not valid QQid: %s\n", who); 371 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Not valid QQid: %s\n", who);
381 static void _qq_menu_modify_my_info(GaimPluginAction *action) 380 static void _qq_menu_modify_my_info(GaimPluginAction *action)
382 { 381 {
383 GaimConnection *gc = (GaimConnection *) action->context; 382 GaimConnection *gc = (GaimConnection *) action->context;
384 qq_data *qd; 383 qq_data *qd;
385 384
386 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
387
388 qd = (qq_data *) gc->proto_data; 385 qd = (qq_data *) gc->proto_data;
389 qq_prepare_modify_info(gc); 386 qq_prepare_modify_info(gc);
390 } 387 }
391 388
392 static void _qq_change_face_cb(GaimConnection *gc, GaimRequestFields *fields) 389 static void _qq_change_face_cb(GaimConnection *gc, GaimRequestFields *fields)
393 { 390 {
394 qq_data *qd; 391 qq_data *qd;
395 GaimRequestField *field; 392 GaimRequestField *field;
396 gint suffix; 393 gint suffix;
397 394
398 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
399 qd = (qq_data *) gc->proto_data; 395 qd = (qq_data *) gc->proto_data;
400 396
401 field = gaim_request_fields_get_field(fields, "face_num"); 397 field = gaim_request_fields_get_field(fields, "face_num");
402 suffix = get_icon_offset(gc); 398 suffix = get_icon_offset(gc);
403 qd->my_icon = gaim_request_field_choice_get_value(field) * 3 + suffix; 399 qd->my_icon = gaim_request_field_choice_get_value(field) * 3 + suffix;
483 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 479 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
484 480
485 buddy = (GaimBuddy *) node; 481 buddy = (GaimBuddy *) node;
486 gc = gaim_account_get_connection(buddy->account); 482 gc = gaim_account_get_connection(buddy->account);
487 who = buddy->name; 483 who = buddy->name;
488 g_return_if_fail(gc != NULL && who != NULL); 484 g_return_if_fail(who != NULL);
489 485
490 uid = gaim_name_to_uid(who); 486 uid = gaim_name_to_uid(who);
491 g_return_if_fail(uid > 0); 487 g_return_if_fail(uid > 0);
492 488
493 g = g_new0(gc_and_uid, 1); 489 g = g_new0(gc_and_uid, 1);
508 { 504 {
509 GaimConnection *gc = (GaimConnection *) action->context; 505 GaimConnection *gc = (GaimConnection *) action->context;
510 qq_data *qd; 506 qq_data *qd;
511 GString *info; 507 GString *info;
512 508
513 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
514
515 qd = (qq_data *) gc->proto_data; 509 qd = (qq_data *) gc->proto_data;
516 info = g_string_new("<html><body>\n"); 510 info = g_string_new("<html><body>\n");
517 511
518 g_string_append_printf(info, _("<b>Current Online</b>: %d<br>\n"), qd->all_online); 512 g_string_append_printf(info, _("<b>Current Online</b>: %d<br>\n"), qd->all_online);
519 g_string_append_printf(info, _("<b>Last Refresh</b>: %s<br>\n"), ctime(&qd->last_get_online)); 513 g_string_append_printf(info, _("<b>Last Refresh</b>: %s<br>\n"), ctime(&qd->last_get_online));
547 541
548 /* 542 /*
549 static void _qq_menu_create_permanent_group(GaimPluginAction * action) 543 static void _qq_menu_create_permanent_group(GaimPluginAction * action)
550 { 544 {
551 GaimConnection *gc = (GaimConnection *) action->context; 545 GaimConnection *gc = (GaimConnection *) action->context;
552 g_return_if_fail(gc != NULL);
553 gaim_request_input(gc, _("Create QQ Qun"), 546 gaim_request_input(gc, _("Create QQ Qun"),
554 _("Input Qun name here"), 547 _("Input Qun name here"),
555 _("Only QQ member can create permanent Qun"), 548 _("Only QQ member can create permanent Qun"),
556 "OpenQ", FALSE, FALSE, NULL, 549 "OpenQ", FALSE, FALSE, NULL,
557 _("Create"), G_CALLBACK(qq_group_create_with_name), _("Cancel"), NULL, gc); 550 _("Create"), G_CALLBACK(qq_group_create_with_name), _("Cancel"), NULL, gc);
564 GaimConnection *gc = gaim_account_get_connection(chat->account); 557 GaimConnection *gc = gaim_account_get_connection(chat->account);
565 GHashTable *components = chat -> components; 558 GHashTable *components = chat -> components;
566 559
567 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 560 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
568 561
569 g_return_if_fail(gc != NULL && components != NULL); 562 g_return_if_fail(components != NULL);
570 qq_group_exit(gc, components); 563 qq_group_exit(gc, components);
571 } 564 }
572 565
573 /* 566 /*
574 static void _qq_menu_manage_group(GaimBlistNode * node) 567 static void _qq_menu_manage_group(GaimBlistNode * node)
577 GaimConnection *gc = gaim_account_get_connection(chat->account); 570 GaimConnection *gc = gaim_account_get_connection(chat->account);
578 GHashTable *components = chat -> components; 571 GHashTable *components = chat -> components;
579 572
580 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 573 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
581 574
582 g_return_if_fail(gc != NULL && components != NULL); 575 g_return_if_fail(components != NULL);
583 qq_group_manage_group(gc, components); 576 qq_group_manage_group(gc, components);
584 } 577 }
585 */ 578 */
586 579
587 /* TODO: re-enable this 580 /* TODO: re-enable this
763 gchar tmp[15]; 756 gchar tmp[15];
764 qq_data *qd; 757 qq_data *qd;
765 758
766 gc = (GaimConnection *) action->context; 759 gc = (GaimConnection *) action->context;
767 qd = (qq_data *) gc->proto_data; 760 qd = (qq_data *) gc->proto_data;
768 g_return_if_fail(gc != NULL && qd != NULL);
769 761
770 fields = gaim_request_fields_new(); 762 fields = gaim_request_fields_new();
771 group = gaim_request_field_group_new(_("Basic Elements")); 763 group = gaim_request_field_group_new(_("Basic Elements"));
772 gaim_request_fields_add_group(fields, group); 764 gaim_request_fields_add_group(fields, group);
773 g_snprintf(tmp, sizeof(tmp), "%04X", QQ_CLIENT); 765 g_snprintf(tmp, sizeof(tmp), "%04X", QQ_CLIENT);
884 { 876 {
885 qq_group *group; 877 qq_group *group;
886 qq_data *qd; 878 qq_data *qd;
887 GList *list; 879 GList *list;
888 880
889 g_return_if_fail(gc != NULL);
890 if (NULL == (qd = (qq_data *) gc->proto_data)) 881 if (NULL == (qd = (qq_data *) gc->proto_data))
891 return; 882 return;
892 883
893 list = qd->groups; 884 list = qd->groups;
894 while (list != NULL) { 885 while (list != NULL) {
908 /* convert chat nickname to qq-uid to get this buddy info */ 899 /* convert chat nickname to qq-uid to get this buddy info */
909 /* who is the nickname of buddy in QQ chat-room (Qun) */ 900 /* who is the nickname of buddy in QQ chat-room (Qun) */
910 static void _qq_get_chat_buddy_info(GaimConnection *gc, gint channel, const gchar *who) 901 static void _qq_get_chat_buddy_info(GaimConnection *gc, gint channel, const gchar *who)
911 { 902 {
912 gchar *gaim_name; 903 gchar *gaim_name;
913 g_return_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL); 904 g_return_if_fail(who != NULL);
914 905
915 gaim_name = chat_name_to_gaim_name(who); 906 gaim_name = chat_name_to_gaim_name(who);
916 if (gaim_name != NULL) 907 if (gaim_name != NULL)
917 _qq_get_info(gc, gaim_name); 908 _qq_get_info(gc, gaim_name);
918 } 909 }
919 910
920 /* convert chat nickname to qq-uid to invite individual IM to buddy */ 911 /* convert chat nickname to qq-uid to invite individual IM to buddy */
921 /* who is the nickname of buddy in QQ chat-room (Qun) */ 912 /* who is the nickname of buddy in QQ chat-room (Qun) */
922 static gchar *_qq_get_chat_buddy_real_name(GaimConnection *gc, gint channel, const gchar *who) 913 static gchar *_qq_get_chat_buddy_real_name(GaimConnection *gc, gint channel, const gchar *who)
923 { 914 {
924 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, NULL); 915 g_return_val_if_fail(who != NULL, NULL);
925 return chat_name_to_gaim_name(who); 916 return chat_name_to_gaim_name(who);
926 } 917 }
927 918
928 void qq_function_not_implemented(GaimConnection *gc) 919 void qq_function_not_implemented(GaimConnection *gc)
929 { 920 {