зеркало из https://github.com/mozilla/pjs.git
implementation for updated Multiple Accounts. create accounts/identities lazily, etc
This commit is contained in:
Родитель
910bd725b8
Коммит
dc94e0bc7c
|
@ -22,55 +22,34 @@
|
|||
|
||||
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMsgIdentity, nsIMsgIdentity::GetIID());
|
||||
|
||||
|
||||
nsMsgIdentity::nsMsgIdentity():
|
||||
m_identityName(nsnull),
|
||||
m_fullName(nsnull),
|
||||
m_email(nsnull),
|
||||
m_replyTo(nsnull),
|
||||
m_organization(nsnull),
|
||||
m_useHtml(PR_FALSE),
|
||||
m_signature(nsnull),
|
||||
m_vCard(nsnull),
|
||||
m_smtpHostname(nsnull),
|
||||
m_smtpUsername(nsnull)
|
||||
m_identityKey(0),
|
||||
m_prefs(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsMsgIdentity::~nsMsgIdentity()
|
||||
{
|
||||
PR_FREEIF(m_identityName);
|
||||
PR_FREEIF(m_fullName);
|
||||
PR_FREEIF(m_email);
|
||||
PR_FREEIF(m_replyTo);
|
||||
PR_FREEIF(m_organization);
|
||||
NS_IF_RELEASE(m_signature);
|
||||
NS_IF_RELEASE(m_vCard);
|
||||
PR_FREEIF(m_smtpHostname);
|
||||
PR_FREEIF(m_smtpUsername);
|
||||
PR_FREEIF(m_identityKey);
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
|
||||
m_prefs,
|
||||
nsnull);
|
||||
}
|
||||
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, IdentityName, m_identityName)
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, FullName, m_fullName)
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, Email, m_email)
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, ReplyTo, m_replyTo)
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, Organization, m_organization)
|
||||
NS_IMPL_GETSET(nsMsgIdentity, UseHtml, PRBool, m_useHtml)
|
||||
|
||||
// XXX - these are a COM objects, use NS_ADDREF
|
||||
NS_IMPL_GETSET(nsMsgIdentity, Signature, nsIMsgSignature*, m_signature);
|
||||
NS_IMPL_GETSET(nsMsgIdentity, VCard, nsIMsgVCard*, m_vCard);
|
||||
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, SmtpHostname, m_smtpHostname);
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, SmtpUsername, m_smtpUsername);
|
||||
NS_IMPL_GETSET_STR(nsMsgIdentity, Key, m_key);
|
||||
/*
|
||||
* accessors for pulling values directly out of preferences
|
||||
* instead of member variables, etc
|
||||
*/
|
||||
|
||||
/* convert an identity key and preference name
|
||||
to mail.identity.<identityKey>.<prefName>
|
||||
*/
|
||||
char *
|
||||
nsMsgIdentity::getPrefName(const char *identityKey,
|
||||
const char *prefName)
|
||||
|
@ -78,50 +57,77 @@ nsMsgIdentity::getPrefName(const char *identityKey,
|
|||
return PR_smprintf("mail.identity.%s.%s", identityKey, prefName);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMsgIdentity::getBoolPref(nsIPref *prefs,
|
||||
const char *identityKey,
|
||||
const char *prefname)
|
||||
/* The following are equivalent to the nsIPref's Get/CopyXXXPref
|
||||
except they construct the preference name with the above function
|
||||
*/
|
||||
nsresult
|
||||
nsMsgIdentity::getBoolPref(const char *prefname,
|
||||
PRBool *val)
|
||||
{
|
||||
char *prefName = getPrefName(identityKey, prefname);
|
||||
PRBool val=PR_FALSE;
|
||||
prefs->GetBoolPref(prefName, &val);
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
nsresult rv = m_prefs->GetBoolPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return val;
|
||||
}
|
||||
|
||||
char *
|
||||
nsMsgIdentity::getCharPref(nsIPref *prefs,
|
||||
const char *identityKey,
|
||||
const char *prefname)
|
||||
{
|
||||
char *prefName = getPrefName(identityKey, prefname);
|
||||
char *val=nsnull;
|
||||
nsresult rv = prefs->CopyCharPref(prefName, &val);
|
||||
PR_Free(prefName);
|
||||
if (NS_FAILED(rv)) return nsnull;
|
||||
return val;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::LoadPreferences(nsIPref *prefs, const char* identityKey)
|
||||
nsMsgIdentity::setBoolPref(const char *prefname,
|
||||
PRBool val)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("Loading identity for %s\n", identityKey);
|
||||
#endif
|
||||
|
||||
NS_ADDREF(prefs);
|
||||
m_identityName = getCharPref(prefs, identityKey, "name");
|
||||
m_fullName = getCharPref(prefs, identityKey, "fullName");
|
||||
m_email = getCharPref(prefs, identityKey, "useremail");
|
||||
m_replyTo = getCharPref(prefs, identityKey, "reply_to");
|
||||
m_organization = getCharPref(prefs, identityKey, "organization");
|
||||
m_useHtml = getBoolPref(prefs, identityKey, "send_html");
|
||||
m_smtpHostname = getCharPref(prefs, identityKey, "smtp_server");
|
||||
m_smtpUsername = getCharPref(prefs, identityKey, "smtp_name");
|
||||
NS_RELEASE(prefs);
|
||||
|
||||
return NS_OK;
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
nsresult rv = m_prefs->SetBoolPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::getCharPref(const char *prefname,
|
||||
char **val)
|
||||
{
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
nsresult rv = m_prefs->CopyCharPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::setCharPref(const char *prefname,
|
||||
char *val)
|
||||
{
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
nsresult rv = m_prefs->SetCharPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::SetKey(char* identityKey)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// in order to actually make use of the key, we need the prefs
|
||||
if (!m_prefs)
|
||||
rv = nsServiceManager::GetService(kPrefServiceCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports**)&m_prefs);
|
||||
|
||||
m_identityKey = PL_strdup(identityKey);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* Identity attribute accessors */
|
||||
|
||||
// XXX - these are a COM objects, use NS_ADDREF
|
||||
NS_IMPL_GETSET(nsMsgIdentity, Signature, nsIMsgSignature*, m_signature);
|
||||
NS_IMPL_GETSET(nsMsgIdentity, VCard, nsIMsgVCard*, m_vCard);
|
||||
|
||||
NS_IMPL_GETTER_STR(nsMsgIdentity::GetKey, m_identityKey);
|
||||
|
||||
NS_IMPL_IDPREF_STR(IdentityName, "identityName");
|
||||
NS_IMPL_IDPREF_STR(FullName, "fullName");
|
||||
NS_IMPL_IDPREF_STR(Email, "useremail");
|
||||
NS_IMPL_IDPREF_STR(ReplyTo, "reply_to");
|
||||
NS_IMPL_IDPREF_STR(Organization, "organization");
|
||||
NS_IMPL_IDPREF_BOOL(UseHtml, "send_html");
|
||||
NS_IMPL_IDPREF_STR(SmtpHostname, "smtp_server");
|
||||
NS_IMPL_IDPREF_STR(SmtpUsername, "smtp_name");
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define nsMsgIdentity_h___
|
||||
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// an identity is an object designed to encapsulate all the information we need
|
||||
|
@ -28,11 +29,6 @@
|
|||
// these identities.
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* E7F875B0-D5AC-11d2-806A-006008128C4E */
|
||||
#define NS_IMSGIDENTITY_CID \
|
||||
{ 0xe7f875b0, 0xd5ac, 0x11d2, \
|
||||
{ 0x80, 0x6a, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e } }
|
||||
|
||||
|
||||
class nsMsgIdentity : public nsIMsgIdentity
|
||||
{
|
||||
|
@ -86,26 +82,45 @@ public:
|
|||
NS_IMETHOD GetKey(char * *aKey);
|
||||
NS_IMETHOD SetKey(char * aKey);
|
||||
|
||||
NS_IMETHOD LoadPreferences(nsIPref *prefs, const char *identityKey);
|
||||
|
||||
protected:
|
||||
char *m_identityName;
|
||||
char *m_fullName;
|
||||
char *m_email;
|
||||
char *m_replyTo;
|
||||
char *m_organization;
|
||||
PRBool m_useHtml;
|
||||
private:
|
||||
nsIMsgSignature* m_signature;
|
||||
nsIMsgVCard* m_vCard;
|
||||
|
||||
char *m_smtpHostname;
|
||||
char *m_smtpUsername;
|
||||
char *m_key;
|
||||
char *m_identityKey;
|
||||
nsIPref *m_prefs;
|
||||
|
||||
char *getPrefName(const char *identityKey, const char *pref);
|
||||
char *getCharPref(nsIPref *prefs, const char *identityKey, const char *pref);
|
||||
PRBool getBoolPref(nsIPref *prefs, const char *identityKey, const char *pref);
|
||||
protected:
|
||||
static char *getPrefName(const char *identityKey, const char *pref);
|
||||
nsresult getCharPref(const char *pref, char **);
|
||||
nsresult setCharPref(const char *pref, char *);
|
||||
nsresult getBoolPref(const char *pref, PRBool *);
|
||||
nsresult setBoolPref(const char *pref, PRBool);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define NS_IMPL_IDPREF_STR(_postfix, _prefname) \
|
||||
NS_IMETHODIMP \
|
||||
nsMsgIdentity::Get##_postfix(char **retval) \
|
||||
{ \
|
||||
return getCharPref(_prefname, retval); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsMsgIdentity::Set##_postfix(char *value) \
|
||||
{ \
|
||||
return setCharPref(_prefname, value);\
|
||||
}
|
||||
|
||||
#define NS_IMPL_IDPREF_BOOL(_postfix, _prefname)\
|
||||
NS_IMETHODIMP \
|
||||
nsMsgIdentity::Get##_postfix(PRBool *retval) \
|
||||
{ \
|
||||
return getBoolPref(_prefname, retval); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsMsgIdentity::Set##_postfix(PRBool value) \
|
||||
{ \
|
||||
return setBoolPref(_prefname, value); \
|
||||
}
|
||||
|
||||
|
||||
#endif /* nsMsgIdentity_h___ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
|
@ -23,92 +23,195 @@
|
|||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
nsMsgIncomingServer::nsMsgIncomingServer():
|
||||
m_prettyName(0),
|
||||
m_hostName(0),
|
||||
m_userName(0),
|
||||
m_password(0),
|
||||
m_doBiff(PR_FALSE),
|
||||
m_biffMinutes(0)
|
||||
m_prefs(0),
|
||||
m_serverKey(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsMsgIncomingServer::~nsMsgIncomingServer()
|
||||
{
|
||||
PR_FREEIF(m_prettyName);
|
||||
PR_FREEIF(m_hostName);
|
||||
PR_FREEIF(m_userName);
|
||||
PR_FREEIF(m_password);
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
|
||||
m_prefs,
|
||||
nsnull);
|
||||
PR_FREEIF(m_serverKey)
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMsgIncomingServer, GetIID());
|
||||
|
||||
NS_IMPL_GETSET_STR(nsMsgIncomingServer, PrettyName, m_prettyName)
|
||||
NS_IMPL_GETSET_STR(nsMsgIncomingServer, HostName, m_hostName)
|
||||
NS_IMPL_GETSET_STR(nsMsgIncomingServer, UserName, m_userName)
|
||||
NS_IMPL_GETSET_STR(nsMsgIncomingServer, Password, m_password)
|
||||
NS_IMPL_GETSET(nsMsgIncomingServer, DoBiff, PRBool, m_doBiff)
|
||||
NS_IMPL_GETSET(nsMsgIncomingServer, BiffMinutes, PRInt32, m_biffMinutes)
|
||||
|
||||
char *
|
||||
nsMsgIncomingServer::getPrefName(const char *serverKey,
|
||||
const char *prefName)
|
||||
{
|
||||
return PR_smprintf("mail.server.%s.%s", serverKey, prefName);
|
||||
}
|
||||
NS_IMPL_GETTER_STR(nsMsgIncomingServer::GetKey, m_serverKey)
|
||||
|
||||
PRBool
|
||||
nsMsgIncomingServer::getBoolPref(nsIPref *prefs,
|
||||
const char *serverKey,
|
||||
const char *prefname)
|
||||
{
|
||||
char *prefName = getPrefName(serverKey, prefname);
|
||||
PRBool val=PR_FALSE;
|
||||
prefs->GetBoolPref(prefName, &val);
|
||||
PR_Free(prefName);
|
||||
return val;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsMsgIncomingServer::getIntPref(nsIPref *prefs,
|
||||
const char *serverKey,
|
||||
const char *prefname)
|
||||
{
|
||||
char *prefName = getPrefName(serverKey, prefname);
|
||||
PRInt32 val=0;
|
||||
prefs->GetIntPref(prefName, &val);
|
||||
PR_Free(prefName);
|
||||
return val;
|
||||
}
|
||||
|
||||
char *
|
||||
nsMsgIncomingServer::getCharPref(nsIPref *prefs,
|
||||
const char *serverKey,
|
||||
const char *prefname)
|
||||
{
|
||||
char *prefName = getPrefName(serverKey, prefname);
|
||||
char *val=nsnull;
|
||||
nsresult rv = prefs->CopyCharPref(prefName, &val);
|
||||
PR_Free(prefName);
|
||||
if (NS_FAILED(rv)) return nsnull;
|
||||
return val;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::LoadPreferences(nsIPref *prefs, const char *serverKey)
|
||||
nsMsgIncomingServer::SetKey(char * serverKey)
|
||||
{
|
||||
#ifdef DEBUG_alecf
|
||||
printf("Loading generic server prefs for %s\n", serverKey);
|
||||
#endif
|
||||
|
||||
m_prettyName = getCharPref(prefs, serverKey, "name");
|
||||
m_hostName = getCharPref(prefs, serverKey, "hostname");
|
||||
m_userName = getCharPref(prefs, serverKey, "userName");
|
||||
m_password = getCharPref(prefs, serverKey, "password");
|
||||
m_doBiff = getBoolPref(prefs, serverKey, "check_new_mail");
|
||||
m_biffMinutes = getIntPref(prefs, serverKey, "check_time");
|
||||
nsresult rv = NS_OK;
|
||||
// in order to actually make use of the key, we need the prefs
|
||||
if (!m_prefs)
|
||||
rv = nsServiceManager::GetService(kPrefServiceCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports**)&m_prefs);
|
||||
|
||||
return NS_OK;
|
||||
PR_FREEIF(m_serverKey);
|
||||
m_serverKey = PL_strdup(serverKey);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
nsMsgIncomingServer::getPrefName(const char *serverKey,
|
||||
const char *fullPrefName)
|
||||
{
|
||||
return PR_smprintf("mail.server.%s.%s", serverKey, fullPrefName);
|
||||
}
|
||||
|
||||
// this will be slightly faster than the above, and allows
|
||||
// the "default" server preference root to be set in one place
|
||||
char *
|
||||
nsMsgIncomingServer::getDefaultPrefName(const char *fullPrefName)
|
||||
{
|
||||
return PR_smprintf("mail.server.default.%s", fullPrefName);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getBoolPref(const char *prefname,
|
||||
PRBool *val)
|
||||
{
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
nsresult rv = m_prefs->GetBoolPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultBoolPref(prefname, val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getDefaultBoolPref(const char *prefname,
|
||||
PRBool *val) {
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(m_serverKey);
|
||||
nsresult rv = m_prefs->GetBoolPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::setBoolPref(const char *prefname,
|
||||
PRBool val)
|
||||
{
|
||||
nsresult rv;
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
|
||||
PRBool defaultValue;
|
||||
rv = getDefaultBoolPref(prefname, &defaultValue);
|
||||
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
val == defaultValue)
|
||||
rv = m_prefs->ClearUserPref(fullPrefName);
|
||||
else
|
||||
rv = m_prefs->SetBoolPref(fullPrefName, val);
|
||||
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getIntPref(const char *prefname,
|
||||
PRInt32 *val)
|
||||
{
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
nsresult rv = m_prefs->GetIntPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultIntPref(prefname, val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getDefaultIntPref(const char *prefname,
|
||||
PRInt32 *val) {
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(m_serverKey);
|
||||
nsresult rv = m_prefs->GetIntPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::setIntPref(const char *prefname,
|
||||
PRInt32 val)
|
||||
{
|
||||
nsresult rv;
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
|
||||
PRInt32 defaultVal;
|
||||
rv = getDefaultIntPref(prefname, &defaultVal);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && defaultVal == val)
|
||||
rv = m_prefs->ClearUserPref(fullPrefName);
|
||||
else
|
||||
rv = m_prefs->SetIntPref(fullPrefName, val);
|
||||
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getCharPref(const char *prefname,
|
||||
char **val)
|
||||
{
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
nsresult rv = m_prefs->CopyCharPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultCharPref(prefname, val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::setCharPref(const char *prefname,
|
||||
char * val)
|
||||
{
|
||||
nsresult rv;
|
||||
char *fullPrefName = getPrefName(m_serverKey, prefname);
|
||||
|
||||
char *defaultVal=nsnull;
|
||||
rv = getDefaultCharPref(prefname, &defaultVal);
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
PL_strcmp(defaultVal, val) == 0)
|
||||
rv = m_prefs->ClearUserPref(fullPrefName);
|
||||
else
|
||||
rv = m_prefs->SetCharPref(fullPrefName, val);
|
||||
|
||||
PR_FREEIF(defaultVal);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// use the convenience macros to implement the accessors
|
||||
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, PrettyName, "name")
|
||||
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, HostName, "hostname");
|
||||
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, UserName, "userName");
|
||||
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Password, "password");
|
||||
NS_IMPL_SERVERPREF_BOOL(nsMsgIncomingServer, DoBiff, "check_new_mail");
|
||||
NS_IMPL_SERVERPREF_INT(nsMsgIncomingServer, BiffMinutes, "check_time");
|
||||
|
|
|
@ -32,6 +32,10 @@ class nsMsgIncomingServer : public nsIMsgIncomingServer {
|
|||
nsMsgIncomingServer();
|
||||
virtual ~nsMsgIncomingServer();
|
||||
|
||||
/* attribute string key; */
|
||||
NS_IMETHOD GetKey(char * *aKey);
|
||||
NS_IMETHOD SetKey(char * aKey);
|
||||
|
||||
/* attribute string prettyName; */
|
||||
NS_IMETHOD GetPrettyName(char * *aPrettyName);
|
||||
NS_IMETHOD SetPrettyName(char * aPrettyName);
|
||||
|
@ -55,24 +59,61 @@ class nsMsgIncomingServer : public nsIMsgIncomingServer {
|
|||
NS_IMETHOD GetBiffMinutes(PRInt32 *aBiffMinutes);
|
||||
NS_IMETHOD SetBiffMinutes(PRInt32 aBiffMinutes);
|
||||
|
||||
NS_IMETHOD LoadPreferences(nsIPref *prefs, const char *serverKey);
|
||||
|
||||
private:
|
||||
char *m_prettyName;
|
||||
char *m_hostName;
|
||||
char *m_userName;
|
||||
char *m_password;
|
||||
|
||||
PRBool m_doBiff;
|
||||
PRInt32 m_biffMinutes;
|
||||
private:
|
||||
nsIPref *m_prefs;
|
||||
char *m_serverKey;
|
||||
|
||||
protected:
|
||||
char *getPrefName(const char *serverKey, const char *pref);
|
||||
char *getCharPref(nsIPref *prefs, const char *serverKey, const char *pref);
|
||||
PRBool getBoolPref(nsIPref *prefs, const char *serverKey, const char *pref);
|
||||
PRInt32 getIntPref(nsIPref *prefs, const char *serverKey, const char *pref);
|
||||
char *getDefaultPrefName(const char *pref);
|
||||
|
||||
|
||||
nsresult getCharPref(const char *pref, char **);
|
||||
nsresult getDefaultCharPref(const char *pref, char **);
|
||||
nsresult setCharPref(const char *pref, char *);
|
||||
|
||||
nsresult getBoolPref(const char *pref, PRBool *);
|
||||
nsresult getDefaultBoolPref(const char *pref, PRBool *);
|
||||
nsresult setBoolPref(const char *pref, PRBool);
|
||||
|
||||
nsresult getIntPref(const char *pref, PRInt32 *);
|
||||
nsresult getDefaultIntPref(const char *pref, PRInt32 *);
|
||||
nsresult setIntPref(const char *pref, PRInt32);
|
||||
};
|
||||
|
||||
/* some useful macros to implement accessors */
|
||||
#define NS_IMPL_SERVERPREF_STR(_class, _postfix, _prefname) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_postfix(char **retval) \
|
||||
{ \
|
||||
return getCharPref(_prefname, retval); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_postfix(char *value) \
|
||||
{ \
|
||||
return setCharPref(_prefname, value); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_SERVERPREF_BOOL(_class, _postfix, _prefname)\
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_postfix(PRBool *retval) \
|
||||
{ \
|
||||
return getBoolPref(_prefname, retval); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_postfix(PRBool value) \
|
||||
{ \
|
||||
return setBoolPref(_prefname, value); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_SERVERPREF_INT(_class, _postfix, _prefname)\
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_postfix(PRInt32 *retval) \
|
||||
{ \
|
||||
return getIntPref(_prefname, retval); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_postfix(PRInt32 value) \
|
||||
{ \
|
||||
return setIntPref(_prefname, value); \
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче