void nsHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **cb) { NS_IF_ADDREF(*cb = mCallbacks); }
NS_IMETHODIMP nsBaseChannel::GetSecurityInfo(nsISupports **aSecurityInfo) { NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo); return NS_OK; }
/* readonly attribute nsIPerformanceStats process; */ NS_IMETHODIMP nsPerformanceSnapshot::GetProcessData(nsIPerformanceStats * *aProcess) { NS_IF_ADDREF(*aProcess = mProcessData); return NS_OK; }
NS_IMETHODIMP nsBaseChannel::GetURI(nsIURI **aURI) { NS_IF_ADDREF(*aURI = mURI); return NS_OK; }
NS_IMETHODIMP nsBaseChannel::GetLoadInfo(nsILoadInfo** aLoadInfo) { NS_IF_ADDREF(*aLoadInfo = mLoadInfo); return NS_OK; }
NS_IMETHODIMP nsExtProtocolChannel::GetLoadInfo(nsILoadInfo **aLoadInfo) { NS_IF_ADDREF(*aLoadInfo = mLoadInfo); return NS_OK; }
nsresult nsMsgQuickSearchDBView::GetFirstMessageHdrToDisplayInThread(nsIMsgThread *threadHdr, nsIMsgDBHdr **result) { uint32_t numChildren; nsresult rv = NS_OK; uint8_t minLevel = 0xff; threadHdr->GetNumChildren(&numChildren); nsMsgKey threadRootKey; nsCOMPtr<nsIMsgDBHdr> rootParent; int32_t rootIndex; threadHdr->GetRootHdr(&rootIndex, getter_AddRefs(rootParent)); if (rootParent) rootParent->GetMessageKey(&threadRootKey); else threadHdr->GetThreadKey(&threadRootKey); if ((int32_t) numChildren < 0) numChildren = 0; nsCOMPtr <nsIMsgDBHdr> retHdr; // iterate over thread, finding mgsHdr in view with the lowest level. for (uint32_t childIndex = 0; childIndex < numChildren; childIndex++) { nsCOMPtr <nsIMsgDBHdr> child; rv = threadHdr->GetChildHdrAt(childIndex, getter_AddRefs(child)); if (NS_SUCCEEDED(rv) && child) { nsMsgKey msgKey; child->GetMessageKey(&msgKey); // this works because we've already sorted m_keys by id. nsMsgViewIndex keyIndex = m_origKeys.BinaryIndexOf(msgKey); if (keyIndex != nsMsgViewIndex_None) { // this is the root, so it's the best we're going to do. if (msgKey == threadRootKey) { retHdr = child; break; } uint8_t level = 0; nsMsgKey parentId; child->GetThreadParent(&parentId); nsCOMPtr <nsIMsgDBHdr> parent; // count number of ancestors - that's our level while (parentId != nsMsgKey_None) { rv = m_db->GetMsgHdrForKey(parentId, getter_AddRefs(parent)); if (parent) { nsMsgKey saveParentId = parentId; parent->GetThreadParent(&parentId); // message is it's own parent - bad, let's break out of here. // Or we've got some circular ancestry. if (parentId == saveParentId || level > numChildren) break; level++; } else // if we can't find the parent, don't loop forever. break; } if (level < minLevel) { minLevel = level; retHdr = child; } } } } NS_IF_ADDREF(*result = retHdr); return NS_OK; }
nsresult nsEudoraEditor::GetEmbeddedObjects(nsIArray ** aNodeList) { NS_ENSURE_ARG_POINTER(aNodeList); // Check to see if we were already called if (m_EmbeddedObjectList != nullptr) { *aNodeList = m_EmbeddedObjectList; return NS_OK; } // Create array in m_EmbeddedObjectList nsresult rv; m_EmbeddedObjectList = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); // Return m_EmbeddedObjectList in aNodeList and increment ref count - caller // assumes that we incremented the ref count. NS_IF_ADDREF(*aNodeList = m_EmbeddedObjectList); // Create the embedded folder spec nsCOMPtr<nsIFile> embeddedFolderSpec; // Create the embedded image spec nsCOMPtr<nsIFile> embeddedImageSpec; // Fill in the details for the embedded folder spec - "Embedded" folder // inside of the mail folder. We don't bother to check to see if the embedded // folder exists, because it seems to me that would only save time in the // unexpected case where it doesn't exist. Keep in mind that we will be checking // for the existence of any embedded images anyway - if the folder doesn't // exist that check will fail. rv = m_pMailImportLocation->Clone(getter_AddRefs(embeddedFolderSpec)); NS_ENSURE_SUCCESS(rv, rv); embeddedFolderSpec->AppendNative(NS_LITERAL_CSTRING("Embedded")); // Look for the start of the last closing tag so that we only search for // valid "Embedded Content" lines. (In practice this is not super important, // but there were some proof of concept exploits at one point where "Embedded // Content" lines were faked in the body of messages). int32_t startLastClosingTag = m_body.RFind("</"); if (startLastClosingTag == kNotFound) startLastClosingTag = 0; bool foundEmbeddedContentLines = false; // Search for various translations of "Embedded Content" - as of this writing only // one that I know of, but then again I didn't realize that Eudora translators had // ever translated "Attachment Converted" as suggested by other Eudora importing code. for (int32_t i = 0; *sEudoraEmbeddedContentLines[i] != '\0'; i++) { // Search for "Embedded Content: " lines starting after last closing tag (if any) int32_t startEmbeddedContentLine = startLastClosingTag; int32_t lenEmbeddedContentTag = strlen(sEudoraEmbeddedContentLines[i]); while ((startEmbeddedContentLine = m_body.Find(sEudoraEmbeddedContentLines[i], true, startEmbeddedContentLine+1)) != kNotFound) { // Found this translation of "Embedded Content" - remember that so that we don't // bother looking for any other translations. foundEmbeddedContentLines = true; // Extract the file name from the embedded content line int32_t startFileName = startEmbeddedContentLine + lenEmbeddedContentTag; int32_t endFileName = m_body.Find(":", false, startFileName); // Create the file spec for the embedded image embeddedFolderSpec->Clone(getter_AddRefs(embeddedImageSpec)); embeddedImageSpec->Append(Substring(m_body, startFileName, endFileName - startFileName)); // Verify that the embedded image spec exists and is a file bool isFile = false; bool exists = false; if (NS_FAILED(embeddedImageSpec->Exists(&exists)) || NS_FAILED(embeddedImageSpec->IsFile(&isFile))) continue; if (!exists || !isFile) continue; // Extract CID hash from the embedded content line int32_t cidHashValue; int32_t startCIDHash = m_body.Find(",", false, endFileName); if (startCIDHash != kNotFound) { startCIDHash++; int32_t endCIDHash = m_body.Find(",", false, startCIDHash); if (endCIDHash != kNotFound) { nsString cidHash; cidHash.Assign(Substring(m_body, startCIDHash, endCIDHash - startCIDHash)); if (!cidHash.IsEmpty()) { // Convert CID hash string to numeric value nsresult aErrorCode; cidHashValue = cidHash.ToInteger(&aErrorCode, 16); } } } // Get the URL for the embedded image nsCString embeddedImageURL; rv = NS_GetURLSpecFromFile(embeddedImageSpec, embeddedImageURL); NS_ENSURE_SUCCESS(rv, rv); NS_ConvertASCIItoUTF16 srcUrl(embeddedImageURL); nsString cid; // We're going to remember the original cid in the image element, // which the send code will retrieve as the kMozCIDAttrName property. GetEmbeddedImageCID(cidHashValue, srcUrl, cid); nsCOMPtr<nsIURI> embeddedFileURI; NS_NewFileURI(getter_AddRefs(embeddedFileURI), embeddedImageSpec); // Create the embedded image node nsImportEmbeddedImageData *imageData = new nsImportEmbeddedImageData(embeddedFileURI, NS_LossyConvertUTF16toASCII(cid)); // Append the embedded image node to the list m_EmbeddedObjectList->AppendElement(imageData, false); int32_t endEmbeddedContentLine = m_body.Find("\r\n", true, startEmbeddedContentLine+1); if (endEmbeddedContentLine != kNotFound) { // We recognized the "Embedded Content" line correctly and found the associated image. // Remove the Eudora specific line about it now. m_body.Cut(startEmbeddedContentLine, endEmbeddedContentLine - startEmbeddedContentLine + 2); // Backup by one to correct where we start looking for the next line startEmbeddedContentLine--; } } // Assume at most one translation for "Embedded Content: " in a given message if (foundEmbeddedContentLines) break; } return NS_OK; }
/* attribute nsILocalHandlerApp app; */ NS_IMETHODIMP JumpListShortcut::GetApp(nsILocalHandlerApp **aApp) { NS_IF_ADDREF(*aApp = mHandlerApp); return NS_OK; }
nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal) { // Copied from nsAppFileLocationProvider (more or less) nsresult rv; nsCOMPtr<nsIFile> localDir; #if defined(XP_MACOSX) FSRef fsRef; OSType folderType; if (aLocal) { folderType = kCachedDataFolderType; } else { #ifdef MOZ_THUNDERBIRD folderType = kDomainLibraryFolderType; #else folderType = kApplicationSupportFolderType; #endif } OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); NS_ENSURE_FALSE(err, NS_ERROR_FAILURE); rv = NS_NewNativeLocalFile(EmptyCString(), true, getter_AddRefs(localDir)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsILocalFileMac> dirFileMac = do_QueryInterface(localDir); NS_ENSURE_TRUE(dirFileMac, NS_ERROR_UNEXPECTED); rv = dirFileMac->InitWithFSRef(&fsRef); NS_ENSURE_SUCCESS(rv, rv); localDir = do_QueryInterface(dirFileMac, &rv); #elif defined(XP_WIN) nsString path; if (aLocal) { rv = GetShellFolderPath(CSIDL_LOCAL_APPDATA, path); if (NS_FAILED(rv)) rv = GetRegWindowsAppDataFolder(aLocal, path); } if (!aLocal || NS_FAILED(rv)) { rv = GetShellFolderPath(CSIDL_APPDATA, path); if (NS_FAILED(rv)) { if (!aLocal) rv = GetRegWindowsAppDataFolder(aLocal, path); } } NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir)); #elif defined(MOZ_WIDGET_GONK) rv = NS_NewNativeLocalFile(NS_LITERAL_CSTRING("/data/b2g"), true, getter_AddRefs(localDir)); #elif defined(XP_UNIX) const char* homeDir = getenv("HOME"); if (!homeDir || !*homeDir) return NS_ERROR_FAILURE; #ifdef ANDROID /* We want (ProfD == ProfLD) on Android. */ aLocal = false; #endif if (aLocal) { // If $XDG_CACHE_HOME is defined use it, otherwise use $HOME/.cache. const char* cacheHome = getenv("XDG_CACHE_HOME"); if (cacheHome && *cacheHome) { rv = NS_NewNativeLocalFile(nsDependentCString(cacheHome), true, getter_AddRefs(localDir)); } else { rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true, getter_AddRefs(localDir)); if (NS_SUCCEEDED(rv)) rv = localDir->AppendNative(NS_LITERAL_CSTRING(".cache")); } } else { rv = NS_NewNativeLocalFile(nsDependentCString(homeDir), true, getter_AddRefs(localDir)); } #else #error "Don't know how to get product dir on your platform" #endif NS_IF_ADDREF(*aFile = localDir); return rv; }
NS_IMETHODIMP nsTreeSelection::GetCurrentColumn(nsITreeColumn** aCurrentColumn) { NS_IF_ADDREF(*aCurrentColumn = mCurrentColumn); return NS_OK; }
NS_IMETHODIMP nsTreeSelection::GetTree(nsITreeBoxObject * *aTree) { NS_IF_ADDREF(mTree); *aTree = mTree; return NS_OK; }
NS_IMETHODIMP nsXULTemplateQueryProcessorStorage::CompileQuery(nsIXULTemplateBuilder* aBuilder, nsIDOMNode* aQueryNode, nsIAtom* aRefVariable, nsIAtom* aMemberVariable, nsISupports** aReturn) { nsCOMPtr<nsIDOMNodeList> childNodes; aQueryNode->GetChildNodes(getter_AddRefs(childNodes)); uint32_t length; childNodes->GetLength(&length); nsCOMPtr<mozIStorageStatement> statement; nsCOMPtr<nsIContent> queryContent = do_QueryInterface(aQueryNode); nsAutoString sqlQuery; // Let's get all text nodes (which should be the query) if (!nsContentUtils::GetNodeTextContent(queryContent, false, sqlQuery, fallible)) { return NS_ERROR_OUT_OF_MEMORY; } nsresult rv = mStorageConnection->CreateStatement(NS_ConvertUTF16toUTF8(sqlQuery), getter_AddRefs(statement)); if (NS_FAILED(rv)) { nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_STORAGE_BAD_QUERY); return rv; } uint32_t parameterCount = 0; for (nsIContent* child = queryContent->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->NodeInfo()->Equals(nsGkAtoms::param, kNameSpaceID_XUL)) { nsAutoString value; if (!nsContentUtils::GetNodeTextContent(child, false, value, fallible)) { return NS_ERROR_OUT_OF_MEMORY; } uint32_t index = parameterCount; nsAutoString name, indexValue; if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) { rv = statement->GetParameterIndex(NS_ConvertUTF16toUTF8(name), &index); if (NS_FAILED(rv)) { nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_STORAGE_UNKNOWN_QUERY_PARAMETER); return rv; } parameterCount++; } else if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::index, indexValue)) { PR_sscanf(NS_ConvertUTF16toUTF8(indexValue).get(),"%d",&index); if (index > 0) index--; } else { parameterCount++; } static nsIContent::AttrValuesArray sTypeValues[] = { &nsGkAtoms::int32, &nsGkAtoms::integer, &nsGkAtoms::int64, &nsGkAtoms::null, &nsGkAtoms::double_, &nsGkAtoms::string, nullptr }; int32_t typeError = 1; int32_t typeValue = child->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type, sTypeValues, eCaseMatters); rv = NS_ERROR_ILLEGAL_VALUE; int32_t valInt32 = 0; int64_t valInt64 = 0; double valFloat = 0; switch (typeValue) { case 0: case 1: typeError = PR_sscanf(NS_ConvertUTF16toUTF8(value).get(),"%d",&valInt32); if (typeError > 0) rv = statement->BindInt32ByIndex(index, valInt32); break; case 2: typeError = PR_sscanf(NS_ConvertUTF16toUTF8(value).get(),"%lld",&valInt64); if (typeError > 0) rv = statement->BindInt64ByIndex(index, valInt64); break; case 3: rv = statement->BindNullByIndex(index); break; case 4: typeError = PR_sscanf(NS_ConvertUTF16toUTF8(value).get(),"%lf",&valFloat); if (typeError > 0) rv = statement->BindDoubleByIndex(index, valFloat); break; case 5: case nsIContent::ATTR_MISSING: rv = statement->BindStringByIndex(index, value); break; default: typeError = 0; } if (typeError <= 0) { nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_STORAGE_WRONG_TYPE_QUERY_PARAMETER); return rv; } if (NS_FAILED(rv)) { nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND); return rv; } } } *aReturn = statement; NS_IF_ADDREF(*aReturn); return NS_OK; }
NS_IMETHODIMP nsOperaProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult) { if (!mProfiles) { nsresult rv; mProfiles = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIProperties> fileLocator(do_GetService("@mozilla.org/file/directory_service;1")); nsCOMPtr<nsILocalFile> file; #ifdef XP_WIN fileLocator->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(file)); // Opera profile lives under %APP_DATA%\Opera\<operaver>\profile file->Append(OPERA_PREFERENCES_FOLDER_NAME); nsCOMPtr<nsISimpleEnumerator> e; rv = file->GetDirectoryEntries(getter_AddRefs(e)); if (NS_FAILED(rv)) return rv; PRBool hasMore; e->HasMoreElements(&hasMore); while (hasMore) { nsCOMPtr<nsILocalFile> curr; e->GetNext(getter_AddRefs(curr)); PRBool isDirectory = PR_FALSE; curr->IsDirectory(&isDirectory); if (isDirectory) { nsCOMPtr<nsISupportsString> string(do_CreateInstance("@mozilla.org/supports-string;1")); nsAutoString leafName; curr->GetLeafName(leafName); string->SetData(leafName); mProfiles->AppendElement(string); } e->HasMoreElements(&hasMore); } #elif defined (XP_MACOSX) fileLocator->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(file)); file->Append(NS_LITERAL_STRING("Preferences")); file->Append(OPERA_PREFERENCES_FOLDER_NAME); PRBool exists; file->Exists(&exists); if (exists) { nsCOMPtr<nsISupportsString> string(do_CreateInstance("@mozilla.org/supports-string;1")); string->SetData(OPERA_PREFERENCES_FOLDER_NAME); mProfiles->AppendElement(string); } #elif defined (XP_UNIX) fileLocator->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(file)); file->Append(OPERA_PREFERENCES_FOLDER_NAME); PRBool exists; file->Exists(&exists); if (exists) { nsCOMPtr<nsISupportsString> string(do_CreateInstance("@mozilla.org/supports-string;1")); string->SetData(OPERA_PREFERENCES_FOLDER_NAME); mProfiles->AppendElement(string); } #endif } *aResult = mProfiles; NS_IF_ADDREF(*aResult); return NS_OK; }
NS_IMETHODIMP nsExtProtocolChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup) { NS_IF_ADDREF(*aLoadGroup = mLoadGroup); return NS_OK; }
/* attribute long iconURI; */ NS_IMETHODIMP JumpListShortcut::GetFaviconPageUri(nsIURI **aFaviconPageURI) { NS_IF_ADDREF(*aFaviconPageURI = mFaviconPageURI); return NS_OK; }
NS_IMETHODIMP nsExtProtocolChannel::GetURI(nsIURI* *aURI) { *aURI = mUrl; NS_IF_ADDREF(*aURI); return NS_OK; }
/* attribute nsIURI uri; */ NS_IMETHODIMP JumpListLink::GetUri(nsIURI **aURI) { NS_IF_ADDREF(*aURI = mURI); return NS_OK; }
NS_IMETHODIMP InterceptedChannelContent::GetChannel(nsIChannel** aChannel) { NS_IF_ADDREF(*aChannel = mChannel); return NS_OK; }
int main(int argc, char **argv) { #ifdef WIN32 PRBool bLoadMySQL = PR_FALSE; #ifdef DEBUG // the pref setting for debug is too late. Let's use a cmdline arg of -debug for(int i=1; i<argc; i++) { if (stricmp(argv[i], "-debug") == 0) { char szMessage [256]; wsprintf (szMessage, "Please attach a debugger to the process 0x%X" " [%d] and click OK", GetCurrentProcessId(), GetCurrentProcessId() ); MessageBox(NULL, szMessage, "Jaxer Debug Time!", MB_OK | MB_SERVICE_NOTIFICATION); removeArg(&argc, &argv[i]); break; } } #endif #endif nsresult rv; nsIServiceManager* serviceManager; AppDirectoryProvider appDirectoryProvider; nsCOMPtr<nsIDirectoryServiceProvider> dirProvider(&appDirectoryProvider); /* Preprocess specific command line args */ for (int i = 1; i < argc; /*NOP*/ ) { if (!strcmp(argv[i], "-tempdir") || !strcmp(argv[i], "--tempdir")) { removeArg(&argc, &argv[i]); if (i < argc) { appDirectoryProvider.SetTempPath(nsDependentCString(argv[i])); removeArg(&argc, &argv[i]); } } else if (!strcmp(argv[i], "-extensions") || !strcmp(argv[i], "--extensions")) { removeArg(&argc, &argv[i]); if (i < argc) { appDirectoryProvider.SetExtensionsPath(nsDependentCString(argv[i])); removeArg(&argc, &argv[i]); } } else if (!strcmp(argv[i], "-handlewinmysqlclientbug") || !strcmp(argv[i], "--handlewinmysqlclientbug")) { removeArg(&argc, &argv[i]); if (i < argc) { #ifdef _WIN32 if(!stricmp(argv[i], "true") || !strcmp(argv[i], "1")) bLoadMySQL = PR_TRUE; #endif removeArg(&argc, &argv[i]); } } else if (!PL_strcasecmp(argv[i], "-webserverconfig")) { removeArg(&argc, &argv[i]); if (i < argc) { gWebServerConfig = strdup(argv[i]); removeArg(&argc, &argv[i]); } } else { ++i; } } #ifdef _WIN32 HINSTANCE hMySQL = NULL; BOOL bSuccess = FALSE; if (bLoadMySQL) { //printf("Enabled LoadMySQL\n"); hMySQL = LoadLibrary("libmysql.dll"); if (hMySQL) { bSuccess = DisableThreadLibraryCalls(hMySQL); if (!bSuccess) fprintf(stderr, "Failed to disable thread library call: err=%d\n", GetLastError()); }else { fprintf(stderr, "Failed to load libmysql.dll: err=%d\n", GetLastError()); } } #endif #ifdef _BUILD_STATIC_BIN // Combine the static components and the app components. PRUint32 combinedCount = kStaticModuleCount + kModulesCount; static nsStaticModuleInfo *sCombined = new nsStaticModuleInfo[combinedCount]; NS_ENSURE_TRUE(sCombined, NS_ERROR_OUT_OF_MEMORY); memcpy(sCombined, kPStaticModules, sizeof(nsStaticModuleInfo) * kStaticModuleCount); memcpy(sCombined + kStaticModuleCount, &kStaticModules, sizeof(nsStaticModuleInfo) * kModulesCount); // Spin up the XPCOM infrastructure. NS_InitXPCOM3(&serviceManager, nsnull, dirProvider, sCombined, combinedCount); #else // Spin up the XPCOM infrastructure. NS_InitXPCOM3(&serviceManager, nsnull, dirProvider, &kStaticModules, kModulesCount); #endif // Exit immediately if we're only interested in XPCOM auto-registration. int exitCode = 1; if (argc > 1 && !strcmp(argv[1], "-reg")) { exitCode = 0; gJaxerLog.Log(eDEBUG, "Jaxer -reg call."); } else { // Give FCGX a chance to adopt stdin/stdout. do { /* Initialize appData */ nsCOMPtr<nsIFile> processDir; rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(processDir)); if (NS_FAILED(rv)) { fprintf(stderr, "Get current process directory failed: rv=0x%x", rv); break; } nsCOMPtr<nsILocalFile> xreDirectory(do_QueryInterface(processDir)); appData.xreDirectory = xreDirectory; NS_IF_ADDREF(appData.xreDirectory); #ifdef MOZ_CRASHREPORTER rv = CrashReporter::SetExceptionHandler(appData.xreDirectory, appData.crashReporterURL); if (NS_SUCCEEDED(rv)) { // pass some basic info from the app data if (appData.vendor) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Vendor"), nsDependentCString(appData.vendor)); if (appData.name) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProductName"), nsDependentCString(appData.name)); if (appData.version) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Version"), nsDependentCString(appData.version)); if (appData.buildID) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("BuildID"), nsDependentCString(appData.buildID)); } nsCOMPtr<nsIFile> dumpD; rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(dumpD)); if (NS_FAILED(rv)) { fprintf(stderr, "Jaxer: Cannot get OS tmp dir. rv=0x%x", rv); break; } nsAutoString pathStr; rv = dumpD->GetPath(pathStr); if(NS_SUCCEEDED(rv)) { CrashReporter::SetMinidumpPath(pathStr); } #endif // call Jaxer main exitCode = jaxerMain(argc, argv); } while(PR_FALSE); } #ifdef MOZ_CRASHREPORTER CrashReporter::UnsetExceptionHandler(); #endif NS_IF_RELEASE(appData.xreDirectory); appDirectoryProvider.DoShutdown(); dirProvider = nsnull; NS_ShutdownXPCOM(serviceManager); #ifdef _BUILD_STATIC_BIN delete[] sCombined; #endif #ifdef _WIN32 if (bLoadMySQL && hMySQL) FreeLibrary(hMySQL); #endif return exitCode; }
NS_IMETHODIMP nsBaseChannel::GetLoadGroup(nsILoadGroup **aLoadGroup) { NS_IF_ADDREF(*aLoadGroup = mLoadGroup); return NS_OK; }
NS_IMETHODIMP nsMsgMailNewsUrl::GetMimeHeaders(nsIMimeHeaders * *mimeHeaders) { NS_ENSURE_ARG_POINTER(mimeHeaders); NS_IF_ADDREF(*mimeHeaders = mMimeHeaders); return (mMimeHeaders) ? NS_OK : NS_ERROR_NULL_POINTER; }
NS_IMETHODIMP nsBaseChannel::GetOwner(nsISupports **aOwner) { NS_IF_ADDREF(*aOwner = mOwner); return NS_OK; }
NS_IMETHODIMP nsMsgMailNewsUrl::GetMsgHeaderSink(nsIMsgHeaderSink * *aMsgHdrSink) { NS_ENSURE_ARG_POINTER(aMsgHdrSink); NS_IF_ADDREF(*aMsgHdrSink = mMsgHeaderSink); return NS_OK; }
NS_IMETHODIMP nsBaseChannel::GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks) { NS_IF_ADDREF(*aCallbacks = mCallbacks); return NS_OK; }
nsresult nsKeygenFormProcessor::GetPublicKey(nsAString& aValue, nsAString& aChallenge, nsAFlatString& aKeyType, nsAString& aOutPublicKey, nsAString& aKeyParams) { nsNSSShutDownPreventionLock locker; nsresult rv = NS_ERROR_FAILURE; char *keystring = nsnull; char *keyparamsString = nsnull, *str = nsnull; KeyType type; PRUint32 keyGenMechanism; PRInt32 primeBits; PK11SlotInfo *slot = nsnull; PK11RSAGenParams rsaParams; SECOidTag algTag; int keysize = 0; void *params; SECKEYPrivateKey *privateKey = nsnull; SECKEYPublicKey *publicKey = nsnull; CERTSubjectPublicKeyInfo *spkInfo = nsnull; PRArenaPool *arena = nsnull; SECStatus sec_rv = SECFailure; SECItem spkiItem; SECItem pkacItem; SECItem signedItem; CERTPublicKeyAndChallenge pkac; pkac.challenge.data = nsnull; nsIGeneratingKeypairInfoDialogs * dialogs; nsKeygenThread *KeygenRunnable = 0; nsCOMPtr<nsIKeygenThread> runnable; // Get the key size // for (size_t i = 0; i < number_of_key_size_choices; ++i) { if (aValue.Equals(mSECKeySizeChoiceList[i].name)) { keysize = mSECKeySizeChoiceList[i].size; break; } } if (!keysize) { goto loser; } arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); if (!arena) { goto loser; } // Set the keygen mechanism if (aKeyType.IsEmpty() || aKeyType.LowerCaseEqualsLiteral("rsa")) { type = rsaKey; keyGenMechanism = CKM_RSA_PKCS_KEY_PAIR_GEN; } else if (aKeyType.LowerCaseEqualsLiteral("dsa")) { char * end; keyparamsString = ToNewCString(aKeyParams); if (!keyparamsString) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; } type = dsaKey; keyGenMechanism = CKM_DSA_KEY_PAIR_GEN; if (strcmp(keyparamsString, "null") == 0) goto loser; str = keyparamsString; PRBool found_match = PR_FALSE; do { end = strchr(str, ','); if (end != nsnull) *end = '\0'; primeBits = pqg_prime_bits(str); if (keysize == primeBits) { found_match = PR_TRUE; break; } str = end + 1; } while (end != nsnull); if (!found_match) { goto loser; } } else if (aKeyType.LowerCaseEqualsLiteral("ec")) { keyparamsString = ToNewCString(aKeyParams); if (!keyparamsString) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; } type = ecKey; keyGenMechanism = CKM_EC_KEY_PAIR_GEN; /* ecParams are initialized later */ } else { goto loser; } // Get the slot rv = GetSlot(keyGenMechanism, &slot); if (NS_FAILED(rv)) { goto loser; } switch (keyGenMechanism) { case CKM_RSA_PKCS_KEY_PAIR_GEN: rsaParams.keySizeInBits = keysize; rsaParams.pe = DEFAULT_RSA_KEYGEN_PE; algTag = DEFAULT_RSA_KEYGEN_ALG; params = &rsaParams; break; case CKM_DSA_KEY_PAIR_GEN: // XXX Fix this! XXX // goto loser; case CKM_EC_KEY_PAIR_GEN: /* XXX We ought to rethink how the KEYGEN tag is * displayed. The pulldown selections presented * to the user must depend on the keytype. * The displayed selection could be picked * from the keyparams attribute (this is currently called * the pqg attribute). * For now, we pick ecparams from the keyparams field * if it specifies a valid supported curve, or else * we pick one of secp384r1, secp256r1 or secp192r1 * respectively depending on the user's selection * (High, Medium, Low). * (RSA uses RSA-2048, RSA-1024 and RSA-512 for historical * reasons, while ECC choices represent a stronger mapping) * NOTE: The user's selection * is silently ignored when a valid curve is presented * in keyparams. */ if ((params = decode_ec_params(keyparamsString)) == nsnull) { /* The keyparams attribute did not specify a valid * curve name so use a curve based on the keysize. * NOTE: Here keysize is used only as an indication of * High/Medium/Low strength; elliptic curve * cryptography uses smaller keys than RSA to provide * equivalent security. */ switch (keysize) { case 2048: params = decode_ec_params("secp384r1"); break; case 1024: case 512: params = decode_ec_params("secp256r1"); break; } } /* XXX The signature algorithm ought to choose the hashing * algorithm based on key size once ECDSA variations based * on SHA256 SHA384 and SHA512 are standardized. */ algTag = SEC_OID_ANSIX962_ECDSA_SIGNATURE_WITH_SHA1_DIGEST; break; default: goto loser; } /* Make sure token is initialized. */ rv = setPassword(slot, m_ctx); if (NS_FAILED(rv)) goto loser; sec_rv = PK11_Authenticate(slot, PR_TRUE, m_ctx); if (sec_rv != SECSuccess) { goto loser; } rv = getNSSDialogs((void**)&dialogs, NS_GET_IID(nsIGeneratingKeypairInfoDialogs), NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID); if (NS_SUCCEEDED(rv)) { KeygenRunnable = new nsKeygenThread(); NS_IF_ADDREF(KeygenRunnable); } if (NS_FAILED(rv) || !KeygenRunnable) { rv = NS_OK; privateKey = PK11_GenerateKeyPair(slot, keyGenMechanism, params, &publicKey, PR_TRUE, PR_TRUE, m_ctx); } else { KeygenRunnable->SetParams( slot, keyGenMechanism, params, PR_TRUE, PR_TRUE, m_ctx ); runnable = do_QueryInterface(KeygenRunnable); if (runnable) { { nsPSMUITracker tracker; if (tracker.isUIForbidden()) { rv = NS_ERROR_NOT_AVAILABLE; } else { rv = dialogs->DisplayGeneratingKeypairInfo(m_ctx, runnable); // We call join on the thread, // so we can be sure that no simultaneous access to the passed parameters will happen. KeygenRunnable->Join(); } } NS_RELEASE(dialogs); if (NS_SUCCEEDED(rv)) { rv = KeygenRunnable->GetParams(&privateKey, &publicKey); } } } if (NS_FAILED(rv) || !privateKey) { goto loser; } // just in case we'll need to authenticate to the db -jp // privateKey->wincx = m_ctx; /* * Create a subject public key info from the public key. */ spkInfo = SECKEY_CreateSubjectPublicKeyInfo(publicKey); if ( !spkInfo ) { goto loser; } /* * Now DER encode the whole subjectPublicKeyInfo. */ sec_rv=DER_Encode(arena, &spkiItem, CERTSubjectPublicKeyInfoTemplate, spkInfo); if (sec_rv != SECSuccess) { goto loser; } /* * set up the PublicKeyAndChallenge data structure, then DER encode it */ pkac.spki = spkiItem; pkac.challenge.len = aChallenge.Length(); pkac.challenge.data = (unsigned char *)ToNewCString(aChallenge); if (!pkac.challenge.data) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; } sec_rv = DER_Encode(arena, &pkacItem, CERTPublicKeyAndChallengeTemplate, &pkac); if ( sec_rv != SECSuccess ) { goto loser; } /* * now sign the DER encoded PublicKeyAndChallenge */ sec_rv = SEC_DerSignData(arena, &signedItem, pkacItem.data, pkacItem.len, privateKey, algTag); if ( sec_rv != SECSuccess ) { goto loser; } /* * Convert the signed public key and challenge into base64/ascii. */ keystring = BTOA_DataToAscii(signedItem.data, signedItem.len); if (!keystring) { rv = NS_ERROR_OUT_OF_MEMORY; goto loser; } CopyASCIItoUTF16(keystring, aOutPublicKey); nsCRT::free(keystring); rv = NS_OK; loser: if ( sec_rv != SECSuccess ) { if ( privateKey ) { PK11_DestroyTokenObject(privateKey->pkcs11Slot,privateKey->pkcs11ID); } if ( publicKey ) { PK11_DestroyTokenObject(publicKey->pkcs11Slot,publicKey->pkcs11ID); } } if ( spkInfo ) { SECKEY_DestroySubjectPublicKeyInfo(spkInfo); } if ( publicKey ) { SECKEY_DestroyPublicKey(publicKey); } if ( privateKey ) { SECKEY_DestroyPrivateKey(privateKey); } if ( arena ) { PORT_FreeArena(arena, PR_TRUE); } if (slot != nsnull) { PK11_FreeSlot(slot); } if (KeygenRunnable) { NS_RELEASE(KeygenRunnable); } if (keyparamsString) { nsMemory::Free(keyparamsString); } if (pkac.challenge.data) { nsMemory::Free(pkac.challenge.data); } return rv; }
NS_IMETHODIMP nsProxyInfo::GetFailoverProxy(nsIProxyInfo **result) { NS_IF_ADDREF(*result = mNext); return NS_OK; }
NS_IMETHODIMP HTMLOptionsCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn) { NS_IF_ADDREF(*aReturn = mSelect); return NS_OK; }
/* attribute mozIPersonalDictionary personalDictionary; */ NS_IMETHODIMP mozHunspell::GetPersonalDictionary(mozIPersonalDictionary * *aPersonalDictionary) { *aPersonalDictionary = mPersonalDictionary; NS_IF_ADDREF(*aPersonalDictionary); return NS_OK; }
void nsHttpTransaction::SetConnection(nsAHttpConnection *conn) { NS_IF_RELEASE(mConnection); NS_IF_ADDREF(mConnection = conn); }