Back to index

lightning-sunbird  0.9+nobinonly
mimexpcom.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Pierre Phaneuf <pp@ludusdesign.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #include "nsIComponentManager.h" 
00039 #include "nsMimeObjectClassAccess.h"
00040 #include "nsMsgMimeCID.h"
00041 #include "nsCOMPtr.h"
00042 static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID); 
00043 
00044 /*
00045  * These calls are necessary to expose the object class heirarchy 
00046  * to externally developed content type handlers.
00047  */
00048 extern "C" void *
00049 COM_GetmimeInlineTextClass(void)
00050 {
00051   void *ptr = NULL;
00052 
00053   nsresult res;
00054   nsCOMPtr<nsIMimeObjectClassAccess>  objAccess =
00055       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00056   if (NS_SUCCEEDED(res) && objAccess)
00057     objAccess->GetmimeInlineTextClass(&ptr);
00058 
00059   return ptr;
00060 }
00061 
00062 extern "C" void *
00063 COM_GetmimeLeafClass(void)
00064 {
00065   void *ptr = NULL;
00066 
00067   nsresult res;
00068   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00069       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00070   if (NS_SUCCEEDED(res) && objAccess)
00071     objAccess->GetmimeLeafClass(&ptr);
00072 
00073   return ptr;
00074 }
00075 
00076 extern "C" void *
00077 COM_GetmimeObjectClass(void)
00078 {
00079   void *ptr = NULL;
00080 
00081   nsresult res;
00082   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00083       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00084   if (NS_SUCCEEDED(res) && objAccess)
00085     objAccess->GetmimeObjectClass(&ptr);
00086 
00087   return ptr;
00088 }
00089 
00090 extern "C" void *
00091 COM_GetmimeContainerClass(void)
00092 {
00093   void *ptr = NULL;
00094 
00095   nsresult res;
00096   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00097       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00098   if (NS_SUCCEEDED(res) && objAccess)
00099     objAccess->GetmimeContainerClass(&ptr);
00100 
00101   return ptr;
00102 }
00103 
00104 extern "C" void *
00105 COM_GetmimeMultipartClass(void)
00106 {
00107   void *ptr = NULL;
00108 
00109   nsresult res;
00110   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00111       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00112   if (NS_SUCCEEDED(res) && objAccess)
00113     objAccess->GetmimeMultipartClass(&ptr);
00114 
00115   return ptr;
00116 }
00117 
00118 extern "C" void *
00119 COM_GetmimeMultipartSignedClass(void)
00120 {
00121   void *ptr = NULL;
00122 
00123   nsresult res;
00124   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00125       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00126   if (NS_SUCCEEDED(res) && objAccess)
00127     objAccess->GetmimeMultipartSignedClass(&ptr);
00128 
00129   return ptr;
00130 }
00131 
00132 extern "C" int  
00133 COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length, 
00134                      PRBool user_visible_p)
00135 {
00136   PRInt32 rc = -1;
00137 
00138   nsresult res;
00139   nsCOMPtr<nsIMimeObjectClassAccess> objAccess =
00140       do_CreateInstance(kMimeObjectClassAccessCID, &res);
00141   if (NS_SUCCEEDED(res) && objAccess)
00142   { 
00143     if (NS_SUCCEEDED(objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p)))
00144       rc = length;
00145     else
00146       rc = -1;
00147   } 
00148 
00149   return rc;
00150 }