# HG changeset patch # User Sean Egan # Date 1016238773 0 # Node ID 4f2f12bf440830c4ced2089255843f61b7ac1443 # Parent 966c4e460ebb103a68796c7da255acc1e5577e63 [gaim-migrate @ 3074] Code cleanups by Robert McQueen. Michael Golden replaced the multiple per-account signon windows with a single signon window showing the status of all your accounts committer: Tailor Script diff -r 966c4e460ebb -r 4f2f12bf4408 ChangeLog --- a/ChangeLog Fri Mar 15 20:09:14 2002 +0000 +++ b/ChangeLog Sat Mar 16 00:32:53 2002 +0000 @@ -3,6 +3,9 @@ version 0.55: * Better Jabber list management when using multiple resources (Thanks Jim Seymour) + * Various sound cleanups (Thanks Robert McQueen) + * Login process shown in single window (Thanks Michael + Golden) version 0.54 (03/14/2002): * Compiles without GdkPixbuf again diff -r 966c4e460ebb -r 4f2f12bf4408 plugins/mailchk.c --- a/plugins/mailchk.c Fri Mar 15 20:09:14 2002 +0000 +++ b/plugins/mailchk.c Sat Mar 16 00:32:53 2002 +0000 @@ -69,7 +69,7 @@ } if (count & NEW_MAIL) - play_sound(POUNCE_DEFAULT); + play_sound(SND_POUNCE_DEFAULT); if (count & UNREAD_MAIL) gtk_label_set_text(GTK_LABEL(mail), "You have new mail!"); diff -r 966c4e460ebb -r 4f2f12bf4408 src/buddy.c --- a/src/buddy.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/buddy.c Sat Mar 16 00:32:53 2002 +0000 @@ -1559,7 +1559,7 @@ if (strlen(b->sound)) play_file(b->sound); else - play_sound(POUNCE_DEFAULT); + play_sound(SND_POUNCE_DEFAULT); } if (!(b->options & OPT_POUNCE_SAVE)) @@ -2155,7 +2155,7 @@ } if (b->present == 1) { if (bs->sound != 2) - play_sound(BUDDY_ARRIVE); + play_sound(SND_BUDDY_ARRIVE); pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, (char **)login_icon_xpm); gtk_widget_hide(bs->pix); @@ -2218,7 +2218,7 @@ buddies that have already signed off */ if (bs->sound != 1) - play_sound(BUDDY_LEAVE); + play_sound(SND_BUDDY_LEAVE); bs->connlist = g_slist_remove(bs->connlist, gc); update_num_group(gs); diff -r 966c4e460ebb -r 4f2f12bf4408 src/buddy_chat.c --- a/src/buddy_chat.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/buddy_chat.c Sat Mar 16 00:32:53 2002 +0000 @@ -706,16 +706,16 @@ if (!(flag & WFLAG_WHISPER)) { str = g_strdup(normalize (who)); if (!g_strcasecmp(str, normalize(b->gc->username))) { - if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY)) - play_sound(CHAT_YOU_SAY); + if (b->makesound) + play_sound(SND_CHAT_YOU_SAY); flag |= WFLAG_SEND; } else if (!g_strcasecmp(str, normalize(b->gc->displayname))) { - if (b->makesound && (sound_options & OPT_SOUND_CHAT_YOU_SAY)) - play_sound(CHAT_YOU_SAY); + if (b->makesound) + play_sound(SND_CHAT_YOU_SAY); flag |= WFLAG_SEND; } else { - if (b->makesound && (sound_options & OPT_SOUND_CHAT_SAY)) - play_sound(CHAT_SAY); + if (b->makesound) + play_sound(SND_CHAT_SAY); flag |= WFLAG_RECV; } g_free(str); @@ -923,8 +923,8 @@ g_list_length(b->in_room) == 1 ? "person" : "people"); gtk_label_set_text(GTK_LABEL(b->count), tmp); - if (b->makesound && (sound_options & OPT_SOUND_CHAT_JOIN)) - play_sound(CHAT_JOIN); + if (b->makesound) + play_sound(SND_CHAT_JOIN); if (chat_options & OPT_CHAT_LOGON) { g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), name); @@ -1035,8 +1035,8 @@ g_list_length(b->in_room) == 1 ? "person" : "people"); gtk_label_set_text(GTK_LABEL(b->count), tmp); - if (b->makesound && (sound_options & OPT_SOUND_CHAT_PART)) - play_sound(CHAT_LEAVE); + if (b->makesound) + play_sound(SND_CHAT_LEAVE); if (chat_options & OPT_CHAT_LOGON) { if (reason && *reason) diff -r 966c4e460ebb -r 4f2f12bf4408 src/conversation.c --- a/src/conversation.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/conversation.c Sat Mar 16 00:32:53 2002 +0000 @@ -1183,8 +1183,8 @@ write_to_conv(c, bigbuf, WFLAG_SEND, NULL, time(NULL), length); else write_to_conv(c, buffy, WFLAG_SEND, NULL, time(NULL), -1); - if (c->makesound && (sound_options & OPT_SOUND_SEND)) - play_sound(SEND); + if (c->makesound) + play_sound(SND_SEND); if (im_options & OPT_IM_POPDOWN) gtk_widget_hide(c->window); @@ -1196,8 +1196,8 @@ err =serv_send_im(c->gc, c->name, buffy, -1, imflags); if (err > 0) { write_to_conv(c, buf, WFLAG_SEND, NULL, time(NULL), -1); - if (c->makesound && (sound_options & OPT_SOUND_SEND)) - play_sound(SEND); + if (c->makesound) + play_sound(SND_SEND); if (im_options & OPT_IM_POPDOWN) gtk_widget_hide(c->window); } diff -r 966c4e460ebb -r 4f2f12bf4408 src/gaim.h --- a/src/gaim.h Fri Mar 15 20:09:14 2002 +0000 +++ b/src/gaim.h Sat Mar 16 00:32:53 2002 +0000 @@ -279,19 +279,29 @@ #define OPT_SOUND_ESD 0x00010000 #define OPT_SOUND_CMD 0x00020000 -#define BUDDY_ARRIVE 0 -#define BUDDY_LEAVE 1 -#define RECEIVE 2 -#define FIRST_RECEIVE 3 -#define SEND 4 -#define CHAT_JOIN 5 -#define CHAT_LEAVE 6 -#define CHAT_YOU_SAY 7 -#define CHAT_SAY 8 -#define POUNCE_DEFAULT 9 +/* remember to also change the struct in sound.c */ +#define SND_BUDDY_ARRIVE 0 +#define SND_BUDDY_LEAVE 1 +#define SND_RECEIVE 2 +#define SND_FIRST_RECEIVE 3 +#define SND_SEND 4 +#define SND_CHAT_JOIN 5 +#define SND_CHAT_LEAVE 6 +#define SND_CHAT_YOU_SAY 7 +#define SND_CHAT_SAY 8 +#define SND_POUNCE_DEFAULT 9 #define NUM_SOUNDS 10 extern char *sound_file[NUM_SOUNDS]; +/* global sound struct */ +struct sound_struct { + char *label; + guint opt; + unsigned char *snd; + size_t snd_size; +}; +extern struct sound_struct sounds[]; + extern guint away_options; #define OPT_AWAY_DISCARD 0x00000001 #define OPT_AWAY_BACK_ON_IM 0x00000002 diff -r 966c4e460ebb -r 4f2f12bf4408 src/multi.c --- a/src/multi.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/multi.c Sat Mar 16 00:32:53 2002 +0000 @@ -37,6 +37,7 @@ #include "pixmaps/tb_redo.xpm" #include "pixmaps/tb_undo.xpm" #include "pixmaps/tb_refresh.xpm" +#include "pixmaps/no_icon.xpm" #define LOGIN_STEPS 5 @@ -89,6 +90,13 @@ return gc; } +struct meter_window { + GtkWidget *window; + GtkTable *table; + gint rows; + gint active_count; + } *meter_win = NULL; + void destroy_gaim_conn(struct gaim_connection *gc) { GSList *g = gc->groups; @@ -1032,12 +1040,44 @@ struct signon_meter { struct gaim_connection *gc; - GtkWidget *window; + GtkWidget *button; GtkWidget *progress; GtkWidget *status; }; static GSList *meters = NULL; +GtkWidget* create_meter_pixmap (GtkWidget *widget, struct gaim_connection *gc) +{ + GdkColormap *colormap; + GdkPixmap *gdkpixmap; + GdkBitmap *mask; + GtkWidget *pixmap; + GtkStyle *style; + char **xpm; + + style = gtk_widget_get_style( widget ); + + if (gc->prpl->list_icon) + if (gc->prpl->protocol == PROTO_OSCAR) + /* This is such a bad hack to get the right icon + * for OSCAR. But it's pretty */ + if (isdigit(*gc->username)) + xpm = gc->prpl->list_icon(0); + else + xpm = gc->prpl->list_icon(0x10); + else + xpm = gc->prpl->list_icon (0); + if (xpm == NULL) + xpm = (char **)no_icon_xpm; + + gdkpixmap = gdk_pixmap_create_from_xpm_d(widget->window, &mask, &style->bg[GTK_STATE_NORMAL], xpm); + + pixmap = gtk_pixmap_new (gdkpixmap, mask); + gdk_pixmap_unref (gdkpixmap); + gdk_bitmap_unref (mask); + return pixmap; +} + static struct signon_meter *find_signon_meter(struct gaim_connection *gc) { GSList *m = meters; @@ -1049,6 +1089,19 @@ return NULL; } +void kill_meter(struct signon_meter *meter) { + gtk_widget_set_sensitive (meter->button, FALSE); + gtk_progress_bar_update(GTK_PROGRESS_BAR(meter->progress), 1); + gtk_statusbar_pop(GTK_STATUSBAR(meter->status), 1); + gtk_statusbar_push(GTK_STATUSBAR(meter->status), 1, "Done."); + meter_win->active_count--; + if (meter_win->active_count == 0) { + gtk_widget_destroy(meter_win->window); + g_free (meter_win); + meter_win = NULL; + } +} + void account_online(struct gaim_connection *gc) { int i; @@ -1056,7 +1109,7 @@ /* first we hide the login progress meter */ if (meter) { - gtk_widget_destroy(meter->window); + kill_meter(meter); meters = g_slist_remove(meters, meter); g_free(meter); } @@ -1122,7 +1175,7 @@ int i; struct signon_meter *meter = find_signon_meter(gc); if (meter) { - gtk_widget_destroy(meter->window); + kill_meter(meter); meters = g_slist_remove(meters, meter); g_free(meter); } @@ -1161,6 +1214,63 @@ return TRUE; } +static struct signon_meter *register_meter(struct gaim_connection *gc, GtkWidget *widget, GtkTable *table, gint *rows) +{ + GtkWidget *graphic; + GtkWidget *label; + GtkWidget *nest_vbox; + GString *name_to_print; + struct signon_meter *meter; + + name_to_print = g_string_new(gc->username); + + meter = g_new0(struct signon_meter, 1); + + (*rows)++; + gtk_table_resize (table, *rows, 4); + + graphic = create_meter_pixmap( widget , gc); + + nest_vbox = gtk_vbox_new (FALSE, 0); + + name_to_print = g_string_prepend(name_to_print, "Signon: "); + label = gtk_label_new (name_to_print->str); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + + meter->status = gtk_statusbar_new(); + gtk_widget_set_usize(meter->status, 250, 0); + + meter->progress = gtk_progress_bar_new (); + + meter->button = gtk_button_new_with_label ("Cancel"); + gtk_signal_connect (GTK_OBJECT (meter->button), "clicked", GTK_SIGNAL_FUNC (cancel_signon), meter); + + gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); + gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); + gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0); + gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); + gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); + + gtk_widget_show_all (GTK_WIDGET (meter_win->window)); + + meter_win->active_count++; + + return meter; +} + +static void loop_cancel () { + GSList *m = meters; + struct signon_meter *meter = NULL; + + while (m) { + meter = (struct signon_meter *) (m->data); + meter->gc->wants_to_die = TRUE; + signoff((struct gaim_connection *) meter->gc); + m = meters; + } + } + void set_login_progress(struct gaim_connection *gc, float howfar, char *message) { struct signon_meter *meter = find_signon_meter(gc); @@ -1168,49 +1278,47 @@ if (mainwindow) gtk_widget_hide(mainwindow); + if (!meter_win) { + GtkWidget *cancel_button; + GtkWidget *vbox; + GString *name; + + meter_win = g_new0(struct meter_window, 1); + meter_win->rows=0; + + meter_win->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + GAIM_DIALOG(meter_win->window); + gtk_window_set_policy(GTK_WINDOW(meter_win->window), 0, 0, 1); + gtk_window_set_wmclass(GTK_WINDOW(meter_win->window), "signon", "Gaim"); + gtk_container_set_border_width(GTK_CONTAINER(meter_win->window), 5); + gtk_window_set_title (GTK_WINDOW (meter_win->window), "Gaim Account Signon"); + gtk_widget_realize(meter_win->window); + aol_icon(meter_win->window->window); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (meter_win->window), GTK_WIDGET (vbox)); + + meter_win->table = (GtkTable *) gtk_table_new (1 , 4, FALSE); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (meter_win->table), FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (meter_win->table), 5); + gtk_table_set_row_spacings (GTK_TABLE (meter_win->table), 5); + gtk_table_set_col_spacings (GTK_TABLE (meter_win->table), 10); + + cancel_button = gtk_button_new_with_label ("Cancel All"); + gtk_signal_connect_object (GTK_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (loop_cancel), NULL); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (cancel_button), FALSE, FALSE, 0); + + gtk_signal_connect (GTK_OBJECT (meter_win->window), "delete_event", GTK_SIGNAL_FUNC (meter_destroy), NULL); + } + if (!meter) { - GtkWidget *box, *label, *button; char buf[256]; - meter = g_new0(struct signon_meter, 1); + meter = register_meter(gc, GTK_WIDGET (meter_win->window), GTK_TABLE (meter_win->table), (gint *) &meter_win->rows); meter->gc = gc; meters = g_slist_append(meters, meter); - GAIM_DIALOG(meter->window); - gtk_window_set_policy(GTK_WINDOW(meter->window), 0, 0, 1); - gtk_window_set_wmclass(GTK_WINDOW(meter->window), "signon", "Gaim"); - gtk_container_set_border_width(GTK_CONTAINER(meter->window), 5); g_snprintf(buf, sizeof(buf), "%s Signing On (using %s)", gc->username, gc->prpl->name()); - gtk_window_set_title(GTK_WINDOW(meter->window), buf); - gtk_signal_connect(GTK_OBJECT(meter->window), "delete_event", - GTK_SIGNAL_FUNC(meter_destroy), meter); - gtk_widget_realize(meter->window); - aol_icon(meter->window->window); - - box = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(meter->window), box); - gtk_widget_show(box); - - label = gtk_label_new(buf); - gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); - gtk_widget_show(label); - - meter->progress = gtk_progress_bar_new(); - gtk_widget_set_usize(meter->progress, 150, 0); - gtk_box_pack_start(GTK_BOX(box), meter->progress, FALSE, FALSE, 0); - gtk_widget_show(meter->progress); - - meter->status = gtk_statusbar_new(); - gtk_widget_set_usize(meter->status, 150, 0); - gtk_box_pack_start(GTK_BOX(box), meter->status, FALSE, FALSE, 0); - gtk_widget_show(meter->status); - - button = gtk_button_new_with_label(_("Cancel")); - gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_signon), meter); - gtk_widget_show(button); - - gtk_widget_show(meter->window); } gtk_progress_bar_update(GTK_PROGRESS_BAR(meter->progress), howfar / LOGIN_STEPS); @@ -1262,7 +1370,7 @@ kicks = g_slist_append(kicks, k); gtk_signal_connect(GTK_OBJECT(k->dlg), "destroy", GTK_SIGNAL_FUNC(set_kick_null), k); if (meter) { - gtk_widget_destroy(meter->window); + kill_meter(meter); meters = g_slist_remove(meters, meter); g_free(meter); } diff -r 966c4e460ebb -r 4f2f12bf4408 src/prefs.c --- a/src/prefs.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/prefs.c Sat Mar 16 00:32:53 2002 +0000 @@ -1484,6 +1484,8 @@ guint32 tmp_sound = sound_options; if (!(sound_options & OPT_SOUND_WHEN_AWAY)) sound_options ^= OPT_SOUND_WHEN_AWAY; + if (!(sound_options & sounds[snd].opt)) + sound_options ^= sounds[snd].opt; play_sound(snd); sound_options = tmp_sound; } @@ -1525,7 +1527,7 @@ gdk_window_raise(sounddialog->window); } -static void sound_entry(char *label, int opt, GtkWidget *box, int snd) +static void sound_entry(GtkWidget *box, int snd) { GtkWidget *hbox; GtkWidget *entry; @@ -1535,7 +1537,7 @@ gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); - gaim_button(label, &sound_options, opt, hbox); + gaim_button(sounds[snd].label, &sound_options, sounds[snd].opt, hbox); button = gtk_button_new_with_label(_("Test")); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 3); @@ -1599,7 +1601,7 @@ GtkWidget *omenu; GtkWidget *menu; GtkWidget *opt; - int i=1, driver=0; + int i=1, driver=0, j; parent = prefdialog->parent; gtk_widget_destroy(prefdialog); @@ -1648,7 +1650,7 @@ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); gtk_widget_show(hbox); - label = gtk_label_new(_("Sound Player:")); + label = gtk_label_new(_("Sound method")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_widget_show(label); @@ -1718,15 +1720,11 @@ gtk_box_pack_start(GTK_BOX(hbox), omenu, FALSE, FALSE, 5); gtk_widget_show_all(omenu); - sep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); - gtk_widget_show(sep); - hbox = gtk_hbox_new(TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); gtk_widget_show(hbox); - label = gtk_label_new(_("Command to play sound files\n(%s for filename)")); + label = gtk_label_new(_("Sound command\n(%s for filename)")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_widget_show(label); @@ -1738,7 +1736,7 @@ gtk_widget_set_sensitive(sndcmd, (OPT_SOUND_CMD & sound_options)); gtk_widget_show(sndcmd); - frame = gtk_frame_new(_("Events")); + frame = gtk_frame_new(_("Sound played when:")); gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5); gtk_widget_show(frame); @@ -1746,26 +1744,20 @@ gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_widget_show(vbox); - sound_entry(_("Sound when buddy logs in"), OPT_SOUND_LOGIN, vbox, BUDDY_ARRIVE); - sound_entry(_("Sound when buddy logs out"), OPT_SOUND_LOGOUT, vbox, BUDDY_LEAVE); - - sep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 5); - gtk_widget_show(sep); - - sound_entry(_("Sound when received message begins conversation"), OPT_SOUND_FIRST_RCV, vbox, - FIRST_RECEIVE); - sound_entry(_("Sound when message is received"), OPT_SOUND_RECV, vbox, RECEIVE); - sound_entry(_("Sound when message is sent"), OPT_SOUND_SEND, vbox, SEND); - - sep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 5); - gtk_widget_show(sep); - - sound_entry(_("Sound in chat rooms when people enter"), OPT_SOUND_CHAT_JOIN, vbox, CHAT_JOIN); - sound_entry(_("Sound in chat rooms when people leave"), OPT_SOUND_CHAT_PART, vbox, CHAT_LEAVE); - sound_entry(_("Sound in chat rooms when you talk"), OPT_SOUND_CHAT_YOU_SAY, vbox, CHAT_YOU_SAY); - sound_entry(_("Sound in chat rooms when others talk"), OPT_SOUND_CHAT_SAY, vbox, CHAT_SAY); + for (j=0; j < NUM_SOUNDS; j++) { + /* no entry for the buddy pounce sound, it's configurable per-pounce */ + if (j == SND_POUNCE_DEFAULT) + continue; + + /* seperators before SND_RECEIVE and SND_CHAT_JOIN */ + if ((j == SND_RECEIVE) || (j == SND_CHAT_JOIN)) { + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 5); + gtk_widget_show(sep); + } + + sound_entry(vbox, j); + } gtk_widget_show(prefdialog); } diff -r 966c4e460ebb -r 4f2f12bf4408 src/server.c --- a/src/server.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/server.c Sat Mar 16 00:32:53 2002 +0000 @@ -584,9 +584,9 @@ set_convo_gc(cnv, gc); } if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) - play_sound(FIRST_RECEIVE); - else if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) - play_sound(RECEIVE); + play_sound(SND_FIRST_RECEIVE); + else if (cnv->makesound) + play_sound(SND_RECEIVE); write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime, len); } @@ -645,9 +645,9 @@ set_convo_gc(cnv, gc); } if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) - play_sound(FIRST_RECEIVE); - else if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) - play_sound(RECEIVE); + play_sound(SND_FIRST_RECEIVE); + else if (cnv->makesound) + play_sound(SND_RECEIVE); set_convo_name(cnv, name); diff -r 966c4e460ebb -r 4f2f12bf4408 src/sound.c --- a/src/sound.c Fri Mar 15 20:09:14 2002 +0000 +++ b/src/sound.c Sat Mar 16 00:32:53 2002 +0000 @@ -52,6 +52,22 @@ #include "sounds/Receive.h" #include "sounds/RedAlert.h" +/* label and opt are null for the buddy pounce because it's configured * + * per pounce. NULL option means it doesn't get displayed in the sound * + * preferences box */ +struct sound_struct sounds[NUM_SOUNDS] = { + N_("Buddy logs in"), OPT_SOUND_LOGIN, BuddyArrive, sizeof(BuddyArrive), + N_("Buddy logs out"), OPT_SOUND_LOGOUT, BuddyLeave, sizeof(BuddyLeave), + N_("Message recieved begins conversation"), OPT_SOUND_FIRST_RCV, Receive, sizeof(Receive), + N_("Message recieved"), OPT_SOUND_RECV, Receive, sizeof(Receive), + N_("Message sent"), OPT_SOUND_SEND, Send, sizeof(Send), + N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, BuddyArrive, sizeof(BuddyArrive), + N_("Person leaves chat"), OPT_SOUND_CHAT_PART, BuddyLeave, sizeof(BuddyLeave), + N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, Send, sizeof(Send), + N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, Receive, sizeof(Receive), + NULL, NULL, &RedAlert, sizeof(RedAlert) +}; + static int check_dev(char *dev) { struct stat stat_buf; @@ -396,6 +412,10 @@ return; } + else if (sound_options & OPT_SOUND_NORMAL) { + debug_printf("attempting to play audio file with internal method -- this is unlikely to work"); + } + pid = fork(); if (pid < 0) @@ -522,98 +542,23 @@ void play_sound(int sound) { - if (awaymessage && !(sound_options & OPT_SOUND_WHEN_AWAY)) return; - switch (sound) { - case BUDDY_ARRIVE: - if ((sound_options & OPT_SOUND_LOGIN) && logins_not_muted) { - if (sound_file[BUDDY_ARRIVE]) { - play_file(sound_file[BUDDY_ARRIVE]); - } else { - play(BuddyArrive, sizeof(BuddyArrive)); - } - } - break; - case BUDDY_LEAVE: - if (sound_options & OPT_SOUND_LOGOUT) { - if (sound_file[BUDDY_LEAVE]) { - play_file(sound_file[BUDDY_LEAVE]); - } else { - play(BuddyLeave, sizeof(BuddyLeave)); - } - } - break; - case FIRST_RECEIVE: - if (sound_options & OPT_SOUND_FIRST_RCV) { - if (sound_file[FIRST_RECEIVE]) { - play_file(sound_file[FIRST_RECEIVE]); - } else { - play(Receive, sizeof(Receive)); - } - } - break; - case RECEIVE: - if (sound_options & OPT_SOUND_RECV) { - if (sound_file[RECEIVE]) { - play_file(sound_file[RECEIVE]); - } else { - play(Receive, sizeof(Receive)); - } - } - break; - case SEND: - if (sound_options & OPT_SOUND_SEND) { - if (sound_file[SEND]) { - play_file(sound_file[SEND]); - } else { - play(Send, sizeof(Send)); - } + if ((sound == SND_BUDDY_ARRIVE) && !logins_not_muted) + return; + + if (sound >= NUM_SOUNDS) { + debug_printf("sorry old fruit... can't say I know that sound: ", sound); + return; + } + + /* check NULL for sounds that don't have an option, ie buddy pounce */ + if ((sound_options & sounds[sound].opt) || (sounds[sound].opt == NULL)) { + if (sound_file[sound]) { + play_file(sound_file[sound]); + } else { + play(sounds[sound].snd, sounds[sound].snd_size); } - break; - case CHAT_JOIN: - if (sound_options & OPT_SOUND_CHAT_JOIN) { - if (sound_file[CHAT_JOIN]) { - play_file(sound_file[CHAT_JOIN]); - } else { - play(BuddyArrive, sizeof(BuddyArrive)); - } - } - break; - case CHAT_LEAVE: - if (sound_options & OPT_SOUND_CHAT_PART) { - if (sound_file[CHAT_LEAVE]) { - play_file(sound_file[CHAT_LEAVE]); - } else { - play(BuddyLeave, sizeof(BuddyLeave)); - } - } - break; - case CHAT_YOU_SAY: - if (sound_options & OPT_SOUND_CHAT_YOU_SAY) { - if (sound_file[CHAT_YOU_SAY]) { - play_file(sound_file[CHAT_YOU_SAY]); - } else { - play(Send, sizeof(Send)); - } - } - break; - case CHAT_SAY: - if (sound_options & OPT_SOUND_CHAT_SAY) { - if (sound_file[CHAT_SAY]) { - play_file(sound_file[CHAT_SAY]); - } else { - play(Receive, sizeof(Receive)); - } - } - break; - case POUNCE_DEFAULT: - if (sound_file[POUNCE_DEFAULT]) { - play_file(sound_file[POUNCE_DEFAULT]); - } else { - play(RedAlert, sizeof(RedAlert)); - } - break; } }