Bug 1492889 - Implement nsIMsgAccountManager.ReactivateAccounts(). r=aceman,jorgk
☠☠ backed out by 214f21416567 ☠ ☠
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 20 Sep 2018 09:11:00 +0200
changeset 33286 2a51324477b126b2d3f9ed368b94df4daa22e3f1
parent 33285 a98e917dba66d20511b82098de5b47fb3d310ca5
child 33287 0d1897bd80ff5f01d6f8b11cf7ff78bc95b2181b
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersaceman, jorgk
bugs1492889
Bug 1492889 - Implement nsIMsgAccountManager.ReactivateAccounts(). r=aceman,jorgk
db/mork/src/morkConfig.cpp
mailnews/base/public/nsIMsgAccountManager.idl
mailnews/base/src/nsMsgAccount.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/news/test/unit/test_nntpPassword2.js
--- a/db/mork/src/morkConfig.cpp
+++ b/db/mork/src/morkConfig.cpp
@@ -14,20 +14,17 @@
 #ifndef _MORKCONFIG_
 #include "morkConfig.h"
 #endif
 
 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
 
 void mork_assertion_signal(const char* inMessage)
 {
-#if defined(MORK_WIN) || defined(MORK_MAC)
-  // asm { int 3 }
   NS_ERROR(inMessage);
-#endif /*MORK_WIN*/
 }
 
 #ifdef MORK_PROVIDE_STDLIB
 
 MORK_LIB_IMPL(mork_i4)
 mork_memcmp(const void* inOne, const void* inTwo, mork_size inSize)
 {
   const mork_u1* t = (const mork_u1*) inTwo;
--- a/mailnews/base/public/nsIMsgAccountManager.idl
+++ b/mailnews/base/public/nsIMsgAccountManager.idl
@@ -165,16 +165,25 @@ interface nsIMsgAccountManager : nsISupp
   void createLocalMailAccount();
 
   /* load accounts kicks off the creation of all accounts. You do not need
    * to call this and all accounts should be loaded lazily if you use any
    * of the above.
    */
   void LoadAccounts();
 
+  /**
+   * When the server for an account could not be loaded, typically because the
+   * extension providing it could not be loaded, it is deactivated for a period
+   * of time as documented in nsIMsgAccount.idl. The server is normally only
+   * rechecked at startup but this function can be used to recheck all servers
+   * at any time to avoid having to restart to reactivate an account.
+   */
+  void ReactivateAccounts();
+
   void setSpecialFolders();
 
   void loadVirtualFolders();
 
   /* unload accounts frees all the account manager data structures */
   void UnloadAccounts();
 
   void WriteToFolderCache(in nsIMsgFolderCache folderCache);
--- a/mailnews/base/src/nsMsgAccount.cpp
+++ b/mailnews/base/src/nsMsgAccount.cpp
@@ -100,20 +100,17 @@ nsMsgAccount::createIncomingServer()
            do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = accountManager->GetIncomingServer(serverKey, getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // store the server in this structure
-  m_incomingServer = server;
-  accountManager->NotifyServerLoaded(server);
-
-  return NS_OK;
+  return SetIncomingServer(server);
 }
 
 
 NS_IMETHODIMP
 nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer *aIncomingServer)
 {
   NS_ENSURE_ARG_POINTER(aIncomingServer);
 
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -1397,16 +1397,27 @@ nsMsgAccountManager::LoadAccounts()
         if (account)
           account->SetIncomingServer(server);
       }
     }
   }
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsMsgAccountManager::ReactivateAccounts()
+{
+  for (nsIMsgAccount* account : m_accounts) {
+    // This will error out if the account already has its server, or
+    // if this isn't the account that the extension is trying to reactivate.
+    (void)account->CreateServer();
+  }
+  return NS_OK;
+}
+
 // this routine goes through all the identities and makes sure
 // that the special folders for each identity have the
 // correct special folder flags set, e.g, the Sent folder has
 // the sent flag set.
 //
 // it also goes through all the spam settings for each account
 // and makes sure the folder flags are set there, too
 NS_IMETHODIMP
--- a/mailnews/news/test/unit/test_nntpPassword2.js
+++ b/mailnews/news/test/unit/test_nntpPassword2.js
@@ -33,25 +33,21 @@ add_task(async function () {
   Services.prefs.setCharPref("mail.accountmanager.localfoldersserver",
                              "server1");
   Services.prefs.setCharPref("mail.accountmanager.defaultaccount",
                              "account2");
   Services.prefs.setCharPref("mail.identity.id1.fullName", "testnntp");
   Services.prefs.setCharPref("mail.identity.id1.useremail",
                              "testnntp@localhost");
   Services.prefs.setBoolPref("mail.identity.id1.valid", true);
-  Services.prefs.setCharPref("mail.server.server1.directory-rel",
-                             "[ProfD]Mail/Local Folders");
   Services.prefs.setCharPref("mail.server.server1.hostname",
                              "Local Folders");
   Services.prefs.setCharPref("mail.server.server1.name", "Local Folders");
   Services.prefs.setCharPref("mail.server.server1.type", "none");
   Services.prefs.setCharPref("mail.server.server1.userName", "nobody");
-  Services.prefs.setCharPref("mail.server.server2.directory-rel",
-                             "[ProfD]News/invalid");
   Services.prefs.setCharPref("mail.server.server2.hostname", "invalid");
   Services.prefs.setCharPref("mail.server.server2.name",
                              "testnntp on localhost");
   Services.prefs.setIntPref("mail.server.server2.port", server.port);
   Services.prefs.setCharPref("mail.server.server2.realhostname",
                              "localhost");
   Services.prefs.setCharPref("mail.server.server2.type", "nntp");