void ViewMsgDialog::construct_edit_menu() { CmdList *cmdList; _edit_copy = new EditCopyCmd( "Copy", GETMSG(DT_catd, 1, 161, "Copy"), TRUE, this ); _edit_select_all = new EditSelectAllCmd( "Select All", GETMSG(DT_catd, 1, 162, "Select All"), TRUE, this ); cmdList = new CmdList("Edit", GETMSG(DT_catd, 1, 163, "Edit")); cmdList->add(_edit_copy); cmdList->add(_edit_select_all); _menuBar->addCommands(cmdList); }
void ViewMsgDialog::construct_attachment_menu() { // Separator for menu items SeparatorCmd *separator = new SeparatorCmd("Separator", "Separator", TRUE ); _attach_save_as = new SaveAttachCmd ( "Save As...", GETMSG(DT_catd, 1, 164, "Save As..."), GETMSG(DT_catd, 1, 165, "Mailer - Attachments - Save As"), FALSE, ViewMsgDialog::save_attachment_callback, this, this->baseWidget()); _attach_select_all = new SelectAllAttachsCmd( "Select All", GETMSG(DT_catd, 1, 166, "Select All"), this); _attachmentMenuList = new CmdList( "Attachments", GETMSG(DT_catd, 1, 167, "Attachments") ); _attachmentMenuList->add(_attach_save_as); _attachmentMenuList->add(_attach_select_all); _attachmentMenu = _menuBar->addCommands(_attachmentMenuList); }
QuitCmd::QuitCmd ( char *name, char *label, int active, MainWindow *mywindow) : WarnNoUndoCmd ( name, label, active ) { _mywindow = mywindow; _dialogParentWidget = _mywindow->baseWidget(); setQuestion ( GETMSG(catd, 1, 9, "Close this folder?") ); }
void AttachArea::attachment_summary( int live, int dead ) { char *buf = NULL; char * tmp1; char * tmp2; if ((live == 1) && (dead == 0)) { tmp1 = GETMSG(DT_catd, 3, 38, "attachment"); buf = new char[strlen(tmp1) + 64]; sprintf(buf, "%d %s", live, tmp1); } else if ((live >= 0) && (dead == 0)) { /* NL_COMMENT * "attachments" is the plural form of "attachment". */ tmp1 = GETMSG(DT_catd, 3, 39, "attachments"); buf = new char[strlen(tmp1) + 64]; sprintf(buf, "%d %s", live, tmp1); } else if ((live >= 0) && (dead > 0)) { tmp1 = GETMSG(DT_catd, 3, 40, "attachments"); tmp2 = GETMSG(DT_catd, 3, 41, "deleted"); buf = new char[strlen(tmp1) + strlen(tmp2) + 64]; sprintf(buf, "%d %s, %d %s", live, tmp1, dead, tmp2); } if (buf) { XmString buf_str = XmStringCreateLocalized(buf); XtVaSetValues(_attachments_summary, XmNlabelString, buf_str, NULL ); delete [] buf; XmStringFree(buf_str); } }
void singlemsg(int stat1, int stat) /* Gets a system message and displays it. Unlike LIB$SIGNAL it will not terminate the program on fatal errors */ { #if 0 int len; $DESCRIPTOR(mesg_desc , outbuf); if (stat1 !=0) { SYS$GETMSG(stat1,&mesg_desc.dsc$w_length, &mesg_desc,0,0); outbuf[mesg_desc.dsc$w_length]='\0'; put_disp(); mesg_desc.dsc$w_length = 255; } SYS$GETMSG(stat,&mesg_desc.dsc$w_length, &mesg_desc,0,0); outbuf[mesg_desc.dsc$w_length]='\0'; put_disp(); mesg_desc.dsc$w_length = 255; #endif }
void ViewMsgDialog::save_selected_attachment( char *selection ) { DtMailEnv mail_error; mail_error.clear(); DtMailEditor *editor = this->get_editor(); AttachArea *attacharea = editor->attachArea(); Attachment *attachment = attacharea->getSelectedAttachment(); // Get selected attachment, if none selected, then return. if ( attachment == NULL ) { // Let User know that no attachment has been selected??? int answer = 0; char *helpId = NULL; _genDialog->setToErrorDialog( GETMSG(DT_catd, 1, 177, "Mailer"), GETMSG(DT_catd, 2, 20, "An attachment needs to be selected before issuing the\n\"Save As\" command to save to a file.") ); helpId = DTMAILHELPSELECTATTACH; answer = _genDialog->post_and_return( GETMSG(DT_catd, 3, 75, "OK"), helpId ); return; } attachment->saveToFile(mail_error, selection); if (mail_error.isSet()) { // do something } }
char * DtMailEnv::getMessageText(int set, int msg, char *dft) { static int oneTimeFlag = 0; // Only attempt to open message catalog once char *message; if ((oneTimeFlag == 0) && (_errorCatalog == (nl_catd) -1)) { oneTimeFlag++; _errorCatalog = catopen((char*) DtMailCatalogDataFile, NL_CAT_LOCALE); } if (_errorCatalog != (nl_catd) -1) message = GETMSG(_errorCatalog, set, msg, dft); return message; }
static const char * vms_strerror( int status ) { short msglen; static char msgbuf[256]; $DESCRIPTOR(message, msgbuf); register ret; msgbuf[0] = 0; ret = SYS$GETMSG(status, &msglen, &message, 15, 0); if(ret != SS$_BUFFEROVF && ret != SS$_NORMAL) { (void) strcpy(msgbuf, "EVMSERR"); } return(msgbuf); }
void ViewMsgDialog::construct_attachment_popup(void) { _attachmentPopupMenuList = new CmdList( "AttachmentsPopup", "AttachmentsPopup"); LabelCmd *title = new LabelCmd ( "Mailer - Attachments", GETMSG(DT_catd, 1, 168, "Mailer - Attachments"), TRUE); SeparatorCmd *separator = new SeparatorCmd("Separator","Separator", TRUE ); _attachmentPopupMenuList->add(title); _attachmentPopupMenuList->add(separator); _attachmentPopupMenuList->add(_attach_save_as); _attachmentPopupMenuList->add(_attach_select_all); _menuPopupAtt = new MenuBar(my_editor->attachArea()->getClipWindow(), "ViewMsgAttachmentPopup", XmMENU_POPUP); _attachmentPopupMenu = _menuPopupAtt->addCommands(_attachmentPopupMenuList, FALSE, XmMENU_POPUP); }
void ViewMsgDialog::construct_help_menu() { CmdList * cmdList; // Separator for menu items SeparatorCmd *separator= new SeparatorCmd("Separator", "Separator", TRUE ); _overview = new OnAppCmd("Overview", GETMSG(DT_catd, 1, 170, "Overview"), TRUE, this); _tasks = new TasksCmd("Tasks", GETMSG(DT_catd, 1, 171, "Tasks"), TRUE, this); _reference = new ReferenceCmd("Reference", GETMSG(DT_catd, 1, 172, "Reference"), TRUE, this); _on_item = new OnItemCmd("On Item", GETMSG(DT_catd, 1, 173, "On Item"), TRUE, this); _using_help = new UsingHelpCmd("Using Help", GETMSG(DT_catd, 1, 174, "Using Help"), TRUE, this); cmdList = new CmdList( "Help", GETMSG(DT_catd, 1, 175, "Help") ); cmdList->add ( _overview ); cmdList->add ( separator ); cmdList->add ( _tasks ); cmdList->add ( _reference ); cmdList->add ( separator ); cmdList->add ( _on_item ); cmdList->add ( separator ); cmdList->add ( _using_help ); cmdList->add ( separator ); _about_mailer = new RelNoteCmd("About Mailer", GETMSG(DT_catd, 1, 176, "About Mailer..."), TRUE, this); cmdList->add ( _about_mailer ); // Make help menu show up on right side of menubar. _menuBar->addCommands ( cmdList, TRUE ); }
void ViewMsgDialog::construct_text_popup(void) { if (theApplication->bMenuButton() != Button3) return; _textPopupMenuList = new CmdList("TextPopup", "TextPopup"); LabelCmd *title = new LabelCmd ( "Mailer - Text", GETMSG(DT_catd, 1, 169, "Mailer - Text"), TRUE); SeparatorCmd *separator = new SeparatorCmd("Separator", "Separator", TRUE ); _textPopupMenuList->add(title); _textPopupMenuList->add(separator); _textPopupMenuList->add(_edit_copy); _textPopupMenuList->add(_edit_select_all); Widget parent = my_editor->textEditor()->get_editor(); _menuPopupText = new MenuBar(parent, "ViewMsgTextPopup", XmMENU_POPUP); _textPopupMenu = _menuPopupText->addCommands(_textPopupMenuList, FALSE, XmMENU_POPUP); }
void AttachArea::addToRowOfAttachmentsStatus() { XmString labelStr2; // Size of first label labelStr2 = XmStringCreateLocalized( GETMSG(DT_catd, 3, 37, "Summary of attachments")); _attachments_summary = XtCreateManagedWidget("Attachments_Summary", xmLabelWidgetClass, rowOfAttachmentsStatus, NULL, 0); XtVaSetValues(_attachments_summary, XmNalignment, XmALIGNMENT_END, XmNlabelString, labelStr2, XmNrightAttachment, XmATTACH_FORM, NULL ); XmStringFree(labelStr2); }
VMS_MSG (int status) /* Routine to put out the VMS operating system error (if one occurs). */ { #include <descrip.h> char errstr[81], buf[120]; $DESCRIPTOR(errdesc, errstr); short length; #define err_out(msg) fprintf (stderr,msg) /* Check for no error or standard error */ if (~status & 1) { status = status & 0x8000 ? status & 0xFFFFFFF : status & 0xFFFF; if (SYS$GETMSG(status, &length, &errdesc, 1, 0) == SS$_NORMAL) { errstr[length] = '\0'; (void) sprintf(buf, "<0x%x> %s", status, errdesc.dsc$a_pointer); err_out(buf); } else err_out("System error"); } }
Widget DmxPrintSetup::createPrintSetupDialog (Widget parent) { PrintSetupWidgets *widgets; XmString xms; // // Create the app-specific widgets for the Setup Dialog. widgets = (PrintSetupWidgets *) XtMalloc(sizeof(PrintSetupWidgets)); // // Create the DtPrintSetupDialog and specify that the application // specific area be located below the generic area. // Save the PrintSetupWidgets record as UserData so it can be // retrieved later. // widgets->dtprint_setup = DtCreatePrintSetupDialog(parent, "Setup", NULL, 0); XtVaSetValues( widgets->dtprint_setup, DtNworkAreaLocation, DtWORK_AREA_BOTTOM, XmNuserData, widgets, NULL); XtAddCallback( widgets->dtprint_setup, XmNhelpCallback, HelpCB, (void *)DTMAILPRINTSETUPDIALOG); XtAddCallback( widgets->dtprint_setup, XmNdestroyCallback, &DmxPrintSetup::destroyPrintSetupDialogCB, (XtPointer) widgets); widgets->form = XtVaCreateWidget( "PrintSetupForm", xmFormWidgetClass, widgets->dtprint_setup, NULL); xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 12, "Print Separately")); widgets->print_separately_tb = XtVaCreateManagedWidget( "PrintSeparatelyTB", xmToggleButtonWidgetClass, widgets->form, XmNalignment, XmALIGNMENT_BEGINNING, XmNlabelString, xms, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); XmStringFree(xms); xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 13, "Use Word Wrap")); widgets->use_word_wrap_tb = XtVaCreateManagedWidget( "UseWordWrapTB", xmToggleButtonWidgetClass, widgets->form, XmNalignment, XmALIGNMENT_BEGINNING, XmNlabelString, xms, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widgets->print_separately_tb, NULL); XmStringFree(xms); xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 20, "More ...")); widgets->more_options_pb = XtVaCreateManagedWidget( "PrintOptionsPB", xmPushButtonWidgetClass, widgets->form, XmNalignment, XmALIGNMENT_BEGINNING, XmNlabelString, xms, XmNleftAttachment, XmATTACH_NONE, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widgets->use_word_wrap_tb, NULL); XmStringFree(xms); XtAddCallback( widgets->more_options_pb, XmNactivateCallback, &DmxPrintSetup::moreOptionsCB, (XtPointer) NULL); widgets->checkbox_tb = XtNameToWidget(widgets->dtprint_setup, "DestRadioBox.button_1"); widgets->printer_name_tf = XtNameToWidget(widgets->dtprint_setup, "Name"); if (NULL != widgets->checkbox_tb) XtAddCallback( widgets->checkbox_tb, XmNvalueChangedCallback, &DmxPrintSetup::destinationChangedCB, (XtPointer) widgets); XtManageChild(widgets->form); return(widgets->dtprint_setup); }
/* Handles an incoming kvmessage REQMSG, and populates the appropriate fields * of RESPMSG as a response. RESPMSG and REQMSG both must point to valid * kvmessage_t structs. Assumes that the request should be handled as a TPC * message. This should also log enough information in the server's TPC log to * be able to recreate the current state of the server upon recovering from * failure. See the spec for details on logic and error messages. * * Checkpoint 2 only. */ void kvserver_handle_tpc(kvserver_t *server, kvmessage_t *reqmsg, kvmessage_t *respmsg) { // OUR CODE HERE int error = -1; bool initial_check = true; if (respmsg == NULL) { return; } else if (reqmsg == NULL || server == NULL) { goto unsuccessful_request; } else if (reqmsg->key == NULL) { if (reqmsg->type == GETREQ || reqmsg->type == PUTREQ || reqmsg->type == DELREQ) { goto unsuccessful_request; } } else if (reqmsg->value == NULL && reqmsg->type == PUTREQ) { goto unsuccessful_request; } else if (server->state == TPC_INIT) { initial_check = false; goto unsuccessful_request; } initial_check = false; switch (reqmsg->type) { case GETREQ: if ((error = kvserver_get(server, reqmsg->key, &reqmsg->value)) == 0) { respmsg->type = GETRESP; respmsg->key = reqmsg->key; respmsg->value = reqmsg->value; } else { goto unsuccessful_request; } break; case PUTREQ: if (server->state == TPC_WAIT) { initial_check = true; goto unsuccessful_request; } server->state = TPC_WAIT; tpclog_log(&server->log, PUTREQ, reqmsg->key, reqmsg->value); if ((error = kvserver_put_check(server, reqmsg->key, reqmsg->value)) == 0) { if ((error = copy_and_store_kvmessage(server, reqmsg)) == -1) { server->state = TPC_READY; goto unsuccessful_request; } respmsg->type = VOTE_COMMIT; } else { server->state = TPC_READY; respmsg->type = VOTE_ABORT; respmsg->message = GETMSG(error); } break; case DELREQ: if (server->state == TPC_WAIT) { initial_check = true; goto unsuccessful_request; } server->state = TPC_WAIT; tpclog_log(&server->log, DELREQ, reqmsg->key, reqmsg->value); if ((error = kvserver_del_check(server, reqmsg->key)) == 0) { if ((error = copy_and_store_kvmessage(server, reqmsg)) == -1) { server->state = TPC_READY; goto unsuccessful_request; } respmsg->type = VOTE_COMMIT; } else { server->state = TPC_READY; respmsg->type = VOTE_ABORT; respmsg->message = GETMSG(error); // need this field in tests.. specs forgot to say } break; case COMMIT: server->state = TPC_READY; tpclog_log(&server->log, COMMIT, NULL, NULL); if (server->msg->type == PUTREQ) { if ((error = kvserver_put(server, server->msg->key, server->msg->value)) < 0) { goto unsuccessful_request; } respmsg->type = ACK; } else { // type DELREQ if ((error = kvserver_del(server, server->msg->key)) < 0) { goto unsuccessful_request; } respmsg->type = ACK; } break; case ABORT: server->state = TPC_READY; tpclog_log(&server->log, ABORT, NULL, NULL); respmsg->type = ACK; break; default: respmsg->type = RESP; respmsg->message = ERRMSG_INVALID_REQUEST; break; } return; /* All unsuccessful requests will be handled in the same manner. */ unsuccessful_request: respmsg->type = RESP; respmsg->message = (initial_check) ? ERRMSG_INVALID_REQUEST : GETMSG(error); }
void AttachArea::setAttachmentsLabel( ) { char *c = new char[256]; XmString xmstr; String str; unsigned int last_displayCount, last_selectedCount; unsigned int displayCount = _iconCount - _deleteCount; unsigned int attachmentsSize; if((displayCount) == 0) { XtUnmanageChild(_no_attachments_label); XtUnmanageChild(_attachments_label); XtUnmanageChild(_size_attachments_label); XtUnmanageChild(_no_selected_label); XtUnmanageChild(_selected_label); XtUnmanageChild(_size_selected_label); } else { CalcAttachmentsSize(); attachmentsSize = getAttachmentsSize(); // Number of Attachments XtVaGetValues(_no_attachments_label, XmNlabelString, &xmstr, NULL); str = NULL; str = (char *) _XmStringUngenerate( xmstr, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); if (NULL == str) return; // internal error last_displayCount = (unsigned int)strtol(str, NULL, 10); XtFree(str); // Number of Attachments Selected XtVaGetValues(_no_selected_label, XmNlabelString, &xmstr, NULL); str = NULL; str = (char *) _XmStringUngenerate( xmstr, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); if (NULL == str) return; // internal error last_selectedCount = (unsigned int)strtol(str, NULL, 10); XtFree(str); if((last_displayCount == 0 && displayCount == 1) || (last_displayCount == 2 && displayCount == 1)) { sprintf(c, GETMSG(DT_catd, 12, 1, "Attachment")); XtVaSetValues(_attachments_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); } else if(last_displayCount == 1 && displayCount == 2) { sprintf(c, GETMSG(DT_catd, 12, 2, "Attachments")); XtVaSetValues(_attachments_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); } if(last_displayCount != displayCount) { sprintf(c, GETMSG(DT_catd, 12, 3, "displayCount")); XtVaSetValues(_no_attachments_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); } sprintf(c, "(%s),", calcKbytes(attachmentsSize)); XtVaSetValues(_size_attachments_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); if(last_selectedCount != _iconSelectedCount) { sprintf(c, "%d", _iconSelectedCount); XtVaSetValues(_no_selected_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); sprintf(c, "(%s)", calcKbytes(getSelectedAttachmentsSize())); XtVaSetValues(_size_selected_label, XtVaTypedArg, XmNlabelString, XtRString, c, strlen(c)+1, NULL); } if(!XtIsManaged(_no_attachments_label)) { XtManageChild(_no_attachments_label); XtManageChild(_attachments_label); XtManageChild(_size_attachments_label); XtManageChild(_no_selected_label); XtManageChild(_selected_label); XtManageChild(_size_selected_label); } } delete [] c; }
void DmxPrintSetup::attachPrintSetupDialog (void) { unsigned char is_set; Widget dialog; #ifdef REUSE_PRINT_SETUP_DIALOGS if (DmxPrintSetup_default_dtprint_setup != NULL) { // // Attempt to reuse the last print setup and print display connection. // _dtprint_setup = DmxPrintSetup_default_dtprint_setup; DmxPrintSetup_default_dtprint_setup = NULL; } else _dtprint_setup = createPrintSetupDialog(theRoamApp.baseWidget()); #else _dtprint_setup = createPrintSetupDialog(_parent); #endif // // Copy the information about the widgets into the setup. // XtVaGetValues(_dtprint_setup, XmNuserData, &_widgets, NULL); // // Add the setup-specific callbacks // XtAddCallback( _dtprint_setup, DtNprintCallback, DmxPrintSetup::printCB, (XtPointer) this); XtAddCallback( _dtprint_setup, DtNcancelCallback, _cancelCB, (XtPointer) _cancelClosure); XtAddCallback( _dtprint_setup, DtNclosePrintDisplayCallback, _closeDisplayCB, (XtPointer) _closeDisplayClosure); XtAddCallback( _dtprint_setup, DtNsetupCallback, _pdmSetupCB, (XtPointer) _pdmSetupClosure); is_set = (_print_separately) ? XmSET : XmUNSET; XtVaSetValues(_widgets->print_separately_tb, XmNset, is_set, NULL); is_set = (_use_word_wrap) ? XmSET : XmUNSET; XtVaSetValues(_widgets->use_word_wrap_tb, XmNset, is_set, NULL); if (DTM_TRUE == _print_to_file) XtVaSetValues( _dtprint_setup, DtNprintDestination, DtPRINT_TO_FILE, NULL); else XtVaSetValues( _dtprint_setup, DtNprintDestination, DtPRINT_TO_PRINTER, NULL); if (NULL != _printer_name) XtVaSetValues(_dtprint_setup, DtNprinterName, _printer_name, NULL); if (NULL != _filename) XtVaSetValues(_dtprint_setup, DtNfileName, _filename, NULL); dialog = XtParent(_dtprint_setup); if (NULL != dialog && XtIsShell(dialog)) { char *title = (char*) GETMSG(DT_catd, 21, 21, "Mailer - Print Setup"); XtVaSetValues(dialog, XmNtitle, title, NULL); } else { fprintf(stderr, "Print Setup box is not parented to a shell\n"); } }
// // Look for all matching messages. // Boolean FindDialog::findMatching(Boolean findAll) { // TODO - CHECK ERROR!!! DtMailEnv error; unsigned int matchCount = 0; /* NL_COMMENT * This string is displayed on the find dialog status line * when searching for a matching message. */ setStatus(GETMSG(DT_catd, 1, 231, "Searching...")); busyCursor(); theRoamApp.busyAllWindows(NULL); // // Get the active list. // MsgScrollingList * displayList = _roamWindow->list(); // // Find the max. number of messages that we are to find matching. // int numberMessages = displayList->get_num_messages(); // // Are there any messages? // if (numberMessages > 0) { // // A pointer to the currently interesting message. // register DtMailMessageHandle currentHandle = NULL; // // The offset of the currentHandle in the MsgScrollingList. // register int handleOffset; // // Find the current message. We would always start from the // currently selected message. // // Get the handle to the currently displaied message. // DtMailMessageHandle initialHandle = displayList->current_msg_handle(); // // Get the list of DtMailMessageHandle's. MsgHndArray * msgHandles = displayList->get_messages(); // // Up to all of them can match, allocate and clear the list. // DtMailMessageHandle * matchList = NULL; if (findAll) { matchList = new DtMailMessageHandle[numberMessages+1]; } unsigned int matchOffset = 0; // // Deselect all messages. // XmListDeselectAllItems(displayList->baseWidget()); // // Start the search from the initially displaied message (+1). // handleOffset = displayList->position(initialHandle) - 1; if (_searchForward) { handleOffset++; if (handleOffset >= numberMessages) { handleOffset = 0; } } else { handleOffset--; if (handleOffset < 0) { handleOffset = numberMessages - 1; } } for (; handleOffset < numberMessages;) { currentHandle = msgHandles->at(handleOffset)->message_handle; // // See if this message is a match, if it is... // if (compareMessage(currentHandle)) { matchCount++; // // If we are finding all, then add to the list. // If not, then display this message and we are done. // if (findAll) { matchList[matchOffset++] = currentHandle; } else { XmListDeselectAllItems(displayList->baseWidget()); //displayList->set_selected_item_position(handleOffset); displayList->display_and_select_message(error, currentHandle); break; // Only one. } } // // If we have looped back to the initial // message (handle), then we are done. // if (currentHandle == initialHandle) { break; } // // Get the next message. // // If we have reached the end, start over. // (as if the list was a circular list) // // We loop forward (_searchForward == TRUE) else we loop backward. // if (_searchForward) { handleOffset++; if (handleOffset >= numberMessages) { handleOffset = 0; } } else { handleOffset--; if (handleOffset < 0) { handleOffset = numberMessages - 1; } } currentHandle = msgHandles->at(handleOffset)->message_handle; } // // Select all the messages that match, and display the last // one in the list. // if (findAll) { displayList->select_all_and_display_last(error, matchList, matchCount); if (matchCount > 0) { char *line = new char[80]; /* NL_COMMENT * These strings are displayed on the find dialog status line * when one or more matching messages are found. The first * string is displayed when there is one matching message, * and the second string is displayed when there is more than * one. The %d is the number of messages that matched. */ if (matchCount == 1) { strcpy(line, GETMSG(DT_catd, 1, 232, "1 message selected")); } else { sprintf(line, GETMSG(DT_catd, 1, 233, "%d messages selected"), matchCount); } setStatus(line); delete [] line; } // Clean up. delete matchList; matchList = NULL; } } normalCursor(); theRoamApp.unbusyAllWindows(); if (error.isNotSet()) { if (matchCount > 0) { if (!findAll) { clearStatus(); } return(TRUE); } } /* NL_COMMENT * This string is displayed on the find dialog status line when * no matching messages were found. */ setStatus(GETMSG(DT_catd, 1, 234, "No matches were found")); return(False); }
// // Create the guts of the dialog // Widget FindDialog::createWorkArea(Widget dialog) { // TODO - CHECK ERROR!!! Widget *label = new Widget[_num_text_fields]; register unsigned int offset; _name = GETMSG(DT_catd, 1, 192, "Mailer - Find"); title(_name); // make this a modal dialog /* XtVaSetValues (dialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL); */ printHelpId("dialog", dialog); /* add help callback */ // XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId); Widget fd_pane = XtVaCreateWidget ("fd_pane", xmPanedWindowWidgetClass, dialog, XmNsashWidth, 1, XmNsashHeight, 1, NULL); printHelpId ("fd_pane", fd_pane); // add help callback // XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId); Widget fd_form = XtVaCreateWidget ("fd_form", xmFormWidgetClass, fd_pane, XmNfractionBase, 100, NULL); printHelpId ("fd_form", fd_form); // add help callback // XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId); Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox", xmRowColumnWidgetClass, fd_form, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_POSITION, XmNrightAttachment, XmATTACH_POSITION, XmNleftPosition, 5, XmNrightPosition, 95, XmNpacking, XmPACK_COLUMN, XmNnumColumns, 2, XmNorientation, XmVERTICAL, XmNisAligned, True, XmNentryAlignment, XmALIGNMENT_END, XmNentryVerticalAlignment, XmALIGNMENT_CENTER, NULL); printHelpId ("_fd_labelbox", _fd_labelbox); // add help callback // XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId); Widget *_fd_labels = new Widget [_num_text_fields]; int _fd_i = 0; for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++) { _fd_labels [_fd_i] = XtVaCreateManagedWidget ( _text_labels [_fd_i], xmLabelGadgetClass, _fd_labelbox, NULL); printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]); // naturally, this is bogus --must be fixed to return proper label // add help callback // XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId); } for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++) { _text_fields [_fd_i] = XtVaCreateManagedWidget ( _text_names [_fd_i], xmTextFieldWidgetClass, _fd_labelbox, NULL); printHelpId ("_text_fields [%s]", _text_fields [_fd_i]); // naturally, this is bogus --must be fixed to return proper label // add help callback // XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId); XtAddCallback(_text_fields [_fd_i], XmNactivateCallback, (XtCallbackProc)textFieldCallback, (XtPointer)this); } XmString strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward")); XmString strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward")); Widget fd_direction = XmVaCreateSimpleRadioBox(fd_form, "Direction", 0, // Initial selection directionCallback, //NULL, XmVaRADIOBUTTON, strForward, NULL, NULL, NULL, XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL, XmNuserData, this, XmNsensitive, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, _fd_labelbox, XmNorientation, XmHORIZONTAL, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 33, NULL); printHelpId ("fd_direction", fd_direction); // add help callback //XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId); XmStringFree(strForward); XmStringFree(strBackward); // // Now create the Action Area. // #define TIGHTNESS 20 register Widget widget; Widget fd_action = XtVaCreateWidget("actionArea", xmFormWidgetClass, fd_pane, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNfractionBase, TIGHTNESS * _num_buttons-1, NULL); printHelpId ("actionArea", fd_action); // add help callback //XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId); for (offset = 0; offset < _num_buttons; offset++) { widget = XtVaCreateManagedWidget(_buttonData[offset].label, xmPushButtonWidgetClass, fd_action, XmNleftAttachment, offset ? XmATTACH_POSITION:XmATTACH_FORM, XmNleftPosition, TIGHTNESS * offset, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM, XmNrightPosition, TIGHTNESS * offset + (TIGHTNESS - 1), XmNshowAsDefault, offset == 0, NULL); // again, bogus -- doesn't each one need a unique tag? printHelpId ("widget", widget); // add help callback //XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId); if (_buttonData[offset].callback != NULL) { XtAddCallback(widget, XmNactivateCallback, _buttonData[offset].callback, _buttonData[offset].data); } if (offset == 0) { Dimension height; Dimension margin; XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL); XtVaGetValues(widget, XmNheight, &height, NULL); height +=2 * margin; XtVaSetValues(fd_action, XmNdefaultButton, widget, XmNpaneMaximum, height, XmNpaneMinimum, height, NULL); } } _status_text = XtVaCreateManagedWidget("StatusLabel", xmLabelWidgetClass, fd_pane, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNalignment, XmALIGNMENT_BEGINNING, NULL); Dimension height; XtWidgetGeometry size; size.request_mode = CWHeight; XtQueryGeometry(_status_text, NULL, &size); XtVaSetValues(_status_text, XmNpaneMaximum, size.height, XmNpaneMinimum, size.height, NULL); clearStatus(); XtManageChild (fd_form); XtManageChild (fd_direction); XtManageChild(fd_action); XtManageChild(fd_pane); XtManageChild(dialog); // Make sure get the height of the dialog after it has been // managed. XtVaGetValues(dialog, XmNheight, &height, NULL); XtVaSetValues(dialog, XmNmappedWhenManaged, True, XmNminHeight, height, NULL); XtRealizeWidget(dialog); return (fd_pane); }
// // The only constructor. // FindDialog::FindDialog(RoamMenuWindow *parent) : Dialog("find", parent) { _roamWindow = parent; _num_text_fields = 4; _num_buttons = 5; // // Allocate storage for labels, widgets, and data. // _text_labels = new char *[_num_text_fields]; _text_names = new char *[_num_text_fields]; _text_values = new char *[_num_text_fields]; _text_abstract_name = new char *[_num_text_fields]; _text_fields = new Widget[_num_text_fields]; _buttonData = new ActionAreaItem[_num_buttons]; _searchForward = TRUE; // // Initialize the buttons. // _buttonData[0].label = strdup(GETMSG(DT_catd, 1, 183, "Find")); _buttonData[0].callback = findCallback; _buttonData[0].data = (caddr_t) this; #ifdef NL_OBSOLETE /* * NL_COMMENT * This is an obsolete message. Replaced by message 220 in set 1 */ _buttonData[1].label = strdup(GETMSG(DT_catd, 1, 184, "Find & Select All")); #endif /* * NL_COMMENT * This message replaces message 184 in set 1 */ _buttonData[1].label = strdup(GETMSG(DT_catd, 1, 220, "Select All")); _buttonData[1].callback = findSelectAllCallback; _buttonData[1].data = (caddr_t) this; _buttonData[2].label = strdup(GETMSG(DT_catd, 1, 185, "Clear")); _buttonData[2].callback = clearCallback; _buttonData[2].data = (caddr_t) this; _buttonData[3].label = strdup(GETMSG(DT_catd, 1, 186, "Close")); _buttonData[3].callback = closeCallback; _buttonData[3].data = (caddr_t) this; _buttonData[4].label = strdup(GETMSG(DT_catd, 1, 187, "Help")); _buttonData[4].callback = HelpCB; _buttonData[4].data = (caddr_t) DTMAILFINDDIALOG; _text_labels[0] = strdup(GETMSG(DT_catd, 1, 188, "To:")); _text_labels[1] = strdup(GETMSG(DT_catd, 1, 189, "From:")); _text_labels[2] = strdup(GETMSG(DT_catd, 1, 190, "Subject:")); _text_labels[3] = strdup(GETMSG(DT_catd, 1, 191, "Cc:")); // These strings should not be translated. They are // the Motif names for the widgets that will be created (they are // not the labels). _text_names[0] = "To"; _text_names[1] = "From"; _text_names[2] = "Subject"; _text_names[3] = "Cc"; // // Initialize the names of the fields to the abstract // names used by libDtMail. // _text_abstract_name[0] = strdup(DtMailMessageTo); _text_abstract_name[1] = strdup(DtMailMessageSender); _text_abstract_name[2] = strdup(DtMailMessageSubject); _text_abstract_name[3] = strdup(DtMailMessageCc); }
Attachment* AttachArea::addAttachment( DtMail::Message* msg, DtMail::BodyPart *lastAttBP, char *filename, char *name ) { int fd; struct stat s; Boolean validtype = TRUE; DtMail::BodyPart * bp = NULL; DtMailEnv mail_error; int answer; char *helpId = NULL; mail_error.clear(); char *errormsg = new char[512]; char *buf = new char[2048]; char *buffer = NULL, *lbl; char *fname_start; for (fname_start = filename + strlen(filename) - 1; fname_start >= filename && *fname_start != '/'; fname_start--) { continue; } if (*fname_start == '/') { fname_start += 1; } bp = msg->newBodyPart(mail_error, lastAttBP); if (SafeAccess(filename, F_OK) != 0) { sprintf(buf, GETMSG(DT_catd, 3, 34, "%s does not exist."), filename); answer = this->handleErrorDialog(GETMSG(DT_catd, 1, 81, "Mailer"), buf); delete [] buf; delete [] errormsg; return(NULL); } SafeStat(filename, &s); if(S_ISFIFO(s.st_mode)) { sprintf(errormsg, GETMSG(DT_catd, 12, 4, "Cannot attach FIFO files: %s"), filename); validtype = FALSE; } else if(S_ISCHR(s.st_mode)) { sprintf( errormsg, GETMSG(DT_catd, 12, 5, "Cannot attach character special files: %s"), filename ); validtype = FALSE; } else if(S_ISDIR(s.st_mode)) { sprintf( errormsg, GETMSG(DT_catd, 12, 6, "Cannot attach directories: %s"), filename ); validtype = FALSE; } else if(S_ISBLK(s.st_mode)) { sprintf(errormsg, GETMSG(DT_catd, 12, 7, "Cannot attach block special files: %s"), filename ); validtype = FALSE; } else if(S_ISSOCK(s.st_mode)) { sprintf(errormsg, GETMSG(DT_catd, 12, 8, "Cannot attach socket files: %s"), filename ); validtype = FALSE; } if(validtype == FALSE) { answer = this->handleErrorDialog(GETMSG(DT_catd, 1, 81, "Mailer"), errormsg, NULL); delete [] buf; delete [] errormsg; return(NULL); } fd = SafeOpen(filename, O_RDONLY); if (fd < 0) { sprintf(buf, GETMSG(DT_catd, 3, 35, "Unable to open %s."), filename); helpId = DTMAILHELPNOOPEN; answer = this->handleErrorDialog(GETMSG(DT_catd, 1, 82, "Mailer"), buf, helpId); delete [] buf; delete [] errormsg; return(NULL); } int page_size = (int)sysconf(_SC_PAGESIZE); size_t map_size = (size_t) (s.st_size + (page_size - (s.st_size % page_size))); char * map; #if defined(__osf__) // This version of mmap does NOT allow requested length to be // greater than the file size ... in contradiction to the // documentation (don't round up). map = (char *) mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); #else map = (char *) mmap(0, map_size, PROT_READ, MAP_PRIVATE, fd, 0); #endif if (map == (char *)-1) { // We could not map it for some reason. Let's just read it into // buffer and pass it to XmText. // buffer = new char[s.st_size + 1]; if (!buffer) { sprintf(buf, "%s", GETMSG(DT_catd, 3, 36, "Unable to allocate memory.")); helpId = DTMAILHELPNOALLOCMEM; answer = this->handleErrorDialog(GETMSG(DT_catd, 1, 83, "Mailer"), buf, helpId); return(NULL); } if (read(fd, buffer, (unsigned int) s.st_size) < 0) { SafeClose(fd); return(NULL); } buffer[s.st_size] = 0; bp->setContents( mail_error, buffer, s.st_size, NULL, fname_start, 0, NULL ); } else { // We now have a mapped file. XmText wants a zero terminated // buffer. We get luck with mmap because unless the file is // an even page size, we will have some zero fill bytes that // are legal to access. // // Of course in the case of an even page size file we must // copy the buffer, terminate it and then give it to XmText. // bp->setContents( mail_error, map, s.st_size, NULL, fname_start, 0, NULL ); munmap(map, map_size); } SafeClose(fd); // _iconCount + 1 because iconCount starts at 0 and we want // attachmentCount to begin at 1. attachmentCount is set to be // in the widget's userData. if(name) lbl = strdup(name); else { if(strchr(filename, '/') == NULL) // The name does not include a slash lbl = strdup(filename); else // The name does include a slash lbl = strdup(strrchr(filename, '/')+1); } Attachment *attachment = new Attachment(this, lbl, bp, _iconCount + 1); attachment->setAttachArea(this); attachment->initialize(); addToList( attachment ); // Update the display. The Compose Window needs immediate update. this->manageList(); delete [] buf; delete [] errormsg; return(attachment); }
/* Handles an incoming kvmessage REQMSG, and populates the appropriate fields * of RESPMSG as a response. RESPMSG and REQMSG both must point to valid * kvmessage_t structs. Assumes that the request should be handled as a non-TPC * message. See the spec for details on logic and error messages. */ void kvserver_handle_no_tpc(kvserver_t *server, kvmessage_t *reqmsg, kvmessage_t *respmsg) { // OUR CODE HERE bool initial_check = true; if (respmsg == NULL) { return; } else if (reqmsg == NULL || server == NULL) { goto unsuccessful_request; } else if (reqmsg->key == NULL) { if (reqmsg->type == GETREQ || reqmsg->type == PUTREQ || reqmsg->type == DELREQ) { goto unsuccessful_request; } } else if (reqmsg->value == NULL && reqmsg->type == PUTREQ) { goto unsuccessful_request; } else if (server->state == TPC_INIT) { initial_check = false; goto unsuccessful_request; } initial_check = false; int error = -1; switch (reqmsg->type) { case GETREQ: if ((error = kvserver_get(server, reqmsg->key, &reqmsg->value)) == 0) { respmsg->type = GETRESP; respmsg->key = reqmsg->key; respmsg->value = reqmsg->value; } else { goto unsuccessful_request; } break; case PUTREQ: if ((error = kvserver_put(server, reqmsg->key, reqmsg->value)) == 0) { respmsg->type = RESP; respmsg->message = MSG_SUCCESS; } else { goto unsuccessful_request; } break; case DELREQ: if ((error = kvserver_del(server, reqmsg->key)) == 0) { respmsg->type = RESP; respmsg->message = MSG_SUCCESS; } else { goto unsuccessful_request; } break; case INFO: respmsg->type = INFO; respmsg->message = kvserver_get_info_message(server); break; default: respmsg->type = RESP; respmsg->message = ERRMSG_NOT_IMPLEMENTED; break; } return; /* All unsuccessful requests will be handled in the same manner. */ unsuccessful_request: respmsg->type = RESP; respmsg->message = (initial_check) ? ERRMSG_INVALID_REQUEST : GETMSG(error); }