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

📄 msgfindwinc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 2 页
字号:
   VBoxC&	vbox    = ishApp->mainWin->MsgVBox();   VItemListC&	msgList = vbox.VisItems();   u_int	count   = msgList.size();//// If there is a single selected message, use that as the start index//   int		start;   VItemListC&	selList = ishApp->mainWin->MsgVBox().SelItems();   if ( selList.size() == 1 ) {      VItemC	*vi = selList[0];      start = msgList.indexOf(vi) + 1;      if ( start >= count ) start = 0;   }   else      start = findIndex;//// Loop from the start position to the end of the list and look for the//    next message whose number appears in the IMAP number list//   Boolean	found = False;   MsgItemC	*item;   int	index;   for (index=start; !found && index<count; index++) {      item = (MsgItemC*)msgList[index];      found = numList.includes(item->msg->Number());   }//// Loop from the beginning of the list to the start position//   for (index=0; !found && index<start; index++) {      item = (MsgItemC*)msgList[index];      found = numList.includes(item->msg->Number());   }//                            // Next time, start at message after this one//   if ( found ) {      findIndex = index + 1;      if ( findIndex >= count ) findIndex = 0;   }   else {      findIndex = 0;      item      = NULL;   }   return item;} // End FindNextImap/*--------------------------------------------------------------- *  Callback routine to handle press of find prev button in find message dialog */voidMsgFindWinC::DoFindPrev(Widget, MsgFindWinC *This, XtPointer){   This->ClearMessage();//// Get pattern//   if ( XmTextFieldGetLastPosition(This->patternTF) <= 0 ) {      set_invalid(This->patternTF, True, True);      This->PopupMessage("Please enter a search string");      return;   }   ishApp->mainWin->BusyCursor(True);   char	*searchStr = XmTextFieldGetString(This->patternTF);   MsgItemC	*item = NULL;   if ( This->imapOn )      item = This->FindPrevImap(searchStr);   else      item = This->FindPrev(searchStr);   XtFree(searchStr);//// Select the item if it was found//   if ( item ) {//// See if there is an unpinned reading window displayed//      Boolean	found = False;      unsigned	rcount = ishApp->readWinList.size();      for (int i=0; !found && i<rcount; i++) {	 ReadWinC	*readWin = (ReadWinC*)*ishApp->readWinList[i];	 found = (readWin->IsShown() && !readWin->Pinned());      }      if ( found ) {	 ishApp->DisplayMessage(item->msg);      }      else {	 ishApp->mainWin->FieldView().ScrollToItem(*item);	 ishApp->mainWin->MsgVBox().SelectItemOnly(*item);      }   } // End if a matching item was found   else {      ishApp->mainWin->MsgVBox().DeselectAllItems();      This->Message("No match");      XBell(halApp->display, ishApp->appPrefs->bellVolume);   }   ishApp->mainWin->BusyCursor(False);   This->stateChanged = False;} // End DoFindPrev/*--------------------------------------------------------------- *  Method to find the previous matching message in a non-IMAP folder */MsgItemC*MsgFindWinC::FindPrev(const char *searchStr){//// Loop through visible messages//   VItemListC&	msgList = ishApp->mainWin->MsgVBox().VisItems();   unsigned	count = msgList.size();   MsgItemC	*item = NULL;   Boolean	found = False;   int		index;   int		start;//// If there is a single selected message, use that as the start index//   VItemListC&	selList = ishApp->mainWin->MsgVBox().SelItems();   if ( selList.size() == 1 ) {      VItemC	*vi = selList[0];      start = msgList.indexOf(vi) - 1;      if ( start <= 0 ) start = count-1;   }   else      start = findIndex;//// Loop from the start position to the beginning of the list//   for (index=start; !found && index>=0; index--) {      item = (MsgItemC*)msgList[index];      found = MsgContains(item->msg, searchStr);   }//// Loop from the end of the list to the start position//   for (index=count-1; !found && index>start; index--) {      item = (MsgItemC*)msgList[index];      found = MsgContains(item->msg, searchStr);   }//                            // Next time, start at message before this one//   if ( found ) {      findIndex = index - 1;      if ( findIndex <= 0 ) findIndex = count - 1;   }   else {      findIndex = 0;      item      = NULL;   }   return item;} // End FindPrev/*--------------------------------------------------------------- *  Method to find the previous matching message in an IMAP folder */MsgItemC*MsgFindWinC::FindPrevImap(const char *searchStr){//// If we're looking at just the headers, it is quicker to do it locally//   Boolean	checkHead = XmToggleButtonGetState(searchHeadTB);   Boolean	checkBody = XmToggleButtonGetState(searchBodyTB);   if ( checkHead && !checkBody )      return FindPrev(searchStr);   if ( !checkHead && !checkBody )      return NULL;//// If the state has changed, query the server again//   if ( stateChanged )      GetImapNumList(searchStr, checkHead);   VBoxC&	vbox    = ishApp->mainWin->MsgVBox();   VItemListC&	msgList = vbox.VisItems();   u_int	count   = msgList.size();//// If there is a single selected message, use that as the start index//   int		start;   VItemListC&	selList = ishApp->mainWin->MsgVBox().SelItems();   if ( selList.size() == 1 ) {      VItemC	*vi = selList[0];      start = msgList.indexOf(vi) - 1;      if ( start <= 0 ) start = count-1;   }   else      start = findIndex;//// Loop from the start position to the beginning of the list and look for the//    previous message whose number appears in the IMAP number list//   Boolean	found = False;   MsgItemC	*item;   int		index;   for (index=start; !found && index>=0; index--) {      item = (MsgItemC*)msgList[index];      found = numList.includes(item->msg->Number());   }//// Loop from the end of the list to the start position//   for (index=count-1; !found && index>start; index--) {      item = (MsgItemC*)msgList[index];      found = numList.includes(item->msg->Number());   }//                            // Next time, start at message before this one//   if ( found ) {      findIndex = index - 1;      if ( findIndex <= 0 ) findIndex = count - 1;   }   else {      findIndex = 0;      item      = NULL;   }   return item;} // End FindPrevImap/*--------------------------------------------------------------- *  Callback routine to handle press of "find all" button in find *     message dialog */voidMsgFindWinC::DoFindAll(Widget, MsgFindWinC *This, XtPointer){   This->ClearMessage();//// Get pattern//   if ( XmTextFieldGetLastPosition(This->patternTF) <= 0 ) {      set_invalid(This->patternTF, True, True);      This->PopupMessage("Please enter a search string");      return;   }   ishApp->mainWin->BusyCursor(True);   char	*searchStr = XmTextFieldGetString(This->patternTF);   This->findIndex = 0;   ishApp->mainWin->MsgVBox().DeselectAllItems(False);   if ( This->imapOn )      This->FindAllImap(searchStr);   else      This->FindAll(searchStr);   XtFree(searchStr);   VItemListC&	selItems = ishApp->mainWin->MsgVBox().SelItems();   if ( selItems.size() > 0 ) {      StringC	tmp;      tmp += (int)selItems.size();      tmp += " item";      if ( selItems.size() > 1 ) tmp += "s";      tmp += " selected";      This->Message(tmp);//// See if there is an unpinned reading window displayed//      Boolean	found = False;      unsigned	rcount = ishApp->readWinList.size();      for (int i=0; !found && i<rcount; i++) {	 ReadWinC	*readWin = (ReadWinC*)*ishApp->readWinList[i];	 found = (readWin->IsShown() && !readWin->Pinned());      }      MsgItemC	*item = (MsgItemC*)selItems[0];      if ( found )	 ishApp->DisplayMessage(item->msg);      else	 ishApp->mainWin->FieldView().ScrollToItem(*item);   }   else {      This->Message("No match");      XBell(halApp->display, ishApp->appPrefs->bellVolume);   }   ishApp->mainWin->MsgVBox().Refresh();   ishApp->mainWin->EnableButtons();   ishApp->mainWin->BusyCursor(False);   This->stateChanged = False;} // End DoFindAll/*--------------------------------------------------------------- *  Method to find all matching messages in a non-IMAP folder */voidMsgFindWinC::FindAll(const char *searchStr){//// Loop through the visible messages//   VBoxC&	vbox = ishApp->mainWin->MsgVBox();   VItemListC&	msgList = vbox.VisItems();   unsigned	count = msgList.size();   for (int i=0; i<count; i++) {//// See if this one matches//      MsgItemC	*item = (MsgItemC*)msgList[i];      if ( MsgContains(item->msg, searchStr) )	 vbox.SelectItem(*item, False);   }} // End FindAll/*--------------------------------------------------------------- *  Method to find all matching messages in an IMAP folder */voidMsgFindWinC::FindAllImap(const char *searchStr){//// If we're looking at just the headers, it is quicker to do it locally//   Boolean	checkHead = XmToggleButtonGetState(searchHeadTB);   Boolean	checkBody = XmToggleButtonGetState(searchBodyTB);   if ( checkHead && !checkBody ) {      FindAll(searchStr);      return;   }   if ( !checkHead && !checkBody )      return;//// If the state has changed, query the server again//   if ( stateChanged )      GetImapNumList(searchStr, checkHead);//// Loop through the visible messages.  Select any that appear in the numList//   VBoxC&	vbox = ishApp->mainWin->MsgVBox();   VItemListC&	msgList = vbox.VisItems();   unsigned	count = msgList.size();   for (int i=0; i<count; i++) {//// See if this one matches//      MsgItemC	*item = (MsgItemC*)msgList[i];      if ( numList.includes(item->msg->Number()) )	 vbox.SelectItem(*item, False);   }} // End FindAllImap/*--------------------------------------------------------------- *  Callback to handle complex message-find */voidMsgFindWinC::DoComplex(Widget, MsgFindWinC *This, XtPointer){   This->BusyCursor(True);   This->Hide();//// See which window to show//   Boolean	needImap = ishApp->mainWin->curFolder->IsImap();   if ( needImap ) {      if ( !This->complexImapWin )	 This->complexImapWin = new ComplexImapFindWinC(*This);      This->complexImapWin->Show();   }   else {      if ( !This->complexWin )	 This->complexWin = new ComplexMsgFindWinC(*This);      This->complexWin->Show();   }   This->BusyCursor(False);} // End DoComplex/*--------------------------------------------------------------- *  Callback to mark a change to the pattern text or the state of the *     toggle buttons */voidMsgFindWinC::StateChanged(Widget, MsgFindWinC *This, XtPointer){   This->stateChanged = True;}/*--------------------------------------------------------------- *  Method to query the IMAP server for a list of the numbers of matching *     messages. */voidMsgFindWinC::GetImapNumList(const char *searchStr, Boolean checkHead){//// Build query string.  At this point we know we're checking the body//   StringC	query;   if ( checkHead ) {      query = "TEXT ";      query += searchStr;   }   else {      query = "BODY ";      query += searchStr;   }//// Run search//   ImapFolderC	*folder = (ImapFolderC*)ishApp->mainWin->curFolder;   StringListC	output;   numList.removeAll();   if ( !folder->server->Search(query, numList, output) ) {      StringC	errmsg("Could not communicate with IMAP server ");      errmsg += folder->server->name;      PopupMessage(errmsg);   }} // End GetImapNumList

⌨️ 快捷键说明

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