--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
@@ -43,17 +43,16 @@
#include "nsAbLDAPChangeLogQuery.h"
#include "nsILDAPMessage.h"
#include "nsIAbCard.h"
#include "nsIAddrBookSession.h"
#include "nsAbBaseCID.h"
#include "nsAbUtils.h"
#include "nsAbMDBCard.h"
#include "nsAbLDAPCard.h"
-#include "nsProxiedService.h"
#include "nsIAuthPrompt.h"
#include "nsIStringBundle.h"
#include "nsIWindowWatcher.h"
#include "nsUnicharUtils.h"
#include "plstr.h"
#include "nsILDAPErrors.h"
#include "prmem.h"
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -45,17 +45,16 @@
#include "nsCOMPtr.h"
#include "MailNewsTypes2.h"
#include "nsTArray.h"
#include "nsIInterfaceRequestor.h"
#include "nsILoadGroup.h"
#include "nsISupportsArray.h"
#include "nsIAtom.h"
#include "nsINetUtil.h"
-#include "nsIProxyObjectManager.h"
#include "nsServiceManagerUtils.h"
#include "nsUnicharUtils.h"
class nsILocalFile;
class nsIPrefBranch;
class nsIMsgFolder;
class nsIMsgMessageService;
class nsIUrlListener;
@@ -331,18 +330,16 @@ NS_MSG_BASE PRUint64 ParseUint64Str(cons
#define MsgReplaceSubstring(str, what, replacement) \
(str).ReplaceSubstring(what, replacement)
#define MsgIsUTF8(str) \
IsUTF8(str)
#define MsgNewInterfaceRequestorAggregation(aFirst, aSecond, aResult) \
NS_NewInterfaceRequestorAggregation(aFirst, aSecond, aResult)
#define MsgNewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, aResult) \
NS_NewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, aResult)
-#define MsgGetProxyForObject(aTarget, aIID, aObj, aProxyType, aProxyObject) \
- NS_GetProxyForObject(aTarget, aIID, aObj, aProxyType, aProxyObject)
#define MsgGetAtom(aString) \
do_GetAtom(aString)
#define MsgNewAtom(aString) \
NS_NewAtom(aString)
#define MsgReplaceChar(aString, aNeedle, aReplacement) \
(aString).ReplaceChar(aNeedle, aReplacement)
#define MsgFind(str, what, ignore_case, offset) \
(str).Find(what, ignore_case, offset)
@@ -486,31 +483,11 @@ class NS_MSG_BASE MsgQueryElementAt : pu
* internal API only accepts nsICollection* aCollection.
*/
inline
const MsgQueryElementAt
do_QueryElementAt( nsISupportsArray* array, PRUint32 aIndex, nsresult* aErrorPtr = 0 )
{
return MsgQueryElementAt(array, aIndex, aErrorPtr);
}
-
-/// Equivalent of NS_GetProxyForObject(aTarget, aIID, aObj, aProxyType, aProxyObject)
-inline
-nsresult
-MsgGetProxyForObject(nsIEventTarget *target,
- REFNSIID aIID,
- nsISupports* aObj,
- PRInt32 proxyType,
- void** aProxyObject)
-{
- // get the proxy object manager
- nsresult rv;
- nsCOMPtr<nsIProxyObjectManager> proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1", &rv);
- if (NS_FAILED(rv))
- return rv;
- // and try to get the proxy object
- return proxyObjMgr->GetProxyForObject(target, aIID, aObj,
- proxyType, aProxyObject);
-}
-
#endif
#endif
--- a/mailnews/imap/src/Makefile.in
+++ b/mailnews/imap/src/Makefile.in
@@ -68,16 +68,17 @@ CPPSRCS = \
nsImapService.cpp \
nsImapUrl.cpp \
nsImapFlagAndUidState.cpp \
nsImapUndoTxn.cpp \
nsImapStringBundle.cpp \
nsImapOfflineSync.cpp \
nsAutoSyncState.cpp \
nsAutoSyncManager.cpp \
+ nsSyncRunnableHelpers.cpp \
$(NULL)
include $(topsrcdir)/config/config.mk
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -64,17 +64,16 @@
#include "nsImapMailFolder.h"
#include "nsIMsgAccountManager.h"
#include "nsImapServerResponseParser.h"
#include "nspr.h"
#include "plbase64.h"
#include "nsIImapService.h"
#include "nsISocketTransportService.h"
#include "nsIStreamListenerTee.h"
-#include "nsXPCOMCIDInternal.h"
#include "nsNetUtil.h"
#include "nsIDBFolderInfo.h"
#include "nsIPipe.h"
#include "nsIMsgFolder.h"
#include "nsMsgMessageFlags.h"
#include "nsImapStringBundle.h"
#include "nsICopyMsgStreamListener.h"
#include "nsTextFormatter.h"
@@ -89,28 +88,28 @@
#include "nsIMessengerWindowService.h"
#include "nsIWindowMediator.h"
#include "nsIWindowWatcher.h"
#include "nsCOMPtr.h"
#include "nsMimeTypes.h"
#include "nsIInterfaceRequestor.h"
#include "nsXPCOMCIDInternal.h"
#include "nsIXULAppInfo.h"
+#include "nsSyncRunnableHelpers.h"
PRLogModuleInfo *IMAP;
// netlib required files
#include "nsIStreamListener.h"
#include "nsIMsgIncomingServer.h"
#include "nsIImapIncomingServer.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsImapUtils.h"
-#include "nsIProxyObjectManager.h"
#include "nsIStreamConverterService.h"
#include "nsIProxyInfo.h"
#include "nsISSLSocketControl.h"
#include "nsProxyRelease.h"
#include "nsDebug.h"
#include "nsMsgCompressIStream.h"
#include "nsMsgCompressOStream.h"
#include "nsAlgorithm.h"
@@ -605,76 +604,44 @@ nsImapProtocol::GetImapServerKey()
if (m_serverKey.IsEmpty() && server)
server->GetKey(m_serverKey);
return m_serverKey.get();
}
void
nsImapProtocol::SetupSinkProxy()
{
- nsresult res = NS_ERROR_FAILURE;
-
+ nsresult res;
if (m_runningUrl)
{
- NS_ASSERTION(m_sinkEventTarget && m_thread, "fatal... null sink event queue or thread");
-
- nsCOMPtr<nsIProxyObjectManager> proxyManager(do_GetService(NS_XPCOMPROXY_CONTRACTID, &res));
- if (proxyManager) // if we don't get one of these are as good as dead...
- {
- if (!m_imapMailFolderSink)
- {
- nsCOMPtr<nsIImapMailFolderSink> aImapMailFolderSink;
- res = m_runningUrl->GetImapMailFolderSink(getter_AddRefs(aImapMailFolderSink));
- if (NS_SUCCEEDED(res) && aImapMailFolderSink)
- res = proxyManager->GetProxyForObject(m_sinkEventTarget,
- NS_GET_IID(nsIImapMailFolderSink),
- aImapMailFolderSink,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_imapMailFolderSink));
- }
-
- if (!m_imapMessageSink)
- {
- nsCOMPtr<nsIImapMessageSink> aImapMessageSink;
- res = m_runningUrl->GetImapMessageSink(getter_AddRefs(aImapMessageSink));
- if (NS_SUCCEEDED(res) && aImapMessageSink)
- res = proxyManager->GetProxyForObject(m_sinkEventTarget,
- NS_GET_IID(nsIImapMessageSink),
- aImapMessageSink,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_imapMessageSink));
- }
- if (!m_imapServerSink)
- {
- nsCOMPtr<nsIImapServerSink> aImapServerSink;
- res = m_runningUrl->GetImapServerSink(getter_AddRefs(aImapServerSink));
- if (NS_SUCCEEDED(res) && aImapServerSink)
- res = proxyManager->GetProxyForObject( m_sinkEventTarget,
- NS_GET_IID(nsIImapServerSink),
- aImapServerSink,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_imapServerSink));
- NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
- }
- if (!m_imapProtocolSink)
- {
- nsCOMPtr<nsIImapProtocolSink> anImapProxyHelper(do_QueryInterface(NS_ISUPPORTS_CAST(nsIImapProtocolSink*, this), &res));
- if (NS_SUCCEEDED(res) && anImapProxyHelper)
- res = proxyManager->GetProxyForObject( m_sinkEventTarget,
- NS_GET_IID(nsIImapProtocolSink),
- anImapProxyHelper,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_imapProtocolSink));
- NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
- }
- }
- else
- NS_ASSERTION(PR_FALSE, "can't get proxy service");
- }
- NS_ASSERTION(NS_SUCCEEDED(res), "couldn't get proxies");
+ if (!m_imapMailFolderSink)
+ {
+ nsCOMPtr<nsIImapMailFolderSink> aImapMailFolderSink;
+ (void) m_runningUrl->GetImapMailFolderSink(getter_AddRefs(aImapMailFolderSink));
+ m_imapMailFolderSink = new ImapMailFolderSinkProxy(aImapMailFolderSink);
+ }
+
+ if (!m_imapMessageSink)
+ {
+ nsCOMPtr<nsIImapMessageSink> aImapMessageSink;
+ (void) m_runningUrl->GetImapMessageSink(getter_AddRefs(aImapMessageSink));
+ m_imapMessageSink = new ImapMessageSinkProxy(aImapMessageSink);
+ }
+ if (!m_imapServerSink)
+ {
+ nsCOMPtr<nsIImapServerSink> aImapServerSink;
+ res = m_runningUrl->GetImapServerSink(getter_AddRefs(aImapServerSink));
+ m_imapServerSink = new ImapServerSinkProxy(aImapServerSink);
+ }
+ if (!m_imapProtocolSink)
+ {
+ nsCOMPtr<nsIImapProtocolSink> anImapProxyHelper(do_QueryInterface(NS_ISUPPORTS_CAST(nsIImapProtocolSink*, this), &res));
+ m_imapProtocolSink = new ImapProtocolSinkProxy(anImapProxyHelper);
+ }
+ }
}
static void SetSecurityCallbacksFromChannel(nsISocketTransport* aTrans, nsIChannel* aChannel)
{
nsCOMPtr<nsIInterfaceRequestor> callbacks;
aChannel->GetNotificationCallbacks(getter_AddRefs(callbacks));
nsCOMPtr<nsILoadGroup> loadGroup;
@@ -708,29 +675,31 @@ nsresult nsImapProtocol::SetupWithUrl(ns
NS_ENSURE_SUCCESS(rv, rv);
m_server = do_GetWeakReference(server);
}
nsCOMPtr <nsIMsgFolder> folder;
mailnewsUrl->GetFolder(getter_AddRefs(folder));
mFolderLastModSeq = 0;
mFolderTotalMsgCount = 0;
mFolderHighestUID = 0;
+ m_uidValidity = kUidUnknown;
if (folder)
{
nsCOMPtr<nsIMsgDatabase> folderDB;
nsCOMPtr<nsIDBFolderInfo> folderInfo;
folder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(folderDB));
if (folderInfo)
{
nsCString modSeqStr;
folderInfo->GetCharProperty(kModSeqPropertyName, modSeqStr);
mFolderLastModSeq = ParseUint64Str(modSeqStr.get());
folderInfo->GetNumMessages(&mFolderTotalMsgCount);
folderInfo->GetUint32Property(kHighestRecordedUIDPropertyName, 0, &mFolderHighestUID);
- }
+ folderInfo->GetImapUidValidity(&m_uidValidity);
+ }
}
nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryInterface(server);
nsCOMPtr<nsIStreamListener> aRealStreamListener = do_QueryInterface(aConsumer);
m_runningUrl->GetMockChannel(getter_AddRefs(m_mockChannel));
if (!m_mockChannel)
{
// there are several imap operations that aren't initiated via a nsIChannel::AsyncOpen call on the mock channel.
// such as selecting a folder. nsImapProtocol now insists on a mock channel when processing a url.
@@ -775,22 +744,17 @@ nsresult nsImapProtocol::SetupWithUrl(ns
}
// since we'll be making calls directly from the imap thread to the channel listener,
// we need to turn it into a proxy object....we'll assume that the listener is on the same thread
// as the event sink queue
if (aRealStreamListener)
{
NS_ASSERTION(!m_channelListener, "shouldn't already have a channel listener");
- rv = MsgGetProxyForObject(m_sinkEventTarget,
- NS_GET_IID(nsIStreamListener),
- aRealStreamListener,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(m_channelListener));
- if (NS_FAILED(rv)) return rv;
+ m_channelListener = new StreamListenerProxy(aRealStreamListener);
}
PRUint32 capability = kCapabilityUndefined;
m_hostSessionList->GetCapabilityForHost(GetImapServerKey(), capability);
server->GetRealHostName(m_realHostName);
PRInt32 authMethod;
@@ -1811,17 +1775,17 @@ bool nsImapProtocol::ProcessCurrentURL()
m_runningUrl->GetCopyState(getter_AddRefs(copyState));
// this is so hokey...we MUST clear any local references to the url
// BEFORE calling ReleaseUrlState
mailnewsurl = nsnull;
if (suspendUrl)
m_imapServerSink->SuspendUrl(m_runningUrl);
// save the imap folder sink since we need it to do the CopyNextStreamMessage
- nsCOMPtr<nsIImapMailFolderSink> imapMailFolderSink = m_imapMailFolderSink;
+ nsRefPtr<ImapMailFolderSinkProxy> imapMailFolderSink = m_imapMailFolderSink;
// release the url as we are done with it...
ReleaseUrlState(PR_FALSE);
ResetProgressInfo();
ClearFlag(IMAP_CLEAN_UP_URL_STATE);
if (imapMailFolderSink)
{
@@ -2483,29 +2447,22 @@ void nsImapProtocol::ProcessSelectedStat
if (selectIssued)
RefreshACLForFolderIfNecessary(mailboxName.get());
bool uidValidityOk = true;
if (GetServerStateParser().LastCommandSuccessful() && selectIssued &&
(m_imapAction != nsIImapUrl::nsImapSelectFolder) && (m_imapAction != nsIImapUrl::nsImapLiteSelectFolder))
{
- if (m_imapMailFolderSink)
- {
- PRInt32 uidValidity;
- m_imapMailFolderSink->GetUidValidity(&uidValidity);
-
-
- // error on the side of caution, if the fe event fails to set uidStruct->returnValidity, then assume that UIDVALIDITY
- // did not roll. This is a common case event for attachments that are fetched within a browser context.
- if (!DeathSignalReceived())
- uidValidityOk = uidValidity == kUidUnknown ||
- uidValidity == GetServerStateParser().FolderUID();
- }
-
+
+ // error on the side of caution, if the fe event fails to set uidStruct->returnValidity, then assume that UIDVALIDITY
+ // did not roll. This is a common case event for attachments that are fetched within a browser context.
+ if (!DeathSignalReceived())
+ uidValidityOk = m_uidValidity == kUidUnknown ||
+ m_uidValidity == GetServerStateParser().FolderUID();
}
if (!uidValidityOk)
Log("ProcessSelectedStateURL", nsnull, "uid validity not ok");
if (GetServerStateParser().LastCommandSuccessful() && !DeathSignalReceived() && (uidValidityOk || m_imapAction == nsIImapUrl::nsImapDeleteAllMsgs))
{
if (GetServerStateParser().CurrentFolderReadOnly())
{
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -84,16 +84,18 @@
#include "nsIImapHeaderXferInfo.h"
#include "nsMsgLineBuffer.h"
#include "nsIAsyncInputStream.h"
#include "nsITimer.h"
#include "nsAutoPtr.h"
#include "nsIMsgFolder.h"
#include "nsIMsgAsyncPrompter.h"
#include "mozilla/ReentrantMonitor.h"
+#include "nsSyncRunnableHelpers.h"
+
class nsIMAPMessagePartIDArray;
class nsIMsgIncomingServer;
class nsIPrefBranch;
#define kDownLoadCacheSize 16000 // was 1536 - try making it bigger
typedef struct _msg_line_info {
@@ -395,20 +397,20 @@ private:
bool m_imapThreadIsRunning;
void ImapThreadMainLoop(void);
nsresult m_connectionStatus;
nsCString m_connectionType;
bool m_nextUrlReadyToRun;
nsWeakPtr m_server;
- nsCOMPtr<nsIImapMailFolderSink> m_imapMailFolderSink;
- nsCOMPtr<nsIImapMessageSink> m_imapMessageSink;
- nsCOMPtr<nsIImapServerSink> m_imapServerSink;
- nsCOMPtr<nsIImapProtocolSink> m_imapProtocolSink;
+ nsRefPtr<ImapMailFolderSinkProxy> m_imapMailFolderSink;
+ nsRefPtr<ImapMessageSinkProxy> m_imapMessageSink;
+ nsRefPtr<ImapServerSinkProxy> m_imapServerSink;
+ nsRefPtr<ImapProtocolSinkProxy> m_imapProtocolSink;
// helper function to setup imap sink interface proxies
void SetupSinkProxy();
// End thread support stuff
bool GetDeleteIsMoveToTrash();
bool GetShowDeletedMessages();
nsCString m_currentCommand;
@@ -664,16 +666,18 @@ private:
bool m_idle;
bool m_useIdle;
PRInt32 m_noopCount;
bool m_autoSubscribe, m_autoUnsubscribe, m_autoSubscribeOnOpen;
bool m_closeNeededBeforeSelect;
bool m_retryUrlOnError;
bool m_preferPlainText;
+ PRInt32 m_uidValidity; // stored uid validity for the selected folder.
+
enum EMailboxHierarchyNameState {
kNoOperationInProgress,
kDiscoverBaseFolderInProgress,
kDiscoverTrashFolderInProgress,
kDeleteSubFoldersInProgress,
kListingForInfoOnly,
kListingForInfoAndDiscovery,
kDiscoveringNamespacesOnly,
new file mode 100644
--- /dev/null
+++ b/mailnews/imap/src/nsSyncRunnableHelpers.cpp
@@ -0,0 +1,481 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Thunderbird.
+ *
+ * The Initial Developer of the Original Code is
+ * the Mozilla Foundation <http://www.mozilla.org/>.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsSyncRunnableHelpers.h"
+#include "nsIMsgMailNewsUrl.h"
+#include "nsIMsgWindow.h"
+#include "nsImapMailFolder.h"
+
+#include "mozilla/Monitor.h"
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(StreamListenerProxy, nsIStreamListener)
+NS_IMPL_THREADSAFE_ISUPPORTS1(ImapMailFolderSinkProxy, nsIImapMailFolderSink)
+NS_IMPL_THREADSAFE_ISUPPORTS1(ImapServerSinkProxy, nsIImapServerSink)
+NS_IMPL_THREADSAFE_ISUPPORTS1(ImapMessageSinkProxy,
+ nsIImapMessageSink)
+NS_IMPL_THREADSAFE_ISUPPORTS1(ImapProtocolSinkProxy,
+ nsIImapProtocolSink)
+namespace {
+
+// Traits class for a reference type, specialized for parameters which are
+// already references.
+template<typename T>
+struct RefType
+{
+ typedef T& type;
+};
+
+template<>
+struct RefType<nsAString&>
+{
+ typedef nsAString& type;
+};
+
+template<>
+struct RefType<const nsAString&>
+{
+ typedef const nsAString& type;
+};
+
+template<>
+struct RefType<nsACString&>
+{
+ typedef nsACString& type;
+};
+
+template<>
+struct RefType<const nsACString&>
+{
+ typedef const nsACString& type;
+};
+
+template<>
+struct RefType<const nsIID&>
+{
+ typedef const nsIID& type;
+};
+
+class SyncRunnableBase : public nsRunnable
+{
+public:
+ nsresult Result() {
+ return mResult;
+ }
+
+ mozilla::Monitor& Monitor() {
+ return mMonitor;
+ }
+
+protected:
+ SyncRunnableBase()
+ : mResult(NS_ERROR_UNEXPECTED)
+ , mMonitor("SyncRunnableBase")
+ { }
+
+ nsresult mResult;
+ mozilla::Monitor mMonitor;
+};
+
+template<typename Receiver>
+class SyncRunnable0 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)();
+
+ SyncRunnable0(Receiver* receiver, ReceiverMethod method)
+ : mReceiver(receiver)
+ , mMethod(method)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)();
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+};
+
+
+template<typename Receiver, typename Arg1>
+class SyncRunnable1 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1);
+ typedef typename RefType<Arg1>::type Arg1Ref;
+
+ SyncRunnable1(Receiver* receiver, ReceiverMethod method,
+ Arg1Ref arg1)
+ : mReceiver(receiver)
+ , mMethod(method)
+ , mArg1(arg1)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)(mArg1);
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+ Arg1Ref mArg1;
+};
+
+template<typename Receiver, typename Arg1, typename Arg2>
+class SyncRunnable2 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2);
+ typedef typename RefType<Arg1>::type Arg1Ref;
+ typedef typename RefType<Arg2>::type Arg2Ref;
+
+ SyncRunnable2(Receiver* receiver, ReceiverMethod method,
+ Arg1Ref arg1, Arg2Ref arg2)
+ : mReceiver(receiver)
+ , mMethod(method)
+ , mArg1(arg1)
+ , mArg2(arg2)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)(mArg1, mArg2);
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+ Arg1Ref mArg1;
+ Arg2Ref mArg2;
+};
+
+template<typename Receiver, typename Arg1, typename Arg2, typename Arg3>
+class SyncRunnable3 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3);
+ typedef typename RefType<Arg1>::type Arg1Ref;
+ typedef typename RefType<Arg2>::type Arg2Ref;
+ typedef typename RefType<Arg3>::type Arg3Ref;
+
+ SyncRunnable3(Receiver* receiver, ReceiverMethod method,
+ Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3)
+ : mReceiver(receiver)
+ , mMethod(method)
+ , mArg1(arg1)
+ , mArg2(arg2)
+ , mArg3(arg3)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3);
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+ Arg1Ref mArg1;
+ Arg2Ref mArg2;
+ Arg3Ref mArg3;
+};
+
+template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4>
+class SyncRunnable4 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4);
+ typedef typename RefType<Arg1>::type Arg1Ref;
+ typedef typename RefType<Arg2>::type Arg2Ref;
+ typedef typename RefType<Arg3>::type Arg3Ref;
+ typedef typename RefType<Arg4>::type Arg4Ref;
+
+ SyncRunnable4(Receiver* receiver, ReceiverMethod method,
+ Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4)
+ : mReceiver(receiver)
+ , mMethod(method)
+ , mArg1(arg1)
+ , mArg2(arg2)
+ , mArg3(arg3)
+ , mArg4(arg4)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4);
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+ Arg1Ref mArg1;
+ Arg2Ref mArg2;
+ Arg3Ref mArg3;
+ Arg4Ref mArg4;
+};
+
+template<typename Receiver, typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5>
+class SyncRunnable5 : public SyncRunnableBase
+{
+public:
+ typedef nsresult (NS_STDCALL Receiver::*ReceiverMethod)(Arg1, Arg2, Arg3, Arg4, Arg5);
+ typedef typename RefType<Arg1>::type Arg1Ref;
+ typedef typename RefType<Arg2>::type Arg2Ref;
+ typedef typename RefType<Arg3>::type Arg3Ref;
+ typedef typename RefType<Arg4>::type Arg4Ref;
+ typedef typename RefType<Arg5>::type Arg5Ref;
+
+ SyncRunnable5(Receiver* receiver, ReceiverMethod method,
+ Arg1Ref arg1, Arg2Ref arg2, Arg3Ref arg3, Arg4Ref arg4, Arg5Ref arg5)
+ : mReceiver(receiver)
+ , mMethod(method)
+ , mArg1(arg1)
+ , mArg2(arg2)
+ , mArg3(arg3)
+ , mArg4(arg4)
+ , mArg5(arg5)
+ { }
+
+ NS_IMETHOD Run() {
+ mResult = (mReceiver->*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5);
+ mozilla::MonitorAutoLock(mMonitor).Notify();
+ return NS_OK;
+ }
+
+private:
+ Receiver* mReceiver;
+ ReceiverMethod mMethod;
+ Arg1Ref mArg1;
+ Arg2Ref mArg2;
+ Arg3Ref mArg3;
+ Arg4Ref mArg4;
+ Arg5Ref mArg5;
+};
+
+nsresult
+DispatchSyncRunnable(SyncRunnableBase* r)
+{
+ if (NS_IsMainThread()) {
+ r->Run();
+ }
+ else {
+ mozilla::MonitorAutoLock lock(r->Monitor());
+ nsresult rv = NS_DispatchToMainThread(r);
+ if (NS_FAILED(rv))
+ return rv;
+ lock.Wait();
+ }
+ return r->Result();
+}
+
+} // anonymous namespace
+
+#define NS_SYNCRUNNABLEMETHOD0(iface, method) \
+ NS_IMETHODIMP iface##Proxy::method() { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable0<nsI##iface> \
+ (mReceiver, &nsI##iface::method); \
+ return DispatchSyncRunnable(r); \
+ }
+
+
+#define NS_SYNCRUNNABLEMETHOD1(iface, method, \
+ arg1) \
+ NS_IMETHODIMP iface##Proxy::method(arg1 a1) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable1<nsI##iface, arg1> \
+ (mReceiver, &nsI##iface::method, a1); \
+ return DispatchSyncRunnable(r); \
+ }
+
+#define NS_SYNCRUNNABLEMETHOD2(iface, method, \
+ arg1, arg2) \
+ NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable2<nsI##iface, arg1, arg2> \
+ (mReceiver, &nsI##iface::method, a1, a2); \
+ return DispatchSyncRunnable(r); \
+ }
+
+#define NS_SYNCRUNNABLEMETHOD3(iface, method, \
+ arg1, arg2, arg3) \
+ NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable3<nsI##iface, arg1, arg2, arg3> \
+ (mReceiver, &nsI##iface::method, \
+ a1, a2, a3); \
+ return DispatchSyncRunnable(r); \
+ }
+
+#define NS_SYNCRUNNABLEMETHOD4(iface, method, \
+ arg1, arg2, arg3, arg4) \
+ NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable4<nsI##iface, arg1, arg2, arg3, arg4> \
+ (mReceiver, &nsI##iface::method, \
+ a1, a2, a3, a4); \
+ return DispatchSyncRunnable(r); \
+ }
+
+#define NS_SYNCRUNNABLEMETHOD5(iface, method, \
+ arg1, arg2, arg3, arg4, arg5) \
+ NS_IMETHODIMP iface##Proxy::method(arg1 a1, arg2 a2, arg3 a3, arg4 a4, arg5 a5) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable5<nsI##iface, arg1, arg2, arg3, arg4, arg5> \
+ (mReceiver, &nsI##iface::method, \
+ a1, a2, a3, a4, a5); \
+ return DispatchSyncRunnable(r); \
+ }
+
+#define NS_SYNCRUNNABLEATTRIBUTE(iface, attribute, \
+ type) \
+NS_IMETHODIMP iface##Proxy::Get##attribute(type *a1) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable1<nsI##iface, type *> \
+ (mReceiver, &nsI##iface::Get##attribute, a1); \
+ return DispatchSyncRunnable(r); \
+ } \
+NS_IMETHODIMP iface##Proxy::Set##attribute(type a1) { \
+ nsRefPtr<SyncRunnableBase> r = \
+ new SyncRunnable1<nsI##iface, type> \
+ (mReceiver, &nsI##iface::Set##attribute, a1); \
+ return DispatchSyncRunnable(r); \
+ }
+
+
+#define NS_NOTIMPLEMENTED \
+ { NS_RUNTIMEABORT("Not implemented"); return NS_ERROR_UNEXPECTED; }
+
+NS_SYNCRUNNABLEMETHOD5(StreamListener, OnDataAvailable,
+ nsIRequest *, nsISupports *, nsIInputStream *, PRUint32, PRUint32)
+
+NS_SYNCRUNNABLEMETHOD2(StreamListener, OnStartRequest,
+ nsIRequest *, nsISupports *)
+
+NS_SYNCRUNNABLEMETHOD3(StreamListener, OnStopRequest,
+ nsIRequest *, nsISupports *, nsresult)
+
+NS_SYNCRUNNABLEMETHOD2(ImapProtocolSink, GetUrlWindow, nsIMsgMailNewsUrl *,
+ nsIMsgWindow **)
+
+NS_SYNCRUNNABLEMETHOD0(ImapProtocolSink, CloseStreams)
+
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, FolderNeedsACLListed, bool)
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, FolderNeedsSubscribing, bool)
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, FolderNeedsAdded, bool)
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, AclFlags, PRUint32)
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, UidValidity, PRInt32)
+NS_SYNCRUNNABLEATTRIBUTE(ImapMailFolderSink, FolderQuotaCommandIssued, bool)
+NS_SYNCRUNNABLEMETHOD3(ImapMailFolderSink, SetFolderQuotaData, const nsACString &, PRUint32, PRUint32)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, GetShouldDownloadAllHeaders, bool *)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, GetOnlineDelimiter, char **)
+NS_SYNCRUNNABLEMETHOD0(ImapMailFolderSink, OnNewIdleMessages)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, UpdateImapMailboxStatus, nsIImapProtocol *, nsIMailboxSpec *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, UpdateImapMailboxInfo, nsIImapProtocol *, nsIMailboxSpec *)
+NS_SYNCRUNNABLEMETHOD4(ImapMailFolderSink, GetMsgHdrsToDownload, bool *, PRInt32 *, PRUint32 *, nsMsgKey **)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, ParseMsgHdrs, nsIImapProtocol *, nsIImapHeaderXferInfo *)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, AbortHeaderParseStream, nsIImapProtocol *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, OnlineCopyCompleted, nsIImapProtocol *, ImapOnlineCopyState)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, StartMessage, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, EndMessage, nsIMsgMailNewsUrl *, nsMsgKey)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, NotifySearchHit, nsIMsgMailNewsUrl *, const char *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, CopyNextStreamMessage, bool, nsISupports *)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, CloseMockChannel, nsIImapMockChannel *)
+NS_SYNCRUNNABLEMETHOD5(ImapMailFolderSink, SetUrlState, nsIImapProtocol *, nsIMsgMailNewsUrl *,
+ bool, bool, nsresult)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, ReleaseUrlCacheEntry, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, HeaderFetchCompleted, nsIImapProtocol *)
+NS_SYNCRUNNABLEMETHOD1(ImapMailFolderSink, SetBiffStateAndUpdate, PRInt32)
+NS_SYNCRUNNABLEMETHOD3(ImapMailFolderSink, ProgressStatus, nsIImapProtocol*, PRUint32, const PRUnichar *)
+NS_SYNCRUNNABLEMETHOD4(ImapMailFolderSink, PercentProgress, nsIImapProtocol*, const PRUnichar *, PRInt64, PRInt64)
+NS_SYNCRUNNABLEMETHOD0(ImapMailFolderSink, ClearFolderRights)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, SetCopyResponseUid, const char *, nsIImapUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, SetAppendMsgUid, nsMsgKey, nsIImapUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, GetMessageId, nsIImapUrl *, nsACString &)
+
+NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, SetupMsgWriteStream, nsIFile *, bool)
+NS_SYNCRUNNABLEMETHOD4(ImapMessageSink, ParseAdoptedMsgLine, const char *, nsMsgKey, PRInt32, nsIImapUrl *)
+NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NormalEndMsgWriteStream, nsMsgKey, bool, nsIImapUrl *)
+NS_SYNCRUNNABLEMETHOD0(ImapMessageSink, AbortMsgWriteStream)
+NS_SYNCRUNNABLEMETHOD0(ImapMessageSink, BeginMessageUpload)
+NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NotifyMessageFlags, PRUint32, nsMsgKey, PRUint64)
+NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NotifyMessageDeleted, const char *, bool, const char *)
+NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, GetMessageSizeFromDB, const char *, PRUint32 *)
+NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, SetContentModified, nsIImapUrl *, nsImapContentModifiedType)
+NS_SYNCRUNNABLEMETHOD1(ImapMessageSink, SetImageCacheSessionForUrl, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD4(ImapMessageSink, GetCurMoveCopyMessageInfo, nsIImapUrl *, PRTime *, nsACString &, PRUint32 *)
+
+NS_SYNCRUNNABLEMETHOD4(ImapServerSink, PossibleImapMailbox, const nsACString &, char, PRInt32, bool *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FolderNeedsACLInitialized, const nsACString &, bool *)
+NS_SYNCRUNNABLEMETHOD3(ImapServerSink, AddFolderRights, const nsACString &, const nsACString &, const nsACString &)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, RefreshFolderRights, const nsACString &)
+NS_SYNCRUNNABLEMETHOD0(ImapServerSink, DiscoveryDone)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, OnlineFolderDelete, const nsACString &)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, OnlineFolderCreateFailed, const nsACString &)
+NS_SYNCRUNNABLEMETHOD3(ImapServerSink, OnlineFolderRename, nsIMsgWindow *, const nsACString &, const nsACString &)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FolderIsNoSelect, const nsACString &, bool *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, SetFolderAdminURL, const nsACString &, const nsACString &)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FolderVerifiedOnline, const nsACString &, bool *)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, SetCapability, PRUint32)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, SetServerID, const nsACString &)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, LoadNextQueuedUrl, nsIImapProtocol *, bool *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, PrepareToRetryUrl, nsIImapUrl *, nsIImapMockChannel **)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, SuspendUrl, nsIImapUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, RetryUrl, nsIImapUrl *, nsIImapMockChannel *)
+NS_SYNCRUNNABLEMETHOD0(ImapServerSink, AbortQueuedUrls)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, GetImapStringByID, PRInt32, nsAString &)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, PromptLoginFailed, nsIMsgWindow *, PRInt32 *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FEAlert, const nsAString &, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FEAlertWithID, PRInt32, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FEAlertFromServer, const nsACString &, nsIMsgMailNewsUrl *)
+NS_SYNCRUNNABLEMETHOD0(ImapServerSink, CommitNamespaces)
+NS_SYNCRUNNABLEMETHOD3(ImapServerSink, AsyncGetPassword, nsIImapProtocol *, bool, nsACString &)
+NS_SYNCRUNNABLEATTRIBUTE(ImapServerSink, UserAuthenticated, bool)
+NS_SYNCRUNNABLEMETHOD3(ImapServerSink, SetMailServerUrls, const nsACString &, const nsACString &, const nsACString &)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, GetArbitraryHeaders, nsACString &)
+NS_SYNCRUNNABLEMETHOD0(ImapServerSink, ForgetPassword)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, GetShowAttachmentsInline, bool *)
+NS_SYNCRUNNABLEMETHOD3(ImapServerSink, CramMD5Hash, const char *, const char *, char **)
+NS_SYNCRUNNABLEMETHOD1(ImapServerSink, GetLoginUsername, nsACString &)
new file mode 100644
--- /dev/null
+++ b/mailnews/imap/src/nsSyncRunnableHelpers.h
@@ -0,0 +1,124 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Thunderbird.
+ *
+ * The Initial Developer of the Original Code is
+ * the Mozilla Foundation <http://www.mozilla.org/>.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsSyncRunnableHelpers_h
+#define nsSyncRunnableHelpers_h
+
+#include "nsThreadUtils.h"
+
+#include "nsIStreamListener.h"
+#include "nsIInterfaceRequestor.h"
+#include "nsIImapMailFolderSink.h"
+#include "nsIImapServerSink.h"
+#include "nsIImapProtocolSink.h"
+#include "nsIImapMessageSink.h"
+
+// The classes in this file proxy method calls to the main thread
+// synchronously. The main thread must not block on this thread, or a
+// deadlock condition can occur.
+
+class StreamListenerProxy : public nsIStreamListener
+{
+public:
+ StreamListenerProxy(nsIStreamListener* receiver)
+ : mReceiver(receiver)
+ { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIREQUESTOBSERVER
+ NS_DECL_NSISTREAMLISTENER
+
+private:
+ nsCOMPtr<nsIStreamListener> mReceiver;
+};
+
+class ImapMailFolderSinkProxy : public nsIImapMailFolderSink
+{
+public:
+ ImapMailFolderSinkProxy(nsIImapMailFolderSink* receiver)
+ : mReceiver(receiver)
+ { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIIMAPMAILFOLDERSINK
+
+private:
+ nsCOMPtr<nsIImapMailFolderSink> mReceiver;
+};
+
+class ImapServerSinkProxy : public nsIImapServerSink
+{
+public:
+ ImapServerSinkProxy(nsIImapServerSink* receiver)
+ : mReceiver(receiver)
+ { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIIMAPSERVERSINK
+
+private:
+ nsCOMPtr<nsIImapServerSink> mReceiver;
+};
+
+
+class ImapMessageSinkProxy: public nsIImapMessageSink
+{
+public:
+ ImapMessageSinkProxy(nsIImapMessageSink* receiver)
+ : mReceiver(receiver)
+ { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIIMAPMESSAGESINK
+
+private:
+ nsCOMPtr<nsIImapMessageSink> mReceiver;
+};
+
+class ImapProtocolSinkProxy : public nsIImapProtocolSink
+{
+public:
+ ImapProtocolSinkProxy(nsIImapProtocolSink* receiver)
+ : mReceiver(receiver)
+ { }
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIIMAPPROTOCOLSINK
+
+private:
+ nsCOMPtr<nsIImapProtocolSink> mReceiver;
+};
+#endif // nsSyncRunnableHelpers_h
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -42,19 +42,18 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURI.h"
-#include "nsIProxyObjectManager.h"
-#include "nsProxiedService.h"
#include "nsIOutputStream.h"
+#include "nsThreadUtils.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsIMsgCompose.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgSend.h"
#include "nsIMsgAccountManager.h"
@@ -186,17 +185,16 @@ nsresult EudoraSendListener::CreateSendL
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
nsEudoraCompose::nsEudoraCompose()
{
- m_pIOService = nsnull;
m_pAttachments = nsnull;
m_pListener = nsnull;
m_pMsgFields = nsnull;
m_pHeaders = p_test_headers;
if (m_pHeaders)
m_headerLen = strlen( m_pHeaders);
else
m_headerLen = 0;
@@ -207,29 +205,31 @@ nsEudoraCompose::nsEudoraCompose()
m_bodyLen = 0;
m_readHeaders.m_convertCRs = PR_TRUE;
}
nsEudoraCompose::~nsEudoraCompose()
{
- NS_IF_RELEASE( m_pIOService);
NS_IF_RELEASE( m_pListener);
NS_IF_RELEASE( m_pMsgFields);
}
nsresult nsEudoraCompose::CreateIdentity( void)
{
if (s_pIdentity)
return( NS_OK);
- nsresult rv;
- NS_WITH_PROXIED_SERVICE(nsIMsgAccountManager, accMgr, NS_MSGACCOUNTMANAGER_CONTRACTID, NS_PROXY_TO_MAIN_THREAD, &rv);
- if (NS_FAILED(rv)) return( rv);
+ // Should only create identity from main thread
+ NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_FAILURE);
+ nsresult rv;
+ nsCOMPtr<nsIMsgAccountManager> accMgr(do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
rv = accMgr->CreateIdentity( &s_pIdentity);
nsString name(NS_LITERAL_STRING("Import Identity"));
if (s_pIdentity) {
s_pIdentity->SetFullName(name);
s_pIdentity->SetIdentityName(name);
s_pIdentity->SetEmail(NS_LITERAL_CSTRING("import@import.service"));
// SetDoFcc to PR_FALSE to save time when CreateAndSendMessage operates.
@@ -256,22 +256,19 @@ void nsEudoraCompose::ReleaseIdentity( v
nsresult nsEudoraCompose::CreateComponents( void)
{
nsresult rv = NS_OK;
if (!m_pIOService) {
IMPORT_LOG0( "Creating nsIOService\n");
-
- NS_WITH_PROXIED_SERVICE(nsIIOService, service, NS_IOSERVICE_CONTRACTID, NS_PROXY_TO_MAIN_THREAD, &rv);
- if (NS_FAILED(rv))
- return( rv);
- m_pIOService = service;
- NS_IF_ADDREF( m_pIOService);
+
+ m_pIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
}
NS_IF_RELEASE( m_pMsgFields);
if (!m_pListener && NS_SUCCEEDED( rv))
rv = EudoraSendListener::CreateSendListener( &m_pListener);
if (NS_SUCCEEDED(rv)) {
rv = CallCreateInstance( kMsgCompFieldsCID, &m_pMsgFields);
@@ -560,18 +557,16 @@ nsresult nsEudoraCompose::GetLocalAttach
}
return NS_OK;
}
// Test a message send????
nsresult nsEudoraCompose::SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg)
{
nsresult rv = CreateComponents();
- if (NS_SUCCEEDED( rv))
- rv = CreateIdentity();
if (NS_FAILED( rv))
return( rv);
// IMPORT_LOG0( "Outlook Compose created necessary components\n");
nsString bodyType;
nsString charSet;
nsString headerVal;
--- a/mailnews/import/eudora/src/nsEudoraCompose.h
+++ b/mailnews/import/eudora/src/nsEudoraCompose.h
@@ -138,21 +138,21 @@ public:
void SetBody( const char *pBody, PRInt32 len, nsCString &bodyType) { m_pBody = pBody; m_bodyLen = len; m_bodyType = bodyType;}
void SetHeaders( const char *pHeaders, PRInt32 len) { m_pHeaders = pHeaders; m_headerLen = len;}
void SetAttachments( nsVoidArray *pAttachments) { m_pAttachments = pAttachments;}
void SetDefaultDate( nsCString date) { m_defaultDate = date;}
nsresult CopyComposedMessage( nsCString& fromLine, nsIFile *pSrc, nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& copy);
static nsresult FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
- static void ReleaseIdentity( void);
+ static nsresult CreateIdentity(void);
+ static void ReleaseIdentity(void);
private:
nsresult CreateComponents( void);
- static nsresult CreateIdentity( void);
void GetNthHeader( const char *pData, PRInt32 dataLen, PRInt32 n, nsCString& header, nsCString& val, bool unwrap);
void GetHeaderValue( const char *pData, PRInt32 dataLen, const char *pHeader, nsCString& val, bool unwrap = true);
void GetHeaderValue( const char *pData, PRInt32 dataLen, const char *pHeader, nsString& val) {
val.Truncate();
nsCString hVal;
GetHeaderValue( pData, dataLen, pHeader, hVal, PR_TRUE);
NS_CopyNativeToUnicode( hVal, val);
@@ -170,17 +170,17 @@ private:
bool IsReplaceHeader( const char *pHeader);
private:
static nsIMsgIdentity * s_pIdentity;
nsVoidArray * m_pAttachments;
nsIMsgSendListener * m_pListener;
nsIMsgCompFields * m_pMsgFields;
- nsIIOService * m_pIOService;
+ nsCOMPtr<nsIIOService> m_pIOService;
PRInt32 m_headerLen;
const char * m_pHeaders;
PRInt32 m_bodyLen;
const char * m_pBody;
nsCString m_bodyType;
nsString m_defCharset;
SimpleBufferTonyRCopiedOnce m_readHeaders;
nsCOMPtr<nsIImportService> m_pImportService;
--- a/mailnews/import/eudora/src/nsEudoraImport.cpp
+++ b/mailnews/import/eudora/src/nsEudoraImport.cpp
@@ -364,16 +364,17 @@ nsresult ImportEudoraMailImpl::Create(ns
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
ImportEudoraMailImpl::ImportEudoraMailImpl()
{
+ nsEudoraCompose::CreateIdentity();
// Create keys to support the default Eudora label colors.
// Ideally importing the settings will have already created these,
// in which case we won't bother (we'll detect that each key already
// exists). But to be sure we need to create the keys here, at
// least until the infrastructure is improved in some fashion so
// that we can rely on settings *always* being imported before mail.
nsresult rv;
nsCOMPtr<nsIMsgTagService> pTagService = do_GetService(NS_MSGTAGSERVICE_CONTRACTID, &rv);
--- a/mailnews/import/outlook/src/MapiMessage.cpp
+++ b/mailnews/import/outlook/src/MapiMessage.cpp
@@ -81,24 +81,22 @@ static const char * sDaysOfWeek[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
static const char *sMonths[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
CMapiMessage::CMapiMessage( LPMESSAGE lpMsg)
- : m_lpMsg(lpMsg), m_pIOService(0), m_dldStateHeadersOnly(false), m_msgFlags(0)
+ : m_lpMsg(lpMsg), m_dldStateHeadersOnly(false), m_msgFlags(0)
{
nsresult rv;
- NS_WITH_PROXIED_SERVICE(nsIIOService, service, NS_IOSERVICE_CONTRACTID,
- NS_PROXY_TO_MAIN_THREAD, &rv);
+ m_pIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return;
- NS_IF_ADDREF(m_pIOService = service);
FetchHeaders();
if (ValidState()) {
BuildFromLine();
FetchFlags();
GetDownloadState();
if (FullMessageDownloaded()) {
FetchBody();
@@ -107,17 +105,16 @@ CMapiMessage::CMapiMessage( LPMESSAGE lp
}
}
CMapiMessage::~CMapiMessage()
{
ClearAttachments();
if (m_lpMsg)
m_lpMsg->Release();
- NS_IF_RELEASE(m_pIOService);
}
void CMapiMessage::FormatDateTime(SYSTEMTIME& tm, nsCString& s, bool includeTZ)
{
long offset = _timezone;
s += sDaysOfWeek[tm.wDayOfWeek];
s += ", ";
s.AppendInt((PRInt32) tm.wDay);
--- a/mailnews/import/outlook/src/MapiMessage.h
+++ b/mailnews/import/outlook/src/MapiMessage.h
@@ -38,18 +38,16 @@
#define MapiMessage_h___
#include "nsTArray.h"
#include "nsString.h"
#include "nsILocalFile.h"
#include "MapiApi.h"
#include "nsIMsgSend.h"
-#include "nsProxiedService.h"
-
#include <vector>
#ifndef PR_LAST_VERB_EXECUTED
#define PR_LAST_VERB_EXECUTED PROP_TAG( PT_LONG, 0x1081)
#endif
#define EXCHIVERB_REPLYTOSENDER (102)
#define EXCHIVERB_REPLYTOALL (103)
@@ -258,18 +256,18 @@ private:
std::vector<attach_data*> m_stdattachments;
std::vector<attach_data*> m_embattachments; // Embedded
nsString m_body; // to be converted from UTF-16 using m_mimeCharset
bool m_bodyIsHtml;
PRUint32 m_msgFlags;
PRUint32 m_msgLastVerb;
-
- nsIIOService * m_pIOService;
+
+ nsCOMPtr<nsIIOService> m_pIOService;
void GetDownloadState();
// Headers - fetch will get PR_TRANSPORT_MESSAGE_HEADERS
// or if they do not exist will build a header from
// PR_DISPLAY_TO, _CC, _BCC
// PR_SUBJECT
// PR_MESSAGE_RECIPIENTS
--- a/mailnews/import/outlook/src/nsOutlookCompose.cpp
+++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp
@@ -42,18 +42,16 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIIOService.h"
#include "nsIURI.h"
-#include "nsIProxyObjectManager.h"
-#include "nsProxiedService.h"
#include "nsMsgI18N.h"
#include "nsNativeCharsetUtils.h"
#include "nsIOutputStream.h"
#include "nsMsgBaseCID.h"
#include "nsMsgCompCID.h"
#include "nsIArray.h"
#include "nsIMsgCompose.h"
@@ -246,36 +244,41 @@ nsOutlookCompose::~nsOutlookCompose()
}
void nsOutlookCompose::ClearReplaceCids()
{
std::for_each(m_replacedCids.begin(), m_replacedCids.end(), ClearReplaceCid);
m_replacedCids.clear();
}
+nsIMsgIdentity * nsOutlookCompose::m_pIdentity = nsnull;
+
nsresult nsOutlookCompose::CreateIdentity( void)
{
if (m_pIdentity)
return NS_OK;
nsresult rv;
- NS_WITH_PROXIED_SERVICE(nsIMsgAccountManager, accMgr,
- NS_MSGACCOUNTMANAGER_CONTRACTID,
- NS_PROXY_TO_MAIN_THREAD, &rv);
+ nsCOMPtr<nsIMsgAccountManager> accMgr =
+ do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = accMgr->CreateIdentity(&m_pIdentity);
nsString name;
name.AssignLiteral("Import Identity");
if (m_pIdentity) {
m_pIdentity->SetFullName(name);
m_pIdentity->SetIdentityName(name);
m_pIdentity->SetEmail(NS_LITERAL_CSTRING("import@import.service"));
}
+ return rv;
+}
- return rv;
+void nsOutlookCompose::ReleaseIdentity()
+{
+ NS_IF_RELEASE(m_pIdentity);
}
nsresult nsOutlookCompose::CreateComponents( void)
{
nsresult rv = NS_OK;
NS_IF_RELEASE(m_pMsgFields);
if (!m_pListener && NS_SUCCEEDED( rv))
--- a/mailnews/import/outlook/src/nsOutlookCompose.h
+++ b/mailnews/import/outlook/src/nsOutlookCompose.h
@@ -61,24 +61,25 @@ class nsIIOService;
///////////////////////////////////////////////////////////////////////////////////////////////
class nsOutlookCompose {
public:
nsOutlookCompose();
~nsOutlookCompose();
nsresult ProcessMessage(nsMsgDeliverMode mode, CMapiMessage &msg, nsIOutputStream *pDst);
+ static nsresult CreateIdentity(void);
+ static void ReleaseIdentity(void);
private:
struct CidReplacePair {
nsCString cidOrig;
nsCString cidNew;
};
nsresult CreateComponents( void);
- nsresult CreateIdentity( void);
void UpdateHeader(CMapiMessageHeaders& oldHeaders, const CMapiMessageHeaders& newHeaders, CMapiMessageHeaders::SpecialHeader header, bool addIfAbsent = true);
void UpdateHeaders(CMapiMessageHeaders& oldHeaders, const CMapiMessageHeaders& newHeaders);
nsresult ComposeTheMessage(nsMsgDeliverMode mode, CMapiMessage &msg, nsIFile **pMsg);
nsresult CopyComposedMessage( nsIFile *pSrc, nsIOutputStream *pDst, CMapiMessage& origMsg);
// Bug 593907
@@ -99,17 +100,17 @@ private:
private:
nsCString& m_line;
bool m_finishedReplacing;
};
nsIMsgSendListener * m_pListener;
nsIMsgCompFields * m_pMsgFields;
- nsIMsgIdentity * m_pIdentity;
+ static nsIMsgIdentity * m_pIdentity;
char* m_optimizationBuffer;
unsigned int m_optimizationBufferSize;
nsCOMPtr<nsIImportService> m_pImportService;
// Bug 593907
nsString m_hackedPostfix;
// End Bug 593907
};
--- a/mailnews/import/outlook/src/nsOutlookImport.cpp
+++ b/mailnews/import/outlook/src/nsOutlookImport.cpp
@@ -224,17 +224,17 @@ NS_IMETHODIMP nsOutlookImport::GetSuppor
}
NS_IMETHODIMP nsOutlookImport::GetSupportsUpgrade( bool *pUpgrade)
{
NS_PRECONDITION(pUpgrade != nsnull, "null ptr");
if (! pUpgrade)
return NS_ERROR_NULL_POINTER;
- *pUpgrade = PR_TRUE;
+ *pUpgrade = true;
return( NS_OK);
}
NS_IMETHODIMP nsOutlookImport::GetImportInterface( const char *pImportType, nsISupports **ppInterface)
{
NS_PRECONDITION(pImportType != nsnull, "null ptr");
if (! pImportType)
return NS_ERROR_NULL_POINTER;
@@ -315,35 +315,37 @@ nsresult ImportOutlookMailImpl::Create(n
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aImport);
return NS_OK;
}
ImportOutlookMailImpl::ImportOutlookMailImpl()
{
+ nsOutlookCompose::CreateIdentity();
}
ImportOutlookMailImpl::~ImportOutlookMailImpl()
{
+ nsOutlookCompose::ReleaseIdentity();
}
NS_IMPL_THREADSAFE_ISUPPORTS1(ImportOutlookMailImpl, nsIImportMail)
NS_IMETHODIMP ImportOutlookMailImpl::GetDefaultLocation( nsIFile **ppLoc, bool *found, bool *userVerify)
{
NS_PRECONDITION(ppLoc != nsnull, "null ptr");
NS_PRECONDITION(found != nsnull, "null ptr");
NS_PRECONDITION(userVerify != nsnull, "null ptr");
if (!ppLoc || !found || !userVerify)
return NS_ERROR_NULL_POINTER;
- *found = PR_FALSE;
+ *found = false;
*ppLoc = nsnull;
- *userVerify = PR_FALSE;
+ *userVerify = false;
// We need to verify here that we can get the mail, if true then
// return a dummy location, otherwise return no location
CMapiApi mapi;
if (!mapi.Initialize())
return( NS_OK);
if (!mapi.LogOn())
return( NS_OK);
@@ -355,19 +357,19 @@ NS_IMETHODIMP ImportOutlookMailImpl::Get
return( NS_OK);
nsresult rv;
nsCOMPtr <nsILocalFile> resultFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return(rv);
- *found = PR_TRUE;
+ *found = true;
NS_IF_ADDREF(*ppLoc = resultFile);
- *userVerify = PR_FALSE;
+ *userVerify = false;
return( NS_OK);
}
NS_IMETHODIMP ImportOutlookMailImpl::FindMailboxes( nsIFile *pLoc, nsISupportsArray **ppArray)
{
NS_PRECONDITION(pLoc != nsnull, "null ptr");
@@ -428,17 +430,17 @@ NS_IMETHODIMP ImportOutlookMailImpl::Imp
NS_PRECONDITION(pDestination != nsnull, "null ptr");
NS_PRECONDITION(fatalError != nsnull, "null ptr");
nsString success;
nsString error;
if (!pSource || !pDestination || !fatalError) {
nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_BADPARAM, error);
if (fatalError)
- *fatalError = PR_TRUE;
+ *fatalError = true;
SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
bool abort = false;
nsString name;
PRUnichar * pName;
if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
@@ -525,17 +527,17 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(ImportOutl
NS_IMETHODIMP ImportOutlookAddressImpl::GetAutoFind(PRUnichar **description, bool *_retval)
{
NS_PRECONDITION(description != nsnull, "null ptr");
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (! description || !_retval)
return NS_ERROR_NULL_POINTER;
- *_retval = PR_TRUE;
+ *_retval = true;
nsString str;
nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRNAME, str);
*description = ToNewUnicode(str);
return( NS_OK);
}
NS_IMETHODIMP ImportOutlookAddressImpl::FindAddressBooks(nsIFile *location, nsISupportsArray **_retval)
{
@@ -561,17 +563,17 @@ NS_IMETHODIMP ImportOutlookAddressImpl::
NS_PRECONDITION(fatalError != nsnull, "null ptr");
nsString success;
nsString error;
if (!source || !destination || !fatalError) {
IMPORT_LOG0( "*** Bad param passed to outlook address import\n");
nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error);
if (fatalError)
- *fatalError = PR_TRUE;
+ *fatalError = true;
ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
return NS_ERROR_NULL_POINTER;
}
nsString name;
source->GetPreferredName(name);
PRUint32 id;
--- a/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
+++ b/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
@@ -36,17 +36,16 @@
* ***** END LICENSE BLOCK ***** */
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsReadableUtils.h"
#include "nsIStringBundle.h"
#include "nsOutlookStringBundle.h"
#include "nsIServiceManager.h"
-#include "nsIProxyObjectManager.h"
#include "nsIURI.h"
#define OUTLOOK_MSGS_URL "chrome://messenger/locale/outlookImportMsgs.properties"
nsIStringBundle * nsOutlookStringBundle::m_pBundle = nsnull;
nsIStringBundle *nsOutlookStringBundle::GetStringBundle( void)
{
--- a/mailnews/import/src/nsImportMail.cpp
+++ b/mailnews/import/src/nsImportMail.cpp
@@ -53,31 +53,30 @@
#include "nsIImportMail.h"
#include "nsIImportGeneric.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIImportMailboxDescriptor.h"
#include "nsStringGlue.h"
#include "nsUnicharUtils.h"
-#include "nsIProxyObjectManager.h"
#include "nsIMsgAccountManager.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgFolder.h"
#include "nsImportStringBundle.h"
#include "nsIStringBundle.h"
#include "nsTextFormatter.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIImportService.h"
-#include "nsXPCOMCIDInternal.h"
#include "ImportDebug.h"
#include "plstr.h"
#include "MailNewsTypes.h"
+#include "nsThreadUtils.h"
#define IMPORT_MSGS_URL "chrome://messenger/locale/importMsgs.properties"
////////////////////////////////////////////////////////////////////////
static void ImportMailThread( void *stuff);
class ImportThreadData;
@@ -159,16 +158,30 @@ public:
ImportThreadData();
~ImportThreadData();
void DriverDelete();
void ThreadDelete();
void DriverAbort();
};
+// forward decl for proxy methods
+nsresult ProxyGetSubFolders(nsIMsgFolder *aFolder,
+ nsISimpleEnumerator **aEnumerator);
+nsresult ProxyGetChildNamed(nsIMsgFolder *aFolder,const nsAString & aName,
+ nsIMsgFolder **aChild);
+nsresult ProxyGetParent(nsIMsgFolder *aFolder, nsIMsgFolder **aParent);
+nsresult ProxyContainsChildNamed(nsIMsgFolder *aFolder, const nsAString &aName,
+ bool *aResult);
+nsresult ProxyGenerateUniqueSubfolderName(nsIMsgFolder *aFolder,
+ const nsAString& aPrefix,
+ nsIMsgFolder *aOtherFolder,
+ nsAString& aName);
+nsresult ProxyCreateSubfolder(nsIMsgFolder *aFolder, const nsAString &aName);
+nsresult ProxyForceDBClosed(nsIMsgFolder *aFolder);
nsresult NS_NewGenericMail(nsIImportGeneric** aImportGeneric)
{
NS_PRECONDITION(aImportGeneric != nsnull, "null ptr");
if (! aImportGeneric)
return NS_ERROR_NULL_POINTER;
nsImportGenericMail *pGen = new nsImportGenericMail();
@@ -180,31 +193,31 @@ nsresult NS_NewGenericMail(nsIImportGene
nsresult rv = pGen->QueryInterface( NS_GET_IID(nsIImportGeneric), (void **)aImportGeneric);
NS_RELEASE( pGen);
return( rv);
}
nsImportGenericMail::nsImportGenericMail()
{
- m_found = PR_FALSE;
- m_userVerify = PR_FALSE;
- m_gotLocation = PR_FALSE;
+ m_found = false;
+ m_userVerify = false;
+ m_gotLocation = false;
m_pInterface = nsnull;
m_pMailboxes = nsnull;
m_pSuccessLog = nsnull;
m_pErrorLog = nsnull;
m_totalSize = 0;
- m_doImport = PR_FALSE;
+ m_doImport = false;
m_pThreadData = nsnull;
m_pDestFolder = nsnull;
- m_deleteDestFolder = PR_FALSE;
- m_createdFolder = PR_FALSE;
- m_performingMigration = PR_FALSE;
+ m_deleteDestFolder = false;
+ m_createdFolder = false;
+ m_performingMigration = false;
// Init logging module.
if (!IMPORTLOGMODULE)
IMPORTLOGMODULE = PR_NewLogModule("IMPORT");
nsresult rv = nsImportStringBundle::GetStringBundle(IMPORT_MSGS_URL, getter_AddRefs(m_stringBundle));
if (NS_FAILED(rv))
IMPORT_LOG0("Failed to get string bundle for Importing Mail");
@@ -313,17 +326,17 @@ NS_IMETHODIMP nsImportGenericMail::SetDa
m_pSrcLocation = location;
}
}
if (!PL_strcasecmp( dataId, "mailDestination")) {
NS_IF_RELEASE( m_pDestFolder);
if (item)
item->QueryInterface( NS_GET_IID(nsIMsgFolder), (void **) &m_pDestFolder);
- m_deleteDestFolder = PR_FALSE;
+ m_deleteDestFolder = false;
}
if (!PL_strcasecmp( dataId, "name")) {
nsCOMPtr<nsISupportsString> nameString;
if (item) {
item->QueryInterface( NS_GET_IID(nsISupportsString), getter_AddRefs(nameString));
rv = nameString->GetData(m_pName);
}
@@ -365,17 +378,17 @@ NS_IMETHODIMP nsImportGenericMail::GetSt
void nsImportGenericMail::GetDefaultLocation( void)
{
if (!m_pInterface)
return;
if (m_pSrcLocation && m_gotLocation)
return;
- m_gotLocation = PR_TRUE;
+ m_gotLocation = true;
nsCOMPtr <nsIFile> pLoc;
m_pInterface->GetDefaultLocation( getter_AddRefs(pLoc), &m_found, &m_userVerify);
if (!m_pSrcLocation)
m_pSrcLocation = pLoc;
}
void nsImportGenericMail::GetDefaultMailboxes( void)
@@ -389,22 +402,22 @@ void nsImportGenericMail::GetDefaultMail
void nsImportGenericMail::GetDefaultDestination( void)
{
if (m_pDestFolder)
return;
if (!m_pInterface)
return;
nsIMsgFolder * rootFolder;
- m_deleteDestFolder = PR_FALSE;
- m_createdFolder = PR_FALSE;
+ m_deleteDestFolder = false;
+ m_createdFolder = false;
if (CreateFolder( &rootFolder)) {
m_pDestFolder = rootFolder;
- m_deleteDestFolder = PR_TRUE;
- m_createdFolder = PR_TRUE;
+ m_deleteDestFolder = true;
+ m_createdFolder = true;
return;
}
IMPORT_LOG0("*** GetDefaultDestination: Failed to create a default import destination folder.");
}
NS_IMETHODIMP nsImportGenericMail::WantsProgress(bool *_retval)
{
NS_PRECONDITION(_retval != nsnull, "null ptr");
@@ -436,22 +449,22 @@ NS_IMETHODIMP nsImportGenericMail::Wants
PRUint32 size;
rv = m_pMailboxes->Count( &count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsIImportMailboxDescriptor> box =
do_QueryElementAt(m_pMailboxes, i);
if (box) {
- import = PR_FALSE;
+ import = false;
size = 0;
rv = box->GetImport( &import);
if (import) {
rv = box->GetSize( &size);
- result = PR_TRUE;
+ result = true;
}
totalSize += size;
}
}
m_totalSize = totalSize;
}
@@ -484,35 +497,35 @@ NS_IMETHODIMP nsImportGenericMail::Begin
nsString success;
nsString error;
if (!m_doImport) {
nsImportStringBundle::GetStringByID(IMPORT_NO_MAILBOXES,
m_stringBundle, success);
SetLogs( success, error, successLog, errorLog);
- *_retval = PR_TRUE;
+ *_retval = true;
return( NS_OK);
}
if (!m_pInterface || !m_pMailboxes) {
IMPORT_LOG0( "*** BeginImport: Either the interface or source mailbox is not set properly.");
nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOTINITIALIZED,
m_stringBundle, error);
SetLogs( success, error, successLog, errorLog);
- *_retval = PR_FALSE;
+ *_retval = false;
return( NS_OK);
}
if (!m_pDestFolder) {
IMPORT_LOG0( "*** BeginImport: The destination mailbox is not set properly.");
nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NODESTFOLDER,
m_stringBundle, error);
SetLogs( success, error, successLog, errorLog);
- *_retval = PR_FALSE;
+ *_retval = false;
return( NS_OK);
}
if (m_pThreadData) {
m_pThreadData->DriverAbort();
m_pThreadData = nsnull;
}
@@ -544,42 +557,42 @@ NS_IMETHODIMP nsImportGenericMail::Begin
PRThread *pThread = PR_CreateThread( PR_USER_THREAD, &ImportMailThread, m_pThreadData,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
if (!pThread) {
m_pThreadData->ThreadDelete();
- m_pThreadData->abort = PR_TRUE;
+ m_pThreadData->abort = true;
m_pThreadData->DriverAbort();
m_pThreadData = nsnull;
- *_retval = PR_FALSE;
+ *_retval = false;
nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOTHREAD,
m_stringBundle, error);
SetLogs( success, error, successLog, errorLog);
}
else
- *_retval = PR_TRUE;
+ *_retval = true;
return( NS_OK);
}
NS_IMETHODIMP nsImportGenericMail::ContinueImport(bool *_retval)
{
NS_PRECONDITION(_retval != nsnull, "null ptr");
if (!_retval)
return NS_ERROR_NULL_POINTER;
- *_retval = PR_TRUE;
+ *_retval = true;
if (m_pThreadData) {
if (m_pThreadData->fatalError)
- *_retval = PR_FALSE;
+ *_retval = false;
}
return( NS_OK);
}
NS_IMETHODIMP nsImportGenericMail::GetProgress(PRInt32 *_retval)
{
@@ -651,35 +664,35 @@ void nsImportGenericMail::SetLogs(nsStri
str.Append(error);
pError->SetData(str);
}
}
NS_IMETHODIMP nsImportGenericMail::CancelImport(void)
{
if (m_pThreadData) {
- m_pThreadData->abort = PR_TRUE;
+ m_pThreadData->abort = true;
m_pThreadData->DriverAbort();
m_pThreadData = nsnull;
}
return( NS_OK);
}
ImportThreadData::ImportThreadData()
{
- fatalError = PR_FALSE;
- driverAlive = PR_TRUE;
- threadAlive = PR_TRUE;
- abort = PR_FALSE;
+ fatalError = false;
+ driverAlive = true;
+ threadAlive = true;
+ abort = false;
currentTotal = 0;
currentSize = 0;
destRoot = nsnull;
- ownsDestRoot = PR_FALSE;
+ ownsDestRoot = false;
boxes = nsnull;
mailImport = nsnull;
successLog = nsnull;
errorLog = nsnull;
stringBundle = nsnull;
}
ImportThreadData::~ImportThreadData()
@@ -689,40 +702,40 @@ ImportThreadData::~ImportThreadData()
NS_IF_RELEASE( mailImport);
NS_IF_RELEASE( errorLog);
NS_IF_RELEASE( successLog);
NS_IF_RELEASE( stringBundle);
}
void ImportThreadData::DriverDelete( void)
{
- driverAlive = PR_FALSE;
+ driverAlive = false;
if (!driverAlive && !threadAlive)
delete this;
}
void ImportThreadData::ThreadDelete()
{
- threadAlive = PR_FALSE;
+ threadAlive = false;
if (!driverAlive && !threadAlive)
delete this;
}
void ImportThreadData::DriverAbort()
{
if (abort && !threadAlive && destRoot) {
if (ownsDestRoot) {
- destRoot->RecursiveDelete(PR_TRUE, nsnull);
+ destRoot->RecursiveDelete(true, nsnull);
}
else {
// FIXME: just delete the stuff we created?
}
}
else
- abort = PR_TRUE;
+ abort = true;
DriverDelete();
}
static void
ImportMailThread( void *stuff)
{
@@ -741,124 +754,83 @@ ImportMailThread( void *stuff)
bool import;
PRUint32 size;
PRUint32 depth = 1;
PRUint32 newDepth;
nsString lastName;
PRUnichar * pName;
nsCOMPtr<nsIMsgFolder> curFolder( destRoot);
- nsCOMPtr<nsIMsgFolder> curProxy;
nsCOMPtr<nsIMsgFolder> newFolder;
nsCOMPtr<nsILocalFile> outBox;
nsCOMPtr<nsIMsgFolder> subFolder;
nsCOMPtr<nsISimpleEnumerator> enumerator;
bool exists;
nsString success;
nsString error;
- // Initialize the curFolder proxy object
- nsCOMPtr<nsIProxyObjectManager> proxyObjMgr =
- do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
- if (NS_FAILED(rv))
- {
- IMPORT_LOG0("*** ImportMailThread: Unable to obtain proxy object manager for the import.");
- pData->abort = PR_TRUE;
- }
-
- rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIMsgFolder),
- curFolder,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(curProxy));
-
- if (NS_SUCCEEDED(rv)) {
- // GetSubfolders() will initialize folders if they are not already initialized.
- curProxy->GetSubFolders(getter_AddRefs(enumerator));
- } else {
- IMPORT_LOG1( "*** ImportMailThread: Can't get the destination root folder proxy. rv=(0x%lx)", (long) rv);
- }
-
+ // GetSubFolders() will initialize folders if they are not already initialized.
+ ProxyGetSubFolders(curFolder, getter_AddRefs(enumerator));
IMPORT_LOG1("ImportMailThread: Total number of folders to import = %d.", count);
// Note that the front-end js script only displays one import result string so
// we combine both good and bad import status into one string (in var 'success').
for (i = 0; (i < count) && !(pData->abort); i++) {
nsCOMPtr<nsIImportMailboxDescriptor> box =
do_QueryElementAt(pData->boxes, i);
if (box) {
pData->currentMailbox = i;
- import = PR_FALSE;
+ import = false;
size = 0;
rv = box->GetImport( &import);
if (import)
rv = box->GetSize( &size);
rv = box->GetDepth( &newDepth);
if (newDepth > depth) {
// OK, we are going to add a subfolder under the last/previous folder we processed, so
// find this folder (stored in 'lastName') who is going to be the new parent folder.
IMPORT_LOG1("ImportMailThread: Processing child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
- rv = curProxy->GetChildNamed( lastName, getter_AddRefs( subFolder));
+ rv = ProxyGetChildNamed(curFolder, lastName, getter_AddRefs(subFolder));
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the interface for child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD,
lastName.get(),
&error, pData->stringBundle);
- pData->fatalError = PR_TRUE;
- break;
- }
-
- rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIMsgFolder),
- subFolder,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(curProxy));
- if (NS_FAILED( rv)) {
- IMPORT_LOG1("*** ImportMailThread: Failed to get the proxy interface for child folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
- nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY, pData->stringBundle,
- error);
- pData->fatalError = PR_TRUE;
+ pData->fatalError = true;
break;
}
// Make sure this new parent folder obj has the correct subfolder list so far.
- rv = curProxy->GetSubFolders(getter_AddRefs(enumerator));
+ rv = ProxyGetSubFolders(subFolder, getter_AddRefs(enumerator));
}
else if (newDepth < depth) {
rv = NS_OK;
while ((newDepth < depth) && NS_SUCCEEDED( rv)) {
- nsCOMPtr<nsIMsgFolder> parFolder;
- rv = curProxy->GetParent( getter_AddRefs( parFolder));
+ rv = curFolder->GetParent(getter_AddRefs(curFolder));
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the interface for parent folder '%s'.", lastName.get());
nsImportGenericMail::ReportError(IMPORT_ERROR_MB_FINDCHILD,
lastName.get(), &error,
pData->stringBundle);
- pData->fatalError = PR_TRUE;
+ pData->fatalError = true;
break;
}
-
- rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIMsgFolder),
- parFolder,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(curProxy));
depth--;
}
if (NS_FAILED( rv)) {
IMPORT_LOG1("*** ImportMailThread: Failed to get the proxy interface for parent folder '%s'.", lastName.get());
nsImportStringBundle::GetStringByID(IMPORT_ERROR_MB_NOPROXY,
pData->stringBundle, error);
- pData->fatalError = PR_TRUE;
+ pData->fatalError = true;
break;
}
}
depth = newDepth;
pName = nsnull;
box->GetDisplayName( &pName);
if (pName) {
lastName = pName;
@@ -867,34 +839,34 @@ ImportMailThread( void *stuff)
else
lastName.AssignLiteral("Unknown!");
// translate the folder name if we are doing migration, but
// only for special folders which are at the root level
if (pData->performingMigration && depth == 1)
pData->mailImport->TranslateFolderName(lastName, lastName);
- exists = PR_FALSE;
- rv = curProxy->ContainsChildNamed( lastName, &exists);
+ exists = false;
+ rv = ProxyContainsChildNamed(curFolder, lastName, &exists);
// If we are performing profile migration (as opposed to importing) then we are starting
// with empty local folders. In that case, always choose to over-write the existing local folder
// with this name. Don't create a unique subfolder name. Otherwise you end up with "Inbox, Inbox0"
// or "Unsent Folders, UnsentFolders0"
if (exists && !pData->performingMigration) {
nsString subName;
- curProxy->GenerateUniqueSubfolderName( lastName, nsnull, subName);
+ ProxyGenerateUniqueSubfolderName(curFolder, lastName, nsnull, subName);
if (!subName.IsEmpty())
lastName.Assign(subName);
}
IMPORT_LOG1("ImportMailThread: Creating new import folder '%s'.", NS_ConvertUTF16toUTF8(lastName).get());
- curProxy->CreateSubfolder( lastName, nsnull); // this may fail if the folder already exists..that's ok
+ ProxyCreateSubfolder(curFolder, lastName); // this may fail if the folder already exists..that's ok
- rv = curProxy->GetChildNamed(lastName, getter_AddRefs(newFolder));
+ rv = ProxyGetChildNamed(curFolder, lastName, getter_AddRefs(newFolder));
if (NS_SUCCEEDED(rv))
newFolder->GetFilePath(getter_AddRefs(outBox));
else
IMPORT_LOG1("*** ImportMailThread: Failed to locate subfolder '%s' after it's been created.", lastName.get());
if (NS_FAILED( rv)) {
nsImportGenericMail::ReportError(IMPORT_ERROR_MB_CREATE, lastName.get(),
&error, pData->stringBundle);
@@ -915,37 +887,26 @@ ImportMailThread( void *stuff)
NS_Free( pSuccess);
}
pData->currentSize = 0;
pData->currentTotal += size;
// commit to the db synchronously, but using a proxy since it doesn't like being used
// elsewhere than from the main thread.
- nsCOMPtr<nsIMsgFolder> newFolderProxy;
- rv = proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
- NS_GET_IID(nsIMsgFolder),
- newFolder,
- NS_PROXY_SYNC | NS_PROXY_ALWAYS,
- getter_AddRefs(newFolderProxy));
-
- if (NS_SUCCEEDED(rv) && newFolderProxy) {
- // OK, we've copied the actual folder/file over if the folder size is not 0
- // (ie, the msg summary is no longer valid) so close the msg database so that
- // when the folder is reopened the folder db can be reconstructed (which
- // validates msg summary and forces folder to be reparsed).
- newFolderProxy->ForceDBClosed();
- }
- else
- // probably a fatal error if you can't commit the mailbox, right?
- fatalError = PR_TRUE;
+ // OK, we've copied the actual folder/file over if the folder size is not 0
+ // (ie, the msg summary is no longer valid) so close the msg database so that
+ // when the folder is reopened the folder db can be reconstructed (which
+ // validates msg summary and forces folder to be reparsed).
+ rv = ProxyForceDBClosed(newFolder);
+ fatalError = NS_FAILED(rv);
if (fatalError) {
IMPORT_LOG1( "*** ImportMailThread: ImportMailbox returned fatalError, mailbox #%d\n", (int) i);
- pData->fatalError = PR_TRUE;
+ pData->fatalError = true;
break;
}
}
}
}
// Now save the new acct info to pref file.
nsCOMPtr <nsIMsgAccountManager> accMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
@@ -955,17 +916,17 @@ ImportMailThread( void *stuff)
}
nsImportGenericMail::SetLogs( success, error, pData->successLog, pData->errorLog);
if (pData->abort || pData->fatalError) {
IMPORT_LOG0( "*** ImportMailThread: Abort or fatalError flag was set\n");
if (pData->ownsDestRoot) {
IMPORT_LOG0( "Calling destRoot->RecursiveDelete\n");
- destRoot->RecursiveDelete( PR_TRUE, nsnull);
+ destRoot->RecursiveDelete( true, nsnull);
}
else {
// FIXME: just delete the stuff we created?
}
}
IMPORT_LOG1( "Import mailbox thread done: %d\n", (int) pData->currentTotal);
@@ -979,50 +940,50 @@ bool nsImportGenericMail::CreateFolder(
{
nsresult rv;
*ppFolder = nsnull;
nsCOMPtr<nsIStringBundle> bundle;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
NS_STRINGBUNDLE_CONTRACTID, &rv));
if (NS_FAILED(rv) || !bundleService)
- return PR_FALSE;
+ return false;
rv = bundleService->CreateBundle(IMPORT_MSGS_URL, getter_AddRefs(bundle));
if (NS_FAILED(rv))
- return PR_FALSE;
+ return false;
nsString folderName;
if (!m_pName.IsEmpty()) {
const PRUnichar *moduleName[] = { m_pName.get() };
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImportModuleFolderName").get(),
moduleName, 1,
getter_Copies(folderName));
}
else {
rv = bundle->GetStringFromName(NS_LITERAL_STRING("DefaultFolderName").get(),
getter_Copies(folderName));
}
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Failed to get Folder Name!\n");
- return PR_FALSE;
+ return false;
}
nsCOMPtr <nsIMsgAccountManager> accMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Failed to create account manager!\n");
- return PR_FALSE;
+ return false;
}
nsCOMPtr <nsIMsgIncomingServer> server;
rv = accMgr->GetLocalFoldersServer(getter_AddRefs(server));
// if Local Folders does not exist already, create it
if (NS_FAILED(rv) || !server)
{
rv = accMgr->CreateLocalMailAccount();
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Failed to create Local Folders!\n");
- return PR_FALSE;
+ return false;
}
rv = accMgr->GetLocalFoldersServer(getter_AddRefs(server));
}
if (NS_SUCCEEDED(rv) && server) {
nsCOMPtr <nsIMsgFolder> localRootFolder;
rv = server->GetRootMsgFolder(getter_AddRefs(localRootFolder));
@@ -1037,31 +998,259 @@ bool nsImportGenericMail::CreateFolder(
rv = localRootFolder->ContainsChildNamed(folderName, &exists);
if (exists) {
nsString name;
localRootFolder->GenerateUniqueSubfolderName(folderName, nsnull, name);
if (!name.IsEmpty())
folderName.Assign(name);
else {
IMPORT_LOG0( "*** Failed to find a unique folder name!\n");
- return PR_FALSE;
+ return false;
}
}
IMPORT_LOG1( "Creating folder for importing mail: '%s'\n", NS_ConvertUTF16toUTF8(folderName).get());
// Bug 564162 identifies a dataloss design flaw.
// A working Thunderbird client can have mail in Local Folders and a
// subsequent import 'Everything' will trigger a migration which
// overwrites existing mailboxes with the imported mailboxes.
rv = localRootFolder->CreateSubfolder(folderName, nsnull);
if (NS_SUCCEEDED(rv)) {
rv = localRootFolder->GetChildNamed(folderName, ppFolder);
if (*ppFolder) {
IMPORT_LOG1("Folder '%s' created successfully\n", NS_ConvertUTF16toUTF8(folderName).get());
- return PR_TRUE;
+ return true;
}
}
}
} // if localRootFolder
} // if server
IMPORT_LOG0("****** FAILED TO CREATE FOLDER FOR IMPORT\n");
- return PR_FALSE;
+ return false;
+}
+
+/**
+ * These are the proxy objects we use to proxy nsIMsgFolder methods back
+ * the the main thread. Since there are only five, we can hand roll them.
+ * A better design might be a co-routine-ish design where the ui thread
+ * hands off each folder to the import thread and when the thread finishes
+ * the folder, the main thread hands it the next folder.
+ */
+
+class GetSubFoldersRunnable : public nsRunnable
+{
+public:
+ GetSubFoldersRunnable(nsIMsgFolder *aFolder,
+ nsISimpleEnumerator **aEnumerator);
+ NS_DECL_NSIRUNNABLE
+private:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsISimpleEnumerator **m_enumerator;
+ nsresult m_status;
+};
+
+GetSubFoldersRunnable::GetSubFoldersRunnable(nsIMsgFolder *aFolder,
+ nsISimpleEnumerator **aEnumerator) :
+ m_folder(aFolder), m_enumerator(aEnumerator)
+{
+}
+
+NS_IMETHODIMP GetSubFoldersRunnable::Run()
+{
+ return m_folder->GetSubFolders(m_enumerator);
+}
+
+
+nsresult ProxyGetSubFolders(nsIMsgFolder *aFolder, nsISimpleEnumerator **aEnumerator)
+{
+ nsRefPtr<GetSubFoldersRunnable> getSubFolders =
+ new GetSubFoldersRunnable(aFolder, aEnumerator);
+ return NS_DispatchToMainThread(getSubFolders, NS_DISPATCH_SYNC);
+}
+
+class GetChildNamedRunnable : public nsRunnable
+{
+public:
+ GetChildNamedRunnable(nsIMsgFolder *aFolder, const nsAString& aName, nsIMsgFolder **aChild);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsString m_name;
+ nsIMsgFolder **m_child;
+};
+
+GetChildNamedRunnable::GetChildNamedRunnable(nsIMsgFolder *aFolder,
+ const nsAString & aName,
+ nsIMsgFolder **aChild) :
+ m_folder(aFolder), m_name(aName), m_child(aChild)
+{
+}
+
+NS_IMETHODIMP GetChildNamedRunnable::Run()
+{
+ return m_folder->GetChildNamed(m_name, m_child);
+}
+
+
+nsresult ProxyGetChildNamed(nsIMsgFolder *aFolder, const nsAString & aName,
+ nsIMsgFolder **aChild)
+{
+ nsRefPtr<GetChildNamedRunnable> getChildNamed =
+ new GetChildNamedRunnable(aFolder, aName, aChild);
+ return NS_DispatchToMainThread(getChildNamed, NS_DISPATCH_SYNC);
+}
+
+class GetParentRunnable : public nsRunnable
+{
+public:
+ GetParentRunnable(nsIMsgFolder *aFolder, nsIMsgFolder **aParent);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsIMsgFolder **m_parent;
+};
+
+GetParentRunnable::GetParentRunnable(nsIMsgFolder *aFolder, nsIMsgFolder **aParent) :
+ m_folder(aFolder), m_parent(aParent)
+{
+}
+
+NS_IMETHODIMP GetParentRunnable::Run()
+{
+ return m_folder->GetParent(m_parent);
+}
+
+
+nsresult ProxyGetParent(nsIMsgFolder *aFolder, nsIMsgFolder **aParent)
+{
+ nsRefPtr<GetParentRunnable> getParent =
+ new GetParentRunnable(aFolder, aParent);
+ return NS_DispatchToMainThread(getParent, NS_DISPATCH_SYNC);
}
+
+class ContainsChildNamedRunnable : public nsRunnable
+{
+public:
+ ContainsChildNamedRunnable(nsIMsgFolder *aFolder, const nsAString& aName, bool *aResult);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsString m_name;
+ bool *m_result;
+};
+
+ContainsChildNamedRunnable::ContainsChildNamedRunnable(nsIMsgFolder *aFolder,
+ const nsAString &aName,
+ bool *aResult) :
+ m_folder(aFolder), m_name(aName), m_result(aResult)
+{
+}
+
+NS_IMETHODIMP ContainsChildNamedRunnable::Run()
+{
+ return m_folder->ContainsChildNamed(m_name, m_result);
+}
+
+
+nsresult ProxyContainsChildNamed(nsIMsgFolder *aFolder, const nsAString &aName,
+ bool *aResult)
+{
+ nsRefPtr<ContainsChildNamedRunnable> containsChildNamed =
+ new ContainsChildNamedRunnable(aFolder, aName, aResult);
+ return NS_DispatchToMainThread(containsChildNamed, NS_DISPATCH_SYNC);
+}
+
+
+class GenerateUniqueSubfolderNameRunnable : public nsRunnable
+{
+public:
+ GenerateUniqueSubfolderNameRunnable(nsIMsgFolder *aFolder,
+ const nsAString& prefix,
+ nsIMsgFolder *otherFolder,
+ nsAString& name);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsString m_prefix;
+ nsCOMPtr<nsIMsgFolder> m_otherFolder;
+ nsString m_name;
+};
+
+GenerateUniqueSubfolderNameRunnable::GenerateUniqueSubfolderNameRunnable(
+ nsIMsgFolder *aFolder, const nsAString& aPrefix, nsIMsgFolder *aOtherFolder,
+ nsAString& aName)
+ : m_folder(aFolder), m_prefix(aPrefix), m_otherFolder(aOtherFolder), m_name(aName)
+{
+}
+
+NS_IMETHODIMP GenerateUniqueSubfolderNameRunnable::Run()
+{
+ return m_folder->GenerateUniqueSubfolderName(m_prefix, m_otherFolder, m_name);
+}
+
+
+nsresult ProxyGenerateUniqueSubfolderName(nsIMsgFolder *aFolder,
+ const nsAString& aPrefix,
+ nsIMsgFolder *aOtherFolder,
+ nsAString& aName)
+
+{
+ nsRefPtr<GenerateUniqueSubfolderNameRunnable> generateUniqueSubfolderName =
+ new GenerateUniqueSubfolderNameRunnable(aFolder, aPrefix, aOtherFolder, aName);
+ return NS_DispatchToMainThread(generateUniqueSubfolderName, NS_DISPATCH_SYNC);
+}
+
+class CreateSubfolderRunnable : public nsRunnable
+{
+public:
+ CreateSubfolderRunnable(nsIMsgFolder *aFolder, const nsAString& aName);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+ nsString m_name;
+};
+
+CreateSubfolderRunnable::CreateSubfolderRunnable(nsIMsgFolder *aFolder,
+ const nsAString &aName) :
+ m_folder(aFolder), m_name(aName)
+{
+}
+
+NS_IMETHODIMP CreateSubfolderRunnable::Run()
+{
+ return m_folder->CreateSubfolder(m_name, nsnull);
+}
+
+
+nsresult ProxyCreateSubfolder(nsIMsgFolder *aFolder, const nsAString &aName)
+{
+ nsRefPtr<CreateSubfolderRunnable> createSubfolder =
+ new CreateSubfolderRunnable(aFolder, aName);
+ return NS_DispatchToMainThread(createSubfolder, NS_DISPATCH_SYNC);
+}
+
+class ForceDBClosedRunnable : public nsRunnable
+{
+public:
+ ForceDBClosedRunnable(nsIMsgFolder *aFolder);
+ NS_DECL_NSIRUNNABLE
+protected:
+ nsCOMPtr<nsIMsgFolder> m_folder;
+};
+
+ForceDBClosedRunnable::ForceDBClosedRunnable(nsIMsgFolder *aFolder) :
+ m_folder(aFolder)
+{
+}
+
+NS_IMETHODIMP ForceDBClosedRunnable::Run()
+{
+ return m_folder->ForceDBClosed();
+}
+
+nsresult ProxyForceDBClosed(nsIMsgFolder *aFolder)
+{
+ nsRefPtr<ForceDBClosedRunnable> forceDBClosed =
+ new ForceDBClosedRunnable(aFolder);
+ return NS_DispatchToMainThread(forceDBClosed, NS_DISPATCH_SYNC);
+}
+
+
--- a/mailnews/import/src/nsImportStringBundle.cpp
+++ b/mailnews/import/src/nsImportStringBundle.cpp
@@ -35,17 +35,16 @@
*
* ***** END LICENSE BLOCK ***** */
#include "prprf.h"
#include "prmem.h"
#include "nsCOMPtr.h"
#include "nsIStringBundle.h"
#include "nsImportStringBundle.h"
#include "nsIServiceManager.h"
-#include "nsIProxyObjectManager.h"
#include "nsIURI.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
nsresult nsImportStringBundle::GetStringBundle(const char *aPropertyURL,
nsIStringBundle **aBundle)
{
nsresult rv;
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -64,19 +64,17 @@
#include "nsStringGlue.h"
#include "nsUnicharUtils.h"
#include "nsIMsgAttachment.h"
#include "nsIMsgCompFields.h"
#include "nsIMsgComposeParams.h"
#include "nsIMsgCompose.h"
#include "nsMsgCompCID.h"
#include "nsIMsgSend.h"
-#include "nsIProxyObjectManager.h"
#include "nsIMsgComposeService.h"
-#include "nsProxiedService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIDirectoryService.h"
#include "nsMsgI18N.h"
#include "msgMapi.h"
#include "msgMapiHook.h"
#include "msgMapiSupport.h"
#include "msgMapiMain.h"
#include "nsThreadUtils.h"