📄 readwinp.c
字号:
// Loop through value components// while ( val ) { if ( val->charset ) msgHeadText->AddCommand(val->charset); msgHeadText->AddString(val->text); if ( val->charset ) msgHeadText->AddCommand(val->charset, True/*negate*/); val = val->next; } // End for each value component } // End if value is complex else { msgHeadText->AddString(head->full); } needNL = True; } // End if header is displayed head = head->next; } // End for each header msgHeadText->ScrollTop(); msgHeadText->Defer(False);} // End DisplayHeaders/*--------------------------------------------------------------- * Method to display the body for the current message */voidReadWinP::DisplayBody(){ if ( !pub->msg ) { msgBodyText->Clear(); return; } pub->BusyCursor(True); msgBodyText->Defer(True); msgBodyText->Clear();//// Tell the richtext widget whether to look for ">From " lines or not// msgBodyText->CheckFroms(pub->msg->HasSafeFroms());//// Check for a MIME message// MsgPartC *body = pub->msg->Body(); if ( (viewType == READ_VIEW_OUTLINE || viewType == READ_VIEW_FLAT) && (pub->msg->IsMime() || body->IsEncoded()) ) { if ( viewType == READ_VIEW_OUTLINE ) msgBodyText->SetTextType(TT_PLAIN); msgBodyText->ForceFixed((viewType != READ_VIEW_OUTLINE) && body->PlainTextOnly()); AddBodyPart(body); } else { StringC bodyStr; pub->msg->GetBodyText(bodyStr); msgBodyText->ForceFixed(True); msgBodyText->SetTextType(TT_PLAIN); msgBodyText->SetString(bodyStr); } msgBodyText->ScrollTop(); msgBodyText->Defer(False); pub->BusyCursor(False);} // End DisplayBody/*--------------------------------------------------------------- * Function to determine if a mime part can be displayed in-line */static BooleanDisplayInline(MsgPartC *part){ if ( part->IsExternal() || part->Is822() || part->IsAttachment() ) return False; //// We won't also display inline attachments with Content-Disposition: inline// set BUT a filename given (a "feature" of Communicator's mail).// ParamC *param = part->Param("filename", part->disParams); if (param) { return False; } //// Look for a mailcap entry and a present command. If there is none,// the front end can display text.// MailcapC *mcap = MailcapEntry(part); if ( !mcap || mcap->present.size() == 0 ) return (part->IsPlainText() || part->IsRichText() || part->IsEnriched() || part->IsMultipart());//// If there is a mailcap entry, see if "Ishmail" is the present command// return mcap->present.Equals("ishmail", IGNORE_CASE);} // End DisplayInline/*--------------------------------------------------------------- * Method to display a single part of a MIME message */voidReadWinP::AddBodyPart(MsgPartC *part, Boolean doNext){ if ( !part ) { if ( debuglev > 0 ) cout <<"Body part is NULL" <<endl; return; } if ( debuglev > 0 ) { cout <<"Msg part " <<part <<": " <<endl; cout <<*part <<endl; } StringC label; part->GetLabel(label); StringC msgStr("Adding part: "); msgStr += label; pub->Message(msgStr);#if 0 if ( !label.EndsWith(part->typeStr) ) { label += " ("; label += part->typeStr; label += ")"; }#endif if ( part->IsExternal() ) { label += " <"; switch (part->accType) { case AT_LOCAL_FILE: label += "local"; break; case AT_ANON_FTP: label += "anon FTP"; break; case AT_FTP: label += "FTP"; break; case AT_TFTP: label += "TFTP"; break; case AT_MAIL_SERVER: label += "mail server"; break; case AT_INLINE: label += "in-line"; break; } label += ">"; }#if 0 else label += "in-line";#endif if ( viewType == READ_VIEW_OUTLINE ) { MailcapC *mcap = NULL; if ( part->IsMultipart() ) mcap = MailcapEntry(part); if ( part->IsMultipart() && (!mcap || mcap->present.size() == 0) ) { StringC desc; part->GetDescription(desc); if ( desc.size() == 0 ) desc = part->conStr; msgBodyText->AddStringPlain(desc); msgBodyText->AddStringPlain("\n"); } else {//// Add an icon// ReadIconC *icon = new ReadIconC(part, msgBodyText); icon->SetLabel(label); icon->AddDoubleClickCallback((CallbackFn*)HandleDoubleClick, this); icon->AddMenuCallback ((CallbackFn*)PostPartMenu, this); msgBodyText->AddStringPlain(part->partNum); msgBodyText->AddStringPlain(" "); msgBodyText->AddGraphic(icon); msgBodyText->AddStringPlain("\n");//// See if there is a fetch in progress// FetchDataT *data = FetchData(part); if ( data ) { data->win = this; data->icon = icon; icon->Highlight(); LoadFetchPixmaps(icon); icon->Animate(fetchPixmaps); } } // End if this is a leaf if ( part->child ) AddBodyPart(part->child); } // End if outline view else {//// Display this part as necessary// Boolean displayHere = DisplayInline(part); if ( displayHere ) { if ( part->IsText() ) {//// Display the description// StringC desc; part->GetDescription(desc); if ( desc.size() > 0 ) { msgBodyText->SetTextType(TT_PLAIN); if ( !msgBodyText->IsEmpty() ) msgBodyText->AddString("\n\n"); msgBodyText->AddCommand("underline"); msgBodyText->AddString(desc); msgBodyText->AddCommand("underline", True/*negate*/); msgBodyText->AddString("\n\n"); }//// Set the text type// TextTypeT ttype = TT_PLAIN; if ( part->IsRichText() ) ttype = TT_RICH; else if ( part->IsEnriched() ) ttype = TT_ENRICHED; msgBodyText->SetTextType(ttype); if ( ttype == TT_PLAIN ) msgBodyText->AddCommand("fixed");//// See if we need an alternate character set// ParamC *csParam = part->Param("charset"); if ( csParam ) msgBodyText->AddCommand(csParam->val);//// Add the text// StringC body; part->GetData(body); msgBodyText->AddString(body);//// Restore the character set if we changed it// if ( csParam ) msgBodyText->AddCommand(csParam->val, True/*negate*/); if ( ttype == TT_PLAIN ) msgBodyText->AddCommand("fixed", True/*negate*/); } // End if this is a text part else if ( part->IsMultipart() && part->child ) {//// If this is a multipart/alternative, find the last text child we can display// if ( part->IsAlternative() ) { MsgPartC *altPart = part->BestTextAlternative(); AddBodyPart(altPart, False/*Don't do next*/);// Show the remaining parts as alternatives to the text part if ( altPart->next ) { msgBodyText->AddStringPlain("\n"); msgBodyText->AddCommand("underline"); msgBodyText->AddStringPlain("Alternatives"); msgBodyText->AddCommand("underline", True/*negate*/); msgBodyText->AddStringPlain("\n"); AddBodyPart(altPart->next, True/*Show all alternatives*/); msgBodyText->AddStringPlain("\n"); msgBodyText->AddCommand("underline"); msgBodyText->AddStringPlain("End Alternatives"); msgBodyText->AddCommand("underline", True/*negate*/); msgBodyText->AddStringPlain("\n\n"); } } else { AddBodyPart(part->child); } } } // End if we're displaying this part//// Build panel label for others// else {//// Add an icon// ReadIconC *icon = new ReadIconC(part, msgBodyText); icon->SetLabel(label); icon->AddDoubleClickCallback((CallbackFn*)HandleDoubleClick, this); icon->AddMenuCallback ((CallbackFn*)PostPartMenu, this); msgBodyText->AddGraphic(icon);//// See if there is a fetch in progress// FetchDataT *data = FetchData(part); if ( data ) { data->win = this; data->icon = icon; icon->Highlight(); LoadFetchPixmaps(icon); icon->Animate(fetchPixmaps); }//// If this is a message in a digest, add a linefeed// if ( part->Is822() && part->parent && part->parent->IsDigest() ) msgBodyText->AddStringPlain("\n"); } // End if we're not displaying this part } // End if not outline view//// Add next part if present// if ( part->next && doNext ) AddBodyPart(part->next);} // End AddBodyPart/*----------------------------------------------------------------------- * Handle drag over event */voidReadWinP::MsgDragOver(Widget w, XtPointer, XmDragProcCallbackStruct *dp){ if ( dp->reason == XmCR_DROP_SITE_MOTION_MESSAGE ) { MimeRichTextC *text; XtVaGetValues(w, XmNuserData, &text, NULL); ReadWinP *This; XtVaGetValues(text->MainWidget(), XmNuserData, &This, NULL); if ( This->pub->Pinned() ) dp->dropSiteStatus = XmINVALID_DROP_SITE; else dp->dropSiteStatus = XmVALID_DROP_SITE; } // End if this is a motion message// dp->animate = False;} // End MsgDragOver/*----------------------------------------------------------------------- * Handle message drop event */voidReadWinP::MsgTextDrop(Widget w, XtPointer, XmDropProcCallbackStruct *dp){ //cout << "Got drop into message text" NL;//// Get the message number and open it// ViewDragDataT *dd; XtVaGetValues(dp->dragContext, XmNclientData, &dd, NULL); //cout <<"Drag data is " << dd NL; MimeRichTextC *text; XtVaGetValues(w, XmNuserData, &text, NULL); ReadWinP *This; XtVaGetValues(text->MainWidget(), XmNuserData, &This, NULL); WArgList args; if ( dp->dropSiteStatus == XmVALID_DROP_SITE && !This->pub->Pinned() ) { MsgItemC *item = (MsgItemC*)(dd->itemList[0]); //cout <<"Item is " << item NL; VBoxC& vbox = ishApp->mainWin->MsgVBox(); VItemListC& selList = vbox.SelItems(); if ( !This->pub->Pinned() && selList.size() == 1 && selList[0] == This->pub->msg->icon ) { vbox.DeselectItem(*This->pub->msg->icon, False/*don't notify*/); vbox.SelectItem(*item); } ishApp->DisplayMessage(item->msg, This->pub); vbox.Refresh(); args.TransferStatus(XmTRANSFER_SUCCESS); } else args.TransferStatus(XmTRANSFER_FAILURE);//// Drop must be acknowledged// XmDropTransferStart(dp->dragContext, ARGS);//// Delete drag data// delete dd;} // End MsgTextDrop/*--------------------------------------------------------------- * Method to clean up child windows and processes */voidReadWinP::Reset(){ if ( editWin ) editWin->Close();//// Kill any display processes still running// u_int count = displayDataList.size(); int i; for (i=0; i<count; i++) { DisplayDataT *data = (DisplayDataT*)*displayDataList[i]; if ( kill(-data->pid, 0) == 0 ) kill(-data->pid, SIGKILL); } displayDataList.removeAll();//// Close local text windows// count = textWinList.size(); for (i=0; i<count; i++) { LocalTextWinC *tw = (LocalTextWinC*)*textWinList[i]; tw->Hide(); }//// Close local message windows// count = msgWinList.size(); for (i=0; i<count; i++) { ReadWinC *rw = (ReadWinC*)*msgWinList[i]; rw->Hide(); }//// Clear text// msgHeadText->Clear(); msgBodyText->Clear();//// Reset message// if ( pub->fullFunction && pub->msg ) { pub->msg->ClearViewed();//// Update main window// ishApp->mainWin->curMsgList->remove(pub->msg->icon); ishApp->mainWin->UpdateTitle(); ishApp->mainWin->EnableButtons();//// Re-sort if threaded. Status could have changed// if ( ishApp->mainWin->curMsgList->size() == 0 ) { SortMgrC *sortMgr = ishApp->mainWin->curFolder->SortMgr(); if ( sortMgr->Threaded() && sortMgr->StatusKey() ) ishApp->mainWin->MsgVBox().Sort(); } } // End if closing a full function window//// Reset pushPin// if ( pushPinTB ) XmToggleButtonSetState(pushPinTB, False, True);} // End Reset
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -