1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
|
/*
* Copyright (C) 2001,2002,2003 Philip Langdale
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "CookiePromptService.h"
#include "ContentHandler.h"
#include "FilePicker.h"
#include "GlobalHistory.h"
#include "MyportalProtocolHandler.h"
#include "PrintingPromptService.h"
#include "ProgressListener.h"
#include "SideBarProxy.h"
#include "EphyPromptService.h"
#ifdef HAVE_NSIJSCONSOLESERVICE_H
#include "JSConsoleService.h"
#endif
#ifdef HAVE_MOZILLA_PSM
#include "GtkNSSDialogs.h"
#include "GtkNSSKeyPairDialogs.h"
#include "GtkNSSClientAuthDialogs.h"
#include "GtkNSSSecurityWarningDialogs.h"
#endif
#include "ExternalProtocolService.h"
#include "GaleonAboutModule.h"
#ifdef HAVE_NSICLASSINFOIMPL_H
#include <nsIClassInfoImpl.h>
#endif
#include <nsIGenericFactory.h>
#include <nsIComponentRegistrar.h>
#include <nsICategoryManager.h>
#include <nsIComponentManager.h>
#include <nsCOMPtr.h>
#include <nsXPCOM.h>
#include <nsComponentManagerUtils.h>
#include <nsServiceManagerUtils.h>
#include <nsDocShellCID.h>
#include <nsXPCOMCID.h>
#include <glib.h>
NS_GENERIC_FACTORY_CONSTRUCTOR(GProgressListener)
NS_GENERIC_FACTORY_CONSTRUCTOR(GFilePicker)
NS_GENERIC_FACTORY_CONSTRUCTOR(GContentHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(MozGlobalHistory)
NS_GENERIC_FACTORY_CONSTRUCTOR(GPrintingPromptService)
NS_GENERIC_FACTORY_CONSTRUCTOR(GSidebarProxy)
NS_DECL_CLASSINFO(GSidebarProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(GCookiePromptService)
NS_GENERIC_FACTORY_CONSTRUCTOR(EphyPromptService)
#ifdef HAVE_MOZILLA_PSM
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSKeyPairDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSClientAuthDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSSecurityWarningDialogs)
#endif
#ifdef HAVE_NSSTRING_INTERNAL
NS_GENERIC_FACTORY_CONSTRUCTOR(GaleonAboutModule)
NS_GENERIC_FACTORY_CONSTRUCTOR(GMyportalProtocolHandler)
#endif
#ifndef XPCOM_GLUE
NS_GENERIC_FACTORY_CONSTRUCTOR(GExternalProtocolService)
#endif
#ifdef HAVE_NSIJSCONSOLESERVICE_H
NS_GENERIC_FACTORY_CONSTRUCTOR(JSConsoleService)
#endif
// NS_DOWNLOAD_CONTRACTID was renamed in mozilla 1.8b
#ifndef NS_TRANSFER_CONTRACTID
#define NS_TRANSFER_CONTRACTID NS_DOWNLOAD_CONTRACTID
#endif
static NS_METHOD
RegisterSidebar(nsIComponentManager *aCompMgr, nsIFile *aPath,
const char *registryLocation, const char *componentType,
const nsModuleComponentInfo *info)
{
nsCOMPtr<nsICategoryManager> cm =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
return cm->AddCategoryEntry("JavaScript global property",
"sidebar", NS_SIDEBAR_CONTRACTID,
PR_FALSE, PR_TRUE, nsnull);
}
static const nsModuleComponentInfo sAppComps[] = {
{
G_PROGRESSDIALOG_CLASSNAME,
G_PROGRESSDIALOG_CID,
G_PROGRESSDIALOG_CONTRACTID,
GProgressListenerConstructor
},
{
G_PROGRESSDIALOG_CLASSNAME,
G_PROGRESSDIALOG_CID,
NS_TRANSFER_CONTRACTID,
GProgressListenerConstructor
},
#ifdef HAVE_NSIJSCONSOLESERVICE_H
{
G_JS_CONSOLESERVICE_CLASSNAME,
G_JSCONSOLESERVICE_CID,
NS_JSCONSOLESERVICE_CONTRACTID,
JSConsoleServiceConstructor
},
#endif
{
G_FILEPICKER_CLASSNAME,
G_FILEPICKER_CID,
G_FILEPICKER_CONTRACTID,
GFilePickerConstructor
},
{
NS_IHELPERAPPLAUNCHERDLG_CLASSNAME,
G_CONTENTHANDLER_CID,
NS_IHELPERAPPLAUNCHERDLG_CONTRACTID,
GContentHandlerConstructor
},
#ifndef XPCOM_GLUE
{
G_EXTERNALPROTOCOLSERVICE_CLASSNAME,
G_EXTERNALPROTOCOLSERVICE_CID,
NS_EXTERNALPROTOCOLSERVICE_CONTRACTID,
GExternalProtocolServiceConstructor
},
#endif
{
GALEON_GLOBALHISTORY_CLASSNAME,
GALEON_GLOBALHISTORY_CID,
NS_GLOBALHISTORY2_CONTRACTID,
MozGlobalHistoryConstructor
},
{
G_PRINTINGPROMPTSERVICE_CLASSNAME,
G_PRINTINGPROMPTSERVICE_CID,
G_PRINTINGPROMPTSERVICE_CONTRACTID,
GPrintingPromptServiceConstructor
},
{
G_SIDEBAR_CLASSNAME,
G_SIDEBAR_CID,
NS_SIDEBAR_CONTRACTID,
GSidebarProxyConstructor,
RegisterSidebar,
nsnull, // No unregister func
nsnull, // No factory destructor
NS_CI_INTERFACE_GETTER_NAME(GSidebarProxy),
nsnull, // No language helper
&NS_CLASSINFO_NAME(GSidebarProxy),
nsIClassInfo::DOM_OBJECT
},
{
G_COOKIEPROMPTSERVICE_CLASSNAME,
G_COOKIEPROMPTSERVICE_CID,
G_COOKIEPROMPTSERVICE_CONTRACTID,
GCookiePromptServiceConstructor
},
#ifdef HAVE_MOZILLA_PSM
#ifdef HAVE_NSIBADCERTLISTENER_H
{
GTK_NSSDIALOGS_CLASSNAME,
GTK_NSSDIALOGS_CID,
NS_BADCERTLISTENER_CONTRACTID,
GtkNSSDialogsConstructor
},
#endif
{
GTK_NSSDIALOGS_CLASSNAME,
GTK_NSSDIALOGS_CID,
NS_CERTIFICATEDIALOGS_CONTRACTID,
GtkNSSDialogsConstructor
},
{
GTK_NSSCLIENTAUTHDIALOGS_CLASSNAME,
GTK_NSSCLIENTAUTHDIALOGS_CID,
NS_CLIENTAUTHDIALOGS_CONTRACTID,
GtkNSSClientAuthDialogsConstructor
},
{
GTK_NSSKEYPAIRDIALOGS_CLASSNAME,
GTK_NSSKEYPAIRDIALOGS_CID,
NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID,
GtkNSSKeyPairDialogsConstructor
},
{
GTK_NSSSECURITYWARNINGDIALOGS_CLASSNAME,
GTK_NSSSECURITYWARNINGDIALOGS_CID,
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
GtkNSSSecurityWarningDialogsConstructor
},
#endif
#ifdef HAVE_NSSTRING_INTERNAL
{
G_ABOUT_MYPORTAL_CLASSNAME,
G_MYPORTAL_PROTOCOL_CID,
G_ABOUT_MYPORTAL_CONTRACTID,
GMyportalProtocolHandlerConstructor
},
{
G_MYPORTAL_HANDLER_CLASSNAME,
G_MYPORTAL_PROTOCOL_CID,
G_MYPORTAL_HANDLER_CONTRACTID,
GMyportalProtocolHandlerConstructor
},
{
GALEON_ABOUT_TOPHER_CLASSNAME,
GALEON_ABOUT_MODULE_CID,
GALEON_ABOUT_TOPHER_CONTRACTID,
GaleonAboutModuleConstructor
},
{
GALEON_ABOUT_NETERROR_CLASSNAME,
GALEON_ABOUT_MODULE_CID,
GALEON_ABOUT_NETERROR_CONTRACTID,
GaleonAboutModuleConstructor
},
#endif
{
EPHY_PROMPT_SERVICE_CLASSNAME,
EPHY_PROMPT_SERVICE_IID,
"@mozilla.org/embedcomp/prompt-service;1",
EphyPromptServiceConstructor
},
#ifdef HAVE_NSINONBLOCKINGALERTSERVICE_H
{
EPHY_PROMPT_SERVICE_CLASSNAME,
EPHY_PROMPT_SERVICE_IID,
"@mozilla.org/embedcomp/nbalert-service;1",
EphyPromptServiceConstructor
},
#endif /* HAVE_NSINONBLOCKINGALERTSERVICE_H */
};
#define NS_MSGCONTENTPOLICY_CONTRACTID "@mozilla.org/messenger/content-policy;1"
static nsresult
remove_thunderbird_contentpolicy()
{
nsCOMPtr<nsICategoryManager> cm;
cm = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
cm->DeleteCategoryEntry("content-policy",
NS_MSGCONTENTPOLICY_CONTRACTID, PR_TRUE);
return NS_OK;
}
gboolean
mozilla_register_components (void)
{
gboolean ret = TRUE;
nsresult rv;
nsCOMPtr<nsIComponentRegistrar> cr;
rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIComponentManager> cm;
NS_GetComponentManager (getter_AddRefs (cm));
NS_ENSURE_TRUE (cm, FALSE);
for (guint i = 0; i < G_N_ELEMENTS (sAppComps); i++)
{
nsCOMPtr<nsIGenericFactory> componentFactory;
componentFactory = do_CreateInstance(NS_GENERICFACTORY_CONTRACTID);
if(!componentFactory)
{
g_warning ("Failed to create a generic factory for %s\n", sAppComps[i].mDescription);
ret = FALSE;
continue;
}
rv = componentFactory->SetComponentInfo(&(sAppComps[i]));
if (NS_FAILED(rv))
{
g_warning ("Failed to make a factory for %s\n", sAppComps[i].mDescription);
ret = FALSE;
continue; // don't abort registering other components
}
rv = cr->RegisterFactory(sAppComps[i].mCID,
sAppComps[i].mDescription,
sAppComps[i].mContractID,
componentFactory);
if (NS_FAILED(rv))
{
g_warning ("Failed to register %s\n", sAppComps[i].mDescription);
ret = FALSE;
}
if (sAppComps[i].mRegisterSelfProc)
{
rv = sAppComps[i].mRegisterSelfProc (cm, nsnull, nsnull, nsnull, &sAppComps[i]);
if (NS_FAILED (rv))
{
g_warning ("Failed to register-self for %s\n", sAppComps[i].mDescription);
ret = FALSE;
}
}
}
// Thunderbird includes a fascist content policy - we don't need it
remove_thunderbird_contentpolicy ();
return ret;
}
|