Back to index

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

#include <nsDBFolderInfo.h>

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

List of all members.

Public Member Functions

 nsDBFolderInfo (nsMsgDatabase *mdb)
virtual ~nsDBFolderInfo ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDBFOLDERINFO
nsresult 
AddToNewMDB ()
PRBool TestFlag (PRInt32 flags)
PRInt16 GetIMAPHierarchySeparator ()
void SetIMAPHierarchySeparator (PRInt16 hierarchySeparator)
void ChangeImapTotalPendingMessages (PRInt32 delta)
void ChangeImapUnreadPendingMessages (PRInt32 delta)
nsresult InitFromExistingDB ()
nsresult SetPropertyWithToken (mdb_token aProperty, const nsAString &propertyStr)
nsresult SetUint32PropertyWithToken (mdb_token aProperty, PRUint32 propertyValue)
nsresult SetInt32PropertyWithToken (mdb_token aProperty, PRInt32 propertyValue)
nsresult GetPropertyWithToken (mdb_token aProperty, nsAString &resultProperty)
nsresult GetUint32PropertyWithToken (mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue=0)
nsresult GetInt32PropertyWithToken (mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue=0)
nsresult GetConstCharPtrCharacterSet (const char **result)
long OrFlags (in long flags)
long AndFlags (in long flags)
void SetHighWater (in nsMsgKey highwater, in boolean force)
void ChangeNumUnreadMessages (in long delta)
void ChangeNumMessages (in long delta)
void ChangeExpungedBytes (in long delta)
string getCharPtrProperty (in string propertyName)
void setCharPtrProperty (in string aPropertyName, in string aPropertyValue)
void setUint32Property (in string propertyName, in unsigned long propertyValue)
unsigned long getUint32Property (in string propertyName, in unsigned long defaultValue)
boolean getBooleanProperty (in string propertyName, in boolean defaultValue)
void setBooleanProperty (in string propertyName, in boolean aPropertyValue)
nsIDBFolderInfo GetTransferInfo ()
void initFromTransferInfo (in nsIDBFolderInfo transferInfo)
void getCharacterSet (out ACString charSet, out boolean overriden)
void setCharacterSet (in string charSet)
string getCharPtrCharacterSet ()
AString getProperty (in string propertyName)
void setProperty (in string propertyName, in AString propertyStr)

Public Attributes

nsMsgKeyArray m_lateredKeys
attribute long Flags
attribute nsMsgKey HighWater
attribute nsMsgKey ExpiredMark
attribute unsigned long FolderSize
attribute unsigned long FolderDate
attribute long NumUnreadMessages
attribute long NumMessages
attribute long expungedBytes
attribute long ImapUidValidity
attribute unsigned long Version
attribute long ImapTotalPendingMessages
attribute long ImapUnreadPendingMessages
attribute wchar IMAPHierarchySeparator
attribute nsMsgViewTypeValue viewType
attribute nsMsgViewFlagsTypeValue viewFlags
attribute nsMsgViewSortTypeValue sortType
attribute nsMsgViewSortOrderValue sortOrder
attribute boolean characterSetOverride
attribute AString locale
attribute AString mailboxName
attribute string knownArtsSet
attribute string folderName

Protected Member Functions

nsresult InitMDBInfo ()
nsresult LoadMemberVariables ()
void ReleaseExternalReferences ()

Protected Attributes

PRInt32 m_folderSize
PRInt32 m_expungedBytes
PRUint32 m_folderDate
nsMsgKey m_highWaterMessageKey
PRInt32 m_numUnreadMessages
PRInt32 m_numMessages
PRInt32 m_flags
PRUint16 m_version
PRInt16 m_IMAPHierarchySeparator
PRInt32 m_ImapUidValidity
PRInt32 m_totalPendingMessages
PRInt32 m_unreadPendingMessages
nsMsgKey m_expiredMark
nsMsgDatabasem_mdb
nsIMdbTablem_mdbTable
nsIMdbRowm_mdbRow
nsCString m_charSet
PRBool m_charSetOverride
PRBool m_mdbTokensInitialized
mdb_token m_rowScopeToken
mdb_token m_tableKindToken
mdb_token m_mailboxNameColumnToken
mdb_token m_numMessagesColumnToken
mdb_token m_numUnreadMessagesColumnToken
mdb_token m_flagsColumnToken
mdb_token m_folderSizeColumnToken
mdb_token m_expungedBytesColumnToken
mdb_token m_folderDateColumnToken
mdb_token m_highWaterMessageKeyColumnToken
mdb_token m_imapUidValidityColumnToken
mdb_token m_totalPendingMessagesColumnToken
mdb_token m_unreadPendingMessagesColumnToken
mdb_token m_expiredMarkColumnToken
mdb_token m_versionColumnToken

Friends

class nsMsgDatabase

Detailed Description

Definition at line 60 of file nsDBFolderInfo.h.


Constructor & Destructor Documentation

Definition at line 173 of file nsDBFolderInfo.cpp.

                  : m_flags(0),
                    m_expiredMark(0),
                    m_expiredMarkColumnToken(0)
{
  m_mdbTable = NULL;
  m_mdbRow = NULL;
  m_version = 1;                   // for upgrading...
  m_IMAPHierarchySeparator = 0;    // imap path separator
  // mail only (for now)
  m_folderSize = 0;
  m_folderDate = 0;
  m_expungedBytes = 0;      // sum of size of deleted messages in folder
  m_highWaterMessageKey = 0;
  
  m_numUnreadMessages = 0;
  m_numMessages = 0;
  // IMAP only
  m_ImapUidValidity = 0;
  m_totalPendingMessages =0;
  m_unreadPendingMessages = 0;
  
  m_mdbTokensInitialized = PR_FALSE;
  m_charSetOverride = PR_FALSE;
  
  if (!gInitializeObserver)
  {
    gInitializeObserver = PR_TRUE;
    nsresult rv;
    nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
    nsCOMPtr<nsIPrefBranch> prefBranch;
    if (NS_SUCCEEDED(rv))
    {
      rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
    }
    if (NS_SUCCEEDED(rv))
    {
      nsCOMPtr<nsIPrefLocalizedString> pls;
      rv = prefBranch->GetComplexValue(kMAILNEWS_VIEW_DEFAULT_CHARSET,
        NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls));
      if (NS_SUCCEEDED(rv)) 
      {
        nsXPIDLString ucsval;
        pls->ToString(getter_Copies(ucsval));
        if (ucsval)
        {
          if (gDefaultCharacterSet)
            nsMemory::Free(gDefaultCharacterSet);
          gDefaultCharacterSet = ToNewCString(ucsval);
        }
      }
      rv = prefBranch->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride);
      
      gFolderCharsetObserver = new nsFolderCharsetObserver();
      NS_ASSERTION(gFolderCharsetObserver, "failed to create observer");
      
      // register prefs callbacks
      if (gFolderCharsetObserver)
      {
        NS_ADDREF(gFolderCharsetObserver);
        nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(prefBranch);
        if (pbi) {
          rv = pbi->AddObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, gFolderCharsetObserver, PR_FALSE);
          rv = pbi->AddObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, gFolderCharsetObserver, PR_FALSE);
        }
        
        // also register for shutdown
        nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
        if (NS_SUCCEEDED(rv))
        {
          rv = observerService->AddObserver(gFolderCharsetObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
        }
      }
    }
  }
  
  m_mdb = mdb;
  if (mdb)
  {
    mdb_err err;
    
    //        mdb->AddRef();
    err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoScope, &m_rowScopeToken); 
    if (err == NS_OK)
    {
      err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoTableKind, &m_tableKindToken); 
      if (err == NS_OK)
      {
        gDBFolderInfoOID.mOid_Scope = m_rowScopeToken;
        gDBFolderInfoOID.mOid_Id = 1;
      }
    }
    InitMDBInfo();
  }
}

Here is the call graph for this function:

Definition at line 269 of file nsDBFolderInfo.cpp.

{
  // nsMsgDatabase strictly owns nsDBFolderInfo, so don't ref-count db.
  ReleaseExternalReferences();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 308 of file nsDBFolderInfo.cpp.

{
  nsresult ret = NS_OK;
  if (m_mdb && m_mdb->GetStore())
  {
    nsIMdbStore *store = m_mdb->GetStore();
    // create the unique table for the dbFolderInfo.
    mdb_err err = store->NewTable(m_mdb->GetEnv(), m_rowScopeToken, 
      m_tableKindToken, PR_TRUE, nsnull, &m_mdbTable);
    
    // make sure the oid of the table is 1.
    struct mdbOid folderInfoTableOID;
    folderInfoTableOID.mOid_Id = 1;
    folderInfoTableOID.mOid_Scope = m_rowScopeToken;
    
    //        m_mdbTable->BecomeContent(m_mdb->GetEnv(), &folderInfoTableOID);
    
    // create the singleton row for the dbFolderInfo.
    err  = store->NewRowWithOid(m_mdb->GetEnv(),
      &gDBFolderInfoOID, &m_mdbRow);
    
    // add the row to the singleton table.
    if (m_mdbRow && NS_SUCCEEDED(err))
    {
      err = m_mdbTable->AddRow(m_mdb->GetEnv(), m_mdbRow);
    }
    
    ret = err;       // what are we going to do about mdb_err's?
  }
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long nsIDBFolderInfo::AndFlags ( in long  flags) [inherited]

Here is the caller graph for this function:

Definition at line 744 of file nsDBFolderInfo.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

boolean nsIDBFolderInfo::getBooleanProperty ( in string  propertyName,
in boolean  defaultValue 
) [inherited]
void nsIDBFolderInfo::getCharacterSet ( out ACString  charSet,
out boolean  overriden 
) [inherited]
string nsIDBFolderInfo::getCharPtrProperty ( in string  propertyName) [inherited]

Definition at line 667 of file nsDBFolderInfo.cpp.

{
  if (!m_charSet.IsEmpty())
    *result = m_charSet.get();
  else
    *result = gDefaultCharacterSet;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 721 of file nsDBFolderInfo.cpp.

{
  if (!hierarchySeparator)
    return NS_ERROR_NULL_POINTER;
  *hierarchySeparator = m_IMAPHierarchySeparator;
  return NS_OK;
}
nsresult nsDBFolderInfo::GetInt32PropertyWithToken ( mdb_token  aProperty,
PRInt32 propertyValue,
PRInt32  defaultValue = 0 
)

Definition at line 910 of file nsDBFolderInfo.cpp.

{
  return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, (PRUint32 &) propertyValue, defaultValue);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AString nsIDBFolderInfo::getProperty ( in string  propertyName) [inherited]
nsresult nsDBFolderInfo::GetPropertyWithToken ( mdb_token  aProperty,
nsAString &  resultProperty 
)

Definition at line 900 of file nsDBFolderInfo.cpp.

{
  return m_mdb->RowCellColumnTonsString(m_mdbRow, aProperty, resultProperty);
}

Here is the call graph for this function:

unsigned long nsIDBFolderInfo::getUint32Property ( in string  propertyName,
in unsigned long  defaultValue 
) [inherited]
nsresult nsDBFolderInfo::GetUint32PropertyWithToken ( mdb_token  aProperty,
PRUint32 propertyValue,
PRUint32  defaultValue = 0 
)

Definition at line 905 of file nsDBFolderInfo.cpp.

{
  return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, propertyValue, defaultValue);
}

Here is the call graph for this function:

Definition at line 340 of file nsDBFolderInfo.cpp.

{
  nsresult ret = NS_OK;
  if (m_mdb && m_mdb->GetStore())
  {
    nsIMdbStore *store = m_mdb->GetStore();
    if (store)
    {
      mdb_pos        rowPos;
      mdb_count outTableCount; // current number of such tables
      mdb_bool mustBeUnique; // whether port can hold only one of these
      mdb_bool hasOid;
      ret = store->GetTableKind(m_mdb->GetEnv(), m_rowScopeToken, m_tableKindToken, &outTableCount, 
        &mustBeUnique, &m_mdbTable);
      //                    NS_ASSERTION(mustBeUnique && outTableCount == 1, "only one global db info allowed");
      
      if (m_mdbTable)
      {
        // find singleton row for global info.
        ret = m_mdbTable->HasOid(m_mdb->GetEnv(), &gDBFolderInfoOID, &hasOid);
        if (ret == NS_OK)
        {
          nsIMdbTableRowCursor *rowCursor;
          rowPos = -1;
          ret= m_mdbTable->GetTableRowCursor(m_mdb->GetEnv(), rowPos, &rowCursor);
          if (ret == NS_OK)
          {
            ret = rowCursor->NextRow(m_mdb->GetEnv(), &m_mdbRow, &rowPos);
            NS_RELEASE(rowCursor);
            if (!m_mdbRow)
              ret = NS_ERROR_FAILURE;
            if (ret == NS_OK)
              LoadMemberVariables();
          }
        }
      }
      else
        ret = NS_ERROR_FAILURE;
    }
  }
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long nsIDBFolderInfo::OrFlags ( in long  flags) [inherited]

Here is the caller graph for this function:

Definition at line 277 of file nsDBFolderInfo.cpp.

{
  if (gReleaseObserver && gFolderCharsetObserver) 
  {
    NS_IF_RELEASE(gFolderCharsetObserver);
  
    // this can be called many times
    if (gDefaultCharacterSet)
    {
      nsMemory::Free(gDefaultCharacterSet);
      gDefaultCharacterSet = NULL; // free doesn't null out our ptr.
    }
  }
  
  if (m_mdb)
  {
    if (m_mdbTable)
    {
      NS_RELEASE(m_mdbTable);
      m_mdbTable = nsnull;
    }
    if (m_mdbRow)
    {
      NS_RELEASE(m_mdbRow);
      m_mdbRow = nsnull;
    }
    m_mdb = nsnull;
  }
}

Here is the caller graph for this function:

void nsIDBFolderInfo::setBooleanProperty ( in string  propertyName,
in boolean  aPropertyValue 
) [inherited]
void nsIDBFolderInfo::setCharacterSet ( in string  charSet) [inherited]
void nsIDBFolderInfo::setCharPtrProperty ( in string  aPropertyName,
in string  aPropertyValue 
) [inherited]
void nsIDBFolderInfo::SetHighWater ( in nsMsgKey  highwater,
in boolean  force 
) [inherited]

Definition at line 729 of file nsDBFolderInfo.cpp.

{
  m_IMAPHierarchySeparator = hierarchySeparator; 
  return NS_OK;
}

Definition at line 893 of file nsDBFolderInfo.cpp.

{
  nsAutoString propertyStr;
  propertyStr.AppendInt(propertyValue, 16);
  return SetPropertyWithToken(aProperty, propertyStr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDBFolderInfo::setProperty ( in string  propertyName,
in AString  propertyStr 
) [inherited]
nsresult nsDBFolderInfo::SetPropertyWithToken ( mdb_token  aProperty,
const nsAString &  propertyStr 
)

Definition at line 883 of file nsDBFolderInfo.cpp.

{
  return m_mdb->SetNSStringPropertyWithToken(m_mdbRow, aProperty, propertyStr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDBFolderInfo::setUint32Property ( in string  propertyName,
in unsigned long  propertyValue 
) [inherited]

Definition at line 888 of file nsDBFolderInfo.cpp.

{
  return m_mdb->UInt32ToRowCellColumn(m_mdbRow, aProperty, propertyValue);
}

Here is the call graph for this function:

Definition at line 644 of file nsDBFolderInfo.cpp.

{
  return (m_flags & flags) != 0;
}

Friends And Related Function Documentation

friend class nsMsgDatabase [friend]

Definition at line 63 of file nsDBFolderInfo.h.


Member Data Documentation

Definition at line 84 of file nsIDBFolderInfo.idl.

Definition at line 48 of file nsIDBFolderInfo.idl.

Definition at line 58 of file nsIDBFolderInfo.idl.

Definition at line 43 of file nsIDBFolderInfo.idl.

Definition at line 50 of file nsIDBFolderInfo.idl.

Definition at line 96 of file nsIDBFolderInfo.idl.

Definition at line 49 of file nsIDBFolderInfo.idl.

Definition at line 47 of file nsIDBFolderInfo.idl.

Definition at line 63 of file nsIDBFolderInfo.idl.

Definition at line 61 of file nsIDBFolderInfo.idl.

Definition at line 59 of file nsIDBFolderInfo.idl.

Definition at line 62 of file nsIDBFolderInfo.idl.

Definition at line 95 of file nsIDBFolderInfo.idl.

attribute AString nsIDBFolderInfo::locale [inherited]

Definition at line 88 of file nsIDBFolderInfo.idl.

Definition at line 132 of file nsDBFolderInfo.h.

Definition at line 133 of file nsDBFolderInfo.h.

Definition at line 125 of file nsDBFolderInfo.h.

Definition at line 151 of file nsDBFolderInfo.h.

Definition at line 103 of file nsDBFolderInfo.h.

Definition at line 144 of file nsDBFolderInfo.h.

Definition at line 111 of file nsDBFolderInfo.h.

Definition at line 142 of file nsDBFolderInfo.h.

Definition at line 104 of file nsDBFolderInfo.h.

Definition at line 145 of file nsDBFolderInfo.h.

Definition at line 102 of file nsDBFolderInfo.h.

Definition at line 143 of file nsDBFolderInfo.h.

Definition at line 105 of file nsDBFolderInfo.h.

Definition at line 146 of file nsDBFolderInfo.h.

Definition at line 115 of file nsDBFolderInfo.h.

Definition at line 120 of file nsDBFolderInfo.h.

Definition at line 148 of file nsDBFolderInfo.h.

Definition at line 92 of file nsDBFolderInfo.h.

Definition at line 139 of file nsDBFolderInfo.h.

Definition at line 128 of file nsDBFolderInfo.h.

Definition at line 130 of file nsDBFolderInfo.h.

Definition at line 129 of file nsDBFolderInfo.h.

Definition at line 134 of file nsDBFolderInfo.h.

Definition at line 109 of file nsDBFolderInfo.h.

Definition at line 140 of file nsDBFolderInfo.h.

Definition at line 108 of file nsDBFolderInfo.h.

Definition at line 141 of file nsDBFolderInfo.h.

Definition at line 136 of file nsDBFolderInfo.h.

Definition at line 137 of file nsDBFolderInfo.h.

Definition at line 121 of file nsDBFolderInfo.h.

Definition at line 149 of file nsDBFolderInfo.h.

Definition at line 122 of file nsDBFolderInfo.h.

Definition at line 150 of file nsDBFolderInfo.h.

Definition at line 114 of file nsDBFolderInfo.h.

Definition at line 152 of file nsDBFolderInfo.h.

Definition at line 89 of file nsIDBFolderInfo.idl.

Definition at line 56 of file nsIDBFolderInfo.idl.

Definition at line 55 of file nsIDBFolderInfo.idl.

Definition at line 68 of file nsIDBFolderInfo.idl.

Definition at line 67 of file nsIDBFolderInfo.idl.

attribute unsigned long nsIDBFolderInfo::Version [inherited]

Definition at line 60 of file nsIDBFolderInfo.idl.

Definition at line 66 of file nsIDBFolderInfo.idl.

Definition at line 65 of file nsIDBFolderInfo.idl.


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