本文整理汇总了C++中nsIID类的典型用法代码示例。如果您正苦于以下问题:C++ nsIID类的具体用法?C++ nsIID怎么用?C++ nsIID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsIID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
nsIncrementalDownload::GetInterface(const nsIID &iid, void **result)
{
if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
NS_ADDREF_THIS();
*result = static_cast<nsIChannelEventSink *>(this);
return NS_OK;
}
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(mObserver);
if (ir)
return ir->GetInterface(iid, result);
return NS_ERROR_NO_INTERFACE;
}
示例2: if
/*static*/ nsresult
PyG_Base::CreateNew(PyObject *pPyInstance, const nsIID &iid, void **ppResult)
{
NS_PRECONDITION(ppResult && *ppResult==NULL, "NULL or uninitialized pointer");
if (ppResult==nsnull)
return NS_ERROR_NULL_POINTER;
PyG_Base *ret;
// Hack for few extra gateways we support.
if (iid.Equals(NS_GET_IID(nsIModule)))
ret = MakePyG_nsIModule(pPyInstance);
else if (iid.Equals(NS_GET_IID(nsIComponentLoader)))
ret = MakePyG_nsIComponentLoader(pPyInstance);
else if (iid.Equals(NS_GET_IID(nsIInputStream)))
ret = MakePyG_nsIInputStream(pPyInstance);
else
ret = new PyXPCOM_XPTStub(pPyInstance, iid);
if (ret==nsnull)
return NS_ERROR_OUT_OF_MEMORY;
ret->AddRef(); // The first reference for the caller.
*ppResult = ret->ThisAsIID(iid);
NS_ABORT_IF_FALSE(*ppResult != NULL, "ThisAsIID() gave NULL, but we know it supports it!");
return *ppResult ? NS_OK : NS_ERROR_FAILURE;
}
示例3:
nsresult
IFoo::QueryInterface( const nsIID& aIID, void** aResult )
{
total_queries_++;
nsISupports* rawPtr = 0;
nsresult status = NS_OK;
if ( aIID.Equals(NS_GET_IID(IFoo)) )
rawPtr = this;
else
{
nsID iid_of_ISupports = NS_ISUPPORTS_IID;
if ( aIID.Equals(iid_of_ISupports) )
rawPtr = static_cast<nsISupports*>(this);
else
status = NS_ERROR_NO_INTERFACE;
}
NS_IF_ADDREF(rawPtr);
*aResult = rawPtr;
return status;
}
示例4:
NS_IMETHODIMP
nsBaseCommandController::GetInterface(const nsIID & aIID, void * *result)
{
NS_ENSURE_ARG_POINTER(result);
if (NS_SUCCEEDED(QueryInterface(aIID, result)))
return NS_OK;
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable)))
{
if (mCommandTable)
return mCommandTable->QueryInterface(aIID, result);
return NS_ERROR_NOT_INITIALIZED;
}
return NS_NOINTERFACE;
}
示例5: GetInterface
// NS_INTERFACE_MAP_ENTRY(nsITooltipTextProvider) // de: added 7/26/01
NS_INTERFACE_MAP_END
//*****************************************************************************
// CBrowserImpl::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
if(aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mWebBrowser)
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
示例6: QueryInterface
NS_INTERFACE_MAP_END
////////////////////////////////////////////////////////////////////////////////
/* void getInterface (in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result); */
NS_IMETHODIMP
BrowserWindow::GetInterface(const nsIID & aIID, void * *aInstancePtr)
{
if ( aIID.Equals( NS_GET_IID( nsIDOMWindow ) ) ) {
if ( webBrowser ) {
return webBrowser->GetContentDOMWindow( ( nsIDOMWindow** )aInstancePtr );
};
return NS_ERROR_NOT_INITIALIZED;
};
return QueryInterface( aIID, aInstancePtr );
}
示例7:
NS_IMETHODIMP
PipUIContext::GetInterface(const nsIID& uuid, void** result)
{
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
if (!NS_IsMainThread()) {
NS_ERROR("PipUIContext::GetInterface called off the main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
if (!uuid.Equals(NS_GET_IID(nsIPrompt)))
return NS_ERROR_NO_INTERFACE;
nsIPrompt* prompt = nullptr;
nsresult rv = nsNSSComponent::GetNewPrompter(&prompt);
*result = prompt;
return rv;
}
示例8: GetInterface
NS_INTERFACE_MAP_END
///////////////////////////////////////////////////////////////////////////////
// nsIInterfaceRequestor
NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & aIID, void * *result)
{
*result = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mOwner && mOwner->mWebBrowser)
{
return mOwner->mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) result);
}
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, result);
}
示例9: CSecurityContext
// Create the CSecurityContext object for creating object, invoking method,
// getting/setting field in JNI with security context.
NS_METHOD
CSecurityContext::Create(nsISupports* outer,
const char* lpszURL,PRBool isAllPermission,
const nsIID& aIID, void* *aInstancePtr)
{
/* If this is an aggregated object creation (i.e. outer exists)
then we expect to return the special object Internal, which
provides the nondelegating functions */
if (outer && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE; // XXX right error?
CSecurityContext* context = new CSecurityContext(outer, lpszURL, isAllPermission);
if (context == NULL)
return NS_ERROR_OUT_OF_MEMORY;
context->AddRef();
*aInstancePtr = (outer != NULL)
?(void *)context->GetInner()
:(void *)context;
return NS_OK;
}
示例10:
NS_IMETHODIMP
nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult) {
NS_ENSURE_ARG_POINTER(aResult);
if (NS_SUCCEEDED(QueryInterface(aIID, aResult))) {
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
if (mCommandTable) {
*aResult =
do_AddRef(static_cast<nsIControllerCommandTable*>(mCommandTable))
.take();
return NS_OK;
}
return NS_ERROR_NOT_INITIALIZED;
}
return NS_NOINTERFACE;
}
示例11: GetInterface
NS_INTERFACE_MAP_END
//*****************************************************************************
// WebBrowserChrome::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
NS_ENSURE_ARG_POINTER(aInstancePtr);
*aInstancePtr = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mWebBrowser)
{
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
}
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, aInstancePtr);
}
示例12: lock
nsresult
NativeToJavaProxyMap::Find(JNIEnv* env, nsISupports* aNativeObject,
const nsIID& aIID, jobject* aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (!aResult)
return NS_ERROR_FAILURE;
nsAutoLock lock(gJavaXPCOMLock);
*aResult = nsnull;
Entry* e = static_cast<Entry*>(PL_DHashTableOperate(mHashTable,
aNativeObject,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_FREE(e))
return NS_OK;
ProxyList* item = e->list;
while (item != nsnull && *aResult == nsnull) {
if (item->iid.Equals(aIID)) {
jobject referentObj = env->CallObjectMethod(item->javaObject,
getReferentMID);
if (!env->IsSameObject(referentObj, NULL)) {
*aResult = referentObj;
#ifdef DEBUG_JAVAXPCOM
char* iid_str = aIID.ToString();
LOG(("< NativeToJavaProxyMap (Java=%08x | XPCOM=%08x | IID=%s)\n",
(PRUint32) env->CallStaticIntMethod(systemClass, hashCodeMID,
*aResult),
(PRUint32) aNativeObject, iid_str));
NS_Free(iid_str);
#endif
}
}
item = item->next;
}
return NS_OK;
}
示例13: GetInterface
NS_INTERFACE_MAP_END
//*****************************************************************************
// nsChromeTreeOwner::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
{
NS_ENSURE_ARG_POINTER(aSink);
if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow2))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->GetInterface(aIID, aSink);
}
if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
NS_ENSURE_STATE(mXULWindow);
return mXULWindow->QueryInterface(aIID, aSink);
}
return QueryInterface(aIID, aSink);
}
示例14: SetComplexValue
NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID & aType, nsISupports *aValue)
{
ENSURE_MAIN_PROCESS("Cannot SetComplexValue from content process:", aPrefName);
NS_ENSURE_ARG(aPrefName);
nsresult rv = NS_NOINTERFACE;
// also check nsILocalFile, for backwards compatibility
if (aType.Equals(NS_GET_IID(nsIFile)) || aType.Equals(NS_GET_IID(nsILocalFile))) {
nsCOMPtr<nsIFile> file = do_QueryInterface(aValue);
if (!file)
return NS_NOINTERFACE;
nsAutoCString descriptorString;
rv = file->GetPersistentDescriptor(descriptorString);
if (NS_SUCCEEDED(rv)) {
rv = SetCharPrefInternal(aPrefName, descriptorString.get());
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
nsCOMPtr<nsIRelativeFilePref> relFilePref = do_QueryInterface(aValue);
if (!relFilePref)
return NS_NOINTERFACE;
nsCOMPtr<nsIFile> file;
relFilePref->GetFile(getter_AddRefs(file));
if (!file)
return NS_NOINTERFACE;
nsAutoCString relativeToKey;
(void) relFilePref->GetRelativeToKey(relativeToKey);
nsCOMPtr<nsIFile> relativeToFile;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(relativeToKey.get(), NS_GET_IID(nsIFile), getter_AddRefs(relativeToFile));
if (NS_FAILED(rv))
return rv;
nsAutoCString relDescriptor;
rv = file->GetRelativeDescriptor(relativeToFile, relDescriptor);
if (NS_FAILED(rv))
return rv;
nsAutoCString descriptorString;
descriptorString.Append('[');
descriptorString.Append(relativeToKey);
descriptorString.Append(']');
descriptorString.Append(relDescriptor);
return SetCharPrefInternal(aPrefName, descriptorString.get());
}
if (aType.Equals(NS_GET_IID(nsISupportsString))) {
nsCOMPtr<nsISupportsString> theString = do_QueryInterface(aValue);
if (theString) {
nsString wideString;
rv = theString->GetData(wideString);
if (NS_SUCCEEDED(rv)) {
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
nsCOMPtr<nsIPrefLocalizedString> theString = do_QueryInterface(aValue);
if (theString) {
nsXPIDLString wideString;
rv = theString->GetData(getter_Copies(wideString));
if (NS_SUCCEEDED(rv)) {
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
}
NS_WARNING("nsPrefBranch::SetComplexValue - Unsupported interface type");
return NS_NOINTERFACE;
}
示例15: GetComplexValue
NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID & aType, void **_retval)
{
NS_ENSURE_ARG(aPrefName);
nsresult rv;
nsXPIDLCString utf8String;
// we have to do this one first because it's different than all the rest
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
nsCOMPtr<nsIPrefLocalizedString> theString(do_CreateInstance(NS_PREFLOCALIZEDSTRING_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
const char *pref = getPrefName(aPrefName);
bool bNeedDefault = false;
if (mIsDefault) {
bNeedDefault = true;
} else {
// if there is no user (or locked) value
if (!PREF_HasUserPref(pref) && !PREF_PrefIsLocked(pref)) {
bNeedDefault = true;
}
}
// if we need to fetch the default value, do that instead, otherwise use the
// value we pulled in at the top of this function
if (bNeedDefault) {
nsXPIDLString utf16String;
rv = GetDefaultFromPropertiesFile(pref, getter_Copies(utf16String));
if (NS_SUCCEEDED(rv)) {
theString->SetData(utf16String.get());
}
} else {
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
theString->SetData(NS_ConvertUTF8toUTF16(utf8String).get());
}
}
if (NS_SUCCEEDED(rv)) {
theString.forget(reinterpret_cast<nsIPrefLocalizedString**>(_retval));
}
return rv;
}
// if we can't get the pref, there's no point in being here
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_FAILED(rv)) {
return rv;
}
// also check nsILocalFile, for backwards compatibility
if (aType.Equals(NS_GET_IID(nsIFile)) || aType.Equals(NS_GET_IID(nsILocalFile))) {
if (GetContentChild()) {
NS_ERROR("cannot get nsIFile pref from content process");
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
rv = file->SetPersistentDescriptor(utf8String);
if (NS_SUCCEEDED(rv)) {
file.forget(reinterpret_cast<nsIFile**>(_retval));
return NS_OK;
}
}
return rv;
}
if (aType.Equals(NS_GET_IID(nsIRelativeFilePref))) {
if (GetContentChild()) {
NS_ERROR("cannot get nsIRelativeFilePref from content process");
return NS_ERROR_NOT_AVAILABLE;
}
nsACString::const_iterator keyBegin, strEnd;
utf8String.BeginReading(keyBegin);
utf8String.EndReading(strEnd);
// The pref has the format: [fromKey]a/b/c
if (*keyBegin++ != '[')
return NS_ERROR_FAILURE;
nsACString::const_iterator keyEnd(keyBegin);
if (!FindCharInReadable(']', keyEnd, strEnd))
return NS_ERROR_FAILURE;
nsAutoCString key(Substring(keyBegin, keyEnd));
nsCOMPtr<nsIFile> fromFile;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = directoryService->Get(key.get(), NS_GET_IID(nsIFile), getter_AddRefs(fromFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIFile> theFile;
rv = NS_NewNativeLocalFile(EmptyCString(), true, getter_AddRefs(theFile));
if (NS_FAILED(rv))
//.........这里部分代码省略.........