|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
PATCH #1/1 - Try 3 - AlertingHi, I have been running this for a good while now (>6 months) and have had no problems with it. As always a copy of my dongle is at http://imcfarla.homelinux.net/mvpmc/dongle.bin.mvpmc and my git repository is at: http://imcfarla.homelinux.net/cgi-bin/gitweb.cgi?p=mvpmc.git;a=summary Added alerting. New webpage http://mvp-ip-address:webport/alert.html Can also be used by POSTing to /alert?<Title>=<Message>&timeout=<Timeout> A new warning-alpha widget has been created that is used for the alert. This is set to be 50% alpha by default. Notes: Alerting is only available if webport != 0 If timeout is 0 then the message will stay until a key is pressed Limit of 220 characters of message and 50 characters of title Signed-off-by: Iain McFarlane <imcfarla@...> Regards, Iain ------------------------------------------------------- [0001-Added-alerting.patch] From 63e7cde84d9a4c96f0306f1d77bda956c59d43a8 Mon Sep 17 00:00:00 2001 From: Iain McFarlane <iain@...> Date: Wed, 22 Apr 2009 08:09:56 +0100 Subject: [PATCH] Added alerting. New webpage http://mvp-ip-address:webport/alert.html Can also be used by POSTing to /alert?<Title>=<Message>&timeout=<Timeout> A new warning-alpha widget has been created that is used for the alert. This is set to be 50% alpha by default. Notes: Alerting is only available if webport != 0 If timeout is 0 then the message will stay until a key is pressed Limit of 220 characters of message and 50 characters of title --- dongle/filesystem/tree/usr/share/mvpmc/alert.html | 109 +++++++++++++++++++++ src/gui.c | 81 +++++++++++++++ src/mvpmc.h | 1 + src/web_config.c | 71 +++++++++++++- themes/orange.xml | 10 ++ 5 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 dongle/filesystem/tree/usr/share/mvpmc/alert.html diff --git a/dongle/filesystem/tree/usr/share/mvpmc/alert.html b/dongle/filesystem/tree/usr/share/mvpmc/alert.html new file mode 100644 index 0000000..30145e3 --- /dev/null +++ b/dongle/filesystem/tree/usr/share/mvpmc/alert.html @@ -0,0 +1,109 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/htm401/DTD/strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="expires" content="0" /> + <meta http-equiv="Pragma" Content="no-cache" /> + <meta http-equiv="Cache-Control" content="no-cache" /> + <meta name="author" content="Jon Gettler" /> + <title>MediaMVP Media Center Alert</title> + <link rel="stylesheet" type="text/css" title="Default" href="mvpmc.css" /> + <link rel="alternate stylesheet" type="text/css" title="Minimal" href="minimal.css" /> +</head> +<body> +<div id="container"> + <div id="intro"> + <div id="pageHeader"> + <h1><span>mvpmc Alert</span></h1> + </div> + </div> + <div id="supportingText"> + <div class="title"> + <h3><span>MediaMVP Media Center Alert</span></h3> + </div> + +<div class="item"> +<h3><span><a name="s1">Alert</a></span></h3> +<br /> +<FORM method = "POST" ACTION="alert"> +<TABLE BORDER="1"> +<TBODY> +<TR><TD><PRE> + + Message: <INPUT TYPE="TEXT" NAME="Alert" VALUE="Message" SIZE=80 MAXLENGTH=220 /> + + Timeout: <INPUT TYPE="TEXT" NAME="timeout" VALUE="5" SIZE=6 MAXLENGTH=5 /> + +</TD></TR></PRE> +<T/BODY> +</TABLE> +<br /> +<INPUT TYPE="SUBMIT" VALUE="Alert"> <INPUT TYPE="reset" VALUE="Reset"> +</FORM> +</div> +<div class="item"> +<h3><span><a name="s2">Status</a></span></h3> +<h4><!--mvpmc ID="800" --></h4> +</div> +<div id="linkList"> + <div id="linkList2"> + <div id="lselect"> + <h3 class="select"> + <span> + Project Links + </span> + </h3> + <ul> + <li> + <a class="link" href="http://www.mvpmc.org/index.php?pg=main">Home</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/index.php?pg=faq">FAQ</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/mvpmc-HOWTO-singlehtml.html">HOWTO</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/windows/mvpmc_windoze_howto.html">Windows HOWTO</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/replaytv/replaytv.html">ReplayTV HOWTO</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/mvpmc_hardware_howto.html">Hardware HOWTO</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/index.php?pg=downloads">Downloads</a> + </li> + <li> + <a class="link" href="http://www.mvpmc.org/index.php?pg=screenshots">Screenshots</a> + </li> + <li> + <a class="link" href="http://sourceforge.net/projects/mvpmc/">Project summary</a> + </li> + <li> + <a class="link" href="http://sourceforge.net/mail/?group_id=103474">Mailing + lists</a> + </li> + <li> + <a class="link" href="http://sourceforge.net/forum/?group_id=103474">Forums</a> + </li> + <li> + <a class="link" href="http://sourceforge.net/tracker/?atid=634920&group_id=103474">Bug + Tracker</a> + </li> + <li> + <a class="link" href="http://mvpmc.wikispaces.com/">Wiki</a> + </li> + <li> + <a class="link" href="http://git.mvpmc.org/">GIT repository</a> + </li> + </ul> + </div> + </div> +</div> +</div> +</div> +</body> +</html> + diff --git a/src/gui.c b/src/gui.c index 99ea98f..dc97bf0 100644 --- a/src/gui.c +++ b/src/gui.c @@ -608,6 +608,20 @@ static mvpw_text_attr_t weather_attr = { .margin = 0, }; +static mvpw_dialog_attr_t warn_attr_a = { + .font = FONT_STANDARD, + .fg = mvpw_color_alpha(MVPW_WHITE, 0x50), + .bg = mvpw_color_alpha(MVPW_DARKGREY, 0x50), + .title_fg = mvpw_color_alpha(MVPW_BLACK, 0x50), + .title_bg = mvpw_color_alpha(MVPW_WHITE, 0x50), + .modal = true, + .border = mvpw_color_alpha(MVPW_RED, 0x50), + .border_size = 4, + .margin = 4, + .justify_title = MVPW_TEXT_CENTER, + .justify_body = MVPW_TEXT_CENTER, +}; + static mvpw_dialog_attr_t warn_attr = { .font = FONT_STANDARD, .fg = MVPW_WHITE, @@ -969,6 +983,9 @@ theme_attr_t theme_attr[] = { { .name = "warning", .type = WIDGET_DIALOG, .attr.dialog = &warn_attr }, + { .name = "warning-alpha", + .type = WIDGET_DIALOG, + .attr.dialog = &warn_attr_a }, { .name = "rtv_device_menu", .type = WIDGET_MENU, @@ -1103,6 +1120,7 @@ static mvp_widget_t *weather_image; static mvp_widget_t *mclient_image; static mvp_widget_t *exit_image; static mvp_widget_t *warn_widget; +static mvp_widget_t *warn_widget_a; static mvp_widget_t *busy_widget; static mvp_widget_t *busy_graph; static mvp_widget_t *themes_menu; @@ -1662,6 +1680,21 @@ warn_key_callback(mvp_widget_t *widget, char key) } static void +warn_a_key_callback(mvp_widget_t *widget, char key) +{ + mvpw_hide(widget); + mvpw_set_timer(widget, NULL, 0); +} + +static void +warn_a_timer_callback(mvp_widget_t *widget) +{ + fprintf(stderr, "Alert timeout expired\n"); + mvpw_hide(widget); + mvpw_set_timer(widget, NULL, 0); +} + +static void mythtv_info_key_callback(mvp_widget_t *widget, char key) { mvpw_hide(mythtv_info); @@ -8508,6 +8541,30 @@ gui_mesg(char *title, char *msg) } void +gui_mesg_a(char *title, char *msg, int timeout) +{ + char *key = "\n\nPress any key to continue."; + char *buf; + + mvpw_set_dialog_title(warn_widget_a, title); + + fprintf(stderr, "%s: %s, timeout: %i\n", title, msg, timeout); + + if ((buf=alloca(strlen(msg) + strlen(key) + 1)) == NULL) + buf = msg; + else + sprintf(buf, "%s%s", msg, key); + + mvpw_set_dialog_text(warn_widget_a, buf); + + screensaver_disable(); + mvpw_show(warn_widget_a); + if ( timeout != 0) mvpw_set_timer(warn_widget_a, warn_a_timer_callback, timeout * 1000); + + mvpw_event_flush(); +} + +void gui_error(char *msg) { gui_mesg("Warning", msg); @@ -8547,6 +8604,29 @@ warn_init(void) mvpw_set_key(warn_widget, warn_key_callback); } +void +warn_a_init(void) +{ + int h, w, x, y; + + h = 6 * FONT_HEIGHT(warn_attr_a); + w = 400; + + x = (si.cols - w) / 2; + y = (si.rows - h) / 2; + + warn_widget_a = mvpw_create_dialog(NULL, x, y, w, h, + warn_attr_a.bg, + warn_attr_a.border, + warn_attr_a.border_size); + + mvpw_set_dialog_attr(warn_widget_a, &warn_attr_a); + + mvpw_set_dialog_title(warn_widget_a, "Warning"); + + mvpw_set_key(warn_widget_a, warn_a_key_callback); +} + static void* busy_loop(void *arg) { @@ -8792,6 +8872,7 @@ gui_init(char *server, char *replaytv) playlist_init(); busy_init(); warn_init(); + warn_a_init(); screensaver_init(); mclient_init(); mclient_fullscreen_init(); diff --git a/src/mvpmc.h b/src/mvpmc.h index 1fc1d19..fe4a235 100644 --- a/src/mvpmc.h +++ b/src/mvpmc.h @@ -364,6 +364,7 @@ extern int is_image(char *item); extern void gui_error(char*); extern void gui_mesg(char*, char*); +extern void gui_mesg_a(char*, char*, int timeout); extern pthread_t video_write_thread; extern pthread_t audio_write_thread; diff --git a/src/web_config.c b/src/web_config.c index d4bc86e..a981f59 100644 --- a/src/web_config.c +++ b/src/web_config.c @@ -109,6 +109,7 @@ static void clear_ndelay( int fd ); static int hexit( char c ); void strencode( char* to, size_t tosize, const char* from ); int mvp_load_data(FILE *stream,char *); +int mvp_show_alert(char *); int mvp_config_radio(char *); int mvp_config_general(char *); int mvp_config_script(char *); @@ -277,14 +278,35 @@ www_mvpmc_start(void *arg) { mvp_config_general(line); } else if (strcmp(path,"/mount")==0 ) { mvp_config_script(line); + } else if (strcmp(path,"/alert")==0 ) { + if ( mvp_show_alert(line)==0 ) { + send_headers(stream, 202, "OK", (char*) 0, "text/html", -1, sb.st_mtime ); + (void) fprintf(stream, "<html><body><H1>Alert accepted</H1><BR><BR /><a href=\"%s\">%s</a></address>\n</body></html>\n", "/alert.html", "Return"); + fflush(stream); + fclose(stream); + } else { + send_error(stream, 400, "Bad request", (char*) 0, "Alert not accepted" ); + } + continue; } else { send_error(stream, 400, "Bad request", (char*) 0, "POST received not supported" ); continue; } } else { - send_error(stream, 400, "Bad request", (char*) 0, "POST received but not accepted" ); - continue; - + if (strcmp(path,"/alert")==0 ) { + if ( mvp_show_alert(line)==0 ) { + send_headers(stream, 202, "OK", (char*) 0, "text/html", -1, sb.st_mtime ); + (void) fprintf(stream, "<html><body><H1>Alert accepted</H1><BR>"); + fflush(stream); + fclose(stream); + } else { + send_error(stream, 400, "Bad request", (char*) 0, "Alert not accepted" ); + } + continue; + } else { + send_error(stream, 400, "Bad request", (char*) 0, "POST received but not accepted" ); + continue; + } } send_headers(stream, 202, "OK", (char*) 0, "text/html", -1, sb.st_mtime ); (void) fprintf(stream, "<html><body><H1>Changes accepted</H1><BR /><a href=\"%s\">%s</a></address>\n</body></html>\n", "/", "Return to configuration"); @@ -629,6 +651,49 @@ static void clear_ndelay( int fd ) #define IS_WEB_ENABLED(x) (web_config->bitmask & (1 << (x-WEB_CONFIG_USE_MYTH)) ) #define NOT_WEB_ENABLED(x) (0==(IS_WEB_ENABLED(x))) + +int mvp_show_alert(char *line) +{ + int rc = 0; + char *ptr,*equals; + char alert[1024]; + char title[51]; + char message[221]; + char *duplicate; + int x = 0; + int timeout = 0; + + duplicate = strdup(line); + ptr = strtok(duplicate, "&"); + equals = NULL; + while (ptr!=NULL) { + urldecode( alert, ptr ); + x = strcspn(alert, "="); + if (strstr(ptr, "timeout=")!= NULL) { + equals = strchr(alert,'='); + if (equals == NULL) { + rc = -1; + } else { + equals++; + timeout = atoi(equals); + } + } else { + snprintf(title,x+1,"%s",alert); + equals = strchr(alert,'='); + if (equals == NULL) { + rc = -1; + } else { + equals++; + snprintf(message,220,"%s",equals); + } + } + ptr = strtok(NULL,"&"); + } + if (rc != -1) gui_mesg_a(title, message, timeout); + free(duplicate); + return rc; +} + void playlist_key_callback(mvp_widget_t *widget, char key); void playlist_change(playlist_t *next); void fb_key_callback(mvp_widget_t *widget, char key); diff --git a/themes/orange.xml b/themes/orange.xml index e2bbef2..b2f93b1 100644 --- a/themes/orange.xml +++ b/themes/orange.xml @@ -226,6 +226,16 @@ <font>large</font> </widget> + <widget type="dialog" name="warning-alpha"> + <color type="bg" alpha="50%">black</color> + <color type="fg" alpha="50%">white</color> + <color type="title_bg" alpha="50%">black</color> + <color type="title_fg" alpha="50%">orange3</color> + <color type="border">white</color> + <style type="border_size">0</style> + <font>large</font> + </widget> + <widget type="dialog" name="about"> <color type="bg">gray30</color> <color type="fg">white</color> -- 1.6.2.4 ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ Mvpmc-devel mailing list Mvpmc-devel@... https://lists.sourceforge.net/lists/listinfo/mvpmc-devel |
| Free embeddable forum powered by Nabble | Forum Help |