/* routines associated with displaying simple * information and sending mail to the author. A lot of this * is loosely based on code from Ftptool. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "robot.h" #include "patchlevel.h" #define TO_LEN 64 #ifndef MAILER #define MAILER "/usr/ucb/mail" #endif /* Can get help from a Web based location - can be specified * in the Makefile. * But, if not set up, choose "sensible" defaults */ #ifndef BROWSER #define BROWSER "netscape" #endif #ifndef WEB_HELP #define WEB_HELP "http://www.robotx.cx" #endif #define THE_WIDTH 550 #define PANEL_HEIGHT 27 Frame about_frame; Frame mail_frame; Panel about_panel; Textsw about_text; Panel mail_panel, mail_panel2; Textsw mail_text; Panel_item mail_add; Panel_item mail_cc; Panel_item mail_message; char cc_text[TO_LEN + 1]; char sys_buffer[240]; char about_message[] = "Robot is an open-source graph plotting and data analysis program.\n\ It has been used in many scientific fields including:\n\ astrophysics, solid state physics, psychology, and mathematics.\n\ \n\ http://www.robotx.cx\n\ \n\ Robot will run under (at least) the following systems:\n\ LINUX\n\ SunOS\n\ Solaris\n\ OSF on DEC Alpha's\n\ Ultrix on DECstations\n\ \n\ Robot is under near continual development and comments,\n\ bug reports etc. are invited.\n\ \n\ To obtain on-line help press the button marked Help\n\ (at least on a Sun, F1 on others) with the cursor positioned above\n\ the button or menu item of interest.\n\ If this doesn't work it's probably because the file robot.info\n\ isn't located in a directory listed in the HELPPATH environment\n\ variable.\n\ \n\ To get \"F1\" to act as the Help key you may need to edit your\n\ .xinitrc file:\n\ # Install function key \"F1\" as an Open Look \"Help\" key\n\ # This precludes its use by applications\n\ xmodmap -e \'keysym F1 = Help\'\n\ \n\ There is also a manual and several demonstration scripts are\n\ available.\n\ \n\ The demonstration scripts are located in the directory named Demos\n\ if you have the full robot distribution.\n\ The scripts can be run in several different ways:\n\ (i) Press the button labeled \"File\" and select a file.\n\ (ii) On the line labelled \"Robot Command:\" type:\n\ file Demos/xxxx.rob\n\ where Demos/xxxx.rob is the name of a file (this assumes Demos\n\ is the directory where the file is located).\n\ (iii) Using the OpenWindows file manager you can \"drag and drop\"\n\ a file onto the drop target (the square on the right).\n\ (iv) When you start robot you can give the name of the file to run\n\ on the command line.\n\ \n\ The latest version of Robot can be obtained by anonymous ftp\n\ from ftp.astro.psu.edu in the directory pub/astrod.\n\ \n\ \n\ I would appreciate receiving reprints of any papers that make use\n\ of this program. If you wish to cite this program you may reference\n\ Corbet, R.H.D., Larkin, C. & Nousek, J.A.,\n\ Proceedings of \"Astronomical Data Analysis and Software Systems\",\n\ Tucson, November, 1991. Astronomical Society of the Pacific Conference\n\ Series, 1992, Vol. 25, 106. (ISBN 0-937707-44-9)\n\ \n\ \n\ This software is to be considered prototype, developmental software and\n\ the right is reserved to make changes and improvements to this software\n\ at any time. Full copyright protection is retained. Users are\n\ authorized to make copies and use this software at their own risk. We\n\ make no representation about the suitability of this software for any\n\ purpose. It is provided \"as is\" without express or implied warranty.\n\ Modified copies of this software may be redistributed in line with the\n\ GPL (GNU) copying conditions.\n\ \n\ Robin Corbet\n\ Laboratory for High Energy Astrophysics\n\ Code 662\n\ NASA/Goddard Space Flight Center\n\ Greenbelt, MD 20771\n\ U.S.A.\n\ \n\n\ robot@robotx.cx\n\ \n\ (Also Universities Space Research Association)" ; void web_help() { sprintf(sys_buffer, "%s %s", BROWSER, WEB_HELP); system(sys_buffer); } void show_mail() { xv_set(mail_frame, XV_SHOW, TRUE, NULL); xv_set(mail_frame, FRAME_CMD_PUSHPIN_IN, TRUE, NULL); } void cancel_mail() { textsw_reset(mail_text, 0, 0); xv_set(mail_frame, XV_SHOW, FALSE, NULL); xv_set(mail_frame, FRAME_CMD_PUSHPIN_IN, FALSE, NULL); } void send_mail() { FILE *pp; char addr[TO_LEN + 1], ccmail[TO_LEN + 1], buf[BUFSIZ+1]; int last_was_NL; Textsw_index cur_pos, next_pos; static char *fb_cmd = NULL; last_was_NL = FALSE; strcpy(addr, (char *) xv_get(mail_add, PANEL_VALUE)); if ((int)xv_get(mail_text, TEXTSW_LENGTH) == 0) { totext2_("ERROR: NO TEXT IN MESSAGE."); return; } if (fb_cmd == NULL) fb_cmd = (char *)malloc((unsigned int)(strlen(MAILER) + TO_LEN + 1)); sprintf(fb_cmd, "%s %s", MAILER, addr); if ((pp = popen(fb_cmd, "w")) == NULL) { totext2_("POPEN ERROR; COULDN'T SEND FEEDBACK MESSAGE!"); return; } fprintf(pp, "~s Robot %-1.2fp%d \n\n", VERSION, PATCHLEVEL); fprintf(pp, "~c %s", (char *) xv_get(mail_cc, PANEL_VALUE)); fprintf(pp, "\n"); next_pos = 0; cur_pos = next_pos - BUFSIZ; while (next_pos == cur_pos + BUFSIZ) { cur_pos = next_pos; next_pos = (Textsw_index)xv_get(mail_text, TEXTSW_CONTENTS, cur_pos, buf, BUFSIZ); if ((next_pos - cur_pos) != 0) { buf[next_pos - cur_pos] = '\0'; fprintf(pp, "%s", buf); last_was_NL = (buf[next_pos-cur_pos-1] == '\n'); } } /* * Force last char out to be a newline */ if (!last_was_NL) putc('\n', pp); if(pclose(pp) != 0) { totext2_("ERROR: MAIL FAILED -- MESSAGE NOT SENT!"); return; } cancel_mail(); } /* A window to give information */ void about_frame_create(frame) Frame frame; { about_frame = xv_create(frame, FRAME_CMD, FRAME_LABEL, "About Robot", FRAME_SHOW_FOOTER, FALSE, FRAME_CMD_PUSHPIN_IN, TRUE, NULL); about_panel = xv_get(about_frame, FRAME_CMD_PANEL); xv_set(about_panel, /* XV_WIDTH, THE_WIDTH, */ XV_HEIGHT, PANEL_HEIGHT, XV_X, 0, PANEL_LAYOUT, PANEL_VERTICAL, NULL); xv_set(about_panel, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL); xv_create(about_panel, PANEL_BUTTON, XV_HELP_DATA, "robot:web_help", PANEL_LABEL_STRING, "Web Help...", PANEL_NOTIFY_PROC, web_help, NULL); xv_create(about_panel, PANEL_BUTTON, XV_HELP_DATA, "robot:send_mail", PANEL_LABEL_STRING, "Email...", PANEL_NOTIFY_PROC, show_mail, NULL); if(not_open_look){ xv_create(about_panel, PANEL_BUTTON, XV_HELP_DATA, "robot:dismiss", PANEL_LABEL_STRING, DISMISS, PANEL_NOTIFY_PROC, hide_me, NULL); } about_text = (Textsw) xv_create(about_frame, TEXTSW, XV_WIDTH, THE_WIDTH, WIN_BELOW, about_panel, XV_X, 0, XV_HEIGHT, 320, TEXTSW_READ_ONLY, TRUE, NULL); textsw_insert(about_text, about_message, strlen(about_message)); textsw_normalize_view(about_text, 0); window_fit(about_text); xv_set(about_panel, XV_WIDTH, xv_get(about_text, XV_WIDTH), NULL); window_fit(about_frame); /* and make the mailer window */ mail_frame = xv_create(frame, FRAME_CMD, FRAME_LABEL, "Send Mail to Author", FRAME_SHOW_FOOTER, FALSE, FRAME_CMD_PUSHPIN_IN, TRUE, NULL); mail_panel = xv_get(mail_frame, FRAME_CMD_PANEL); xv_set(mail_panel, XV_WIDTH, THE_WIDTH, /* XV_HEIGHT, 100, */ PANEL_LAYOUT, PANEL_VERTICAL, NULL); mail_message = xv_create(mail_panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Comments and problem reports welcome, author's address is given below", NULL); mail_add = xv_create(mail_panel, PANEL_TEXT, /* XV_X, 0, WIN_BELOW, mail_message, */ XV_HELP_DATA, "robot:mail_to", PANEL_VALUE, MY_ADDRESS, PANEL_LABEL_STRING, "To:", PANEL_VALUE_DISPLAY_LENGTH, 35, NULL); if(getenv("USER") != NULL){ sprintf(cc_text, "%s", (char *) getenv("USER")); if(getenv("HOST") != NULL){ strcat(cc_text, "@"); strcat(cc_text, (char *) getenv("HOST")); } } mail_cc = xv_create(mail_panel, PANEL_TEXT, /* XV_X, 0, WIN_BELOW, mail_add, */ XV_HELP_DATA, "robot:mail_cc", PANEL_VALUE, cc_text, PANEL_LABEL_STRING, "Cc:", PANEL_VALUE_DISPLAY_LENGTH, 35, NULL); xv_set(mail_panel, XV_HEIGHT, 2 * xv_get(mail_message, XV_HEIGHT) + 2 * xv_get(mail_add, XV_HEIGHT) + 2 * xv_get(mail_cc, XV_HEIGHT), NULL); mail_text = (Textsw) xv_create(mail_frame, TEXTSW, XV_WIDTH, THE_WIDTH, XV_HEIGHT, 120, XV_X, 0, WIN_BELOW, mail_panel, NULL); mail_panel2 = xv_create(mail_frame, PANEL, XV_WIDTH, THE_WIDTH, XV_HEIGHT, PANEL_HEIGHT, WIN_BELOW, mail_text, XV_X, 0, NULL); xv_create(mail_panel2, PANEL_BUTTON, XV_HELP_DATA, "robot:send", PANEL_LABEL_STRING, "Send", PANEL_NOTIFY_PROC, send_mail, XV_WIDTH, THE_WIDTH, NULL); xv_create(mail_panel2, PANEL_BUTTON, XV_HELP_DATA, "robot:mail_cancel", PANEL_LABEL_STRING, "Cancel", PANEL_NOTIFY_PROC, cancel_mail, NULL); window_fit(mail_frame); } void show_about() { xv_set(about_frame, XV_SHOW, TRUE, NULL); xv_set(about_frame, FRAME_CMD_PUSHPIN_IN, TRUE, NULL); }