Back to index

lightning-sunbird  0.9+nobinonly
nsImportModule.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00039 // Core Module Include Files
00041 #include "nsCOMPtr.h"
00042 #include "nsIModule.h"
00043 #include "nsIGenericFactory.h"
00044 #include "nsICategoryManager.h"
00045 #include "nsCRT.h"
00046 
00048 // core import Include Files
00050 #include "nsImportService.h"
00051 #include "nsImportMimeEncode.h"
00052 #include "nsImportStringBundle.h"
00053 
00055 // text import Include Files
00057 #include "nsTextImport.h"
00058 #include "nsTextStringBundle.h"
00059 
00060 static NS_DEFINE_CID(kTextImportCID,      NS_TEXTIMPORT_CID);
00061 
00063 // nsComm4x import Include Files
00065 #include "nsComm4xProfile.h"
00066 #include "nsComm4xMailStringBundle.h"
00067 #include "nsComm4xMailImport.h"
00068 
00069 static NS_DEFINE_CID(kComm4xMailImportCID,      NS_COMM4XMAILIMPORT_CID);
00070 
00072 // eudora import Include Files
00074 #if defined(XP_WIN) || defined(XP_MACOSX)
00075 #include "nsEudoraImport.h"
00076 #include "nsEudoraStringBundle.h"
00077 
00078 static NS_DEFINE_CID(kEudoraImportCID,           NS_EUDORAIMPORT_CID);
00079 #endif
00080 
00082 // outlook import Include Files
00084 #ifdef XP_WIN
00085 #if defined(_MSC_VER) && _MSC_VER >= 1100
00086 #include "nsOEImport.h"
00087 #include "nsOEStringBundle.h"
00088 #include "nsOutlookImport.h"
00089 #include "nsOutlookStringBundle.h"
00090 
00091 static NS_DEFINE_CID(kOEImportCID,        NS_OEIMPORT_CID);
00092 static NS_DEFINE_CID(kOutlookImportCID,          NS_OUTLOOKIMPORT_CID);
00093 #endif
00094 
00095 #endif // XP_WIN
00096 
00098 // core import factories
00100 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImportService)
00101 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIImportMimeEncodeImpl)
00102 
00104 // text import factories
00106 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextImport)
00107 
00108 NS_METHOD TextRegister(nsIComponentManager *aCompMgr,
00109                        nsIFile *aPath, const char *registryLocation,
00110                        const char *componentType,
00111                        const nsModuleComponentInfo *info)
00112 {      
00113        nsresult rv;
00114 
00115        nsCOMPtr<nsICategoryManager> catMan = do_GetService( NS_CATEGORYMANAGER_CONTRACTID, &rv);
00116        if (NS_SUCCEEDED( rv)) {
00117               nsXPIDLCString       replace;
00118               char *theCID = kTextImportCID.ToString();
00119               rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kTextSupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace));
00120               nsCRT::free( theCID);
00121        }
00122 
00123        return( rv);
00124 }
00125 
00127 // nsComm4x import factories
00129 NS_GENERIC_FACTORY_CONSTRUCTOR(nsComm4xMailImport)
00130 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ImportComm4xMailImpl, Initialize)
00131 NS_GENERIC_FACTORY_CONSTRUCTOR(nsComm4xProfile)
00132 
00133 NS_METHOD Comm4xMailRegister(nsIComponentManager *aCompMgr,
00134                        nsIFile *aPath, const char *registryLocation,
00135                        const char *componentType,
00136                        const nsModuleComponentInfo *info)
00137 {   
00138     nsresult rv;
00139 
00140     nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
00141     if (NS_SUCCEEDED(rv)) {
00142         nsXPIDLCString  replace;
00143         char *theCID = kComm4xMailImportCID.ToString();
00144         rv = catMan->AddCategoryEntry("mailnewsimport", theCID, kComm4xMailSupportsString, PR_TRUE, PR_TRUE, getter_Copies(replace));
00145         nsCRT::free(theCID);
00146     }
00147 
00148     return rv;
00149 }
00150 
00152 // eudora import factories
00154 #if defined(XP_WIN) || defined(XP_MACOSX)
00155 NS_GENERIC_FACTORY_CONSTRUCTOR(nsEudoraImport)
00156 
00157 NS_METHOD EudoraRegister(nsIComponentManager *aCompMgr,
00158                          nsIFile *aPath, const char *registryLocation,
00159                          const char *componentType,
00160                          const nsModuleComponentInfo *info)
00161 {      
00162        nsresult rv;
00163 
00164        nsCOMPtr<nsICategoryManager> catMan = do_GetService( NS_CATEGORYMANAGER_CONTRACTID, &rv);
00165        if (NS_SUCCEEDED( rv)) {
00166               nsXPIDLCString       replace;
00167               char *theCID = kEudoraImportCID.ToString();
00168               rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kEudoraSupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace));
00169               nsCRT::free( theCID);
00170        }
00171 
00172        return( rv);
00173 }
00174 #endif
00175 
00177 // outlook import factories
00179 #ifdef XP_WIN
00180 
00181 #if defined(_MSC_VER) && _MSC_VER >= 1100
00182 
00183 NS_GENERIC_FACTORY_CONSTRUCTOR(nsOEImport)
00184 NS_GENERIC_FACTORY_CONSTRUCTOR(nsOutlookImport)
00185 
00186 NS_METHOD OERegister(nsIComponentManager *aCompMgr,
00187                      nsIFile *aPath,
00188                      const char *registryLocation,
00189                      const char *componentType,
00190                      const nsModuleComponentInfo *info)
00191 {
00192        nsresult rv;
00193        
00194        nsCOMPtr<nsICategoryManager> catMan = do_GetService( NS_CATEGORYMANAGER_CONTRACTID, &rv);
00195        if (NS_SUCCEEDED( rv)) {
00196               nsXPIDLCString       replace;
00197               char *theCID = kOEImportCID.ToString();
00198               rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kOESupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace));
00199               nsCRT::free( theCID);
00200        }
00201 
00202     return( rv);
00203 }
00204 
00205 NS_METHOD OutlookRegister(nsIComponentManager *aCompMgr,
00206                           nsIFile *aPath, const char *registryLocation,
00207                           const char *componentType,
00208                           const nsModuleComponentInfo *info)
00209 {
00210        nsresult rv;
00211        
00212        nsCOMPtr<nsICategoryManager> catMan = do_GetService( NS_CATEGORYMANAGER_CONTRACTID, &rv);
00213        if (NS_SUCCEEDED( rv)) {
00214               nsXPIDLCString       replace;
00215               char *theCID = kOutlookImportCID.ToString();
00216               rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kOutlookSupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace));
00217               nsCRT::free( theCID);
00218        }
00219 
00220        return( rv);
00221 }
00222 #endif
00223 
00224 #endif // XP_WIN
00225 
00226 static const nsModuleComponentInfo components[] = {
00228     // core import components
00230     { "Import Service Component", NS_IMPORTSERVICE_CID, 
00231         NS_IMPORTSERVICE_CONTRACTID, nsImportServiceConstructor },
00232     { "Import Mime Encoder", NS_IMPORTMIMEENCODE_CID, 
00233       "@mozilla.org/import/import-mimeencode;1", nsIImportMimeEncodeImplConstructor},
00234    
00236     // text import components
00238     { "Text Import Component", NS_TEXTIMPORT_CID,
00239          "@mozilla.org/import/import-text;1", nsTextImportConstructor, TextRegister, nsnull },
00240 
00242     // nsComm4x import components
00244     { "Comm4xMail Import Component", NS_COMM4XMAILIMPORT_CID,
00245       "@mozilla.org/import/import-comm4xMail;1", nsComm4xMailImportConstructor, Comm4xMailRegister, nsnull },
00246     { "Comm4xMail Import Mail Implementation", NS_COMM4XMAILIMPL_CID,
00247       NS_COMM4XMAILIMPL_CONTRACTID, ImportComm4xMailImplConstructor},
00248     { NS_ICOMM4XPROFILE_CLASSNAME, NS_ICOMM4XPROFILE_CID,
00249       NS_ICOMM4XPROFILE_CONTRACTID, nsComm4xProfileConstructor }
00250 
00252     // eduora import components
00254 #if defined(XP_WIN) || defined(XP_MACOSX)
00255     ,{ "Text Import Component", NS_EUDORAIMPORT_CID,
00256          "@mozilla.org/import/import-eudora;1", nsEudoraImportConstructor, EudoraRegister, nsnull }
00257 #endif
00258 
00259 #ifdef XP_WIN
00260 #if defined(_MSC_VER) && _MSC_VER >= 1100
00261 
00262     // oexpress import components
00264     ,{ "Outlook Express Import Component", NS_OEIMPORT_CID,
00265          "@mozilla.org/import/import-oe;1", nsOEImportConstructor,    OERegister,   nsnull },
00266     { "Outlook Import Component", NS_OUTLOOKIMPORT_CID,
00267          "@mozilla.org/import/import-outlook;1", nsOutlookImportConstructor, OutlookRegister, nsnull }
00268 #endif
00269 #endif
00270 
00271 };
00272 
00273 
00274 PR_STATIC_CALLBACK(void) importModuleDtor(nsIModule* self)
00275 {
00276        nsImportStringBundle::Cleanup();
00277     nsTextStringBundle::Cleanup();
00278 
00279 #if defined(XP_WIN) || defined(XP_MACOSX)
00280     nsEudoraStringBundle::Cleanup();
00281 #endif
00282 
00283 #ifdef XP_WIN
00284 
00285 #if defined(_MSC_VER) && _MSC_VER >= 1100
00286     nsOEStringBundle::Cleanup();
00287     nsOutlookStringBundle::Cleanup();
00288 #endif
00289 
00290 #endif
00291 }
00292 
00293 NS_IMPL_NSGETMODULE_WITH_DTOR( nsImportServiceModule, components, importModuleDtor)
00294 
00295