From c4c91237ac4949d28ed7a3862c71af98b3cf6fcd Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Fri, 12 Mar 1999 00:47:09 +0000 Subject: [PATCH] Initial checkin, part of integration of preference into compose git-svn-id: svn://10.0.0.236/trunk@23808 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/compose/src/nsMsgCompPrefs.cpp | 81 +++++++++++++++++++ mozilla/mailnews/compose/src/nsMsgCompPrefs.h | 41 ++++++++++ 2 files changed, 122 insertions(+) create mode 100644 mozilla/mailnews/compose/src/nsMsgCompPrefs.cpp create mode 100644 mozilla/mailnews/compose/src/nsMsgCompPrefs.h diff --git a/mozilla/mailnews/compose/src/nsMsgCompPrefs.cpp b/mozilla/mailnews/compose/src/nsMsgCompPrefs.cpp new file mode 100644 index 00000000000..8684ad7acb7 --- /dev/null +++ b/mozilla/mailnews/compose/src/nsMsgCompPrefs.cpp @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; 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 "nsIMsgMailSession.h" +#include "nsIMsgIdentity.h" +#include "nsMsgCompPrefs.h" + +static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID); + + +nsMsgCompPrefs::nsMsgCompPrefs(void * identiy /*= nsnull*/) +{ + nsresult res; + + m_organization = nsnull; + m_userFullName = nsnull; + m_userEmail = nsnull; + + // get the current identity from the mail session.... + nsIMsgMailSession * mailSession = nsnull; + res = nsServiceManager::GetService(kCMsgMailSessionCID, + nsIMsgMailSession::GetIID(), + (nsISupports **) &mailSession); + if (NS_SUCCEEDED(res) && mailSession) { + nsIMsgIdentity * identity = nsnull; + res = mailSession->GetCurrentIdentity(&identity); + // now release the mail service because we are done with it + nsServiceManager::ReleaseService(kCMsgMailSessionCID, mailSession); + if (NS_SUCCEEDED(res) && identity) { + const char * aString = nsnull; + + identity->GetOrganization(&aString); + if (aString) + m_organization = PL_strdup(aString); + else + NS_ASSERTION(0, "no email address defined for this user...."); + + + identity->GetUserFullName(&aString); + if (aString) + m_userFullName = PL_strdup(aString); + else + NS_ASSERTION(0, "no email address defined for this user...."); + + + identity->GetUserEmail(&aString); + if (aString) + m_userEmail = PL_strdup(aString); + else + NS_ASSERTION(0, "no email address defined for this user...."); + + + // release the identity + NS_IF_RELEASE(identity); + } // if we have an identity + else + NS_ASSERTION(0, "no current identity found for this user...."); + } +} + +nsMsgCompPrefs::~nsMsgCompPrefs() +{ + PR_FREEIF(m_organization); + PR_FREEIF(m_userFullName); + PR_FREEIF(m_userEmail); +} diff --git a/mozilla/mailnews/compose/src/nsMsgCompPrefs.h b/mozilla/mailnews/compose/src/nsMsgCompPrefs.h new file mode 100644 index 00000000000..bf03a61ccb2 --- /dev/null +++ b/mozilla/mailnews/compose/src/nsMsgCompPrefs.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; 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 _MsgCompPrefs_H_ +#define _MsgCompPrefs_H_ + +#include "msgCore.h" + + +class nsMsgCompPrefs { +public: + nsMsgCompPrefs(void * identiy = nsnull); + virtual ~nsMsgCompPrefs(); + + const char * GetOrganization() {return m_organization;} + const char * GetUserFullName() {return m_userFullName;} + const char * GetUserEmail() {return m_userEmail;} + +private: + char * m_organization; + char * m_userFullName; + char * m_userEmail; +}; + + +#endif /* _MsgCompPrefs_H_ */