📄 ishappp.c
字号:
error = (fwrite(start, 1, len, fp) != len); if ( !error && cp < end ) error = (fwrite("\\\n", 1, 2, fp) != 2); start = cp; cp = strchr(start, ';'); } // End for each ';' return !error;} // End WriteRules/*--------------------------------------------------------------- * Create ishmail pixmaps */voidIshAppP::CreatePixmaps(){ Window appWin = XtWindow(pub->appShell); Screen *scr = pub->screen; Pixel black = BlackPixelOfScreen(scr); Pixel white = WhitePixelOfScreen(scr); pub->ishmailPM = new PixmapC(ishmail_xpm, appWin); if ( !pub->ishmailPM->reg ) pub->ishmailPM->Set("ishmail.xbm", black, white, white, black, scr, appWin); if ( pub->ishmailPM->reg == XmUNSPECIFIED_PIXMAP ) pub->ishmailPM->reg = (Pixmap)NULL; messagePM = new PixmapC(ishmail_info_xpm, appWin); if ( !messagePM->reg ) messagePM->Set("ishmail_info.xbm", black, white, white, black, scr, appWin); if ( messagePM->reg == XmUNSPECIFIED_PIXMAP ) messagePM->reg = (Pixmap)NULL; questionPM = new PixmapC(ishmail_question_xpm, appWin); if ( !questionPM->reg ) questionPM->Set("ishmail_question.xbm", black, white, white, black, scr, appWin); if ( questionPM->reg == XmUNSPECIFIED_PIXMAP ) questionPM->reg = (Pixmap)NULL; warningPM = new PixmapC(ishmail_warning_xpm, appWin); if ( !warningPM->reg ) warningPM->Set("ishmail_warning.xbm", black, white, white, black, scr, appWin); if ( warningPM->reg == XmUNSPECIFIED_PIXMAP ) warningPM->reg = (Pixmap)NULL; errorPM = new PixmapC(ishmail_error_xpm, appWin); if ( !errorPM->reg ) errorPM->Set("ishmail_error.xbm", black, white, white, black, scr, appWin); if ( errorPM->reg == XmUNSPECIFIED_PIXMAP ) errorPM->reg = (Pixmap)NULL;} // End CreatePixmaps/*--------------------------------------------------------------- * Timer proc to check for new mail */voidIshAppP::CheckForNewMail(IshAppP *This, XtIntervalId*){//// Do this to protect against multiple threads. This can happen if we// detect an external mod, are waiting for user acknowledgement and// VerifyMailCheck thinks the timer proc has gone south.// static Boolean inCheck = False; if ( inCheck ) return; inCheck = True; This->lastMailCheck = time(0); This->checkTimer = (XtIntervalId)NULL;//// Check system folder// if ( This->pub->systemFolder && This->pub->systemFolder->NewMail() ) This->pub->mainWin->GetNewMail(This->pub->systemFolder);//// Check all folders if showing status// if ( ishApp->folderPrefs->showStatus ) { FolderListC list = ishApp->folderPrefs->OpenFolders(); u_int count = list.size(); for (int i=0; i<count; i++) { FolderC *folder = list[i]; if ( folder->NewMail() ) This->pub->mainWin->GetNewMail(folder); } }//// Check current folder if other than system// else if ( This->pub->mainWin->curFolder != This->pub->systemFolder && This->pub->mainWin->curFolder->NewMail() ) This->pub->mainWin->GetNewMail(This->pub->mainWin->curFolder); inCheck = False;//// Start another timer// if ( This->pub->appPrefs->checkInterval > 0 ) This->checkTimer = XtAppAddTimeOut(This->pub->context, This->pub->appPrefs->checkInterval*1000, (XtTimerCallbackProc)CheckForNewMail, (XtPointer)This);} // End CheckForNewMail/*--------------------------------------------------------------- * Method to re-open a dialog if the user closes it with the window * manager close button */voidIshAppP::PreventClose(Widget shell, Widget dialog, XtPointer){ XtManageChild(dialog); XMapRaised(halApp->display, XtWindow(shell));}/*--------------------------------------------------------------- * Method to ask the user if they will be using an IMAP server */voidIshAppP::QueryImap(){//// See if this information is available in the in-box name// if ( pub->appPrefs->inBox.StartsWith('{') ) { int pos = pub->appPrefs->inBox.PosOf('}'); if ( pos > 0 ) { StringC server = pub->appPrefs->inBox(1,pos-1); pub->appPrefs->usingImap = True; pub->appPrefs->imapServer = server; pub->appPrefs->WriteDatabase(); pub->appPrefs->WriteFile(); return; } } QueryAnswerT answer;//// Ask if they will be using an IMAP server// WArgList args; args.DialogStyle(XmDIALOG_FULL_APPLICATION_MODAL); if ( halApp->questionPM ) args.SymbolPixmap(halApp->questionPM); Widget dialog = XmCreateQuestionDialog(*pub, "queryImapWin", ARGS); XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)HalAppC::DoHelp, (char *) "helpcard");//// Don't allow window manager close function// XmAddWMProtocolCallback(XtParent(dialog), halApp->delWinAtom, (XtCallbackProc)PreventClose, dialog); XtManageChild(dialog); XMapRaised(halApp->display, XtWindow(XtParent(dialog)));//// Simulate the main event loop and wait for the answer// answer = QUERY_NONE; while ( answer == QUERY_NONE ) { XtAppProcessEvent(halApp->context, XtIMXEvent); XSync(halApp->display, False); } XtUnmanageChild(dialog); XSync(halApp->display, False); XmUpdateDisplay(dialog);//// Delete the dialog// XtDestroyWidget(dialog); if ( answer == QUERY_YES ) {//// Get the name of the IMAP server// args.Reset(); args.DialogStyle(XmDIALOG_FULL_APPLICATION_MODAL); args.AutoUnmanage(False); dialog = XmCreatePromptDialog(*pub, "queryImapServerWin", ARGS); XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)HalAppC::DoHelp, (char *) "helpcard"); Widget serverTF = XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT);//// Don't allow window manager close function// XmAddWMProtocolCallback(XtParent(dialog), halApp->delWinAtom, (XtCallbackProc)PreventClose, dialog); XtManageChild(dialog); XMapRaised(halApp->display, XtWindow(XtParent(dialog)));//// Loop until a name is entered or the dialog is cancelled// Boolean done = False; while ( !done ) {//// Simulate the main event loop and wait for the answer// answer = QUERY_NONE; while ( answer == QUERY_NONE ) { XtAppProcessEvent(halApp->context, XtIMXEvent); XSync(halApp->display, False); } if ( answer == QUERY_CANCEL ) { pub->appPrefs->usingImap = False; done = True; } else { char *cs = XmTextFieldGetString(serverTF); CharC server(cs); server.Trim(); if ( server.Length() == 0 ) { set_invalid(serverTF, True, True); pub->PopupMessage("Please enter the host name of your IMAP server."); } else { pub->appPrefs->usingImap = True; pub->appPrefs->imapServer = cs; done = True; } XtFree(cs); } } // End while not done XtUnmanageChild(dialog); XSync(halApp->display, False); XmUpdateDisplay(dialog);//// Delete the dialog// XtDestroyWidget(dialog); } // End if using an imap server else { // Not using an IMAP server pub->appPrefs->usingImap = False; } pub->appPrefs->WriteDatabase(); pub->appPrefs->WriteFile();} // End QueryImap/*--------------------------------------------------------------- * Method to ask the user if they will be using a POP server */voidIshAppP::QueryPop(){ QueryAnswerT answer;//// Ask if they will be using a POP server// WArgList args; args.DialogStyle(XmDIALOG_FULL_APPLICATION_MODAL); if ( halApp->questionPM ) args.SymbolPixmap(halApp->questionPM); Widget dialog = XmCreateQuestionDialog(*pub, "queryPopWin", ARGS); XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)HalAppC::DoHelp, (char *) "helpcard");//// Don't allow window manager close function// XmAddWMProtocolCallback(XtParent(dialog), halApp->delWinAtom, (XtCallbackProc)PreventClose, dialog); XtManageChild(dialog); XMapRaised(halApp->display, XtWindow(XtParent(dialog)));//// Simulate the main event loop and wait for the answer// answer = QUERY_NONE; while ( answer == QUERY_NONE ) { XtAppProcessEvent(halApp->context, XtIMXEvent); XSync(halApp->display, False); } XtUnmanageChild(dialog); XSync(halApp->display, False); XmUpdateDisplay(dialog);//// Delete the dialog// XtDestroyWidget(dialog); if ( answer == QUERY_YES ) {//// Get the name and type of the POP server and the path to the "popclient"// command// args.Reset(); args.DialogStyle(XmDIALOG_FULL_APPLICATION_MODAL); args.AutoUnmanage(False); args.Add(XmNchildPlacement, XmPLACE_BELOW_SELECTION); dialog = XmCreatePromptDialog(*pub, "queryPopServerWin", ARGS); XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)AnswerQuery, (XtPointer)&answer); XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)HalAppC::DoHelp, (char *) "helpcard"); Widget serverTF = XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT);//// Create a form for other choices// args.Reset(); args.Orientation(XmVERTICAL); args.Packing(XmPACK_TIGHT); Widget popRC = XmCreateRowColumn(dialog, "popRC", ARGS);//// Add the POP2/POP3 choice buttons// Widget popTypeLabel = XmCreateLabel(popRC, "popTypeLabel", 0,0); Widget popTypeFrame = XmCreateFrame(popRC, "popTypeFrame", 0,0); args.Reset(); args.Orientation(XmHORIZONTAL); args.Packing(XmPACK_TIGHT); Widget popTypeRadio = XmCreateRadioBox(popTypeFrame, "popTypeRadio", ARGS); Widget popType2TB = XmCreateToggleButton(popTypeRadio, "popType2TB", 0,0); Widget popType3TB = XmCreateToggleButton(popTypeRadio, "popType3TB", 0,0); XtManageChild(popType2TB); XtManageChild(popType3TB); XtManageChild(popTypeRadio);//// Add the popclient command name// Widget popCmdLabel = XmCreateLabel (popRC, "popCmdLabel", 0,0); Widget popCmdTF = XmCreateTextField(popRC, "popCmdTF", 0,0); XmTextFieldSetString(popCmdTF, pub->appPrefs->popclientCmd); XtManageChild(popTypeLabel); XtManageChild(popTypeFrame); XtManageChild(popCmdLabel); XtManageChild(popCmdTF); XtManageChild(popRC);//// Don't allow window manager close function// XmAddWMProtocolCallback(XtParent(dialog), halApp->delWinAtom, (XtCallbackProc)PreventClose, dialog); XtManageChild(dialog); XMapRaised(halApp->display, XtWindow(XtParent(dialog)));//// Loop until a name is entered or the dialog is cancelled// Boolean done = False; while ( !done ) {//// Simulate the main event loop and wait for the answer// answer = QUERY_NONE; while ( answer == QUERY_NONE ) { XtAppProcessEvent(halApp->context, XtIMXEvent); XSync(halApp->display, False); } if ( answer == QUERY_CANCEL ) { pub->appPrefs->usingPop = False; done = True; } else { char *cs = XmTextFieldGetString(serverTF); CharC server(cs); server.Trim(); if ( server.Length() == 0 ) { set_invalid(serverTF, True, True); pub->PopupMessage("Please enter the host name of your POP server."); } else { pub->appPrefs->usingPop = True; pub->appPrefs->popServer = cs; XtFree(cs); cs = XmTextFieldGetString(popCmdTF); CharC cmd(cs); cmd.Trim(); if ( cmd.Length() > 0 ) pub->appPrefs->popclientCmd = cmd; else pub->appPrefs->popclientCmd = "popclient -3"; if ( XmToggleButtonGetState(popType2TB) ) pub->appPrefs->popclientCmd.Replace(" -3", " -2"); else pub->appPrefs->popclientCmd.Replace(" -2", " -3"); done = True; } XtFree(cs); } } // End while not done XtUnmanageChild(dialog); XSync(halApp->display, False); XmUpdateDisplay(dialog);//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -