Esempio n. 1
0
int main()
{

	NS_InitEmbedding(NULL, NULL);

    InvokeTestTarget *test = new InvokeTestTarget();

    /* here we make the global 'check for alloc failure' checker happy */
    if(!test)
        return 1;


    InvokeTestTargetInterface* proxy;
    NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
                         kTheCID, 
                         test, 
                         PROXY_SYNC | PROXY_ALWAYS, 
                         (void**)(&proxy));


	char* buffer;
	proxy->PassTwoStrings("", "a", "b", &buffer);


    NS_RELEASE(test);

	extern int x_main();
	x_main();
    return NS_OK;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    printf("You are embedded, man!\n\n");
    printf("******************************************************************\n");
    printf("*                                                                *\n");
    printf("*  IMPORTANT NOTE:                                               *\n");
    printf("*                                                                *\n");
    printf("*  WinEmbed is not supported!!! Do not raise bugs on it unless   *\n");
    printf("*  it is badly broken (e.g. crash on start/exit, build errors)   *\n");
    printf("*  or you have the patch to make it better! MFCEmbed is now our  *\n");
    printf("*  embedding test application on Win32 and all testing should    *\n");
    printf("*  be done on that.                                              *\n");
    printf("*                                                                *\n");
    printf("******************************************************************\n");
    printf("\n\n");
    
    // Sophisticated command-line parsing in action
#ifdef MINIMO
    char *szFirstURL = "http://www.mozilla.org/projects/embedding";
#else
    char *szFirstURL = "http://www.mozilla.org/projects/minimo";
#endif
	int argn;
    for (argn = 1; argn < argc; argn++)
    {
		szFirstURL = argv[argn];
    }
    strncpy(gFirstURL, szFirstURL, sizeof(gFirstURL) - 1);

    ghInstanceApp = GetModuleHandle(NULL);
    ghInstanceResources = GetModuleHandle(NULL);

    // Initialize global strings
    TCHAR szTitle[MAX_LOADSTRING];
    LoadString(ghInstanceResources, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    MyRegisterClass(ghInstanceApp);

    // Init Embedding APIs
    NS_InitEmbedding(nsnull, nsnull, kPStaticModules, kStaticModuleCount);

    // Choose the new profile
    if (NS_FAILED(StartupProfile()))
    {
        NS_TermEmbedding();
        return 1;
    }
    WPARAM rv;
    {   
		InitializeWindowCreator();

        // Open the initial browser window
        OpenWebPage(gFirstURL);

        // Main message loop.
        // NOTE: We use a fake event and a timeout in order to process idle stuff for
        //       Mozilla every 1/10th of a second.
        PRBool runCondition = PR_TRUE;

        rv = AppCallbacks::RunEventLoop(runCondition);
    }
    // Close down Embedding APIs
    NS_TermEmbedding();

    return rv;
}
JNIEXPORT void JNICALL 
Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize(
										JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath, jint nativeWF, jobject nativeEventThread)
{
    const char *nativePath = nsnull;
    NativeWrapperFactory *nativeWrapperFactory = (NativeWrapperFactory *) nativeWF;
    nsresult rv;
    nsCOMPtr<nsILocalFile> binDir;
    
    // PENDING(edburns): We need this for rdf_getChildCount
    PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");

    // 
    // create an nsILocalFile from our argument
    //
    
    PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, 
           ("WrapperFactoryImpl_nativeAppInitialize: entering\n"));

    nativePath = (const char *) ::util_GetStringUTFChars(env, 
                                                   verifiedBinDirAbsolutePath);
    PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, 
           ("WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: %s\n", 
            nativePath));
    
    if (nativePath) {
        rv = NS_NewNativeLocalFile(nsDependentCString(nativePath), 1, 
                                   getter_AddRefs(binDir));
        PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, 
               ("WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: %d\n", 
                rv));
        
        if (NS_FAILED(rv)) {
            ::util_ThrowExceptionToJava(env, 
                                  "Can't get nsILocalFile from bin directory");
        }
    }
    ::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, nativePath);
    
    //
    // Make the all important NS_InitEmbedding call
    // 
    
    rv = NS_InitEmbedding(binDir, nsnull);
    PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, 
          ("WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: %d\n",
           rv));

    if (NS_FAILED(rv)) {
        ::util_ThrowExceptionToJava(env, "NS_InitEmbedding() failed.");
    }

    // the rest of the startup tasks are coordinated from the java side.
    PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, 
           ("WrapperFactoryImpl_nativeAppInitialize: exiting\n"));

    char propValue[50];
    ::util_getSystemProperty(env, "native.waitForDebugger", propValue, 50);
    if (nsnull != propValue[0] &&
        0 < nsCRT::strlen(propValue)) {
#ifdef XP_UNIX
        pid_t pid = getpid();
        printf("++++++++++++++++debug: pid is: %d\n", pid);
#endif
#ifdef XP_PC
        printf("++++++++++++++++debug: pid is: %d\n", GetCurrentProcessId());
#endif
        fflush(stdout);
        PR_Sleep(700000);
    }
    
    // Store our pointer to the global vm
    if (nsnull == gVm) { // declared in ../src_share/jni_util.h
        ::util_GetJavaVM(env, &gVm);  // save this vm reference
    }

    util_InitializeShareInitContext(env, &(nativeWrapperFactory->shareContext));
    rv = nativeWrapperFactory->Init(env, nativeEventThread);
    if (NS_FAILED(rv)) {
        ::util_ThrowExceptionToJava(env, 
                                    "Failed to init NativeWrapperFactory");
    }
}