зеркало из https://github.com/mozilla/pjs.git
Bug #210984 --> let extensions extend entries in the account manager. This allows extensions like PGP/mime to directly add panels
to the account manager. r/sr=sspitzer
This commit is contained in:
Родитель
45f04d4def
Коммит
a8b279976a
|
@ -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);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = catman->EnumerateCategory(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, getter_AddRefs(e));
|
||||
if(NS_SUCCEEDED(rv) && e) {
|
||||
while (PR_TRUE) {
|
||||
nsCOMPtr<nsISupportsCString> 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 <nsIMsgAccountManagerExtension> 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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<nsIMsgAccountManager> 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";
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ function MDNService()
|
|||
{}
|
||||
|
||||
MDNService.prototype.name = "mdn";
|
||||
MDNService.prototype.chromePackageName = "messenger";
|
||||
MDNService.prototype.showPanel =
|
||||
|
||||
function (server)
|
||||
|
|
|
@ -36,6 +36,7 @@ function SMIMEService()
|
|||
{}
|
||||
|
||||
SMIMEService.prototype.name = "smime";
|
||||
SMIMEService.prototype.chromePackageName = "messenger";
|
||||
SMIMEService.prototype.showPanel =
|
||||
|
||||
function (server)
|
||||
|
|
Загрузка…
Ссылка в новой задаче