本文整理汇总了C++中NS_InitXPCOM2函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_InitXPCOM2函数的具体用法?C++ NS_InitXPCOM2怎么用?C++ NS_InitXPCOM2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_InitXPCOM2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
nsresult init()
{
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
return CallGetService(kCharsetConverterManagerCID, &ccMan);
}
示例2: main
int
main(int argc, char* argv[])
{
nsresult rv;
{
nsCOMPtr<nsIFile> topDir;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) return -1;
if (argc > 1 && argv[1] != nsnull)
{
char* pathStr = argv[1];
NS_NewNativeLocalFile(nsDependentCString(pathStr), false, getter_AddRefs(topDir));
}
if (!topDir)
{
printf("No Top Dir\n");
return -1;
}
PRInt32 startTime = PR_IntervalNow();
LoopInDir(topDir);
PRInt32 endTime = PR_IntervalNow();
printf("\nTime: %d\n", PR_IntervalToMilliseconds(endTime - startTime));
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return 0;
}
示例3: main
int
main(int argc, char* argv[])
{
nsresult rv;
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "AutoregisterComponents failed");
if (argc < 2) {
printf("usage: %s resource://foo/<path-to-resolve>\n", argv[0]);
return -1;
}
rv = SetupMapping();
NS_ASSERTION(NS_SUCCEEDED(rv), "SetupMapping failed");
if (NS_FAILED(rv)) return rv;
rv = TestOpenInputStream(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestOpenInputStream failed");
rv = TestAsyncRead(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return rv;
}
示例4: main
int main(int argc, char** argv) {
NS_InitXPCOM2(nsnull, nsnull, nsnull);
// --------------------------------------------
printf("Test Line Break\n");
PRBool lbok ;
PRBool wbok ;
lbok =TestWordBreaker();
if(lbok)
printf("Line Break Test\nOK\n");
else
printf("Line Break Test\nFailed\n");
wbok = TestLineBreaker();
if(wbok)
printf("Word Break Test\nOK\n");
else
printf("Word Break Test\nFailed\n");
SampleWordBreakUsage();
// --------------------------------------------
printf("Finish All The Test Cases\n");
if(lbok && wbok)
printf("Line/Word Break Test\nOK\n");
else
printf("Line/Word Break Test\nFailed\n");
return 0;
}
示例5: main
int
main(int argc, char **argv)
{
if (PR_GetEnv("MOZ_BREAK_ON_MAIN"))
NS_BREAK();
if (argc < 5) {
fprintf(stderr, "USAGE: TestIncrementalDownload <url> <file> <chunksize> <interval-in-seconds>\n");
return -1;
}
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return -1;
int32_t chunkSize = atoi(argv[3]);
int32_t interval = atoi(argv[4]);
rv = DoIncrementalFetch(argv[1], argv[2], chunkSize, interval);
if (NS_FAILED(rv))
fprintf(stderr, "ERROR: DoIncrementalFetch failed [%x]\n",
static_cast<uint32_t>(rv));
NS_ShutdownXPCOM(nullptr);
return 0;
}
示例6: main
int main(int argc, char** argv)
{
if (argc <= 1) {
puts("nrun <contractid>");
return EXIT_FAILURE;
}
const char* contract_id = argv[1];
// initialize XPCOM
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("XPCOM initialization failed: [%x]\n", rv);
return EXIT_FAILURE;
}
// check for new components
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);
// run the application
run(contract_id);
// shut down and go home
NS_ShutdownXPCOM(nsnull);
return EXIT_SUCCESS;
}
示例7: main
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
/* I need this to free shared memory in case of a crash */
signal(SIGTERM, abnormal_exit_handler);
signal(SIGQUIT, abnormal_exit_handler);
signal(SIGINT, abnormal_exit_handler);
signal(SIGHUP, abnormal_exit_handler);
signal(SIGSEGV, abnormal_exit_handler);
signal(SIGILL, abnormal_exit_handler);
signal(SIGABRT, abnormal_exit_handler);
// Initialize XPCOM
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
if (NS_SUCCEEDED(rv)) {
// The toolkit service in mozilla will look in the environment
// to determine which toolkit to use. Yes, it is a dumb hack to
// force it here, but we have no choice because of toolkit specific
// code linked into the viewer.
putenv("MOZ_TOOLKIT=photon");
gTheApp = new nsNativeViewerApp();
gTheApp->Initialize(argc, argv);
gTheApp->Run();
delete gTheApp;
// Shutdown XPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
}
return 0;
}
示例8: main
int
main(int argc, char* argv[])
{
{
NS_InitXPCOM2(nullptr, nullptr, nullptr);
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs) {
return -1;
}
// When NSS initializes, it attempts to get some localized strings.
// As a result, OS X and Windows flip out if this isn't set.
// (This isn't done automatically since this test doesn't have a
// lot of the other boilerplate components that would otherwise
// keep the certificate db alive longer than we want it to.)
nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true);
if (NS_FAILED(rv)) {
return -1;
}
nsCOMPtr<nsIX509CertDB> certdb(do_GetService(NS_X509CERTDB_CONTRACTID));
if (!certdb) {
return -1;
}
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
NS_ShutdownXPCOM(nullptr);
return 0;
}
示例9: main
int main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "%s [FILE]...\n", argv[0]);
}
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return (int)rv;
int res = 0;
for (int i = 1; i < argc; ++i) {
const char *filename = argv[i];
printf("\nParsing %s.\n", filename);
nsCOMPtr<nsIURI> uri = FileToURI(filename, &rv);
if (rv == NS_ERROR_OUT_OF_MEMORY) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
if (uri)
res = ParseCSSFile(uri);
}
NS_ShutdownXPCOM(nullptr);
return res;
}
示例10: main
int main(int argc, char** argv) {
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM2 failed\n");
return 1;
}
// --------------------------------------------
TestCaseConversion();
// --------------------------------------------
FuzzCaseConversion();
// --------------------------------------------
TestEntityConversion(nsIEntityConverter::html40);
// --------------------------------------------
TestSaveAsCharset();
// --------------------------------------------
TestNormalization();
// --------------------------------------------
printf("Finish All The Test Cases\n");
return 0;
}
示例11: main
int
main(int argc, char* argv[])
{
nsresult rv = NS_OK;
// Start up XPCOM
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
/**
* Create event queue for this thread
*/
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) goto error_exit;
eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(gEventQ));
/**
* Test Cache
*/
TestMemoryObjectCache();
error_exit:
gEventQ = nsnull;
eventQService = nsnull;
NS_ShutdownXPCOM(nsnull);
printf("XPCOM shut down.\n\n");
return rv;
}
示例12: main
int main(int argc, char **argv)
{
if (test_common_init(&argc, &argv) != 0)
return -1;
nsresult rv;
#if defined(PR_LOGGING)
gTestLog = PR_NewLogModule("Test");
#endif
rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return rv;
rv = RunTest();
if (NS_FAILED(rv))
LOG(("RunTest failed [rv=%x]\n", rv));
LOG(("sleeping main thread for 2 seconds...\n"));
PR_Sleep(PR_SecondsToInterval(2));
NS_ShutdownXPCOM(nullptr);
return 0;
}
示例13: main
void main(int argc, char* argv[])
{
nsresult rv;
nsIServiceManager* servMgr;
rv = NS_InitXPCOM2(&servMgr, NULL, NULL);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
// try loading a component and releasing it to see if it leaks
if (argc > 1 && argv[1] != nsnull) {
char* cidStr = argv[1];
nsISupports* obj = nsnull;
if (cidStr[0] == '{') {
nsCID cid;
cid.Parse(cidStr);
rv = CallCreateInstance(cid, &obj);
}
else {
// contractID case:
rv = CallCreateInstance(cidStr, &obj);
}
if (NS_SUCCEEDED(rv)) {
printf("Successfully created %s\n", cidStr);
NS_RELEASE(obj);
}
else {
printf("Failed to create %s (%x)\n", cidStr, rv);
}
}
rv = NS_ShutdownXPCOM(servMgr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
}
示例14: main
int
main(int argc, char** argv)
{
nsresult rv;
if (argc < 2) {
fprintf(stderr, "usage: %s <url> [<poll-interval>]\n", argv[0]);
return 1;
}
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
fprintf(stderr, "NS_InitXPCOM2 failed\n");
return 1;
}
// Create a stream data source and initialize it on argv[1], which
// is hopefully a "file:" URL. (Actually, we can do _any_ kind of
// URL, but only a "file:" URL will be written back to disk.)
nsCOMPtr<nsIRDFDataSource> ds = do_CreateInstance(kRDFXMLDataSourceCID, &rv);
if (NS_FAILED(rv)) {
NS_ERROR("unable to create RDF/XML data source");
return rv;
}
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(ds);
if (! remote)
return NS_ERROR_UNEXPECTED;
rv = remote->Init(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to initialize data source");
if (NS_FAILED(rv)) return rv;
// The do_QI() on the pointer is a hack to make sure that the new
// object gets AddRef()-ed.
nsCOMPtr<nsIRDFObserver> observer = do_QueryInterface(new Observer);
if (! observer)
return NS_ERROR_OUT_OF_MEMORY;
rv = ds->AddObserver(observer);
if (NS_FAILED(rv)) return rv;
while (1) {
// Okay, this should load the XML file...
rv = remote->Refresh(PR_TRUE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open datasource");
if (NS_FAILED(rv)) return rv;
if (argc <= 2)
break;
PRInt32 pollinterval = atol(argv[2]);
if (! pollinterval)
break;
PR_Sleep(PR_SecondsToInterval(pollinterval));
}
return NS_OK;
}
示例15: InitXPCOM_Impl
nsresult
InitXPCOM_Impl(JNIEnv* env, jobject aMozBinDirectory,
jobject aAppFileLocProvider, jobject* aResult)
{
nsresult rv;
// create an nsILocalFile from given java.io.File
nsCOMPtr<nsIFile> directory;
if (aMozBinDirectory) {
rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, rv);
}
// create nsAppFileLocProviderProxy from given Java object
nsCOMPtr<nsIDirectoryServiceProvider> provider;
if (aAppFileLocProvider) {
rv = NS_NewAppFileLocProviderProxy(aAppFileLocProvider,
getter_AddRefs(provider));
NS_ENSURE_SUCCESS(rv, rv);
}
// init XPCOM
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), directory, provider);
NS_ENSURE_SUCCESS(rv, rv);
// create Java proxy for service manager returned by NS_InitXPCOM2
return NativeInterfaceToJavaObject(env, servMan, NS_GET_IID(nsIServiceManager),
nullptr, aResult);
}