Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the "fossil chat" command that attempts to bring up a chat window in the default web browser and provide alerts through the TTY. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
f62805ed859bc871a47813313c5b6b20 |
| User & Date: | drh 2020-12-24 15:57:18.891 |
Context
|
2020-12-24
| ||
| 15:58 | Fix a harmless compiler warning. check-in: b4862238ec user: drh tags: trunk | |
| 15:57 | Add the "fossil chat" command that attempts to bring up a chat window in the default web browser and provide alerts through the TTY. check-in: f62805ed85 user: drh tags: trunk | |
| 15:10 | The ping=TCPPORT query parameter to /chat causes a call to /chat-ping on localhost and the given port whenever new chat content arrives. Can be used for notifications. check-in: ebdd91b92f user: drh tags: trunk | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
553 554 555 556 557 558 559 |
** a single \007 (bel) character to be written on the controlling TTY.
** This is used to implement an audiable alert by local web clients.
*/
void chat_ping_webpage(void){
const char *zIpAddr = PD("REMOTE_ADDR","nil");
if( cgi_is_loopback(zIpAddr) ) fputc(7, stderr);
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
** a single \007 (bel) character to be written on the controlling TTY.
** This is used to implement an audiable alert by local web clients.
*/
void chat_ping_webpage(void){
const char *zIpAddr = PD("REMOTE_ADDR","nil");
if( cgi_is_loopback(zIpAddr) ) fputc(7, stderr);
}
/*
** COMMAND: chat
**
** Usage: %fossil chat ?URL?
**
** Bring up a window to the chatroom feature of the Fossil repository
** at URL. Or if URL is not specified, use the default remote repository.
** Event notifications on this session cause the U+0007 character to
** be sent to the TTY on which the "fossil chat" command is run, thus
** causing an auditory notification.
*/
void chat_command(void){
const char *zUrl;
char *azArgv[5];
db_find_and_open_repository(0,0);
if( g.argc==3 ){
zUrl = g.argv[2];
}else if( g.argc!=2 ){
usage("?URL?");
}else{
zUrl = db_get("last-sync-url",0);
if( zUrl==0 ){
fossil_fatal("no \"remote\" repository defined. Use a URL argument");
}
url_parse(zUrl, 0);
if( g.url.port==g.url.dfltPort ){
zUrl = mprintf(
"%s://%T%T",
g.url.protocol, g.url.name, g.url.path
);
}else{
zUrl = mprintf(
"%s://%T:%d%T",
g.url.protocol, g.url.name, g.url.port, g.url.path
);
}
}
if( strncmp(zUrl,"http://",7)!=0 && strncmp("https://",zUrl,8)!=0 ){
fossil_fatal("Not a valid URL: %s", zUrl);
}
azArgv[0] = g.argv[0];
azArgv[1] = "ui";
azArgv[2] = "--internal-chat-url";
azArgv[3] = mprintf("%s/chat?ping=%%d", zUrl);
azArgv[4] = 0;
g.argv = azArgv;
g.argc = 4;
cmd_webserver();
}
|
Changes to src/main.c.
| ︙ | ︙ | |||
2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 |
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
| > | 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 |
#endif
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
const char *zChat = 0; /* Remote chat URL. (undocumented) */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
|
| ︙ | ︙ | |||
2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 |
g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd;
if( find_option("https",0,0)!=0 ){
cgi_replace_parameter("HTTPS","on");
}
if( find_option("localhost", 0, 0)!=0 ){
flags |= HTTP_SERVER_LOCALHOST;
}
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
| > | 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 |
g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd;
if( find_option("https",0,0)!=0 ){
cgi_replace_parameter("HTTPS","on");
}
if( find_option("localhost", 0, 0)!=0 ){
flags |= HTTP_SERVER_LOCALHOST;
}
zChat = find_option("internal-chat-url",0,1);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
|
| ︙ | ︙ | |||
2908 2909 2910 2911 2912 2913 2914 |
break;
}
}
}
#else
zBrowser = db_get("web-browser", "open");
#endif
| > > | | 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 |
break;
}
}
}
#else
zBrowser = db_get("web-browser", "open");
#endif
if( zChat ){
zBrowserCmd = mprintf("%s \"%s\" &", zBrowser, zChat);
}else if( zIpAddr==0 ){
zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
zBrowser, zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserCmd = mprintf("%s \"http://[%s]:%%d/%s\" &",
zBrowser, zIpAddr, zInitPage);
}else{
zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
|
| ︙ | ︙ | |||
2971 2972 2973 2974 2975 2976 2977 |
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
getpid());
}
#else
/* Win32 implementation */
if( isUiCmd ){
zBrowser = db_get("web-browser", "start");
| > > | | 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 |
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
getpid());
}
#else
/* Win32 implementation */
if( isUiCmd ){
zBrowser = db_get("web-browser", "start");
if( zChat ){
zBrowserCmd = mprintf("%s \"%s\" &", zBrowser, zChat);
}else if( zIpAddr==0 ){
zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
zBrowser, zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
zBrowser, zIpAddr, zInitPage);
}else{
zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
|
| ︙ | ︙ |