VOID PASCAL INTERNAL CheckMail ( LONG lNow ) { FLAG fFirstTime = lTmLastMail == 0L; INT idoc; INT cMsg; LONG lTemp; PSTR p = NULL; /* Don't do auto new mail * if current folder is not default folder * if wzmail invoked to compose a single message * if user is typing a command * if current folder is readonly */ if ( !fCurFldIsDefFld || fDirectComp || WindLevel != 0 || fReadOnlyCur ) return; /* Do automail if fCheckMail or first time or * (periodic checking and enough time has elapsed) * For perf reasons, order of test is inverted * Return if not fCheckMail if NOT first time && * (if not requested by user ( cSecNewmail == 0 => don't check ) or * if not enough time elapsed ) */ if ( !fCheckMail && !fFirstTime && ( !cSecNewmail || ( lNow < lTmLastMail + cSecNewmail ) ) ) return; fCheckMail = FALSE; #if (defined (OS2) | defined (NT)) if (ISFULLSCREEN && ISVISIBLE) #endif { SendMessage ( hCommand, DISPLAYSTR, "Checking mailbox ... " ); p = ZMMakeStr ( asctime ( localtime ( &lNow ) ) ); strcpy ( p+16, strBLANK ); SendMessage ( hCommand, DISPLAYSTR, p ); ZMfree ( p ); } /* Don't let connection made by auto newmail keep lazy connection open * DownloadMail updates lTmLastMail * BUT ... the first time, allow lazy connection to be made on startup */ idoc = ( inoteBold != -1 ? mpInoteIdoc [ inoteBold ] : -1 ); if ( !fFirstTime ) lTemp = lTmConnect; cMsg = DownloadMail (FALSE); if ( !fFirstTime ) lTmConnect = lTemp; Disconnect ( ); #if (defined (OS2) | defined (NT)) if (cMsg || (ISFULLSCREEN && ISVISIBLE)) #endif SendMessage ( hCommand, CLRCMDLN, 0 ); /* if first time, then find the first unread message * else don't change the "current" message */ if ( fFirstTime ) { if ( ( idoc = NextUnread ( -1 ) ) != -1 ) SendMessage ( hHeaders, GOTOIDOCALL, idoc ); } else { if ( idoc != -1 ) SendMessage ( hHeaders, GOTOIDOCALL, idoc ); } }
nsresult nsMsgOfflineManager::AdvanceToNextState(nsresult exitStatus) { // NS_BINDING_ABORTED is used for the user pressing stop, which // should cause us to abort the offline process. Other errors // should allow us to continue. if (exitStatus == NS_BINDING_ABORTED) { return StopRunning(exitStatus); } if (m_curOperation == eGoingOnline) { switch (m_curState) { case eNoState: m_curState = eSendingUnsent; if (m_sendUnsentMessages) { SendUnsentMessages(); } else AdvanceToNextState(NS_OK); break; case eSendingUnsent: m_curState = eSynchronizingOfflineImapChanges; if (m_playbackOfflineImapOps) return SynchronizeOfflineImapChanges(); else AdvanceToNextState(NS_OK); // recurse to next state. break; case eSynchronizingOfflineImapChanges: m_curState = eDone; return StopRunning(exitStatus); default: NS_ASSERTION(false, "unhandled current state when going online"); } } else if (m_curOperation == eDownloadingForOffline) { switch (m_curState) { case eNoState: m_curState = eDownloadingNews; if (m_downloadNews) DownloadOfflineNewsgroups(); else AdvanceToNextState(NS_OK); break; case eSendingUnsent: if (m_goOfflineWhenDone) { SetOnlineState(false); } break; case eDownloadingNews: m_curState = eDownloadingMail; if (m_downloadMail) DownloadMail(); else AdvanceToNextState(NS_OK); break; case eDownloadingMail: m_curState = eSendingUnsent; if (m_sendUnsentMessages) SendUnsentMessages(); else AdvanceToNextState(NS_OK); break; default: NS_ASSERTION(false, "unhandled current state when downloading for offline"); } } return NS_OK; }