📄 appprefc.c
字号:
/* * $Id: AppPrefC.C,v 1.6 2000/12/13 08:53:38 evgeny Exp $ * * Copyright (c) 1994 HAL Computer Systems International, Ltd. * * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. * 1315 Dell Avenue * Campbell, CA 95008 * * Author: Greg Hilton * Contributors: Tom Lang, Frank Bieser, and others * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <config.h>#include "IshAppC.h"#include "AppPrefC.h"#include "AlertPrefC.h"#include "ShellExp.h"#include "Misc.h"#include "MainWinC.h"#include "AppPrefWinC.h"#include "FolderPrefC.h"#include "ImapMisc.h"#include "ReadWinC.h"#include "SendWinC.h"#include <hgl/rsrc.h>#include <hgl/CharC.h>#include <hgl/StringListC.h>#include <hgl/VBoxC.h>#include <hgl/FieldViewC.h>#ifndef MAIL_DIR# define MAIL_DIR "/var/spool/mail"#endif/*--------------------------------------------------------------- * Constructor */AppPrefC::AppPrefC() : PrefC(){ prefWin = NULL;//// Read resources// orig.folderDir = ishApp->home + "/Mail"; orig.folderDir = get_string(*halApp, "folderDirectory", orig.folderDir); orig.saveDir = get_string(*halApp, "saveDirectory", orig.folderDir); orig.saveFile = get_string(*halApp, "saveFile", "+mbox"); orig.archiveFolder = get_string(*halApp, "archiveFolder", "+mbox"); char *defAuto = ""; orig.automountRoot = get_string(*halApp, "automountRoot", defAuto); StringC saveStr = get_string(*halApp, "saveType", "folder"); if ( saveStr.Equals("folder", IGNORE_CASE) ) saveType = SAVE_TO_FOLDER; else if ( saveStr.Equals("user", IGNORE_CASE) ) saveType = SAVE_BY_USER; else if ( saveStr.Equals("address", IGNORE_CASE) ) saveType = SAVE_BY_ADDRESS; else if ( saveStr.Equals("pattern", IGNORE_CASE) ) saveType = SAVE_BY_PATTERN; else if ( saveStr.Equals("pattern/user", IGNORE_CASE) ) saveType = SAVE_BY_PATTERN_OR_USER; else if ( saveStr.Equals("pattern/address", IGNORE_CASE) ) saveType = SAVE_BY_PATTERN_OR_ADDRESS; deleteSaved = get_boolean(*halApp, "deleteAfterSave", False); hideDeleted = get_boolean(*halApp, "hideDeleted", False); printCmd = get_string (*halApp, "printCommand", "pr | lp -s"); char *cs = getenv("MAILCHECK"); int mailcheck = cs ? atoi(cs) : 60; checkInterval = get_int(*halApp, "checkInterval", mailcheck); // seconds//// Get system mail folder name// cs = getenv("MAIL"); if ( cs && strlen(cs)>0 ) inBox = cs; else inBox = MAIL_DIR + ("/" + ishApp->userId); inBox = get_string (*halApp, "inBox", inBox); bellVolume = get_int (*halApp, "bellVolume", 0); scrollToNew = get_boolean(*halApp, "scrollToNew", True); rememberWindows = get_boolean(*halApp, "rememberWindows", False); markNewAsUnread = get_boolean(*halApp, "markNewAsUnread", True); archiveOnSave = get_boolean(*halApp, "archiveOnSave", False); recentFolderCount = get_int (*halApp, "recentFolderCount", 10); recentFolders.AllowDuplicates(FALSE); StringC tmp = get_string(*halApp, "recentFolders", ""); ExtractList(tmp, recentFolders); recentFolderTime = time(0);//// Read IMAP settings// usingImap = get_boolean(*halApp, "usingImap", False); imapServer = get_string (*halApp, "imapServer", ishApp->host);//// Read POP settings// usingPop = get_boolean(*halApp, "usingPop", False); popServer = get_string (*halApp, "popServer", ishApp->host); popclientCmd = get_string (*halApp, "popclientCommand", "popclient -3 -s -u %user -p %pass -o $MAIL");//// For POP/IMAP login window, show password field first or login name field// pwFieldFirst = get_boolean(*halApp, "pwFieldFirst", True);} // End constructor/*--------------------------------------------------------------- * Method to expand values. Can only be called after folderPrefs object is * created. */voidAppPrefC::ExpandValues(){//// Expand settings that could contain abbreviations or environment vars// folderDir = orig.folderDir; ShellExpand(folderDir, True/*oneWord*/); // pre-pend home directory to relative path names if ( !folderDir.StartsWith("/") ) { // don't pre-pend if IMAP folder if ( !IsImapName(folderDir) ) folderDir = ishApp->home + "/" + folderDir; } if ( folderDir.size() > 1 && folderDir.EndsWith("/") ) folderDir.CutEnd(1); if ( debuglev > 0 ) cout <<"Folder directory is: " <<folderDir <<endl; saveFile = orig.saveFile; ishApp->ExpandFolderName(saveFile); saveDir = orig.saveDir; ishApp->ExpandFolderName(saveDir); archiveFolder = orig.archiveFolder; ishApp->ExpandFolderName(archiveFolder); automountRoot = orig.automountRoot; ShellExpand(automountRoot, True/*oneWord*/);} // End ExpandValues/*--------------------------------------------------------------- * destructor */AppPrefC::~AppPrefC(){ delete prefWin;}/*--------------------------------------------------------------- * Method to write resources to resource database */BooleanAppPrefC::WriteDatabase(){ Store("inBox", inBox); Store("folderDirectory", orig.folderDir); Store("saveFile", orig.saveFile); Store("saveDirectory", orig.saveDir); switch (saveType) { case (SAVE_BY_USER): Store("saveType", "User"); break; case (SAVE_BY_ADDRESS): Store("saveType", "Address"); break; case (SAVE_BY_PATTERN): Store("saveType", "Pattern"); break; case (SAVE_BY_PATTERN_OR_USER): Store("saveType", "Pattern/User"); break; case (SAVE_BY_PATTERN_OR_ADDRESS): Store("saveType", "Pattern/Address"); break; case (SAVE_TO_FOLDER): default: Store("saveType", "Folder"); break; } Store("automountRoot", orig.automountRoot); Store("deleteAfterSave", deleteSaved); Store("hideDeleted", hideDeleted); Store("printCommand", printCmd); Store("checkInterval", checkInterval); Store("bellVolume", bellVolume); Store("scrollToNew", scrollToNew); Store("rememberWindows", rememberWindows); Store("markNewAsUnread", markNewAsUnread); Store("archiveOnSave", archiveOnSave); Store("archiveFolder", orig.archiveFolder); Store("showQuickHelp", halApp->quickHelpEnabled); Store("alertIfNewMail", ishApp->alertPrefs->alertOn); Store("recentFolderCount", recentFolderCount); Store("usingImap", usingImap); Store("imapServer", imapServer); Store("usingPop", usingPop); Store("popServer", popServer); Store("popclientCommand", popclientCmd); return True;} // End WriteDatabase/*--------------------------------------------------------------- * Method to write resources to a file */BooleanAppPrefC::WriteFile(){ StringListC lineList; ReadResFile(lineList); Update(lineList, "inBox", inBox); Update(lineList, "folderDirectory", orig.folderDir); Update(lineList, "saveFile", orig.saveFile); Update(lineList, "saveDirectory", orig.saveDir); switch (saveType) { case (SAVE_BY_USER): Update(lineList, "saveType", "User"); break; case (SAVE_BY_ADDRESS): Update(lineList, "saveType", "Address"); break; case (SAVE_BY_PATTERN): Update(lineList, "saveType", "Pattern"); break; case (SAVE_BY_PATTERN_OR_USER): Update(lineList, "saveType", "Pattern/User"); break; case (SAVE_BY_PATTERN_OR_ADDRESS): Update(lineList, "saveType", "Pattern/Address"); break; case (SAVE_TO_FOLDER): default: Update(lineList, "saveType", "Folder"); break; } Update(lineList, "automountRoot", orig.automountRoot); Update(lineList, "deleteAfterSave", deleteSaved); Update(lineList, "hideDeleted", hideDeleted); Update(lineList, "printCommand", printCmd); Update(lineList, "checkInterval", checkInterval); Update(lineList, "bellVolume", bellVolume); Update(lineList, "scrollToNew", scrollToNew); Update(lineList, "rememberWindows", rememberWindows); Update(lineList, "markNewAsUnread", markNewAsUnread); Update(lineList, "archiveOnSave", archiveOnSave); Update(lineList, "archiveFolder", orig.archiveFolder); Update(lineList, "showQuickHelp", halApp->quickHelpEnabled); Update(lineList, "alertIfNewMail", ishApp->alertPrefs->alertOn); Update(lineList, "recentFolderCount", recentFolderCount); Update(lineList, "usingImap", usingImap); Update(lineList, "imapServer", imapServer); Update(lineList, "usingPop", usingPop); Update(lineList, "popServer", popServer); Update(lineList, "popclientCommand", popclientCmd);//// Write the information back to the file// return WriteResFile(lineList);} // End WriteFile/*--------------------------------------------------------------- * Method to write recent folder list to a file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -