Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsMsgBiffManager Class Reference

#include <nsMsgBiffManager.h>

Inheritance diagram for nsMsgBiffManager:
Inheritance graph
[legend]
Collaboration diagram for nsMsgBiffManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsMsgBiffManager ()
virtual ~nsMsgBiffManager ()
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGBIFFMANAGER
NS_DECL_NSIINCOMINGSERVERLISTENER
NS_DECL_NSIOBSERVER nsresult 
PerformBiff ()
void init ()
void addServerBiff (in nsIMsgIncomingServer server)
void removeServerBiff (in nsIMsgIncomingServer server)
void forceBiff (in nsIMsgIncomingServer server)
void forceBiffAll ()
void shutdown ()
void onServerLoaded (in nsIMsgIncomingServer server)
void onServerUnloaded (in nsIMsgIncomingServer server)
void onServerChanged (in nsIMsgIncomingServer server)
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Protected Member Functions

PRInt32 FindServer (nsIMsgIncomingServer *server)
nsresult SetNextBiffTime (nsBiffEntry *biffEntry, nsTime startTime)
nsresult SetupNextBiff ()
nsresult AddBiffEntry (nsBiffEntry *biffEntry)

Protected Attributes

nsCOMPtr< nsITimermBiffTimer
nsVoidArraymBiffArray
PRBool mHaveShutdown
PRBool mInited

Detailed Description

Definition at line 57 of file nsMsgBiffManager.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsMsgBiffManager.cpp.

Definition at line 71 of file nsMsgBiffManager.cpp.

{
  
  if (mBiffTimer) {
    mBiffTimer->Cancel();
  }
  
  PRInt32 count = mBiffArray->Count();
  PRInt32 i;
  for(i=0; i < count; i++)
  {
    nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(i);
    delete biffEntry;
  }
  delete mBiffArray;
  
  if(!mHaveShutdown)
  {
    Shutdown();
  }
}

Here is the call graph for this function:


Member Function Documentation

nsresult nsMsgBiffManager::AddBiffEntry ( nsBiffEntry biffEntry) [protected]

Definition at line 262 of file nsMsgBiffManager.cpp.

{
  PRInt32 i;
  PRInt32 count = mBiffArray->Count();
  for(i = 0; i < count; i++)
  {
    nsBiffEntry *current = (nsBiffEntry*)mBiffArray->ElementAt(i);
    if(biffEntry->nextBiffTime < current->nextBiffTime)
      break;
    
  }
  PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("inserting biff entry at %d\n", i));
  mBiffArray->InsertElementAt(biffEntry, i);
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 250 of file nsMsgBiffManager.cpp.

{
  PRInt32 count = mBiffArray->Count();
  for(PRInt32 i = 0; i < count; i++)
  {
    nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(i);
    if(server == biffEntry->server.get())
      return i;
  }
  return -1;
}

Here is the call graph for this function:

void nsIMsgBiffManager::init ( ) [inherited]
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Definition at line 338 of file nsMsgBiffManager.cpp.

{
  nsTime currentTime;
  nsCOMArray <nsIMsgFolder> targetFolders;
  PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("performing biffs\n"));

  for(PRInt32 i = 0; i < mBiffArray->Count(); i++)
  {
    nsBiffEntry *current = (nsBiffEntry*)mBiffArray->ElementAt(i);
    if(current->nextBiffTime < currentTime)
    {
      PRBool serverBusy = PR_FALSE;
      PRBool serverRequiresPassword = PR_TRUE;
      PRBool passwordPromptRequired; 

      current->server->GetPasswordPromptRequired(&passwordPromptRequired);
      current->server->GetServerBusy(&serverBusy);
      current->server->GetServerRequiresPasswordForBiff(&serverRequiresPassword);
      // find the dest folder we're actually downloading to...
      nsCOMPtr<nsIMsgFolder> rootMsgFolder;
      current->server->GetRootMsgFolder(getter_AddRefs(rootMsgFolder));
      PRInt32 targetFolderIndex = targetFolders.IndexOfObject(rootMsgFolder);
      if (targetFolderIndex == kNotFound)
        targetFolders.AppendObject(rootMsgFolder);

      // so if we need to be authenticated to biff, check that we are
      // (since we don't want to prompt the user for password UI)
      // and make sure the server isn't already in the middle of downloading new messages
      if(!serverBusy && (!serverRequiresPassword || !passwordPromptRequired) && targetFolderIndex == kNotFound)
      {
        nsXPIDLCString serverKey;
        current->server->GetKey(getter_Copies(serverKey));
        nsresult rv = current->server->PerformBiff(nsnull);
        PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("biffing server %s rv = %x\n", serverKey.get(), rv));
      }
      else
      {
        PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("not biffing server serverBusy = %d requirespassword = %d password prompt required = %d targetFolderIndex = %d\n",
          serverBusy, serverRequiresPassword, passwordPromptRequired, targetFolderIndex));
      }
      // if we didn't do this server because the destination server was already being
      // biffed into, leave this server in the biff array so it will fire next.
      if (targetFolderIndex == kNotFound)
      {
        mBiffArray->RemoveElementAt(i);
        i--; //Because we removed it we need to look at the one that just moved up.
        SetNextBiffTime(current, currentTime);
        AddBiffEntry(current);
      }
#ifdef DEBUG_David_Bienvenu
      else
        printf("dest account performing biff\n");
#endif
    }
    else
      //since we're in biff order, there's no reason to keep checking
      break;
  }
  SetupNextBiff();
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgBiffManager::SetNextBiffTime ( nsBiffEntry biffEntry,
nsTime  startTime 
) [protected]

Definition at line 278 of file nsMsgBiffManager.cpp.

{
  nsresult rv;
  nsIMsgIncomingServer *server = biffEntry->server;
  
  if(!server)
    return NS_ERROR_FAILURE;
  
  PRInt32 biffInterval;
  rv = server->GetBiffMinutes(&biffInterval);
  if(NS_FAILED(rv))
    return rv;
  //Add 60 secs/minute in microseconds to current time. biffEntry->nextBiffTime's
  //constructor makes it the current time.
  nsInt64 chosenTimeInterval = biffInterval;
  chosenTimeInterval *= 60000000;
  biffEntry->nextBiffTime = startTime;
  biffEntry->nextBiffTime += chosenTimeInterval;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 299 of file nsMsgBiffManager.cpp.

{
  
  if(mBiffArray->Count() > 0)
  {
    
    //Get the next biff entry
    nsBiffEntry *biffEntry = (nsBiffEntry*)mBiffArray->ElementAt(0);
    nsTime currentTime;
    nsInt64 biffDelay;
    nsInt64 ms(1000);
    if(currentTime > biffEntry->nextBiffTime)
    {
      PRInt64 microSecondsPerSecond;
  
      LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
      LL_MUL(biffDelay, 30, microSecondsPerSecond); //let's wait 30 seconds before firing biff again
    }
    else
      biffDelay = biffEntry->nextBiffTime - currentTime;
    //Convert biffDelay into milliseconds
    nsInt64 timeInMS = biffDelay / ms;
    PRUint32 timeInMSUint32 = (PRUint32)timeInMS;
    //Can't currently reset a timer when it's in the process of
    //calling Notify. So, just release the timer here and create a new one.
    if(mBiffTimer)
    {
      mBiffTimer->Cancel();
    }
    PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("setting %d timer\n", timeInMSUint32));
    mBiffTimer = do_CreateInstance("@mozilla.org/timer;1");
    mBiffTimer->InitWithFuncCallback(OnBiffTimer, (void*)this, timeInMSUint32, 
                                     nsITimer::TYPE_ONE_SHOT);
    
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 82 of file nsMsgBiffManager.h.

Definition at line 81 of file nsMsgBiffManager.h.

Definition at line 83 of file nsMsgBiffManager.h.

Definition at line 84 of file nsMsgBiffManager.h.


The documentation for this class was generated from the following files: