Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 5420:c54cb8f8655f
[gaim-migrate @ 5799]
This fixes a memleak on the preferences plugins page thing, and I changed
some static buffers to dynamic stuff in oscar.c. Wheeeee.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 18 May 2003 02:47:53 +0000 |
parents | 2c4188300aba |
children | 7955274fa92b |
comparison
equal
deleted
inserted
replaced
5419:ab1cb8b5e42b | 5420:c54cb8f8655f |
---|---|
542 "major connection error\n"); | 542 "major connection error\n"); |
543 hide_login_progress_error(gc, _("Disconnected.")); | 543 hide_login_progress_error(gc, _("Disconnected.")); |
544 signoff(gc); | 544 signoff(gc); |
545 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | 545 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
546 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | 546 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); |
547 char buf[BUF_LONG]; | 547 char *buf; |
548 gaim_debug(GAIM_DEBUG_INFO, "oscar", | 548 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
549 "disconnected from chat room %s\n", c->name); | 549 "disconnected from chat room %s\n", c->name); |
550 c->conn = NULL; | 550 c->conn = NULL; |
551 if (c->inpa > 0) | 551 if (c->inpa > 0) |
552 gaim_input_remove(c->inpa); | 552 gaim_input_remove(c->inpa); |
553 c->inpa = 0; | 553 c->inpa = 0; |
554 c->fd = -1; | 554 c->fd = -1; |
555 aim_conn_kill(od->sess, &conn); | 555 aim_conn_kill(od->sess, &conn); |
556 snprintf(buf, sizeof(buf), _("You have been disconnected from chat room %s."), c->name); | 556 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
557 do_error_dialog(buf, NULL, GAIM_ERROR); | 557 do_error_dialog(buf, NULL, GAIM_ERROR); |
558 g_free(buf); | |
558 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | 559 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
559 if (od->cnpa > 0) | 560 if (od->cnpa > 0) |
560 gaim_input_remove(od->cnpa); | 561 gaim_input_remove(od->cnpa); |
561 od->cnpa = 0; | 562 od->cnpa = 0; |
562 gaim_debug(GAIM_DEBUG_INFO, "oscar", | 563 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
1239 g_free(pos); | 1240 g_free(pos); |
1240 } | 1241 } |
1241 | 1242 |
1242 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { | 1243 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
1243 struct pieceofcrap *pos = data; | 1244 struct pieceofcrap *pos = data; |
1244 char buf[BUF_LONG]; | 1245 gchar *buf; |
1245 | 1246 |
1246 pos->fd = source; | 1247 pos->fd = source; |
1247 | 1248 |
1248 if (source < 0) { | 1249 if (source < 0) { |
1249 char buf[256]; | 1250 buf = g_strdup_printf(_("You may be disconnected shortly. You may want to use TOC until " |
1250 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
1251 "this is fixed. Check %s for updates."), WEBSITE); | 1251 "this is fixed. Check %s for updates."), WEBSITE); |
1252 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), | 1252 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), buf, GAIM_WARNING); |
1253 buf, GAIM_WARNING); | 1253 g_free(buf); |
1254 if (pos->modname) | 1254 if (pos->modname) |
1255 g_free(pos->modname); | 1255 g_free(pos->modname); |
1256 g_free(pos); | 1256 g_free(pos); |
1257 return; | 1257 return; |
1258 } | 1258 } |
1259 | 1259 |
1260 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | 1260 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
1261 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
1262 pos->offset, pos->len, pos->modname ? pos->modname : ""); | 1261 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
1263 write(pos->fd, buf, strlen(buf)); | 1262 write(pos->fd, buf, strlen(buf)); |
1263 g_free(buf); | |
1264 if (pos->modname) | 1264 if (pos->modname) |
1265 g_free(pos->modname); | 1265 g_free(pos->modname); |
1266 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); | 1266 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
1267 return; | 1267 return; |
1268 } | 1268 } |
2690 | 2690 |
2691 return ret; | 2691 return ret; |
2692 } | 2692 } |
2693 | 2693 |
2694 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { | 2694 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
2695 char *buf; | |
2695 va_list ap; | 2696 va_list ap; |
2696 fu16_t chan, nummissed, reason; | 2697 fu16_t chan, nummissed, reason; |
2697 aim_userinfo_t *userinfo; | 2698 aim_userinfo_t *userinfo; |
2698 char buf[1024]; | |
2699 | 2699 |
2700 va_start(ap, fr); | 2700 va_start(ap, fr); |
2701 chan = (fu16_t)va_arg(ap, unsigned int); | 2701 chan = (fu16_t)va_arg(ap, unsigned int); |
2702 userinfo = va_arg(ap, aim_userinfo_t *); | 2702 userinfo = va_arg(ap, aim_userinfo_t *); |
2703 nummissed = (fu16_t)va_arg(ap, unsigned int); | 2703 nummissed = (fu16_t)va_arg(ap, unsigned int); |
2704 reason = (fu16_t)va_arg(ap, unsigned int); | 2704 reason = (fu16_t)va_arg(ap, unsigned int); |
2705 va_end(ap); | 2705 va_end(ap); |
2706 | 2706 |
2707 switch(reason) { | 2707 switch(reason) { |
2708 case 0: | 2708 case 0: /* Invalid (0) */ |
2709 /* Invalid (0) */ | 2709 buf = g_strdup_printf( |
2710 g_snprintf(buf, | 2710 ngettext( |
2711 sizeof(buf), | |
2712 ngettext( | |
2713 "You missed %hu message from %s because it was invalid.", | 2711 "You missed %hu message from %s because it was invalid.", |
2714 "You missed %hu messages from %s because they were invalid.", | 2712 "You missed %hu messages from %s because they were invalid.", |
2715 nummissed), | 2713 nummissed), |
2716 nummissed, | 2714 nummissed, |
2717 userinfo->sn); | 2715 userinfo->sn); |
2718 break; | 2716 break; |
2719 case 1: | 2717 case 1: /* Message too large */ |
2720 /* Message too large */ | 2718 buf = g_strdup_printf( |
2721 g_snprintf(buf, | 2719 ngettext( |
2722 sizeof(buf), | |
2723 ngettext( | |
2724 "You missed %hu message from %s because it was too large.", | 2720 "You missed %hu message from %s because it was too large.", |
2725 "You missed %hu messages from %s because they were too large.", | 2721 "You missed %hu messages from %s because they were too large.", |
2726 nummissed), | 2722 nummissed), |
2727 nummissed, | 2723 nummissed, |
2728 userinfo->sn); | 2724 userinfo->sn); |
2729 break; | 2725 break; |
2730 case 2: | 2726 case 2: /* Rate exceeded */ |
2731 /* Rate exceeded */ | 2727 buf = g_strdup_printf( |
2732 g_snprintf(buf, | 2728 ngettext( |
2733 sizeof(buf), | |
2734 ngettext( | |
2735 "You missed %hu message from %s because the rate limit has been exceeded.", | 2729 "You missed %hu message from %s because the rate limit has been exceeded.", |
2736 "You missed %hu messages from %s because the rate limit has been exceeded.", | 2730 "You missed %hu messages from %s because the rate limit has been exceeded.", |
2737 nummissed), | 2731 nummissed), |
2738 nummissed, | 2732 nummissed, |
2739 userinfo->sn); | 2733 userinfo->sn); |
2740 break; | 2734 break; |
2741 case 3: | 2735 case 3: /* Evil Sender */ |
2742 /* Evil Sender */ | 2736 buf = g_strdup_printf( |
2743 g_snprintf(buf, | 2737 ngettext( |
2744 sizeof(buf), | |
2745 ngettext( | |
2746 "You missed %hu message from %s because he/she was too evil.", | 2738 "You missed %hu message from %s because he/she was too evil.", |
2747 "You missed %hu messages from %s because he/she was too evil.", | 2739 "You missed %hu messages from %s because he/she was too evil.", |
2748 nummissed), | 2740 nummissed), |
2749 nummissed, | 2741 nummissed, |
2750 userinfo->sn); | 2742 userinfo->sn); |
2751 break; | 2743 break; |
2752 case 4: | 2744 case 4: /* Evil Receiver */ |
2753 /* Evil Receiver */ | 2745 buf = g_strdup_printf( |
2754 g_snprintf(buf, | 2746 ngettext( |
2755 sizeof(buf), | |
2756 ngettext( | |
2757 "You missed %hu message from %s because you are too evil.", | 2747 "You missed %hu message from %s because you are too evil.", |
2758 "You missed %hu messages from %s because you are too evil.", | 2748 "You missed %hu messages from %s because you are too evil.", |
2759 nummissed), | 2749 nummissed), |
2760 nummissed, | 2750 nummissed, |
2761 userinfo->sn); | 2751 userinfo->sn); |
2762 break; | 2752 break; |
2763 default: | 2753 default: |
2764 g_snprintf(buf, | 2754 buf = g_strdup_printf( |
2765 sizeof(buf), | 2755 ngettext( |
2766 ngettext( | |
2767 "You missed %hu message from %s for an unknown reason.", | 2756 "You missed %hu message from %s for an unknown reason.", |
2768 "You missed %hu messages from %s for an unknown reason.", | 2757 "You missed %hu messages from %s for an unknown reason.", |
2769 nummissed), | 2758 nummissed), |
2770 nummissed, | 2759 nummissed, |
2771 userinfo->sn); | 2760 userinfo->sn); |
2772 break; | 2761 break; |
2773 } | 2762 } |
2774 do_error_dialog(buf, NULL, GAIM_ERROR); | 2763 do_error_dialog(buf, NULL, GAIM_ERROR); |
2764 g_free(buf); | |
2775 | 2765 |
2776 return 1; | 2766 return 1; |
2777 } | 2767 } |
2778 | 2768 |
2779 static char *gaim_icq_status(int state) { | 2769 static char *gaim_icq_status(int state) { |
2985 | 2975 |
2986 return 1; | 2976 return 1; |
2987 } | 2977 } |
2988 | 2978 |
2989 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { | 2979 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2980 char *buf; | |
2990 va_list ap; | 2981 va_list ap; |
2982 fu16_t reason; | |
2991 char *destn; | 2983 char *destn; |
2992 fu16_t reason; | |
2993 char buf[1024]; | |
2994 | 2984 |
2995 va_start(ap, fr); | 2985 va_start(ap, fr); |
2996 reason = (fu16_t) va_arg(ap, unsigned int); | 2986 reason = (fu16_t) va_arg(ap, unsigned int); |
2997 destn = va_arg(ap, char *); | 2987 destn = va_arg(ap, char *); |
2998 va_end(ap); | 2988 va_end(ap); |
2999 | 2989 |
3000 snprintf(buf, sizeof(buf), _("User information for %s unavailable:"), destn); | 2990 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
3001 do_error_dialog(buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); | 2991 do_error_dialog(buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
2992 g_free(buf); | |
3002 | 2993 |
3003 return 1; | 2994 return 1; |
3004 } | 2995 } |
3005 | 2996 |
3006 static char *images(int flags) { | 2997 static char *images(int flags) { |
3095 } | 3086 } |
3096 | 3087 |
3097 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { | 3088 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
3098 struct gaim_connection *gc = sess->aux_data; | 3089 struct gaim_connection *gc = sess->aux_data; |
3099 struct oscar_data *od = gc->proto_data; | 3090 struct oscar_data *od = gc->proto_data; |
3100 char header[BUF_LONG]; | 3091 gchar *header; |
3101 GSList *l = od->evilhack; | 3092 GSList *l = od->evilhack; |
3102 gboolean evilhack = FALSE; | 3093 gboolean evilhack = FALSE; |
3103 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; | 3094 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; |
3104 va_list ap; | 3095 va_list ap; |
3105 aim_userinfo_t *info; | 3096 aim_userinfo_t *info; |
3138 idle = g_strdup_printf(_("Idle : <b>%s</b>"), itime); | 3129 idle = g_strdup_printf(_("Idle : <b>%s</b>"), itime); |
3139 g_free(itime); | 3130 g_free(itime); |
3140 } else | 3131 } else |
3141 idle = g_strdup(_("Idle: <b>Active</b>")); | 3132 idle = g_strdup(_("Idle: <b>Active</b>")); |
3142 | 3133 |
3143 g_snprintf(header, sizeof header, | 3134 header = g_strdup_printf(_("Username : <b>%s</b> %s <br>\n" |
3144 _("Username : <b>%s</b> %s <br>\n" | |
3145 "Warning Level : <b>%d %%</b><br>\n" | 3135 "Warning Level : <b>%d %%</b><br>\n" |
3146 "%s" | 3136 "%s" |
3147 "%s" | 3137 "%s" |
3148 "%s\n" | 3138 "%s\n" |
3149 "<hr>\n"), | 3139 "<hr>\n"), |
3192 g_show_info_text(gc, info->sn, 1, | 3182 g_show_info_text(gc, info->sn, 1, |
3193 (utf8 && *utf8) ? away_subs(utf8, gc->username) : _("<i>No Information Provided</i>"), | 3183 (utf8 && *utf8) ? away_subs(utf8, gc->username) : _("<i>No Information Provided</i>"), |
3194 NULL); | 3184 NULL); |
3195 } | 3185 } |
3196 | 3186 |
3187 g_free(header); | |
3197 g_free(utf8); | 3188 g_free(utf8); |
3198 | 3189 |
3199 return 1; | 3190 return 1; |
3200 } | 3191 } |
3201 | 3192 |
4008 | 3999 |
4009 return 1; | 4000 return 1; |
4010 } | 4001 } |
4011 | 4002 |
4012 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { | 4003 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
4004 GString *buf; | |
4005 int at = 0, len; | |
4013 va_list ap; | 4006 va_list ap; |
4014 char *address, *SNs; | 4007 char *address, *SNs; |
4015 int i, num; | 4008 int i, num; |
4016 char *buf; | |
4017 int at = 0, len; | |
4018 | 4009 |
4019 va_start(ap, fr); | 4010 va_start(ap, fr); |
4020 address = va_arg(ap, char *); | 4011 address = va_arg(ap, char *); |
4021 num = va_arg(ap, int); | 4012 num = va_arg(ap, int); |
4022 SNs = va_arg(ap, char *); | 4013 SNs = va_arg(ap, char *); |
4023 va_end(ap); | 4014 va_end(ap); |
4024 | 4015 |
4025 len = num * (MAXSNLEN + 1) + 1024; | 4016 buf = g_string_new(""); |
4026 buf = g_malloc(len); | 4017 g_string_printf(buf, _("<B>%s has the following screen names:</B><BR>"), address); |
4027 at += g_snprintf(buf + at, len - at, _("<B>%s has the following screen names:</B><BR>"), address); | |
4028 for (i = 0; i < num; i++) | 4018 for (i = 0; i < num; i++) |
4029 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | 4019 g_string_append_printf(buf, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4030 g_show_info_text(NULL, NULL, 2, buf, NULL); | 4020 g_show_info_text(NULL, NULL, 2, buf->str, NULL); |
4031 g_free(buf); | 4021 g_string_free(buf, TRUE); |
4032 | 4022 |
4033 return 1; | 4023 return 1; |
4034 } | 4024 } |
4035 | 4025 |
4036 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { | 4026 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
4037 va_list ap; | 4027 va_list ap; |
4038 char *address; | 4028 char *address; |
4039 char buf[BUF_LONG]; | 4029 char *buf; |
4040 | 4030 |
4041 va_start(ap, fr); | 4031 va_start(ap, fr); |
4042 address = va_arg(ap, char *); | 4032 address = va_arg(ap, char *); |
4043 va_end(ap); | 4033 va_end(ap); |
4044 | 4034 |
4045 g_snprintf(buf, sizeof(buf), _("No results found for email address %s"), address); | 4035 buf = g_strdup_printf(_("No results found for email address %s"), address); |
4046 do_error_dialog(buf, NULL, GAIM_ERROR); | 4036 do_error_dialog(buf, NULL, GAIM_ERROR); |
4037 g_free(buf); | |
4047 | 4038 |
4048 return 1; | 4039 return 1; |
4049 } | 4040 } |
4050 | 4041 |
4051 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { | 4042 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
5534 g_free(data->who); | 5525 g_free(data->who); |
5535 g_free(data); | 5526 g_free(data); |
5536 } | 5527 } |
5537 | 5528 |
5538 static void oscar_ask_direct_im(struct gaim_connection *gc, const char *who) { | 5529 static void oscar_ask_direct_im(struct gaim_connection *gc, const char *who) { |
5539 char buf[BUF_LONG]; | 5530 gchar *buf; |
5540 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | 5531 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
5541 data->who = g_strdup(who); | 5532 data->who = g_strdup(who); |
5542 data->gc = gc; | 5533 data->gc = gc; |
5543 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); | 5534 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), who); |
5544 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im, my_protocol->handle, FALSE); | 5535 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im, my_protocol->handle, FALSE); |
5536 g_free(buf); | |
5545 } | 5537 } |
5546 | 5538 |
5547 static void oscar_set_permit_deny(struct gaim_connection *gc) { | 5539 static void oscar_set_permit_deny(struct gaim_connection *gc) { |
5548 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | 5540 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
5549 #ifdef NOSSI | 5541 #ifdef NOSSI |