ProbeManager::ProbeManager(const nsCID &aApplicationUID, const nsACString &aApplicationName) : mApplicationUID(aApplicationUID) , mApplicationName(aApplicationName) , mSessionHandle(0) , mRegistrationHandle(0) { #if defined(MOZ_LOGGING) char cidStr[NSID_LENGTH]; aApplicationUID.ToProvidedString(cidStr); LOG(("ProbeManager::Init for application %s, %s", aApplicationName.Data(), cidStr)); #endif }
NS_IMETHODIMP nsScriptSecurityManager::CanGetService(JSContext *cx, const nsCID &aCID) { if (nsContentUtils::IsCallerChrome()) { return NS_OK; } //-- Access denied, report an error nsAutoCString errorMsg("Permission denied to get service. CID="); char cidStr[NSID_LENGTH]; aCID.ToProvidedString(cidStr); errorMsg.Append(cidStr); SetPendingException(cx, errorMsg.get()); return NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED; }
NS_IMETHODIMP nsScriptSecurityManager::CanCreateInstance(JSContext *cx, const nsCID &aCID) { if (SubjectIsPrivileged()) { return NS_OK; } //-- Access denied, report an error nsAutoCString errorMsg("Permission denied to create instance of class. CID="); char cidStr[NSID_LENGTH]; aCID.ToProvidedString(cidStr); errorMsg.Append(cidStr); SetPendingException(cx, errorMsg.get()); return NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED; }
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr, const nsCID &aClass, const char *aClassName, const char *aContractID, nsIFactory **aFactory) { if (!aClass.Equals(kCLiveconnectCID)) { return NS_ERROR_FACTORY_NOT_LOADED; // XXX right error? } nsCLiveconnectFactory* factory = new nsCLiveconnectFactory(); if (factory == NULL) return NS_ERROR_OUT_OF_MEMORY; factory->AddRef(); *aFactory = factory; return NS_OK; }
/* The very first function called (Unless we are using nsIModule) */ extern "C" nsresult NSGetFactory(nsISupports * pProvider, const nsCID &aClass, const char * aClassName, const char * aProgID, nsIFactory **aFactory) { UNUSED(aClassName); UNUSED(aProgID); nsresult rv = NS_OK; if (aFactory == NULL){ fprintf(stderr, "Received a null pointer to pointer in NSGetFactory!\n"); return NS_ERROR_UNEXPECTED; } void* libjpinsp = NULL; if (LoadNSCore(&libjpinsp) != JD_OK) return NS_ERROR_FAILURE; if (libjpinsp != NULL && aClass.Equals(kPluginCID)) { JDSmartPtr<IFactory> spFactory; #ifdef NS6_ADAPTER JDSmartPtr<IPluginServiceProvider> spPluginSvcProvider(new CNS6Adapter_PluginServiceProvider(pProvider)); #else JDSmartPtr<IPluginServiceProvider> spPluginSvcProvider(new CNS7Adapter_PluginServiceProvider(pProvider)); #endif if (spPluginSvcProvider == NULL) return NS_ERROR_OUT_OF_MEMORY; JD_METHOD (*createPluginFactory)(ISupports* sm, IUnixService* us, IFactory* *res); createPluginFactory = (JD_METHOD (*)(ISupports*, IUnixService*, IFactory**)) dlsym(libjpinsp, "createPluginFactory"); if (createPluginFactory == NULL){ fprintf(stderr, "Can't find createPluginFactory symbol !\n"); return NS_ERROR_UNEXPECTED; } rv = createPluginFactory(spPluginSvcProvider, new CNSAdapter_NSPR, &spFactory); if (NS_SUCCEEDED(rv) && spFactory) { #ifdef NS6_ADAPTER *aFactory = new CNS6Adapter_JavaPluginFactory(spFactory); #else *aFactory = new CNS7Adapter_JavaPluginFactory(spFactory); #endif if (*aFactory == NULL) return NS_ERROR_OUT_OF_MEMORY; (*aFactory)->AddRef(); } } else { rv = NS_ERROR_NO_INTERFACE; } return rv; }
nsresult JPI_NSGetFactory(nsISupports * pProvider, const nsCID &aClass, const char * aClassName, const char * aProgID, nsIFactory **aFactory) { (void) aClassName; // defeat compiler "not used" warning. (void) aProgID; trace("JPI_NSGetFactory\n"); if (aFactory == NULL){ plugin_error("Received a null pointer to pointer in NSGetFactory!\n"); return NS_ERROR_UNEXPECTED; } if (aClass.Equals(kPluginCID)) { #ifdef __linux__ void *handle = 0; #else void *handle = dlopen("libnspr4.so", RTLD_LAZY); #endif if (!handle) { /* Navigator 4.0 or less */ in_oji_version = 0; *aFactory = new CJavaPluginFactory(); } else { TRACE("Detected Mozilla 5 or greater\n"); char factory5path[MAXPATHLEN]; in_oji_version = 1; // Initialize the 5.0 factory functions from libjavaplugin5.so char *home = getenv("HOME"); if (home == NULL) { plugin_error("Could not load 5.0 plugin. $HOME not set", PLUGIN_OJI_SO); return NS_ERROR_UNEXPECTED; } trace("$HOME for loading %s = %s\n", PLUGIN_OJI_SO, home); if ((strlen(home) + 100) > MAXPATHLEN) { plugin_error("Too long $HOME %s \n", home); return NS_ERROR_UNEXPECTED; } sprintf(factory5path, "%s/.netscape/java/lib/%s", home, PLUGIN_OJI_SO); if (tracing) trace("Loading Mozilla 5 plugin from: %s \n", factory5path); void *factory5_handle = dlopen(factory5path, RTLD_LAZY); if (!factory5_handle) { plugin_error("Could not load %s: linking error=%s\n", PLUGIN_OJI_SO, dlerror()); return NS_ERROR_UNEXPECTED; } CreateFactoryFnType create_factory_fn = (CreateFactoryFnType) (jlong) load_function(factory5_handle, "CreateOJIFactory"); *aFactory = (*create_factory_fn)(pProvider); } init_utils(); (*aFactory)->AddRef(); return NS_OK; } return NS_ERROR_NO_INTERFACE; }