1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla XForms support.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
23 * Brian Ryner <bryner@brianryner.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsIGenericFactory.h"
40 #include "nsXFormsElementFactory.h"
41 #include "nsXFormsUtilityService.h"
42 #include "nsXFormsAtoms.h"
43 #include "nsXFormsModelElement.h"
44 #include "nsXFormsUtils.h"
45 #include "nsICategoryManager.h"
46 #include "nsIServiceManager.h"
47 #include "nsIClassInfoImpl.h"
48 #include "nsXFormsXPathFunctions.h"
49 #include "nsServiceManagerUtils.h"
51 // bb0d9c8b-3096-4b66-92a0-6c1ddf80e65f
52 #define NS_XFORMSUTILITYSERVICE_CID \
53 { 0xbb0d9c8b, 0x3096, 0x4b66, { 0x92, 0xa0, 0x6c, 0x1d, 0xdf, 0x80, 0xe6, 0x5f }}
55 #define NS_XFORMSUTILITYSERVICE_CONTRACTID \
56 "@mozilla.org/xforms-utility-service;1"
58 #define XFORMSXPATHFUNCTIONS_CID \
59 { 0x8edc8cf1, 0x69a3, 0x11d9, { 0x97, 0x91, 0x00, 0x0a, 0x95, 0xdc, 0x23, 0x4c } }
60 #define XFORMSXPATHFUNCTIONS_CONTRACTID \
61 "@mozilla.org/xforms-xpath-functions;1"
63 NS_GENERIC_FACTORY_CONSTRUCTOR(nsXFormsElementFactory
)
64 NS_GENERIC_FACTORY_CONSTRUCTOR(nsXFormsUtilityService
)
65 NS_GENERIC_FACTORY_CONSTRUCTOR(nsXFormsXPathFunctions
)
66 NS_DECL_CLASSINFO(nsXFormsXPathFunctions
)
69 RegisterXFormsModule(nsIComponentManager
*aCompMgr
,
71 const char *aRegistryLocation
,
72 const char *aComponentType
,
73 const nsModuleComponentInfo
*aInfo
)
76 printf("XFORMS Module: Registering\n");
79 nsCOMPtr
<nsICategoryManager
> catman
=
80 do_GetService(NS_CATEGORYMANAGER_CONTRACTID
);
83 return NS_ERROR_FAILURE
;
87 catman
->AddCategoryEntry(NS_DOMNS_FEATURE_PREFIX
"org.w3c.xforms.dom",
89 NS_XTF_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_NAMESPACE_XFORMS
,
90 PR_TRUE
, PR_TRUE
, getter_Copies(previous
));
91 NS_ENSURE_SUCCESS(rv
, rv
);
94 catman
->AddCategoryEntry(NS_DOMNS_FEATURE_PREFIX NS_XFORMS_INSTANCE_OWNER
,
96 NS_XTF_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_NAMESPACE_XFORMS
,
97 PR_TRUE
, PR_TRUE
, getter_Copies(previous
));
98 NS_ENSURE_SUCCESS(rv
, rv
);
100 return catman
->AddCategoryEntry("agent-style-sheets",
102 "chrome://xforms/content/xforms.css",
103 PR_TRUE
, PR_TRUE
, getter_Copies(previous
));
107 UnregisterXFormsModule(nsIComponentManager
*aCompMgr
,
109 const char *aRegistryLocation
,
110 const nsModuleComponentInfo
*aInfo
)
113 printf("XFORMS Module: Unregistering\n");
116 nsXFormsUtils::Shutdown();
118 nsCOMPtr
<nsICategoryManager
> catman
=
119 do_GetService(NS_CATEGORYMANAGER_CONTRACTID
);
122 return NS_ERROR_FAILURE
;
124 catman
->DeleteCategoryEntry(NS_DOMNS_FEATURE_PREFIX
"org.w3c.xforms.dom",
127 catman
->DeleteCategoryEntry(NS_DOMNS_FEATURE_PREFIX NS_XFORMS_INSTANCE_OWNER
,
130 return catman
->DeleteCategoryEntry("agent-style-sheets",
131 "xforms stylesheet", PR_TRUE
);
134 static const nsModuleComponentInfo components
[] = {
135 { "XForms element factory",
136 NS_XFORMSELEMENTFACTORY_CID
,
137 NS_XTF_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_NAMESPACE_XFORMS
,
138 nsXFormsElementFactoryConstructor
,
139 RegisterXFormsModule
,
140 UnregisterXFormsModule
142 { "XForms Utility Service",
143 NS_XFORMSUTILITYSERVICE_CID
,
144 NS_XFORMSUTILITYSERVICE_CONTRACTID
,
145 nsXFormsUtilityServiceConstructor
147 { "XForms XPath extension functions",
148 XFORMSXPATHFUNCTIONS_CID
,
149 XFORMSXPATHFUNCTIONS_CONTRACTID
,
150 nsXFormsXPathFunctionsConstructor
,
151 nsnull
, nsnull
, nsnull
,
152 NS_CI_INTERFACE_GETTER_NAME(nsXFormsXPathFunctions
),
154 &NS_CLASSINFO_NAME(nsXFormsXPathFunctions
)
158 PR_STATIC_CALLBACK(nsresult
)
159 XFormsModuleCtor(nsIModule
* aSelf
)
161 nsXFormsAtoms::InitAtoms();
162 nsXFormsUtils::Init();
163 nsXFormsModelElement::Startup();
167 NS_IMPL_NSGETMODULE_WITH_CTOR(xforms
, components
, XFormsModuleCtor
)