diff --git a/mailnews/base/prefs/resources/content/AccountManager.js b/mailnews/base/prefs/resources/content/AccountManager.js index 508ea18bd25..a2b200944c8 100644 --- a/mailnews/base/prefs/resources/content/AccountManager.js +++ b/mailnews/base/prefs/resources/content/AccountManager.js @@ -761,10 +761,21 @@ function onPanelLoaded(pageId) { pendingPageId = null; } - function loadPage(pageId) { - document.getElementById("contentFrame").setAttribute("src","chrome://messenger/content/" + pageId); + var chromePackageName; + try + { + // we could compare against "main","server","copies","offline","addressing", + // "smtp","advanced", and "fakeaccount" first to save the work, but don't + // as some of these might be turned into extensions (for thunderbird) + chromePackageName = accountManager.getChromePackageName(pageId.split("am-")[1].split(".xul")[0]); + } + catch (ex) + { + chromePackageName = "messenger"; + } + document.getElementById("contentFrame").setAttribute("src","chrome://" + chromePackageName + "/content/" + pageId); } // diff --git a/mailnews/base/public/nsIMsgAccountManager.idl b/mailnews/base/public/nsIMsgAccountManager.idl index 57b5bc77415..acf6e8be6e1 100644 --- a/mailnews/base/public/nsIMsgAccountManager.idl +++ b/mailnews/base/public/nsIMsgAccountManager.idl @@ -192,6 +192,8 @@ interface nsIMsgAccountManager : nsISupports { // force account info out to prefs file void saveAccountInfo(); + + string getChromePackageName(in string aExtenstionName); }; @@ -203,7 +205,8 @@ interface nsIMsgAccountManager : nsISupports { [scriptable, uuid(9ce9fc76-1dd1-11b2-8da2-bf6b98b4c537)] interface nsIMsgAccountManagerExtension : nsISupports { - readonly attribute string name; + readonly attribute string name; // examples: mdn boolean showPanel(in nsIMsgIncomingServer server); + readonly attribute string chromePackageName; // example: messenger, chrome://messenger/content/am-mdn.xul and chrome://messenger/locale/am-mdn.properties }; diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 76d678adc45..a0c058d6c8a 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -79,6 +79,8 @@ #include "nsIImapIncomingServer.h" #include "nsIImapUrl.h" #include "nsIMessengerOSIntegration.h" +#include "nsICategoryManager.h" +#include "nsISupportsPrimitives.h" #define PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS "mail.accountmanager.accounts" #define PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT "mail.accountmanager.defaultaccount" @@ -2342,3 +2344,49 @@ nsMsgAccountManager::SaveAccountInfo() return m_prefs->SavePrefFile(nsnull); } +NS_IMETHODIMP +nsMsgAccountManager::GetChromePackageName(const char *aExtenstionName, char **aChromePackageName) +{ + NS_ENSURE_ARG_POINTER(aExtenstionName); + NS_ENSURE_ARG_POINTER(aChromePackageName); + + nsresult rv; + nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv,rv); + + nsCOMPtr e; + rv = catman->EnumerateCategory(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, getter_AddRefs(e)); + if(NS_SUCCEEDED(rv) && e) { + while (PR_TRUE) { + nsCOMPtr catEntry; + rv = e->GetNext(getter_AddRefs(catEntry)); + if (NS_FAILED(rv) || !catEntry) + break; + + nsCAutoString entryString; + rv = catEntry->GetData(entryString); + if (NS_FAILED(rv)) + break; + + nsXPIDLCString contractidString; + rv = catman->GetCategoryEntry(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, entryString.get(), getter_Copies(contractidString)); + if (NS_FAILED(rv)) + break; + + nsCOMPtr extension = do_GetService(contractidString.get(), &rv); + if (NS_FAILED(rv) || !extension) + break; + + nsXPIDLCString name; + rv = extension->GetName(getter_Copies(name)); + if (NS_FAILED(rv)) + break; + + if (!strcmp(name.get(), aExtenstionName)) + return extension->GetChromePackageName(aChromePackageName); + } + } + return NS_ERROR_UNEXPECTED; +} + + diff --git a/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mailnews/base/src/nsMsgAccountManagerDS.cpp index 25819a0c5e6..e3bbf60ab6b 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp @@ -403,10 +403,19 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source, // make sure the pointer math we're about to do is safe. NS_ENSURE_TRUE(sourceValue && (strlen(sourceValue) > strlen(NC_RDF_PAGETITLE_PREFIX)), NS_ERROR_UNEXPECTED); - nsCAutoString bundleURL; - bundleURL = "chrome://messenger/locale/"; - bundleURL += "am-"; + nsCOMPtr am = + do_QueryReferent(mAccountManager, &rv); + NS_ENSURE_SUCCESS(rv, PR_FALSE); + // turn NC#PageTitlefoobar into foobar, so we can get the am-foobar.properties bundle + nsXPIDLCString chromePackageName; + rv = am->GetChromePackageName((sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX)), getter_Copies(chromePackageName)); + NS_ENSURE_SUCCESS(rv,rv); + + nsCAutoString bundleURL; + bundleURL = "chrome://"; + bundleURL += chromePackageName; + bundleURL += "/locale/am-"; bundleURL += (sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX)); bundleURL += ".properties"; diff --git a/mailnews/extensions/mdn/src/mdn-service.js b/mailnews/extensions/mdn/src/mdn-service.js index 90c5ff9b234..647ea0a627b 100644 --- a/mailnews/extensions/mdn/src/mdn-service.js +++ b/mailnews/extensions/mdn/src/mdn-service.js @@ -36,6 +36,7 @@ function MDNService() {} MDNService.prototype.name = "mdn"; +MDNService.prototype.chromePackageName = "messenger"; MDNService.prototype.showPanel = function (server) diff --git a/mailnews/extensions/smime/src/smime-service.js b/mailnews/extensions/smime/src/smime-service.js index b0651469575..0f842903741 100644 --- a/mailnews/extensions/smime/src/smime-service.js +++ b/mailnews/extensions/smime/src/smime-service.js @@ -36,6 +36,7 @@ function SMIMEService() {} SMIMEService.prototype.name = "smime"; +SMIMEService.prototype.chromePackageName = "messenger"; SMIMEService.prototype.showPanel = function (server)