static NS_METHOD IconDecoderUnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; catMan->DeleteCategoryEntry("Gecko-Content-Viewers", gIconMimeType, PR_TRUE); return NS_OK; }
static NS_METHOD RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, const char *location, const char *type, const nsModuleComponentInfo *info) { nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); return catMan->AddCategoryEntry("command-line-handler", "m-compose", NS_MSGCOMPOSESTARTUPHANDLER_CONTRACTID, PR_TRUE, PR_TRUE, nsnull); }
static NS_METHOD UnregisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, const char *location, const nsModuleComponentInfo *info) { nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); catMan->DeleteCategoryEntry("command-line-handler", "m-compose", PR_TRUE); return NS_OK; }
static NS_METHOD ImageUnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const nsModuleComponentInfo *info) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; for (unsigned i = 0; i < sizeof(gImageMimeTypes)/sizeof(*gImageMimeTypes); i++) catMan->DeleteCategoryEntry("Gecko-Content-Viewers", gImageMimeTypes[i], PR_TRUE); return NS_OK; }
static NS_METHOD IconDecoderRegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; catMan->AddCategoryEntry("Gecko-Content-Viewers", gIconMimeType, "@mozilla.org/content/document-loader-factory;1", PR_TRUE, PR_TRUE, nsnull); return NS_OK; }
NS_METHOD nsSuiteDirectoryProvider::Unregister(nsIComponentManager* aCompMgr, nsIFile* aPath, const char *aLoaderStr, const nsModuleComponentInfo *aInfo) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; return catMan->DeleteCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, "suite-directory-provider", PR_TRUE); }
static NS_METHOD UnregisterDirectoryProvider(nsIComponentManager* aCompMgr, nsIFile* aPath, const char *aLoaderStr, const nsModuleComponentInfo *aInfo) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); if (!catMan) return NS_ERROR_FAILURE; rv = catMan->DeleteCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, "device-directory-provider", PR_TRUE); return rv; }
static NS_METHOD RegisterCommandLineHandlers(nsIComponentManager* compMgr, nsIFile* path, const char *location, const char *type, const nsModuleComponentInfo *info) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); rv = catMan->AddCategoryEntry("command-line-handler", "m-layoutdebug", "@mozilla.org/commandlinehandler/general-startup;1?type=layoutdebug", PR_TRUE, PR_TRUE, nsnull); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; return NS_OK; }
static NS_METHOD ImageRegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType, const nsModuleComponentInfo *info) { nsresult rv; nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; for (unsigned i = 0; i < sizeof(gImageMimeTypes)/sizeof(*gImageMimeTypes); i++) { catMan->AddCategoryEntry("Gecko-Content-Viewers", gImageMimeTypes[i], "@mozilla.org/content/document-loader-factory;1", PR_TRUE, PR_TRUE, nsnull); } catMan->AddCategoryEntry("content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1", PR_TRUE, PR_TRUE, nsnull); return NS_OK; }
NS_IMETHODIMP nsDirectoryViewerFactory::CreateInstance(const char *aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult) { nsresult rv; // OK - are we going to be using the html listing or not? nsCOMPtr<nsIPrefBranch> prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; PRBool useXUL = PR_FALSE; PRBool viewSource = (PL_strstr(aContentType,"view-source") != 0); #ifdef MOZ_RDF PRInt32 dirPref; rv = prefSrv->GetIntPref("network.dir.format", &dirPref); if (NS_SUCCEEDED(rv) && dirPref == FORMAT_XUL) { useXUL = PR_TRUE; } if ((NS_FAILED(rv) || useXUL) && !viewSource) { // ... and setup the original channel's content type (void)aChannel->SetContentType(NS_LITERAL_CSTRING("application/vnd.mozilla.xul+xml")); // This is where we shunt the HTTP/Index stream into our datasource, // and open the directory viewer XUL file as the content stream to // load in its place. // Create a dummy loader that will load a stub XUL document. nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; nsXPIDLCString contractID; rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "application/vnd.mozilla.xul+xml", getter_Copies(contractID)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID, &rv)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIURI> uri; rv = NS_NewURI(getter_AddRefs(uri), "chrome://communicator/content/directory/directory.xul"); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), uri, nsnull, aLoadGroup); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIStreamListener> listener; rv = factory->CreateInstance(aCommand, channel, aLoadGroup, "application/vnd.mozilla.xul+xml", aContainer, aExtraInfo, getter_AddRefs(listener), aDocViewerResult); if (NS_FAILED(rv)) return rv; rv = channel->AsyncOpen(listener, nsnull); if (NS_FAILED(rv)) return rv; // Create an HTTPIndex object so that we can stuff it into the script context nsCOMPtr<nsIURI> baseuri; rv = aChannel->GetURI(getter_AddRefs(baseuri)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(aContainer,&rv); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIHTTPIndex> httpindex; rv = nsHTTPIndex::Create(baseuri, requestor, getter_AddRefs(httpindex)); if (NS_FAILED(rv)) return rv; // Now shanghai the stream into our http-index parsing datasource // wrapper beastie. listener = do_QueryInterface(httpindex,&rv); *aDocListenerResult = listener.get(); NS_ADDREF(*aDocListenerResult); return NS_OK; } #endif // setup the original channel's content type (void)aChannel->SetContentType(NS_LITERAL_CSTRING("application/xhtml+xml")); // Otherwise, lets use the html listing nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; nsXPIDLCString contractID; rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "application/xhtml+xml", getter_Copies(contractID)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID, &rv)); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIStreamListener> listener; if (viewSource) { rv = factory->CreateInstance("view-source", aChannel, aLoadGroup, "application/xhtml+xml; x-view-type=view-source", aContainer, aExtraInfo, getter_AddRefs(listener), aDocViewerResult); } else { rv = factory->CreateInstance("view", aChannel, aLoadGroup, "application/xhtml+xml", aContainer, aExtraInfo, getter_AddRefs(listener), aDocViewerResult); } if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIStreamConverterService> scs = do_GetService("@mozilla.org/streamConverters;1", &rv); if (NS_FAILED(rv)) return rv; rv = scs->AsyncConvertData("application/http-index-format", "text/html", listener, nsnull, aDocListenerResult); if (NS_FAILED(rv)) return rv; return NS_OK; }
nsresult nsGeolocationService::Init() { mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000); nsContentUtils::RegisterPrefCallback("geo.enabled", GeoEnabledChangedCallback, nsnull); GeoEnabledChangedCallback("geo.enabled", nsnull); if (sGeoEnabled == PR_FALSE) return NS_ERROR_FAILURE; nsCOMPtr<nsIGeolocationProvider> provider = do_GetService(NS_GEOLOCATION_PROVIDER_CONTRACTID); if (provider) mProviders.AppendObject(provider); // look up any providers that were registered via the category manager nsCOMPtr<nsICategoryManager> catMan(do_GetService("@mozilla.org/categorymanager;1")); if (!catMan) return NS_ERROR_FAILURE; // geolocation service can be enabled -> now register observer nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1"); if (!obs) return NS_ERROR_FAILURE; obs->AddObserver(this, "quit-application", false); nsCOMPtr<nsISimpleEnumerator> geoproviders; catMan->EnumerateCategory("geolocation-provider", getter_AddRefs(geoproviders)); if (geoproviders) { PRBool hasMore; while (NS_SUCCEEDED(geoproviders->HasMoreElements(&hasMore)) && hasMore) { nsCOMPtr<nsISupports> elem; geoproviders->GetNext(getter_AddRefs(elem)); nsCOMPtr<nsISupportsCString> elemString = do_QueryInterface(elem); nsCAutoString name; elemString->GetData(name); nsXPIDLCString spec; catMan->GetCategoryEntry("geolocation-provider", name.get(), getter_Copies(spec)); provider = do_GetService(spec); if (provider) mProviders.AppendObject(provider); } } // we should move these providers outside of this file! dft #ifdef WINCE_WINDOWS_MOBILE provider = new WinMobileLocationProvider(); if (provider) mProviders.AppendObject(provider); #endif #ifdef MOZ_PLATFORM_MAEMO provider = new MaemoLocationProvider(); if (provider) mProviders.AppendObject(provider); #endif return NS_OK; }
mozXMLTermStream::mozXMLTermStream() : mUTF8Buffer(""), mUTF8Offset(0), mMaxResizeHeight(0), mDOMWindow( nsnull ), #ifdef NO_WORKAROUND mDOMIFrameElement( nsnull ), mContext( nsnull ), mLoadGroup( nsnull ), mChannel( nsnull ), mStreamListener( nsnull ) #else // !NO_WORKAROUND mDOMHTMLDocument( nsnull ) #endif // !NO_WORKAROUND { } mozXMLTermStream::~mozXMLTermStream() { } // mozIXMLTermStream interface /** Open stream in specified frame, or in current frame if frameName is null * @param aDOMWindow parent window * @param frameName name of child frame in which to display stream, or null * to display in parent window * @param contentURL URL of stream content * @param contentType MIME type of stream content * @param maxResizeHeight maximum resize height (0=> do not resize) * @return NS_OK on success */ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindowInternal* aDOMWindow, const char* frameName, const char* contentURL, const char* contentType, PRInt32 maxResizeHeight) { nsresult result; XMLT_LOG(mozXMLTermStream::Open,20,("contentURL=%s, contentType=%s\n", contentURL, contentType)); mMaxResizeHeight = maxResizeHeight; if (frameName && *frameName) { // Open stream in named subframe of current frame XMLT_LOG(mozXMLTermStream::Open,22,("frameName=%s\n", frameName)); nsAutoString innerFrameName; innerFrameName.AssignASCII(frameName); // Get DOM IFRAME element nsCOMPtr<nsIDOMDocument> domDoc; result = aDOMWindow->GetDocument(getter_AddRefs(domDoc)); if (NS_FAILED(result) || !domDoc) return NS_ERROR_FAILURE; nsCOMPtr<nsIDOMHTMLDocument> domHTMLDoc = do_QueryInterface(domDoc); if (!domHTMLDoc) return NS_ERROR_FAILURE; nsCOMPtr<nsIDOMNodeList> nodeList; result = domHTMLDoc->GetElementsByName(innerFrameName, getter_AddRefs(nodeList)); if (NS_FAILED(result) || !nodeList) return NS_ERROR_FAILURE; PRUint32 count; nodeList->GetLength(&count); PR_ASSERT(count==1); nsCOMPtr<nsIDOMNode> domNode; result = nodeList->Item(0, getter_AddRefs(domNode)); if (NS_FAILED(result) || !domNode) return NS_ERROR_FAILURE; mDOMIFrameElement = do_QueryInterface(domNode); if (!mDOMIFrameElement) return NS_ERROR_FAILURE; // Ensure that it is indeed an IFRAME element nsAutoString tagName; result = mDOMIFrameElement->GetTagName(tagName); if (NS_FAILED(result)) return NS_ERROR_FAILURE; if (!tagName.LowerCaseEqualsLiteral("iframe")) return NS_ERROR_FAILURE; if (mMaxResizeHeight > 0) { // Set initial IFRAME size to be as wide as the window, but very short nsAutoString attWidth(NS_LITERAL_STRING("width")); nsAutoString valWidth(NS_LITERAL_STRING("100%")); mDOMIFrameElement->SetAttribute(attWidth,valWidth); nsAutoString attHeight(NS_LITERAL_STRING("height")); nsAutoString valHeight(NS_LITERAL_STRING("10")); mDOMIFrameElement->SetAttribute(attHeight,valHeight); } // Get inner DOM window by looking up the frames list nsCOMPtr<nsIDOMWindowInternal> innerDOMWindow; result = mozXMLTermUtils::GetInnerDOMWindow(aDOMWindow, innerFrameName, getter_AddRefs(innerDOMWindow)); if (NS_FAILED(result) || !innerDOMWindow) return NS_ERROR_FAILURE; mDOMWindow = innerDOMWindow; } else { // Open stream in current frame mDOMIFrameElement = nsnull; mDOMWindow = aDOMWindow; } // Get docshell for DOM window nsCOMPtr<nsIDocShell> docShell; result = mozXMLTermUtils::ConvertDOMWindowToDocShell(mDOMWindow, getter_AddRefs(docShell)); if (NS_FAILED(result) || !docShell) return NS_ERROR_FAILURE; #ifdef NO_WORKAROUND XMLT_WARNING("mozXMLTermStream::Open, NO_WORKAROUND, url=%s\n", contentURL); nsCOMPtr<nsIInputStream> inputStream = this; // Create a simple URI nsCOMPtr<nsIURI> uri = do_CreateInstance(kSimpleURICID, &result); if (NS_FAILED(result)) return result; result = uri->SetSpec(nsDependentCString(contentURL)); if (NS_FAILED(result)) return result; // Create a new load group result = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), nsnull); if (NS_FAILED(result)) return result; // Create an input stream channel result = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri, inputStream, nsDependentCString(contentType), EmptyCString()); if (NS_FAILED(result)) return result; // Set channel's load group result = mChannel->SetLoadGroup(mLoadGroup); if (NS_FAILED(result)) return result; // Create document loader for specified command and content type nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &result)); if (NS_FAILED(result)) return result; nsXPIDLCString contractID; result = catMan->GetCategoryEntry("Gecko-Content-Viewers", contentType, getter_Copies(contractID)); if (NS_FAILED(result)) return result; nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory; docLoaderFactory = do_GetService(contractID.get(), &result); if (NS_FAILED(result)) return result; nsCOMPtr<nsIContentViewerContainer> contViewContainer = do_QueryInterface(docShell); nsCOMPtr<nsIContentViewer> contentViewer; result = docLoaderFactory->CreateInstance("view", mChannel, mLoadGroup, contentType, contViewContainer, nsnull, getter_AddRefs(mStreamListener), getter_AddRefs(contentViewer) ); if (NS_FAILED(result)) return result; // Set container for content view result = contentViewer->SetContainer(contViewContainer); if (NS_FAILED(result)) return result; // Embed contentViewer in containing docShell result = contViewContainer->Embed(contentViewer, "view", nsnull); if (NS_FAILED(result)) return result; // Start request result = mStreamListener->OnStartRequest(mChannel, mContext); if (NS_FAILED(result)) return result; #else // !NO_WORKAROUND XMLT_WARNING("mozXMLTermStream::Open, WORKAROUND\n"); nsCOMPtr<nsIDOMDocument> innerDOMDoc; result = mDOMWindow->GetDocument(getter_AddRefs(innerDOMDoc)); XMLT_WARNING("mozXMLTermStream::Open,check1, 0x%x, 0x%x\n", result, (int) innerDOMDoc.get()); if (NS_FAILED(result) || !innerDOMDoc) return NS_ERROR_FAILURE; mDOMHTMLDocument = do_QueryInterface(innerDOMDoc); XMLT_WARNING("mozXMLTermStream::Open,check2, 0x%x\n", result); if (!mDOMHTMLDocument) return NS_ERROR_FAILURE; result = mDOMHTMLDocument->Open(); XMLT_WARNING("mozXMLTermStream::Open,check3, 0x%x\n", result); if (NS_FAILED(result)) return result; #endif // !NO_WORKAROUND XMLT_LOG(mozXMLTermStream::Open,21,("returning\n")); return NS_OK; }