📄 sendwinc.c
字号:
// If there is a spell-check in progress, kill it// if ( priv->spell_pid > 0 ) { if ( debuglev > 0 ) cout <<"Killing process " <<priv->spell_pid NL; if ( kill(-priv->spell_pid, SIGKILL) != 0 ) { int err = errno; StringC errmsg = "Could not kill spell-check process: "; errmsg += SystemErrorMessage(err); PopupMessage(errmsg); } priv->spell_pid = 0; } priv->bodyText->Clear(); priv->bodyText->SetTextType(TT_ENRICHED);//// Remove any resend files// count = priv->resendFileList.size(); for (i=0; i<count; i++) { StringC *file = priv->resendFileList[i]; unlink(*file); } priv->resendFileList.removeAll(); priv->SetResendMode(False); if ( type == SEND_RESEND || type == SEND_FORWARD || type == SEND_REPLY ) type = SEND_NEW; priv->msgList.removeAll();//// Remove any auto-save files// if ( priv->autoSaveFile.size() > 0 ) unlink(priv->autoSaveFile); changed = False;//// Close this window// DoHide(NULL, this, NULL); return True;} // End Close/*--------------------------------------------------------------- * Method to set state of addSigTB */voidSendWinC::AddSig(Boolean val){ XmToggleButtonSetState(priv->optAddSigTB, val, False);}/*--------------------------------------------------------------- * Method to query state of addSigTB */BooleanSendWinC::AddingSig(){ return XmToggleButtonGetState(priv->optAddSigTB);}/*--------------------------------------------------------------- * Method to set body text from a character array */voidSendWinC::SetBody(CharC c){ priv->bodyText->SetTextType(TT_PLAIN); priv->bodyText->SetString(c);}/*--------------------------------------------------------------- * Methods to set Cc text */voidSendWinC::SetCc(const char *cs){ if ( IsEditOnly() ) return; AddressC addr(cs); priv->SetField(priv->ccText, &addr);}voidSendWinC::SetCc(StringListC& ccList){ if ( IsEditOnly() ) return;//// Loop through the cc entries// StringC str; u_int count = ccList.size(); int i=0; for (i=0; i<count; i++) { if ( str.size() > 0 ) str += ", "; str += *ccList[i]; } AddressC addr(str); priv->SetField(priv->ccText, &addr);}/*--------------------------------------------------------------- * Method to set Bcc text */voidSendWinC::SetBcc(const char *cs){ if ( IsEditOnly() ) return; AddressC addr(cs); priv->SetField(priv->bccText, &addr);}/*--------------------------------------------------------------- * Method to set Subject text */voidSendWinC::SetSubject(const char *cs){ if ( IsEditOnly() ) return; priv->subText->SetString(cs);}/*--------------------------------------------------------------- * Method to set Other text */voidSendWinC::SetOther(const char *cs){ if ( IsEditOnly() ) return; StringC otherStr = ishApp->mailPrefs->otherHeaders; if ( otherStr.size() > 0 && otherStr.LastChar() != '\n' && *cs != '\n' ) otherStr += "\n"; otherStr += cs; priv->otherText->SetString(otherStr); if ( cs && strlen(cs)>0 ) XmToggleButtonSetState(priv->optOtherTB, True, True); else if ( !ishApp->compPrefs->showCc ) XmToggleButtonSetState(priv->optOtherTB, False, True);}/*----------------------------------------------------------------------- * Return pointer to button manager class */ButtonMgrC*SendWinC::ButtonMgr(){ return priv->buttMgr;}/*--------------------------------------------------------------- * Message to handle display */voidSendWinC::Show(){ if ( IsEditOnly() ) { ClearMessage(); HalTopLevelC::Show(); return; }//// Initialize option buttons// switch (ishApp->mailPrefs->mailType) { case (MAIL_PLAIN): XmToggleButtonSetState(priv->optMsgPlainTB, True, True); break; case (MAIL_MIME): XmToggleButtonSetState(priv->optMsgMimeTB, True, True); break; case (MAIL_ALT): XmToggleButtonSetState(priv->optMsgAltTB, True, True); break; } switch (ishApp->mailPrefs->textType) { case (CT_PLAIN): XmToggleButtonSetState(priv->optTextPlainTB, True, True); break; case (CT_ENRICHED): XmToggleButtonSetState(priv->optTextRichTB, True, True); break; } XmToggleButtonSetState(priv->optAddSigTB, ishApp->sigPrefs->appendSig,False); XmToggleButtonSetState(priv->optCheckAddrTB, ishApp->mailPrefs->verifyAddresses, False); XmToggleButtonSetState(priv->optWrapTB, ishApp->compPrefs->wrap, True); priv->UpdateFcc();#if 0 priv->bodyText->SetSize(ishApp->compPrefs->bodyRows, ishApp->compPrefs->bodyCols, *this);#endif ClearMessage(); HalTopLevelC::Show();#if 0//// Do this because sometimes all fields don't show up until a resize// Dimension wd; XtVaGetValues(*this, XmNwidth, &wd, NULL); XtVaSetValues(*this, XmNwidth, wd+1, NULL);// XtVaSetValues(*this, XmNwidth, wd, NULL);#endif//// Start autoSave timer// if ( ishApp->compPrefs->autoSave && ishApp->compPrefs->autoSaveRate > 0 ) { priv->keystrokeCount = 0; priv->autoSaveTimer = XtAppAddTimeOut(ishApp->context, ishApp->compPrefs->autoSaveRate*1000/*ms*/, (XtTimerCallbackProc)SendWinP::CheckAutoSave, (XtPointer)priv); }} // End Show/*--------------------------------------------------------------- * Method to set To text */voidSendWinC::SetTo(const char *cs){ if ( IsEditOnly() ) return; AddressC addr(cs); priv->SetField(priv->toText, &addr);}/*--------------------------------------------------------------- * Method to determine if this window is unused */BooleanSendWinC::IsEmpty(){ if ( IsEditOnly() ) return False;//// Check header fields// StringC otherStr, otherHeaders; if ( otherVis ) { priv->otherText->GetString(otherStr, TT_PLAIN); otherHeaders = ishApp->mailPrefs->otherHeaders; if( otherStr.EndsWith("\n")) otherStr.CutEnd(1); if( otherHeaders.EndsWith("\n")) otherHeaders.CutEnd(1); } Boolean toEmpty = (priv->toText->IsEmpty()); Boolean ccEmpty = (!ccVis || priv->ccText->IsEmpty()); Boolean bccEmpty = (!bccVis || priv->bccText->IsEmpty()); Boolean otherEmpty = (!otherVis || priv->otherText->IsEmpty() || (otherStr == otherHeaders)); Boolean empty = ( toEmpty && priv->subText->IsEmpty() && ccEmpty && bccEmpty && otherEmpty && priv->bodyText->IsEmpty() ); return empty;} // End IsEmpty/*--------------------------------------------------------------- * Method to reply to a particular message */voidSendWinC::Reply(MsgC *msg, Boolean toAll, Boolean includeText){ BusyCursor(True);//// See who sent the message// AddressC *toAddr = msg->ReplyTo(); if ( !toAddr ) toAddr = msg->From(); if ( toAddr ) priv->SetField(priv->toText, toAddr);//// See if others are to be added// if ( toAll ) {//// Put To: and Cc: addresses in the Cc: field// toAddr = msg->To(); AddressC *ccAddr = msg->Cc();//// Temporarily link them together// AddressC *newcc = toAddr; AddressC **newccend = &newcc; while ( *newccend ) newccend = &((*newccend)->next); *newccend = ccAddr; if ( newcc ) priv->SetField(priv->ccText, newcc); *newccend = NULL; } // End if reply to all//// Display the subject string// HeaderValC *val = msg->Subject(); StringC text; if ( val ) {//// See if there is an alternate character set. If there is, this header was// RFC1522 encoded.// if ( val->charset ) {//// If the alternate charset is compatible with the text field, display the// decoded value. If the charset is not compatible, display the encoded// value.// if ( CharsetOk(val->charset, priv->subText->Charset()) ) val->GetValueText(text); else text = val->full; } // End if there is an alternate charset else text = val->full;//// Update the Re: pattern// Boolean reOk = False; if ( text.StartsWith("re", IGNORE_CASE) ) {//// See if the Re: should be numbered// if ( ishApp->replyPrefs->numberReplies ) { if ( text[2] == ':' ) { text(2,0) = "[2]"; reOk = True; } else if ( text[2] == '[' || text[2] == '(' ) {//// Look for closing delimiter// int pos; if ( text[2] == '[' ) pos = text.PosOf(']', (u_int)2); else pos = text.PosOf(')', (u_int)2);//// Increment number by 1// if ( pos > 2 ) { StringC numStr = text(3,pos-3); int num = atoi(numStr) + 1; numStr.Clear(); numStr += num; text(3,pos-3) = numStr; reOk = True; } } // End if range found } // End if numbering replies else if ( text[2] == ':' || text[2] == '[' || text[2] == '(' ) reOk = True; } // End if "re" at beginning of subject if ( !reOk ) text(0,0) = "Re: "; } // End if there is a subject//// Update the field// priv->subText->SetString(text);//// Clear other fields// SetBcc(""); SetOther("");//// Display the text if necessary// priv->bodyText->Clear(); if ( includeText ) { priv->bodyText->Defer(True);//// Add the attribution// StringC attrib = msg->Attribution(); priv->bodyText->AddStringEnriched(attrib); if ( !attrib.EndsWith('\n') ) priv->bodyText->AddStringPlain("\n");//// Add the message text// priv->bodyText->CheckFroms(msg->HasSafeFroms()); priv->bodyText->AddStringEnriched("<excerpt>"); if ( msg->IsMime() ) { MsgPartC *tree = msg->Body(); priv->AddBodyTree(tree); priv->bodyText->AddStringPlain("\n\n"); } else { StringC body; msg->GetBodyText(body); priv->bodyText->AddStringPlain(body); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -