⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfolder.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *  $Id: MainFolder.C,v 1.6 2000/09/19 14:45:27 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 "MainWinC.h"#include "MainWinP.h"#include "IshAppC.h"#include "QuickMenu.h"#include "FolderPrefC.h"#include "AppPrefC.h"#include "ConfPrefC.h"#include "MsgItemC.h"#include "MsgC.h"#include "FileChooserWinC.h"#include "MhFolderC.h"#include "MmdfFolderC.h"#include "UnixFolderC.h"#include "ImapFolderC.h"#include "ImapMisc.h"#include "ReadWinC.h"#include <hgl/WXmString.h>#include <hgl/VBoxC.h>#include <hgl/rsrc.h>#include <hgl/WArgList.h>#include <hgl/SysErr.h>#include <Xm/MessageB.h>#include <Xm/Frame.h>#include <Xm/RowColumn.h>#include <Xm/ToggleB.h>#include <sys/stat.h>#include <unistd.h>#include <errno.h>/*--------------------------------------------------------------- *  Callback to handle display of folder->open quick pulldown */voidMainWinP::PrepareOpenQuickMenu(Widget cb, MainWinP *This, XtPointer){//// Get the record associated with this cascade button//   QuickInfoT	*data;   XtVaGetValues(cb, XmNuserData, &data, NULL);//// See if the directory has changed since the menu was last built//   struct stat	dstats;   if ( IsImapName(data->dir) || stat(data->dir, &dstats) != 0 ||				 dstats.st_mtime > data->menuTime )      BuildQuickFolderMenu(data, (XtCallbackProc)DoFolderOpenButton,      			   (XtCallbackProc)PrepareOpenQuickMenu, This);} // End PrepareOpenQuickMenu/*--------------------------------------------------------------- *  Callback to handle folder-open quick or recent */voidMainWinP::DoFolderOpenButton(Widget w, MainWinP *This, XtPointer){   ishApp->BusyCursor(True);//// 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-open, 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;   }   XtFree(cs);   XmStringFree(xstr);//// Get a pointer to the folder//   FolderC *folder = ishApp->folderPrefs->GetFolder(name, False/*no create*/);   if ( !folder ) {      StringC	errmsg("Could not open folder: ");      errmsg += name;      errmsg += ".\n";      if ( errno != 0 ) errmsg += SystemErrorMessage(errno);      This->pub->PopupMessage(errmsg);      ishApp->BusyCursor(False);      return;   }   if ( folder->active ) {      ishApp->BusyCursor(False);	// Already open      return;   }//// Close any unpinned reading windows//   u_int	count = ishApp->readWinList.size();   for (int i=0; i<count; i++) {      ReadWinC	*readWin = (ReadWinC*)*ishApp->readWinList[i];      if ( !readWin->Pinned() ) readWin->Hide();   }//// If the folder has not yet been displayed, show it.//   if ( !folder->icon ) This->pub->ShowFolder(folder);//// Switch folders//   This->pub->curFolder->Deactivate();   folder->Activate();   if ( folder->active ) {      This->pub->SetCurrentFolder(folder);      ishApp->appPrefs->AddRecentFolder(name);   }   else {      ishApp->folderPrefs->RemoveFolder(folder);      delete folder;      This->pub->ActivateSystemFolder();   }   This->folderVBox->Refresh();   This->msgVBox->Refresh();   This->pub->BusyCursor(False);} // End DoFolderOpenButton/*--------------------------------------------------------------- *  Callback to handle folder-activate system */voidMainWinP::DoFolderActSys(Widget, MainWinP *This, XtPointer){   OpenFolder(ishApp->systemFolder->icon, This);}/*--------------------------------------------------------------- *  Callback to handle folder-activate selected */voidMainWinP::DoFolderActSel(Widget, MainWinP *This, XtPointer){   VItemC	*item = This->folderVBox->SelItems()[0];   FolderListC&	list  = ishApp->folderPrefs->OpenFolders();   u_int	count = list.size();   for (int i=0; i<count; i++) {      FolderC	*folder = list[i];      if ( folder->icon == item ) {	 OpenFolder(folder->icon, This);	 return;      }   }} // End DoFolderActSel/*--------------------------------------------------------------- *  Callback to handle folder-activate popup */voidMainWinP::DoFolderPUAct(Widget, MainWinP *This, XtPointer){   if ( !This->pub->popupOnSelected && This->pub->popupFolder )      OpenFolder(This->pub->popupFolder->icon, This);}/*--------------------------------------------------------------- *  Callback to handle folder-save (remove deleted messages) */voidMainWinP::DoFolderSaveCur(Widget, MainWinP *This, XtPointer){   ishApp->Broadcast("");   This->SaveFolder(This->pub->curFolder);}voidMainWinP::DoFolderPUSave(Widget, MainWinP *This, XtPointer){   if ( This->pub->popupOnSelected ) {      DoFolderSaveSel(NULL, This, NULL);      return;   }   if ( !This->pub->popupFolder ) return;   This->pub->BusyCursor(True);   ishApp->Broadcast("");   This->SaveFolder(This->pub->popupFolder);   This->pub->BusyCursor(False);} // End DoFolderPUSave/*--------------------------------------------------------------- *  Callback to handle folder-save-selected (remove deleted messages) */voidMainWinP::DoFolderSaveSel(Widget, MainWinP *This, XtPointer){   This->pub->BusyCursor(True);   ishApp->Broadcast("");//// Save folders//   VItemListC&	slist = This->folderVBox->SelItems();   FolderListC&	flist = ishApp->folderPrefs->OpenFolders();   u_int	count = flist.size();   for (int i=0; i<count; i++) {      FolderC	*fp = flist[i];      if ( fp->Changed() && slist.includes(fp->icon) ) This->SaveFolder(fp);   }   This->pub->BusyCursor(False);} // End DoFolderSaveSel/*--------------------------------------------------------------- *  Callback to handle folder-save-all (remove deleted messages) */voidMainWinP::DoFolderSaveAll(Widget, MainWinP *This, XtPointer){   ishApp->Broadcast("");//// Save the in-box//   Boolean	changed = (ishApp->systemFolder->writable &&			   ishApp->systemFolder->Changed());   if ( changed ) This->SaveFolder(ishApp->systemFolder);//// Loop through the user folders//   FolderListC&	list  =	ishApp->folderPrefs->OpenFolders();   unsigned	count = list.size();   for (int i=0; i<count; i++) {      FolderC	*folder = list[i];      changed = (folder->writable && folder->Changed());      if ( changed ) This->SaveFolder(folder);   }} // End DoFolderSaveAll/*--------------------------------------------------------------- *  Method to save an individual folder */voidMainWinP::SaveFolder(FolderC *folder){   pub->BusyCursor(True);   StringC	errmsg;//// Close any reading window open to deleted messages////// See if we're archiving read messages//   if ( folder->isInBox && ishApp->appPrefs->archiveOnSave ) {      errmsg = "Archiving read messages to ";      errmsg += ishApp->appPrefs->ArchiveFolder();      ishApp->Broadcast(errmsg);      FolderC* archiveFolder =	      ishApp->folderPrefs->GetFolder(ishApp->appPrefs->ArchiveFolder(),					     True/*ok to create*/);      if ( !archiveFolder ) {	 StringC	errmsg("Could not create archive folder: ");	 errmsg += ishApp->appPrefs->ArchiveFolder();	 errmsg += ".\n";	 if ( errno != 0 ) errmsg += SystemErrorMessage(errno);	 pub->PopupMessage(errmsg);      }      else {	 VItemListC&	visList = folder->MsgItemList();	 u_int		count   = visList.size();	 VItemListC	delList;	 for (int i=count-1; i>=0; i--) {	    MsgItemC	*item = (MsgItemC *)visList[i];	    MsgC	*msg  = item->msg;	    if ( msg->IsRead() && archiveFolder->AddMessage(msg) ) {	       delList.add((VItemC*)item);	       msg->SetDeleted();	    }	 }      }   } // End if archiving read messages//// Close any reading window open to deleted messages//   if ( folder->active && ishApp->xRunning ) {      unsigned	count = ishApp->readWinList.size();      for (int i=0; i<count; i++) {	 ReadWinC	*readWin = (ReadWinC*)*ishApp->readWinList[i];	 if ( readWin->IsShown() && readWin->msg->IsDeleted() )	    readWin->Hide();      }   }   if ( folder->isInBox )      errmsg = "In-box ";   else {      errmsg = "Folder \"";      errmsg += folder->abbrev;      errmsg += "\" ";   }   if ( folder->Save() ) {      lastDelList->removeAll();      if ( ishApp->xRunning ) {	 pub->EnableButtons();	 pub->UpdateTitle();      }      errmsg += "updated";      if ( folder->active && ishApp->xRunning ) {//// Update message numbers in reading windows//	 unsigned	count = ishApp->readWinList.size();	 for (int i=0; i<count; i++) {	    ReadWinC	*readWin = (ReadWinC*)*ishApp->readWinList[i];	    if ( readWin->IsShown() )	       readWin->SetMessageNumber(readWin->msg->Number());	 }      }   } // End if folder saved   else {      errmsg += "NOT saved";   }   if ( ishApp->xRunning ) {      if ( folder->active ) {         msgVBox->Refresh();      }      VBoxC&	vbox = ishApp->mainWin->FolderVBox();      vbox.Refresh();   }   ishApp->Broadcast(errmsg);   pub->BusyCursor(False);} // End SaveFolder/*--------------------------------------------------------------- *  Callback to handle folder-read */voidMainWinP::DoFolderReadCur(Widget, MainWinP *This, XtPointer){   ishApp->Broadcast("");   This->pub->curFolder->Rescan();}voidMainWinP::DoFolderPURead(Widget, MainWinP *This, XtPointer){   if ( This->pub->popupOnSelected ) {      DoFolderReadSel(NULL, This, NULL);      return;   }   if ( !This->pub->popupFolder ) return;   This->pub->BusyCursor(True);   ishApp->Broadcast("");   if ( This->pub->popupFolder->IsImap() ) {      ImapFolderC *If = (ImapFolderC*) This->pub->popupFolder;      if ( !If->server || !If->server->authenticated ) {         If->server->EstablishSession();      }   }   This->pub->popupFolder->Rescan();   This->pub->BusyCursor(False);} // End DoFolderPURead/*--------------------------------------------------------------- *  Callback to handle folder-read-selected */voidMainWinP::DoFolderReadSel(Widget, MainWinP *This, XtPointer){   This->pub->BusyCursor(True);   ishApp->Broadcast("");//// Read folders//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -