Mercurial > pidgin
changeset 1288:d8eaf65ca9c3
[gaim-migrate @ 1298]
libfaim changes, clean up warn dialog
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 15 Dec 2000 13:04:55 +0000 |
parents | cbb8d7a9be43 |
children | 5aa2831e243e |
files | libfaim/CHANGES libfaim/aim_rxhandlers.c libfaim/faim/aim.h plugins/irc.c src/dialogs.c src/oscar.c |
diffstat | 6 files changed, 115 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/libfaim/CHANGES Fri Dec 15 02:31:36 2000 +0000 +++ b/libfaim/CHANGES Fri Dec 15 13:04:55 2000 +0000 @@ -1,6 +1,13 @@ No release numbers ------------------ + - Fri Dec 15 02:04:12 UTC 2000 + - Parse rate changes *properly* + - Add sample code to faimtest demonstrating my approximations + on how to fiddle with aim_conn_setlatency() in relation + to the rate changes (properly wildly conservative). [I also + copied this stuff into mfaim.] + - Thu Dec 14 03:39:34 UTC 2000 - Change the 0x01 to a 0x00 in auth request to make buddy lists work again - Rearrange bytes in setversions() to match winaim
--- a/libfaim/aim_rxhandlers.c Fri Dec 15 02:31:36 2000 +0000 +++ b/libfaim/aim_rxhandlers.c Fri Dec 15 13:04:55 2000 +0000 @@ -574,6 +574,8 @@ workingPtr->handled = aim_parse_hostonline(sess, workingPtr); else if (subtype == 0x0007) workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x0007, workingPtr); + else if (subtype == 0x000a) + workingPtr->handled = aim_parse_ratechange_middle(sess, workingPtr); else workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, family, subtype, workingPtr); } else if (family == 0x000e) { @@ -657,17 +659,36 @@ { rxcallback_t userfunc = NULL; int ret = 1; - unsigned long newrate; + int i; + int code; + unsigned long parmid, windowsize, clear, alert, limit, disconnect; + unsigned long currentavg, maxavg; + + i = 10; + + code = aimutil_get16(command->data+i); + i += 2; + + parmid = aimutil_get16(command->data+i); + i += 2; - if (command->commandlen != 0x2f) { - printf("faim: unknown rate change length 0x%04x\n", command->commandlen); - return 1; - } - - newrate = aimutil_get32(command->data+34); + windowsize = aimutil_get32(command->data+i); + i += 4; + clear = aimutil_get32(command->data+i); + i += 4; + alert = aimutil_get32(command->data+i); + i += 4; + limit = aimutil_get32(command->data+i); + i += 4; + disconnect = aimutil_get32(command->data+i); + i += 4; + currentavg = aimutil_get32(command->data+i); + i += 4; + maxavg = aimutil_get32(command->data+i); + i += 4; if ((userfunc = aim_callhandler(command->conn, 0x0001, 0x000a))) - ret = userfunc(sess, command, newrate); + ret = userfunc(sess, command, code, parmid, windowsize, clear, alert, limit, disconnect, currentavg, maxavg); return ret; }
--- a/libfaim/faim/aim.h Fri Dec 15 02:31:36 2000 +0000 +++ b/libfaim/faim/aim.h Fri Dec 15 13:04:55 2000 +0000 @@ -577,7 +577,13 @@ int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); faim_internal int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...); faim_internal int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...); + +#define AIM_RATE_CODE_CHANGE 0x0001 +#define AIM_RATE_CODE_WARNING 0x0002 +#define AIM_RATE_CODE_LIMIT 0x0003 +#define AIM_RATE_CODE_CLEARLIMIT 0x0004 faim_internal int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command); + faim_internal int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command); faim_internal int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command);
--- a/plugins/irc.c Fri Dec 15 02:31:36 2000 +0000 +++ b/plugins/irc.c Fri Dec 15 13:04:55 2000 +0000 @@ -40,9 +40,6 @@ #include "prpl.h" #include "gaim.h" -#include "pixmaps/cancel.xpm" -#include "pixmaps/ok.xpm" - #include "pixmaps/free_icon.xpm" #define IRC_BUF_LEN 4096
--- a/src/dialogs.c Fri Dec 15 02:31:36 2000 +0000 +++ b/src/dialogs.c Fri Dec 15 13:04:55 2000 +0000 @@ -321,6 +321,10 @@ destroy_dialog(NULL, w->window); } +static void free_warn_data(GtkObject *obj, struct warning *w) +{ + g_free(w); +} void show_warn_dialog(struct gaim_connection *gc, char *who) { @@ -331,77 +335,65 @@ GtkWidget *bbox; GtkWidget *frame; GtkWidget *fbox; + char buf[128]; struct warning *w = g_new0(struct warning, 1); + w->who = who; + w->gc = gc; - char *buf = g_malloc(128); w->window = gtk_window_new(GTK_WINDOW_DIALOG); + dialogwindows = g_list_prepend(dialogwindows, w->window); gtk_window_set_wmclass(GTK_WINDOW(w->window), "warning", "Gaim"); gtk_window_set_policy(GTK_WINDOW(w->window), FALSE, FALSE, TRUE); - gtk_widget_show(w->window); - dialogwindows = g_list_prepend(dialogwindows, w->window); - bbox = gtk_hbox_new(TRUE, 10); - vbox = gtk_vbox_new(FALSE, 5); + gtk_window_set_title(GTK_WINDOW(w->window), _("Gaim - Warn user?")); + gtk_container_set_border_width(GTK_CONTAINER(w->window), 5); + gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", + GTK_SIGNAL_FUNC(destroy_dialog), w->window); + gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", + GTK_SIGNAL_FUNC(free_warn_data), w); + gtk_widget_realize(w->window); + aol_icon(w->window->window); + fbox = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(w->window), fbox); + gtk_widget_show(fbox); frame = gtk_frame_new(_("Warn")); - - warn = picture_button(w->window, _("Warn"), warn_xpm); - - cancel = picture_button(w->window, _("Cancel"), cancel_xpm); - - if (display_options & OPT_DISP_COOL_LOOK) - { - gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); - gtk_button_set_relief(GTK_BUTTON(warn), GTK_RELIEF_NONE); - } - - /* Put the buttons in the box */ - - gtk_box_pack_start(GTK_BOX(bbox), warn, FALSE, FALSE, 5); - gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); g_snprintf(buf, 127, _("Do you really want to warn %s?"), who); label = gtk_label_new(buf); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); gtk_widget_show(label); + w->anon = gtk_check_button_new_with_label(_("Warn anonymously?")); gtk_box_pack_start(GTK_BOX(vbox), w->anon, TRUE, TRUE, 5); + gtk_widget_show(w->anon); label = gtk_label_new(_("Anonymous warnings are less harsh.")); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); gtk_widget_show(label); - w->who = who; - w->gc = gc; - - gtk_container_add(GTK_CONTAINER(frame), vbox); - - gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 5); + bbox = gtk_hbox_new(TRUE, 10); gtk_box_pack_start(GTK_BOX(fbox), bbox, FALSE, FALSE, 5); - - /* Handle closes right */ - gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", - GTK_SIGNAL_FUNC(destroy_dialog), w->window); - gtk_signal_connect(GTK_OBJECT(cancel), "clicked", - GTK_SIGNAL_FUNC(destroy_dialog), w->window); + gtk_widget_show(bbox); + + warn = picture_button(w->window, _("Warn"), warn_xpm); + gtk_box_pack_start(GTK_BOX(bbox), warn, FALSE, FALSE, 5); gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(do_warn), w); - /* Finish up */ - gtk_widget_show(w->anon); - gtk_widget_show(bbox); - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(fbox); - - gtk_window_set_title(GTK_WINDOW(w->window), _("Gaim - Warn user?")); - gtk_container_add(GTK_CONTAINER(w->window), fbox); - gtk_container_set_border_width(GTK_CONTAINER(w->window), 5); - gtk_widget_realize(w->window); - aol_icon(w->window->window); + + cancel = picture_button(w->window, _("Cancel"), cancel_xpm); + gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(cancel), "clicked", + GTK_SIGNAL_FUNC(destroy_dialog), w->window); gtk_widget_show(w->window); - g_free(buf); }
--- a/src/oscar.c Fri Dec 15 02:31:36 2000 +0000 +++ b/src/oscar.c Fri Dec 15 13:04:55 2000 +0000 @@ -1512,14 +1512,47 @@ } int gaim_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...) { + static char *codes[5] = {"invalid", + "change", + "warning", + "limit", + "limit cleared"}; va_list ap; - unsigned long newrate; + int code; + unsigned long parmid, windowsize, clear, alert, limit, disconnect; + unsigned long currentavg, maxavg; va_start(ap, command); - newrate = va_arg(ap, unsigned long); + code = va_arg(ap, int); + parmid = va_arg(ap, int); + windowsize = va_arg(ap, unsigned long); + clear = va_arg(ap, unsigned long); + alert = va_arg(ap, unsigned long); + limit = va_arg(ap, unsigned long); + disconnect = va_arg(ap, unsigned long); + currentavg = va_arg(ap, unsigned long); + maxavg = va_arg(ap, unsigned long); va_end(ap); - debug_printf("ratechange: %lu\n", newrate); + debug_printf("rate %s (paramid 0x%04lx): curavg = %ld, maxavg = %ld, alert at %ld, " + "clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n", + (code < 5) ? codes[code] : codes[0], + parmid, + currentavg, maxavg, + alert, clear, + limit, disconnect, + windowsize); + + if (code == AIM_RATE_CODE_CHANGE) { + if (currentavg >= clear) + aim_conn_setlatency(command->conn, 0); + } else if (code == AIM_RATE_CODE_WARNING) { + aim_conn_setlatency(command->conn, windowsize/4); + } else if (code == AIM_RATE_CODE_LIMIT) { + aim_conn_setlatency(command->conn, windowsize/2); + } else if (code == AIM_RATE_CODE_CLEARLIMIT) { + aim_conn_setlatency(command->conn, 0); + } return 1; }