Fossil SCM
Improvements to the way that the chat alert sound is configured. Remove the /chat-alert webpage. Access the sound files directly using /builtin.
Commit
21a870d02d853ab09968d14321822c9541663e824fecd4814be166c52f960a50
Parent
42efc6295186af2…
2 files changed
+4
-16
+1
-1
+4
-16
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -144,15 +144,18 @@ | ||
| 144 | 144 | ** |
| 145 | 145 | ** Other /chat-OP pages are used by XHR requests from this page to |
| 146 | 146 | ** send new chat message, delete older messages, or poll for changes. |
| 147 | 147 | */ |
| 148 | 148 | void chat_webpage(void){ |
| 149 | + char *zAlert; | |
| 149 | 150 | login_check_credentials(); |
| 150 | 151 | if( !g.perm.Chat ){ |
| 151 | 152 | login_needed(g.anon.Chat); |
| 152 | 153 | return; |
| 153 | 154 | } |
| 155 | + zAlert = mprintf("%s/builtin/%s", g.zBaseURL, | |
| 156 | + db_get("chat-alert-sound","alerts/plunk.wav")); | |
| 154 | 157 | style_set_current_feature("chat"); |
| 155 | 158 | style_header("Chat"); |
| 156 | 159 | @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off"> |
| 157 | 160 | @ <div id='chat-input-area'> |
| 158 | 161 | @ <div id='chat-input-line'> |
| @@ -193,10 +196,11 @@ | ||
| 193 | 196 | @ window.addEventListener('load', function(){ |
| 194 | 197 | @ document.body.classList.add('chat') |
| 195 | 198 | @ /*^^^for skins which add their own BODY tag */; |
| 196 | 199 | @ window.fossil.config.chat = { |
| 197 | 200 | @ fromcli: %h(PB("cli")?"true":"false"), |
| 201 | + @ alertSound: "%h(zAlert)", | |
| 198 | 202 | @ initSize: %d(db_get_int("chat-initial-history",50)), |
| 199 | 203 | @ imagesInline: !!%d(db_get_boolean("chat-inline-images",1)) |
| 200 | 204 | @ }; |
| 201 | 205 | chat_emit_alert_list(); |
| 202 | 206 | cgi_append_content(builtin_text("chat.js"),-1); |
| @@ -702,26 +706,10 @@ | ||
| 702 | 706 | "COMMIT;", |
| 703 | 707 | mdel, g.zLogin, mdel |
| 704 | 708 | ); |
| 705 | 709 | } |
| 706 | 710 | |
| 707 | -/* | |
| 708 | -** WEBPAGE: chat-alert | |
| 709 | -** | |
| 710 | -** Return the sound file that should be played when a new chat message | |
| 711 | -** arrives. | |
| 712 | -*/ | |
| 713 | -void chat_audio_alert(void){ | |
| 714 | - Blob audio = empty_blob; | |
| 715 | - int n = 0; | |
| 716 | - const char *zName = db_get("chat-alert-sound", "alerts/plunk.wav"); | |
| 717 | - const char *zAudio = (const char*)builtin_file(zName, &n); | |
| 718 | - blob_init(&audio, zAudio, n); | |
| 719 | - cgi_set_content_type("audio/wav"); | |
| 720 | - cgi_set_content(&audio); | |
| 721 | -} | |
| 722 | - | |
| 723 | 711 | /* |
| 724 | 712 | ** COMMAND: chat |
| 725 | 713 | ** |
| 726 | 714 | ** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...] |
| 727 | 715 | ** |
| 728 | 716 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -144,15 +144,18 @@ | |
| 144 | ** |
| 145 | ** Other /chat-OP pages are used by XHR requests from this page to |
| 146 | ** send new chat message, delete older messages, or poll for changes. |
| 147 | */ |
| 148 | void chat_webpage(void){ |
| 149 | login_check_credentials(); |
| 150 | if( !g.perm.Chat ){ |
| 151 | login_needed(g.anon.Chat); |
| 152 | return; |
| 153 | } |
| 154 | style_set_current_feature("chat"); |
| 155 | style_header("Chat"); |
| 156 | @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off"> |
| 157 | @ <div id='chat-input-area'> |
| 158 | @ <div id='chat-input-line'> |
| @@ -193,10 +196,11 @@ | |
| 193 | @ window.addEventListener('load', function(){ |
| 194 | @ document.body.classList.add('chat') |
| 195 | @ /*^^^for skins which add their own BODY tag */; |
| 196 | @ window.fossil.config.chat = { |
| 197 | @ fromcli: %h(PB("cli")?"true":"false"), |
| 198 | @ initSize: %d(db_get_int("chat-initial-history",50)), |
| 199 | @ imagesInline: !!%d(db_get_boolean("chat-inline-images",1)) |
| 200 | @ }; |
| 201 | chat_emit_alert_list(); |
| 202 | cgi_append_content(builtin_text("chat.js"),-1); |
| @@ -702,26 +706,10 @@ | |
| 702 | "COMMIT;", |
| 703 | mdel, g.zLogin, mdel |
| 704 | ); |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | ** WEBPAGE: chat-alert |
| 709 | ** |
| 710 | ** Return the sound file that should be played when a new chat message |
| 711 | ** arrives. |
| 712 | */ |
| 713 | void chat_audio_alert(void){ |
| 714 | Blob audio = empty_blob; |
| 715 | int n = 0; |
| 716 | const char *zName = db_get("chat-alert-sound", "alerts/plunk.wav"); |
| 717 | const char *zAudio = (const char*)builtin_file(zName, &n); |
| 718 | blob_init(&audio, zAudio, n); |
| 719 | cgi_set_content_type("audio/wav"); |
| 720 | cgi_set_content(&audio); |
| 721 | } |
| 722 | |
| 723 | /* |
| 724 | ** COMMAND: chat |
| 725 | ** |
| 726 | ** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...] |
| 727 | ** |
| 728 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -144,15 +144,18 @@ | |
| 144 | ** |
| 145 | ** Other /chat-OP pages are used by XHR requests from this page to |
| 146 | ** send new chat message, delete older messages, or poll for changes. |
| 147 | */ |
| 148 | void chat_webpage(void){ |
| 149 | char *zAlert; |
| 150 | login_check_credentials(); |
| 151 | if( !g.perm.Chat ){ |
| 152 | login_needed(g.anon.Chat); |
| 153 | return; |
| 154 | } |
| 155 | zAlert = mprintf("%s/builtin/%s", g.zBaseURL, |
| 156 | db_get("chat-alert-sound","alerts/plunk.wav")); |
| 157 | style_set_current_feature("chat"); |
| 158 | style_header("Chat"); |
| 159 | @ <form accept-encoding="utf-8" id="chat-form" autocomplete="off"> |
| 160 | @ <div id='chat-input-area'> |
| 161 | @ <div id='chat-input-line'> |
| @@ -193,10 +196,11 @@ | |
| 196 | @ window.addEventListener('load', function(){ |
| 197 | @ document.body.classList.add('chat') |
| 198 | @ /*^^^for skins which add their own BODY tag */; |
| 199 | @ window.fossil.config.chat = { |
| 200 | @ fromcli: %h(PB("cli")?"true":"false"), |
| 201 | @ alertSound: "%h(zAlert)", |
| 202 | @ initSize: %d(db_get_int("chat-initial-history",50)), |
| 203 | @ imagesInline: !!%d(db_get_boolean("chat-inline-images",1)) |
| 204 | @ }; |
| 205 | chat_emit_alert_list(); |
| 206 | cgi_append_content(builtin_text("chat.js"),-1); |
| @@ -702,26 +706,10 @@ | |
| 706 | "COMMIT;", |
| 707 | mdel, g.zLogin, mdel |
| 708 | ); |
| 709 | } |
| 710 | |
| 711 | /* |
| 712 | ** COMMAND: chat |
| 713 | ** |
| 714 | ** Usage: %fossil chat [SUBCOMMAND] [--remote URL] [ARGS...] |
| 715 | ** |
| 716 |
+1
-1
| --- src/chat.js | ||
| +++ src/chat.js | ||
| @@ -375,11 +375,11 @@ | ||
| 375 | 375 | setting is true, else this is a no-op. Returns this. |
| 376 | 376 | */ |
| 377 | 377 | playNewMessageSound: function f(){ |
| 378 | 378 | if(f.uri){ |
| 379 | 379 | try{ |
| 380 | - if(!f.audio) f.audio = new Audio(F.rootPath+"chat-alert"); | |
| 380 | + if(!f.audio) f.audio = new Audio(window.fossil.config.chat.alertSound); | |
| 381 | 381 | f.audio.currentTime = 0; |
| 382 | 382 | f.audio.play(); |
| 383 | 383 | }catch(e){ |
| 384 | 384 | console.error("Audio playblack failed.",e); |
| 385 | 385 | } |
| 386 | 386 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -375,11 +375,11 @@ | |
| 375 | setting is true, else this is a no-op. Returns this. |
| 376 | */ |
| 377 | playNewMessageSound: function f(){ |
| 378 | if(f.uri){ |
| 379 | try{ |
| 380 | if(!f.audio) f.audio = new Audio(F.rootPath+"chat-alert"); |
| 381 | f.audio.currentTime = 0; |
| 382 | f.audio.play(); |
| 383 | }catch(e){ |
| 384 | console.error("Audio playblack failed.",e); |
| 385 | } |
| 386 |
| --- src/chat.js | |
| +++ src/chat.js | |
| @@ -375,11 +375,11 @@ | |
| 375 | setting is true, else this is a no-op. Returns this. |
| 376 | */ |
| 377 | playNewMessageSound: function f(){ |
| 378 | if(f.uri){ |
| 379 | try{ |
| 380 | if(!f.audio) f.audio = new Audio(window.fossil.config.chat.alertSound); |
| 381 | f.audio.currentTime = 0; |
| 382 | f.audio.play(); |
| 383 | }catch(e){ |
| 384 | console.error("Audio playblack failed.",e); |
| 385 | } |
| 386 |