first addition of identity work

- Identity for outgoing mail
- Incoming Server for incoming mail
This commit is contained in:
alecf%netscape.com 1999-04-06 22:34:19 +00:00
Родитель 2ed04ba83e
Коммит 3790ed5c9c
4 изменённых файлов: 430 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,127 @@
/* -*- 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h" // for pre-compiled headers
#include "nsMsgIdentity.h"
#include "nsIPref.h"
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, 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)
{
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);
}
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);
char *
nsMsgIdentity::getPrefName(const char *identityKey,
const char *prefName)
{
return PR_smprintf("mail.identity.%s.%s", identityKey, prefName);
}
PRBool
nsMsgIdentity::getBoolPref(nsIPref *prefs,
const char *identityKey,
const char *prefname)
{
char *prefName = getPrefName(identityKey, prefname);
PRBool val=PR_FALSE;
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;
}
nsresult
nsMsgIdentity::LoadPreferences(nsIPref *prefs, const char* identityKey)
{
#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;
}

Просмотреть файл

@ -0,0 +1,111 @@
/* -*- 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsMsgIdentity_h___
#define nsMsgIdentity_h___
#include "nsIMsgIdentity.h"
///////////////////////////////////////////////////////////////////////////////////
// an identity is an object designed to encapsulate all the information we need
// to know about a user identity. I expect this interface to grow and change a lot
// as we flesh out our thoughts on multiple identities and what properties go into
// 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
{
public:
nsMsgIdentity();
virtual ~nsMsgIdentity();
NS_DECL_ISUPPORTS
/* attribute string identityName; */
NS_IMETHOD GetIdentityName(char * *aIdentityName);
NS_IMETHOD SetIdentityName(char * aIdentityName);
/* attribute string fullName; */
NS_IMETHOD GetFullName(char * *aFullName);
NS_IMETHOD SetFullName(char * aFullName);
/* attribute string email; */
NS_IMETHOD GetEmail(char * *aEmail);
NS_IMETHOD SetEmail(char * aEmail);
/* attribute string replyTo; */
NS_IMETHOD GetReplyTo(char * *aReplyTo);
NS_IMETHOD SetReplyTo(char * aReplyTo);
/* attribute string organization; */
NS_IMETHOD GetOrganization(char * *aOrganization);
NS_IMETHOD SetOrganization(char * aOrganization);
/* attribute boolean useHtml; */
NS_IMETHOD GetUseHtml(PRBool *aUseHtml);
NS_IMETHOD SetUseHtml(PRBool aUseHtml);
/* attribute nsIMsgSignature signature; */
NS_IMETHOD GetSignature(nsIMsgSignature * *aSignature);
NS_IMETHOD SetSignature(nsIMsgSignature * aSignature);
/* attribute nsIMsgVCard vCard; */
NS_IMETHOD GetVCard(nsIMsgVCard * *aVCard);
NS_IMETHOD SetVCard(nsIMsgVCard * aVCard);
/* attribute string smtpHostname; */
NS_IMETHOD GetSmtpHostname(char * *aSmtpHostname);
NS_IMETHOD SetSmtpHostname(char * aSmtpHostname);
/* attribute string smtpUsername; */
NS_IMETHOD GetSmtpUsername(char * *aSmtpUsername);
NS_IMETHOD SetSmtpUsername(char * aSmtpUsername);
/* attribute string key; */
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;
nsIMsgSignature* m_signature;
nsIMsgVCard* m_vCard;
char *m_smtpHostname;
char *m_smtpUsername;
char *m_key;
char *getPrefName(const char *identityKey, const char *pref);
char *getCharPref(nsIPref *pref, const char *identityKey, const char *pref);
PRBool getBoolPref(nsIPref *pref, const char *identityKey, const char *pref);
};
#endif /* nsMsgIdentity_h___ */

Просмотреть файл

@ -0,0 +1,114 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsMsgIncomingServer.h"
#include "nscore.h"
#include "nsCom.h"
#include "plstr.h"
#include "prmem.h"
#include "prprf.h"
nsMsgIncomingServer::nsMsgIncomingServer():
m_prettyName(0),
m_hostName(0),
m_userName(0),
m_password(0),
m_doBiff(PR_FALSE),
m_biffMinutes(0)
{
NS_INIT_REFCNT();
}
nsMsgIncomingServer::~nsMsgIncomingServer()
{
PR_FREEIF(m_prettyName);
PR_FREEIF(m_hostName);
PR_FREEIF(m_userName);
PR_FREEIF(m_password);
}
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);
}
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)
{
#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");
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,78 @@
/* -*- 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIMsgIncomingServer.h"
/*
* base class for nsIMsgIncomingServer - derive your class from here
* if you want to get some free implementation
*
* this particular implementation is not meant to be used directly.
*/
class nsMsgIncomingServer : public nsIMsgIncomingServer {
public:
NS_DECL_ISUPPORTS
nsMsgIncomingServer();
virtual ~nsMsgIncomingServer();
/* attribute string prettyName; */
NS_IMETHOD GetPrettyName(char * *aPrettyName);
NS_IMETHOD SetPrettyName(char * aPrettyName);
/* attribute string hostName; */
NS_IMETHOD GetHostName(char * *aHostName);
NS_IMETHOD SetHostName(char * aHostName);
/* attribute string userName; */
NS_IMETHOD GetUserName(char * *aUserName);
NS_IMETHOD SetUserName(char * aUserName);
NS_IMETHOD GetPassword(char * *aPassword);
NS_IMETHOD SetPassword(char * aPassword);
/* attribute boolean doBiff; */
NS_IMETHOD GetDoBiff(PRBool *aDoBiff);
NS_IMETHOD SetDoBiff(PRBool aDoBiff);
/* attribute long biffMinutes; */
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;
protected:
char *getPrefName(const char *serverKey, const char *pref);
char *getCharPref(nsIPref *pref, const char *serverKey, const char *pref);
PRBool getBoolPref(nsIPref *pref, const char *serverKey, const char *pref);
PRInt32 getIntPref(nsIPref *pref, const char *serverKey, const char *pref);
};