📄 sendedit.c
字号:
XtManageChild(headText->MainWidget());//// If there's no message, create one// FileMsgC *msg = icon->data->ChildMsg(); StringC title; msg->GetSubjectText(title); XtVaSetValues(*pub, XmNtitle, (char*)title, NULL);//// Show the headers// StringC headStr; msg->GetHeaderText(headStr); headText->SetString(headStr);//// Show the body// DisplayBody(msg); } // End if we're editing a message else { containerType = icon->data->conType;//// Turn off the header text field// XtUnmanageChild(headText->MainWidget()); XtVaSetValues(*pub, XmNtitle, (char*)icon->data->conStr, NULL);//// Display the tree// AddBodyTree(icon->data); } // End if we're not editing a message bodyText->ScrollTop(); bodyText->Defer(False); pub->changed = False;} // End Edit/*--------------------------------------------------------------- * Callback to handle part deletion */voidSendWinP::DoDeletePart(Widget, SendWinP *This, XtPointer){ if ( !ishApp->confPrefs->confirmDeleteGraphic ) { FinishDelete(NULL, This, NULL); return; }//// Build verification dialog if necessary// if ( !This->deleteWin ) { WArgList args; args.AutoUnmanage(True); if ( halApp->questionPM ) args.SymbolPixmap(halApp->questionPM); This->deleteWin = XmCreateQuestionDialog(*This->pub, "deleteWin", ARGS); XtAddCallback(This->deleteWin, XmNokCallback, (XtCallbackProc)FinishDelete, (XtPointer)This); XtAddCallback(This->deleteWin, XmNhelpCallback, (XtCallbackProc)HalAppC::DoHelp, (char *) "helpcard"); } PopupOver(This->deleteWin, *This->pub);} // End DeletePartvoidSendWinP::FinishDelete(Widget, SendWinP *This, XtPointer){ This->bodyText->RemoveGraphic(This->popupIcon); This->popupIcon = NULL;}/*--------------------------------------------------------------- * Callbacks to handle modification of container type */voidSendWinP::DoModMixed(Widget, SendWinP *This, XtPointer){ This->popupIcon->data->SetType("multipart/mixed");}voidSendWinP::DoModDigest(Widget, SendWinP *This, XtPointer){ This->popupIcon->data->SetType("multipart/digest");}voidSendWinP::DoModAlt(Widget, SendWinP *This, XtPointer){ This->popupIcon->data->SetType("multipart/alternative");}voidSendWinP::DoModParallel(Widget, SendWinP *This, XtPointer){ This->popupIcon->data->SetType("multipart/parallel");}/*--------------------------------------------------------------- * Method to load pixmaps used for attachment editing animation */voidSendWinP::LoadEditPixmaps(SendIconC *icon){ if ( editPixmaps->size() > 0 ) return; Window win = RootWindowOfScreen(halApp->screen); if ( !win ) return; StringC names; StringListC nameList; nameList.AllowDuplicates(TRUE); names = get_string(*pub, "editPixmaps", "edit-0.xbm" ); ExtractList(names, nameList);; u_int count = nameList.size(); for (int i=0; i<count; i++) { StringC *name = nameList[i]; PixmapC *pm = new PixmapC(*name, icon->regFgColor, icon->regBgColor, icon->invFgColor, icon->invBgColor, halApp->screen, win); void *tmp = (void*)pm; editPixmaps->add(tmp); }} // End LoadEditPixmaps/*--------------------------------------------------------------- * Callback to save composition to a file */voidSendWinP::DoSaveFile(Widget, SendWinP *This, XtPointer){//// Create dialog for getting file name// if ( !This->saveFileWin ) { This->saveFileWin = new FileChooserWinC(*This->pub, "saveCompositionWin"); This->saveFileWin->AddOkCallback((CallbackFn*)FinishSaveFile, This); This->saveFileWin->ShowDirsInFileList(False); This->saveFileWin->ShowFilesInFileList(True); This->saveFileWin->SetDirectory("."); This->saveFileWin->HideImap(); } // End if saveFileWin needed This->saveFileWin->Show(*This->pub);} // End DoSaveFile/*--------------------------------------------------------------- * Callback to handle selection of file in save dialog */voidSendWinP::FinishSaveFile(StringListC *list, SendWinP *This){ StringC name = *((*list)[0]); if ( !This->OkToSaveTo(name) ) return; if ( !This->Save(name) ) This->saveFileWin->HideOk(False); else { StringC msg("Composition saved to "); msg += name; This->pub->Message(msg); }} // End FinishSaveFile/*--------------------------------------------------------------- * Method to determine whether it's ok to save to the given file */BooleanSendWinP::OkToSaveTo(StringC& file){//// If the file doesn't exist, we're fine// if ( access(file, F_OK) != 0 ) return True;//// Make sure name is not a directory// if ( IsDir(file) ) { StringC errmsg = file; errmsg += " is a directory."; pub->PopupMessage(errmsg); return False; }//// See whether the file can be overwritten// if ( OverwriteQuery(file, *pub) == QUERY_YES ) { unlink(file); return True; } return False;} // End OkToSaveTo/*--------------------------------------------------------------- * Callback to load composition from a file */voidSendWinP::DoLoadFile(Widget, SendWinP *This, XtPointer){//// If clears are to be confirmed, clear now.// if ( ishApp->confPrefs->confirmClearSend ) { DoClear(NULL, This, NULL);//// If they didn't clear, return// if ( !This->pub->IsEmpty() ) return; }//// Create dialog for getting file name// if ( !This->loadFileWin ) { This->loadFileWin = new FileChooserWinC(*This->pub, "loadCompositionWin"); This->loadFileWin->AddOkCallback((CallbackFn*)FinishLoadFile, This); This->loadFileWin->ShowDirsInFileList(False); This->loadFileWin->ShowFilesInFileList(True); This->loadFileWin->SetDirectory("."); This->loadFileWin->HideImap(); } // End if loadFileWin needed This->loadFileWin->Show(*This->pub);} // End DoLoadFile/*--------------------------------------------------------------- * Callback to handle selection of file in load dialog */voidSendWinP::FinishLoadFile(StringListC *list, SendWinP *This){ StringC name = *((*list)[0]); This->pub->LoadFile(name);}/*--------------------------------------------------------------- * Function to make sure all newlines are following by whitespace in a * header field */static voidCheckNewlines(StringC& str){ str.Trim(); int pos = 0; u_int off = 0; while ( (pos=str.PosOf('\n', off)) >= 0 ) {//// Remove consecutive newlines// while ( str[pos+1] == '\n' ) str(pos+1,1) = "";//// Check for following whitespace// if ( !isspace(str[pos+1]) ) str(pos+1,0) = " "; off = pos+1; }} // End CheckNewlines/*--------------------------------------------------------------- * Method to save the contents of this window to a file */BooleanSendWinP::Save(char *cs){ if ( !cs && !editIcon && !editMsg ) { StringC errmsg("Trying to save with no edit part and no file name"); errmsg += "\nPlease report this error to Ishmail Support."; pub->PopupMessage(errmsg); return False; } pub->BusyCursor(True); pub->Message("Saving...");//// Save any child windows// u_int count = editWinList.size(); int i; for (i=0; i<count; i++) { SendWinC *editWin = (SendWinC *)*editWinList[i]; if ( editWin->IsShown() && editWin->Changed() ) { if ( !editWin->priv->Save() ) { pub->BusyCursor(False); pub->Message("Composition not saved."); return False; } } } if ( edit_pid ) { StringC errmsg("There is an external edit in progress.\n"); errmsg += "Please exit the editor before saving this message."; pub->PopupMessage(errmsg); pub->BusyCursor(False); pub->Message("Composition not saved."); return False; } if ( spell_pid ) { StringC errmsg("There is an external spell-check in progress.\n"); errmsg += "Please exit the spell checker before saving this message."; pub->PopupMessage(errmsg); pub->BusyCursor(False); pub->Message("Composition not saved."); return False; }//// Read the headers from the address fields// StringListC headList; StringListC contList; StringC headStr; if ( !pub->IsEditOnly() ) { StringC to, sub, cc, bcc, fcc, other; toText->GetString(to, TT_PLAIN); subText->GetString(sub, TT_PLAIN); if ( pub->ccVis ) ccText->GetString(cc, TT_PLAIN); if ( pub->bccVis ) bccText->GetString(bcc, TT_PLAIN); if ( pub->fccVis ) fccText->GetString(fcc, TT_PLAIN); if ( pub->otherVis ) otherText->GetString(other, TT_PLAIN);//// Make sure newlines are followed by whitespace// CheckNewlines(to); CheckNewlines(cc); CheckNewlines(bcc); CheckNewlines(fcc);//// Add headers to list// if ( to.size() > 0 ) { headStr = "To: "; headStr += to; headList.add(headStr); } if ( sub.size() > 0 ) { headStr = "Subject: "; headStr += sub; headList.add(headStr); } if ( cc.size() > 0 ) { headStr = "Cc: "; headStr += cc; headList.add(headStr); } if ( bcc.size() > 0 ) { headStr = "Bcc: "; headStr += bcc; headList.add(headStr); } if ( fcc.size() > 0 ) { headStr = "Fcc: "; headStr += fcc; headList.add(headStr); } if ( other.size() > 0 ) { HeaderC *head = ExtractHeaders(other); while ( head ) { headStr = head->full; if ( head->key.StartsWith("Content-", IGNORE_CASE) ) contList.add(headStr); else headList.add(headStr); head = head->next; } } } // End if saving header fields//// Write the message body to a file. This may also generate additional// headers.// char *bf = tempnam(NULL, "body."); StringC bodyFile = bf; free(bf); OutgoingMailTypeT mailType; if ( !WriteBody(bodyFile, headList, contList, &mailType, /*saving=*/True) ) { unlink(bodyFile); pub->BusyCursor(False); pub->Message("Composition not saved."); return False; }//// Create the final save file// StringC saveFile; if ( cs ) saveFile = cs; else { cs = tempnam(NULL, "save."); saveFile = cs; free(cs); cs = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -