📄 readfile.c
字号:
ishApp->saveMgr->SaveMsgToFile(This->pub->msg, *This->pub, This->pub->msg->folder && This->pub->msg->folder->writable);}/*--------------------------------------------------------------- * Callback to save message to the file named on the button that was * pressed. Used by Save->Recent and Save->Quick */voidReadWinP::DoSaveToButton(Widget w, ReadWinP *This, XtPointer){//// Get the folder name from the button label// XmString xstr; XtVaGetValues(w, XmNlabelString, &xstr, NULL); WXmString wstr(xstr); char *cs = wstr;//// If this is a quick-save, we need to build the full pathname// StringC name = XtName(w); if ( name == "quickPB" ) { QuickInfoT *cbData; XtVaGetValues(w, XmNuserData, &cbData, NULL); name = cbData->dir; if ( name.size() > 0 ) name += '/'; name += cs; } else { name = cs; } ishApp->saveMgr->SaveMsgToFolder(This->pub->msg, name, This->pub->fullFunction && ishApp->appPrefs->deleteSaved); XtFree(cs); XmStringFree(xstr);} // End DoSaveToButton/*--------------------------------------------------------------- * Callback to delete message */voidReadWinP::DoDelete(Widget, ReadWinP *This, XtPointer){ Boolean pinned = This->pub->Pinned(); This->pub->Unpin(); ishApp->mainWin->DeleteMsg(This->pub->msg); if ( pinned ) This->pub->Pin();}/*--------------------------------------------------------------- * Callback to delete message and close window */voidReadWinP::DoDelClose(Widget, ReadWinP *This, XtPointer){ MsgC *msg = This->pub->msg; This->pub->Hide(); ishApp->mainWin->DeleteMsg(msg);}/*--------------------------------------------------------------- * Callback to undelete message */voidReadWinP::DoUndelete(Widget, ReadWinP *This, XtPointer){ ishApp->mainWin->UndeleteMsg(This->pub->msg);}/*--------------------------------------------------------------- * Callback to print message */voidReadWinP::DoPrint(Widget, ReadWinP *This, XtPointer){ ishApp->mainWin->popupMsg = This->pub->msg; ishApp->mainWin->popupOnSelected = False; if ( !This->printWin ) This->printWin = new PrintWinC(*This->pub); This->printWin->HideOrder(); This->printWin->Show(*This->pub);}/*--------------------------------------------------------------- * Callback to pipe message */voidReadWinP::DoPipe(Widget, ReadWinP *This, XtPointer){ ishApp->mainWin->popupMsg = This->pub->msg; ishApp->mainWin->popupOnSelected = False; if ( !This->pipeWin ) This->pipeWin = new PipeWinC(*This->pub); This->pipeWin->HideOrder(); This->pipeWin->Show(*This->pub);}/*--------------------------------------------------------------- * Callback to convert from Sun attachment format to MIME format */voidReadWinP::DoSunToMime(Widget, ReadWinP *This, XtPointer){ This->pub->BusyCursor(True); char *cs = tempnam(NULL, "mime."); StringC newFile(cs); free(cs); StringC bound; GenBoundary(bound); MsgC *oldMsg = This->pub->msg; int status; // If IMAP message, we have it in memory, It must first be written // to a temp file before sun2mime can handle it. For other folder // types, the message is already in a local file. if ( oldMsg->IsImap() ) { cs = tempnam(NULL, "imap."); StringC msgFile(cs); free(cs); oldMsg->WriteFile(msgFile, True, True, False, False, False); status = sun2mime(msgFile, 0, 0 /* don't know size */, newFile, bound); unlink(msgFile); } else { MsgPartC *bod = oldMsg->Body(); status = sun2mime(bod->msgFile, bod->offset, bod->bytes, newFile, bound); } if ( status == 0 ) { int len = 0; struct stat stats; if ( stat(newFile, &stats) == 0 ) len = (int)stats.st_size; FileMsgC *newMsg = new FileMsgC(newFile, 0, len, True, oldMsg->folder); newMsg->SetNumber(oldMsg->Number()); ishApp->DisplayMessage(newMsg, This->pub); if ( oldMsg->folder ) oldMsg->folder->ReplaceMsg(oldMsg, newMsg); } This->pub->BusyCursor(False);} // End DoSunToMime/*--------------------------------------------------------------- * Callback for when decryption is complete */voidReadWinP::CryptDone(int, DisplayDataT *data){ char *file = (char*)data->icon; unlink(file); free(file); data->win->displayDataList.remove(data); delete data;}/*--------------------------------------------------------------- * Callback to pass message through decryptor */voidReadWinP::DoDecrypt(Widget, ReadWinP *This, XtPointer){ This->pub->BusyCursor(True);//// Write message body to a temp file// char *newFile = tempnam(NULL, "cryp."); if ( !This->pub->msg->WriteBody(newFile, False, False) ) { free(newFile); return; }//// Build a data record to store info about this process// DisplayDataT *data = new DisplayDataT; data->win = This; data->icon = (ReadIconC*)newFile;//// Build the command for display.// data->cmdStr = ishApp->readPrefs->decryptCmd; data->cmdStr.Replace("%s", newFile); data->pid = -1; CallbackC doneCb((CallbackFn*)CryptDone, data); data->pid = ForkIt(data->cmdStr, &doneCb);//// If the pid is < 0, an error occurred// if ( data->pid < 0 ) { This->pub->PopupMessage(ForkStatusMsg(data->cmdStr, (int)data->pid)); delete data; }//// Add this process to the list of running processes// else { void *tmp = (void*)data; This->displayDataList.add(tmp); } This->pub->BusyCursor(False);} // End DoDecrypt/*--------------------------------------------------------------- * Callback to pass message through authenticator */voidReadWinP::DoAuth(Widget, ReadWinP *This, XtPointer){ This->pub->BusyCursor(True);//// Write message body to a temp file// char *newFile = tempnam(NULL, "auth."); if ( !This->pub->msg->WriteBody(newFile, False, False) ) { free(newFile); return; }//// Build a data record to store info about this process// DisplayDataT *data = new DisplayDataT; data->win = This; data->icon = (ReadIconC*)newFile;//// Build the command for display.// data->cmdStr = ishApp->readPrefs->authCmd; data->cmdStr.Replace("%s", newFile); data->pid = -1; CallbackC doneCb((CallbackFn*)CryptDone, data); data->pid = ForkIt(data->cmdStr, &doneCb);//// If the pid is < 0, an error occurred// if ( data->pid < 0 ) { This->pub->PopupMessage(ForkStatusMsg(data->cmdStr, (int)data->pid)); delete data; }//// Add this process to the list of running processes// else { void *tmp = (void*)data; This->displayDataList.add(tmp); } This->pub->BusyCursor(False);} // End DoAuth/*--------------------------------------------------------------- * Callback to edit message */voidReadWinP::DoEdit(Widget, ReadWinP *This, XtPointer){ This->pub->BusyCursor(True); if ( !This->editWin ) This->editWin = new SendWinC("sendWin", *This->pub, SEND_EDIT); Boolean editOk = !This->editWin->IsShown(); This->editWin->Show(); if ( editOk ) { MsgC *msg = This->pub->msg; MsgPartC *body = msg->Body(); Boolean editSource = (This->viewType == READ_VIEW_SOURCE || (!msg->IsMime() && !body->IsEncoded())); This->editWin->SetWrap(XmToggleButtonGetState(This->optWrapTB)); This->editWin->EditMsg(msg, editSource, (CallbackFn*)EditFinished, (void*)This); } This->pub->BusyCursor(False);}/*--------------------------------------------------------------- * Callback routine to handle completion of edit */voidReadWinP::EditFinished(char *file, ReadWinP *This){ This->pub->BusyCursor(True); MsgC *oldMsg = This->pub->msg; int len = 0; struct stat stats; if ( stat(file, &stats) == 0 ) len = (int)stats.st_size; FileMsgC *newMsg = new FileMsgC(file, 0, len, True, oldMsg->folder); newMsg->SetNumber(oldMsg->Number()); ishApp->DisplayMessage(newMsg, This->pub); if ( oldMsg->folder ) oldMsg->folder->ReplaceMsg(oldMsg, newMsg); This->pub->BusyCursor(False);} // End EditFinished
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -