diff --git a/mailnews/base/build/nsMsgBaseCID.h b/mailnews/base/build/nsMsgBaseCID.h index 90ee25a774c..d7182034270 100644 --- a/mailnews/base/build/nsMsgBaseCID.h +++ b/mailnews/base/build/nsMsgBaseCID.h @@ -418,4 +418,20 @@ {0xd97edfb5, 0xbcbe, 0x4a15, \ { 0xa4, 0xfb, 0xfb, 0xf2, 0xf9, 0x58, 0xb3, 0x88 }} +#define NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID \ + "@mozilla.org/messenger/localfoldercompactor;1" + +/* 7d1d315c-e5c6-11d4-a5b7-0060b0fc04b7 */ +#define NS_MSGLOCALFOLDERCOMPACTOR_CID \ + {0x7d1d315c, 0xe5c6, 0x11d4, \ + {0xa5, 0xb7, 0x00,0x60, 0xb0, 0xfc, 0x04, 0xb7 }} + +#define NS_MSGOFFLINESTORECOMPACTOR_CONTRACTID \ + "@mozilla.org/messenger/offlinestorecompactor;1" + +/* 2db43d16-e5c8-11d4-a5b7-0060b0fc04b7 */ +#define NS_MSG_OFFLINESTORECOMPACTOR_CID \ + {0x2db43d16, 0xe5c8, 0x11d4, \ + {0xa5, 0xb7, 0x00,0x60, 0xb0, 0xfc, 0x04, 0xb7 }} + #endif // nsMessageBaseCID_h__ diff --git a/mailnews/base/build/nsMsgFactory.cpp b/mailnews/base/build/nsMsgFactory.cpp index 307d434f10f..e4a76c45a61 100644 --- a/mailnews/base/build/nsMsgFactory.cpp +++ b/mailnews/base/build/nsMsgFactory.cpp @@ -83,7 +83,7 @@ #include "nsMsgSearchSession.h" #include "nsMsgSearchAdapter.h" #include "nsMsgSearchDataSource.h" - +#include "nsMsgFolderCompactor.h" // private factory declarations for each component we know how to produce @@ -119,6 +119,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgServiceProviderService, Init); NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSubscribeDataSource, Init); NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSubscribableServer, Init); NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgPrintEngine, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsFolderCompactState) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineStoreCompactState) // The list of components we register static nsModuleComponentInfo gComponents[] = { @@ -283,6 +285,14 @@ static nsModuleComponentInfo gComponents[] = { NS_SUBSCRIBABLESERVER_CONTRACTID, nsSubscribableServerConstructor, }, + { "Local folder compactor", NS_MSGLOCALFOLDERCOMPACTOR_CID, + NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, + nsFolderCompactStateConstructor, + }, + { "offline store compactor", NS_MSG_OFFLINESTORECOMPACTOR_CID, + NS_MSGOFFLINESTORECOMPACTOR_CONTRACTID, + nsOfflineStoreCompactStateConstructor, + } }; NS_IMPL_NSGETMODULE("nsMsgBaseModule", gComponents) diff --git a/mailnews/base/util/nsMsgDBFolder.cpp b/mailnews/base/util/nsMsgDBFolder.cpp index 6e58781df5e..7daa9128412 100644 --- a/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mailnews/base/util/nsMsgDBFolder.cpp @@ -35,6 +35,7 @@ #include "nsLocalFolderSummarySpec.h" #include "nsIFileStream.h" #include "nsIChannel.h" +#include "nsIMsgFolderCompactor.h" #if defined(XP_OS2) #define MAX_FILE_LENGTH_WITHOUT_EXTENSION 8 #elif defined(XP_MAC) @@ -1394,3 +1395,22 @@ nsresult nsMsgDBFolder::EndNewOfflineMessage() return NS_OK; } +nsresult nsMsgDBFolder::CompactOfflineStore(nsIMsgWindow *inWindow) +{ + nsresult rv; + nsCOMPtr folderCompactor = do_CreateInstance(NS_MSGOFFLINESTORECOMPACTOR_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && folderCompactor) + { + GetDatabase(nsnull); + if (NS_SUCCEEDED(rv)) + { + nsCOMPtr pathSpec; + rv = GetPath(getter_AddRefs(pathSpec)); + rv = folderCompactor->Init(this, mBaseMessageURI, mDatabase, pathSpec); + if (NS_SUCCEEDED(rv)) + rv = folderCompactor->StartCompacting(); + } + } + return rv; +} + diff --git a/mailnews/base/util/nsMsgDBFolder.h b/mailnews/base/util/nsMsgDBFolder.h index 02bcebeacc9..049acb0dd11 100644 --- a/mailnews/base/util/nsMsgDBFolder.h +++ b/mailnews/base/util/nsMsgDBFolder.h @@ -119,7 +119,7 @@ protected: nsresult StartNewOfflineMessage(); nsresult WriteStartOfNewLocalMessage(); nsresult EndNewOfflineMessage(); - + nsresult CompactOfflineStore(nsIMsgWindow *inWindow); protected: nsCOMPtr mDatabase;