1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public
5
* License Version 1.1 (the "MPL"); you may not use this file
6
* except in compliance with the MPL. You may obtain a copy of
7
* the MPL at http://www.mozilla.org/MPL/
9
* Software distributed under the MPL is distributed on an "AS
10
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
* implied. See the MPL for the specific language governing
12
* rights and limitations under the MPL.
14
* The Original Code is Enigmail.
16
* The Initial Developer of the Original Code is Ramalingam Saravanan.
17
* Portions created by Ramalingam Saravanan <sarava@sarava.net> are
18
* Copyright (C) 2002 Ramalingam Saravanan. All Rights Reserved.
21
* Patrick Brunschwig <patrick@mozilla-enigmail.org>
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
34
* ***** END LICENSE BLOCK ***** */
38
// Logging of debug output
39
// The following define statement should occur before any include statements
40
#define FORCE_PR_LOG /* Allow logging even in release build */
44
#include "nsEnigContentHandler.h"
45
#include "mimedummy.h"
50
#include "nsStringAPI.h"
51
#include "nsNetUtil.h"
52
#include "nsIThread.h"
53
#include "nsIMimeObjectClassAccess.h"
54
#include "nsMsgMimeCID.h"
56
MimeContainerClass* mimeContainerClassP = NULL;
59
PRLogModuleInfo* gEnigContentHandlerLog = NULL;
62
#define ERROR_LOG(args) PR_LOG(gEnigContentHandlerLog,PR_LOG_ERROR,args)
63
#define WARNING_LOG(args) PR_LOG(gEnigContentHandlerLog,PR_LOG_WARNING,args)
64
#define DEBUG_LOG(args) PR_LOG(gEnigContentHandlerLog,PR_LOG_DEBUG,args)
66
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
69
// nsEnigContentHandler implementation
71
// nsISupports implementation
72
NS_IMPL_THREADSAFE_ISUPPORTS1(nsEnigContentHandler,
73
nsIMimeContentTypeHandler)
76
// nsEnigContentHandler implementation
77
nsEnigContentHandler::nsEnigContentHandler()
85
if (gEnigContentHandlerLog == NULL) {
86
gEnigContentHandlerLog = PR_NewLogModule("nsEnigContentHandler");
91
nsCOMPtr<nsIThread> myThread;
92
rv = ENIG_GET_THREAD(myThread);
93
DEBUG_LOG(("nsEnigContentHandler:: <<<<<<<<< CTOR(%p): myThread=%p\n",
94
this, myThread.get()));
99
nsEnigContentHandler::~nsEnigContentHandler()
103
nsCOMPtr<nsIThread> myThread;
104
rv = ENIG_GET_THREAD(myThread);
105
DEBUG_LOG(("nsEnigContentHandler:: >>>>>>>>> DTOR(%p): myThread=%p\n",
106
this, myThread.get()));
112
///////////////////////////////////////////////////////////////////////////////
113
// nsIMimeContentTypeHandler methods:
114
///////////////////////////////////////////////////////////////////////////////
117
nsEnigContentHandler::GetContentType(char **contentType)
119
DEBUG_LOG(("nsEnigContenthandler::GetContentType: \n"));
120
return NS_ERROR_NOT_IMPLEMENTED;
124
nsEnigContentHandler::CreateContentTypeHandlerClass(
125
const char *content_type,
126
contentTypeHandlerInitStruct *initStruct,
127
MimeObjectClass **objClass)
129
DEBUG_LOG(("nsEnigContenthandler::CreateContentTypeHandlerClass: %s\n", content_type));
132
mContentType = content_type;
136
if (!PL_strcasecmp(content_type, APPLICATION_XENIGMAIL_DUMMY)) {
137
// application/x-enigmail-dummy
139
if (!mimeContainerClassP) {
142
nsCOMPtr<nsIMimeObjectClassAccess> mimeObjectClassAccess(do_CreateInstance(kMimeObjectClassAccessCID, &rv));
146
rv = mimeObjectClassAccess->GetmimeContainerClass((void **) &mimeContainerClassP);
150
// Set superclass by hand
151
MimeObjectClass *clazz = (MimeObjectClass *) &mimeDummyClass;
152
clazz->superclass = (MimeObjectClass *) mimeContainerClassP;
155
*objClass = (MimeObjectClass *) &mimeDummyClass;
157
initStruct->force_inline_display = PR_FALSE;
162
if (!PL_strcasecmp(content_type, MULTIPART_ENCRYPTED)) {
163
// multipart/encrypted
165
if (!mimeContainerClassP || !mimeEncryptedClassP)
166
return NS_ERROR_FAILURE;
168
*objClass = (MimeObjectClass *) &mimeEncryptedEnigClass;
170
initStruct->force_inline_display = PR_FALSE;
175
if (!PL_strcasecmp(content_type, APPLICATION_PGP)) {
178
if (!mimeContainerClassP || !mimeEncryptedClassP)
179
return NS_ERROR_FAILURE;
181
*objClass = (MimeObjectClass *) &mimeEncryptedEnigClass;
183
initStruct->force_inline_display = PR_FALSE;
188
return NS_ERROR_FAILURE;
190
DEBUG_LOG(("nsEnigContenthandler::CreateContentTypeHandlerClass: with nsIPgpMime\n"));