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

📄 mainwinp.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 5 页
字号:
      XtManageChild(pb);   } // End for each button to be added   pub->EnableButtons();   recentMenuTime = time(0);} // End BuildRecentFolderMenus/*--------------------------------------------------------------- *  Method to read main window resources */voidMainWinP::ReadResources(){//// Read title strings//   systemTitleStr = get_string(*msgTBox, "systemTitleString", "In-Box");   folderTitleStr = get_string(*msgTBox, "folderTitleString", "Folder: $NAME");   msgCountStr    = get_string(*msgTBox, "msgCountString", "$COUNT messages");   newMsgCountStr = get_string(*msgTBox, "newMsgCountString",   					 "$COUNT new/unread");   unrMsgCountStr = get_string(*msgTBox, "unreadMsgCountString",   					 "$COUNT old/unread");   savMsgCountStr = get_string(*msgTBox, "savedMsgCountString", "$COUNT saved");   delMsgCountStr = get_string(*msgTBox, "delMsgCountString",					 "$COUNT marked for deletion");//// Create icons.  Use the default colormap rather than the application colormap//    since these icons are displayed in the window manager, not the app.//    The application colormap may be different.//   if ( debuglev > 0 ) cout <<"Creating icons" NL;   Screen	*scr = halApp->screen;   iconFG = get_color(*halApp, "iconForeground", BlackPixelOfScreen(scr));   iconBG = get_color(*halApp, "iconBackground", WhitePixelOfScreen(scr));   StringC	pmName = get_string(*halApp, "newMailPixmap", "flagup");   newMailPM = new PixmapC(pmName, iconFG, iconBG, iconBG, iconFG,   			   scr, (Window)*halApp, XDefaultColormapOfScreen(scr));   pmName = get_string(*halApp, "unreadMailPixmap", "flagdown");   unreadMailPM = new PixmapC(pmName, iconFG, iconBG, iconBG, iconFG,   			      scr, (Window)*halApp,			      XDefaultColormapOfScreen(scr));   pmName = get_string(*halApp, "readMailPixmap", "flagdown");   readMailPM = new PixmapC(pmName, iconFG, iconBG, iconBG, iconFG,   			    scr, (Window)*halApp,			    XDefaultColormapOfScreen(scr));   pmName = get_string(*halApp, "noNewMailPixmap", "flagdown");   pmName = get_string(*halApp, "noMailPixmap", pmName);   noMailPM = new PixmapC(pmName, iconFG, iconBG, iconBG, iconFG,   			  scr, (Window)*halApp, XDefaultColormapOfScreen(scr));} // End ReadResources/*--------------------------------------------------------------- *  Callback for map of main window. */voidMainWinP::DoMap(void*, MainWinP *This){   Boolean	wasSleeping = ishApp->sleeping;   ishApp->sleeping = False;//// Activate current folder//   if ( wasSleeping && This->pub->curFolder ) This->pub->curFolder->Activate();//// Force a mail check if we were sleeping.//   if ( wasSleeping ) {      ishApp->CheckForNewMail();//// See if there's any auto-filing to be done//      if ( ishApp->autoFilePrefs->autoFileOn )	 This->AutoFileNewMail();   }//// Check for the first time displayed.//   static Boolean	firstTime = True;   if ( firstTime ) {//// Display field view//      XtVaSetValues(*This->msgTBox, XmNallowResize, True, NULL);      This->msgVBox->ViewType(This->viewType);      XtVaSetValues(*This->msgTBox, XmNallowResize, False, NULL);//// Set up folder view//      if ( ishApp->folderPrefs->ViewType() != FOLDER_VIEW_LARGE )	 This->folderVBox->ViewType(1);//// Scroll to first new or unread message//      MsgItemC		*firstNew = NULL;      MsgItemC		*lastNew  = NULL;      VItemListC&	list      = This->msgVBox->VisItems();      unsigned		count      = list.size();      int i=0; for (i=0; i<count; i++) {	 MsgItemC	*item = (MsgItemC*)list[i];	 if ( !item->IsDeleted() && !item->IsRead() ) {	    if ( !firstNew ) firstNew = item;	    lastNew = item;	 }      } // End for each message//// Scroll to the last one, then the first one.  Do this to get as many new//    messages on the screen as possible, while making sure the first new//    one is visible//      if ( lastNew  ) {	 This->fieldView->ScrollToItem(*lastNew);	 This->fieldView->ScrollToItem(*firstNew);      }//// Display the first item if there are no new ones//      if ( !lastNew && count > 0 ) This->fieldView->ScrollToItem(*list[0]);      This->pub->UpdateFields();      This->pub->UpdateTitle();      This->pub->EnableButtons();      firstTime = False;   } // End if first time window mapped//// Update the recent folder menus if necessary//   if ( ishApp->appPrefs->recentFolderTime > This->recentMenuTime )      This->BuildRecentFolderMenus();} // End DoMap/*------------------------------------------------------------------------ * Method to return pixmap appropriate to new message */PixmapC *MainWinP::NewMailPixmap(){   if ( ishApp->sleeping ) return newMailPM;//// See if there is an icon rule for the newest message//   MsgC		*msg = ishApp->systemFolder->NewestMsg();   if ( !msg ) return newMailPM;   StringC	*name = msg->Match(ishApp->iconPrefs->iconRules);//// If a name was found, look up or create the pixmap//   if ( name ) {//// If the pixmap already exists, just return it.//      PixmapPtrT	*ptr = iconDict->definitionOf(*name);      PixmapC		*pm  = ptr ? *ptr : (PixmapC*)NULL;      if ( pm ) return pm;//// Create a new pixmap.  The icon pixmaps use the default colormap rather//    than the application colormap since they're displayed in the window//    manager.//      Screen	*scr = halApp->screen;      pm = new PixmapC(*name, iconFG, iconBG, iconBG, iconFG, scr,		       (Window)*halApp, XDefaultColormapOfScreen(scr));      if ( !pm->reg ) {	 delete pm;	 return newMailPM;      }      else {	 iconDict->add(*name, pm);	 return pm;      }   } // End if an image name was found//// Return default pixmap if no match was found//   return newMailPM;} // End NewMailPixmap/*--------------------------------------------------------------- *  Callback used when alert has completed */typedef struct {   StringC	cmd;   char		*msgFile;   char		*headFile;   char		*bodyFile;} AlertDataT;static voidAlertDone(int status, AlertDataT *data){   if ( status != 0 ) {      if ( debuglev > 1 ) cout <<"alert status: " <<status <<endl;      StringC msg = data->cmd;      msg += " reported the following error:\n";      if ( status < 0 )	 msg += SystemErrorMessage(status);      else {         if ( WIFEXITED(status) ) {	    status = WEXITSTATUS(status);	    msg += SystemErrorMessage(status);	 }	 else {	    msg += status;	 }      }      XBell(ishApp->display, ishApp->appPrefs->bellVolume);      ishApp->PopupMessage(msg);   } // End if status non-zero//// Clean up//   if ( data->msgFile ) {      unlink(data->msgFile);      free(data->msgFile);   }   if ( data->headFile ) {      unlink(data->headFile);      free(data->headFile);   }   if ( data->bodyFile ) {      unlink(data->bodyFile);      free(data->bodyFile);   }   delete data;} // End AlertDone/*------------------------------------------------------------------------ * Method to ring bell or execute alert command as appropriate */voidMainWinP::NewMailAlert(){   if ( ishApp->sleeping || !ishApp->alertPrefs->alertOn ) return;//// See if there is a alert rule for the newest message//   MsgC		*msg = ishApp->systemFolder->NewestMsg();   if ( !msg ) return;   StringC	*cmd = msg->Match(ishApp->alertPrefs->alertRules);//// Execute command or ring bell//   if ( !cmd ) {      XBell(ishApp->display, ishApp->appPrefs->bellVolume);   }   else {//// Look for %m, %h or %b in the command.//    %m will be replaced with the name of a file containing the entire message.//    %h will be replaced with the name of a file containing the headers only.//    %b will be replaced with the name of a file containing the body only.//    %% will be replaced with %//      AlertDataT	*data = new AlertDataT;      data->cmd      = *cmd;      data->msgFile  = NULL;      data->headFile = NULL;      data->bodyFile = NULL;      static RegexC	*percPat = NULL;      if ( !percPat ) percPat = new RegexC("%[%mhb]");      int	pos = 0;      while ( (pos=percPat->search(data->cmd, pos)) >= 0 ) {	 char	c     = data->cmd[pos+1];	 RangeC	range = (*percPat)[0];	 switch (c) {	    case '%':	       data->cmd(range) = "%";	       pos++;	       break;	    case 'm':      // Message file	       if ( !data->msgFile ) {		  data->msgFile = tempnam(NULL, "alrt.");		  msg->WriteFile(data->msgFile, /*copyHead=*/True,		  				/*allHead=*/True,		  				/*statHead=*/True,						/*addBlank=*/False,						/*protectFroms=*/False);	       }	       data->cmd(range) = data->msgFile;	       pos += strlen(data->msgFile);	       break;	    case 'h':      // Header file	       if ( !data->headFile ) {		  data->headFile = tempnam(NULL, "alrt.");		  msg->WriteHeaders(data->headFile);	       }	       data->cmd(range) = data->headFile;	       pos += strlen(data->headFile);	       break;	    case 'b':      // Body file	       if ( !data->bodyFile ) {		  data->bodyFile = tempnam(NULL, "alrt.");		  msg->WriteBody(data->bodyFile, /*addBlank=*/False,		  				 /*protectFroms=*/False);	       }	       data->cmd(range) = data->bodyFile;	       pos += strlen(data->bodyFile);	       break;	 } // End switch percent character      } // End while a percent pattern is found//// Run the command.  Add a callback so we can delete any temporary files//    when the command is finished.//      CallbackC	doneCb((CallbackFn*)AlertDone, data);      pid_t	status = ForkIt(data->cmd, &doneCb);      if ( status < 0 ) AlertDone((int)status, data);   } // End if there is a command} // End NewMailAlert/*--------------------------------------------------------------- *  Callback routine to handle selection of a folder icon */voidMainWinP::ChangeFolderSelection(VBoxC *vbox, MainWinP *This){//// If the system folder is selected, deselect it//

⌨️ 快捷键说明

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