Пример #1
0
native_vrml_external_Browser_deleteRoute(JRIEnv* env, struct vrml_external_Browser* self, struct vrml_external_Node *jFromNode, struct java_lang_String *jFromEvent, struct vrml_external_Node *jToNode, struct java_lang_String *jToEvent)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return;

    // check parameters
    LPUNKNOWN fromNode, toNode;
    bool wrongPar = false;
    if (!jFromNode || !jToNode || !jFromEvent || !jToEvent )
    {
        wrongPar = true;
    }
    else
    {
        fromNode = (LPUNKNOWN)get_vrml_external_Node_cNode(env, jFromNode);
        toNode   = (LPUNKNOWN)get_vrml_external_Node_cNode(env, jToNode);
        if (!ctrl->checkRef((void *)fromNode, TypeNode) || !ctrl->checkRef((void *)toNode, TypeNode)) // invalid handle
            wrongPar = true;
    }
    if (wrongPar)
    {
        struct java_lang_Class * exClass = class_java_lang_IllegalArgumentException( env );
        JRI_ThrowNew ( env , exClass , "Invalid Parameter" );
        return;
    }
    const char * fromEvent = JRI_GetStringUTFChars( env , jFromEvent );
    const char * toEvent   = JRI_GetStringUTFChars( env , jToEvent );

    // create route
    ctrl->getCC3D()->deleteRoute(fromNode, fromEvent, toNode, toEvent);
    return;
}
Пример #2
0
native_vrml_external_Browser_nLoadURL(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jUrl, struct java_lang_String *jPar)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return;

    const char * url = JRI_GetStringUTFChars( env , jUrl );
    const char * par = JRI_GetStringUTFChars( env , jPar );
    ctrl->getCC3D()->loadURL(url, par);
}
Пример #3
0
native_vrml_external_Browser_setNodeEventIn(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *node, struct java_lang_String *event, struct java_lang_String *value)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return false;

    const char * nodeName = JRI_GetStringUTFChars( env , node );
    const char * evName = JRI_GetStringUTFChars( env , event );
    const char * valP = JRI_GetStringUTFChars( env , value );

    boolean ret = false;
    if (ctrl->getCC3D()->setNodeEventIn(nodeName, evName, valP))
        ret = true;
    return ret;
}
Пример #4
0
native_vrml_external_Browser_createNode(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jString)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return NULL;

    // get c handle
    const char * str = JRI_GetStringUTFChars( env , jString );
    LPUNKNOWN pNode = ctrl->getCC3D()->createNode(str);
    void * pUnknown = ctrl->getNodeQIPtr(pNode);

    if (!pUnknown) // invalid vrml
    {
        struct java_lang_Class * exClass = class_vrml_external_exception_InvalidVrmlException( env );
        JRI_ThrowNew ( env , exClass , "Invalid VRML" );
        return NULL;
    }

    // convert to java
    struct java_lang_Class * nodeClass = class_vrml_external_Node( env );
    struct vrml_external_Node * node;
    node = vrml_external_Node_new(env, nodeClass, (jint)ctrl, (jint)pUnknown );
    
    return node;
}
Пример #5
0
native_vrml_external_Browser_setString(JRIEnv* env, struct vrml_external_Browser* self, jint opcode, struct java_lang_String *jStr)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return;

    const char * stringUTF = JRI_GetStringUTFChars( env , jStr );
	switch (opcode)
	{
	    case vrml_external_Browser_OP_VIEWERMODE:
            ctrl->getCC3D()->SetNavigationMode(stringUTF);
		    break;
	    case vrml_external_Browser_OP_VIEWPOINT:
            ctrl->getCC3D()->SetViewpoint(stringUTF);
		    break;
	    case vrml_external_Browser_OP_DESCRIPTION:
            ctrl->getCC3D()->SetDescription(stringUTF);
		    break;
	    case vrml_external_Browser_OP_SAVEVIEW:
            ctrl->getCC3D()->saveViewpoint(stringUTF);
		    break;
	    case vrml_external_Browser_OP_PLAYSOUND:
            ctrl->getCC3D()->playSound(stringUTF);
		    break;
	    case vrml_external_Browser_OP_PRINT:
            ctrl->getCC3D()->print(stringUTF);
		    break;
	    case vrml_external_Browser_OP_AVATARURL:
            ctrl->getCC3D()->setMyAvatarURL(stringUTF);
		    break;
	}
    return;
}
	native_Blender3DPlugin_SendMessage(
		JRIEnv* env, 
		Blender3DPlugin* self,
		struct java_lang_String * to,
		struct java_lang_String * from,
		struct java_lang_String * subject,
		struct java_lang_String * body
		)
{
	
	NPP npp = (NPP)netscape_plugin_Plugin_getPeer(env, self);
	BlenderPluginInstance* inst  = NULL;
	char *to_p, *from_p, *subject_p, *body_p;

	B3D_log_entry("native_Blender3DPlugin_SendMessage");

	inst = (BlenderPluginInstance*) npp->pdata;

	fprintf(stderr, "Doing java stuff for instance %p\n",
		inst);
	fflush(stderr);
	
	to_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, to) + 1);
	from_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, from) + 1);
	subject_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, subject) + 1);
	body_p = NPN_MemAlloc(JRI_GetStringUTFLength(env, body) + 1);

	strcpy(to_p, JRI_GetStringUTFChars(env, to));
	strcpy(from_p, JRI_GetStringUTFChars(env, from));
	strcpy(subject_p, JRI_GetStringUTFChars(env, subject));
	strcpy(body_p, JRI_GetStringUTFChars(env, body));

	PLB_native_SendMessage_func(inst, 
				    to_p, 
				    from_p, 
				    subject_p, 
				    body_p);

	NPN_MemFree(to_p);
	NPN_MemFree(from_p);
	NPN_MemFree(subject_p);
	NPN_MemFree(body_p);
}
Пример #7
0
native_vrml_external_Browser_getNodeEventOut(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *node, struct java_lang_String *event)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return NULL;

    const char * nodeName = JRI_GetStringUTFChars( env , node );
    const char * evName = JRI_GetStringUTFChars( env , event );

    struct java_lang_String * retStr = NULL;
    CString cStr;

    if (cStr = ctrl->getCC3D()->getNodeEventOut(nodeName, evName)) 
	{
        retStr = JRI_NewStringUTF ( env , cStr , cStr.GetLength() );
    }
    
    return retStr;
}
Пример #8
0
native_vrml_external_Browser_nCreateVrmlFromURL(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jUrl, struct vrml_external_Node *node, struct java_lang_String *jEvent)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return;

    LPUNKNOWN nodeHdl = 0;
    if (node)
    {
        nodeHdl = (LPUNKNOWN)get_vrml_external_Node_cNode(env, node);
        if (!ctrl->checkRef((void *)nodeHdl, TypeNode)) // invalid handle
            nodeHdl = 0;
    }
    const char * event = JRI_GetStringUTFChars( env , jEvent );
    const char * url   = JRI_GetStringUTFChars( env , jUrl );

    ctrl->getCC3D()->createVrmlFromURL(url, (LPDISPATCH)nodeHdl, event);
    return;
}
Пример #9
0
native_vrml_external_Browser_createVrmlFromString(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jString)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return NULL;

    // get c handle
    const char * str = JRI_GetStringUTFChars( env , jString );
    LPUNKNOWN pVrml = ctrl->getCC3D()->createVrmlFromString(str);
    void * pScene = ctrl->getNodeQIPtr(pVrml);

    if (!pScene) // invalid vrml
    {
        struct java_lang_Class * exClass = class_vrml_external_exception_InvalidVrmlException( env );
        JRI_ThrowNew ( env , exClass , "Invalid VRML" );
        return NULL;
    }

    // cc3d provides a group node instead of a mfnode so we have to read all nodes by ourself
    int type;
    void * pUnknown = ctrl->getEventOut(pScene, "children_changed", &type);
    ctrl->release( pScene );
    pScene = NULL;

    if (!pUnknown) // no children
    {
        struct java_lang_Class * exClass = class_vrml_external_exception_InvalidVrmlException( env );
        JRI_ThrowNew ( env , exClass , "Invalid VRML" );
        return NULL;
    }
	
    // get the size first and create java array
    struct java_lang_Class * nodeClass = class_vrml_external_Node( env );
    int size = ctrl->getSize(pUnknown, type);
	jobjectArray jArray = (jobjectArray)JRI_NewObjectArray(env, size, nodeClass, NULL);

    struct vrml_external_Node * node;
    void * pNode;
    for (int i = 0 ; i < size ; i++)
	{
		pNode = ctrl->getNode(pUnknown, i, type);

		if (!pNode) // shouldn't happen
			break;

		node = vrml_external_Node_new(env, nodeClass, (jint)ctrl, (jint)pNode );
		JRI_SetObjectArrayElement(env, jArray, i, node);
	}

    ctrl->release( pUnknown );
    pUnknown = NULL;

    return jArray;
}
Пример #10
0
native_COW_run(JRIEnv* env, struct COW* self, struct java_lang_String *server, jint port)
{
    char *s;
    char *name="COW Netrek plugin";

    s=JRI_GetStringUTFChars(env,server);
    if (s[0]='\0') s=0;       /* No name given: use defaults */

    cowmain(s, (int)port, name);

    return;
}
Пример #11
0
native_vrml_external_Browser_saveWorld(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jName)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return false;

    const char * name = JRI_GetStringUTFChars( env , jName );
    bool ret = false;
    if (ctrl->getCC3D()->saveWorld(name))
        ret = true;
    return ret;
}
Пример #12
0
native_vrml_external_Browser_getEventOut(JRIEnv* env, struct vrml_external_Browser* self, struct java_lang_String *jName)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return NULL;

    const char * name = JRI_GetStringUTFChars( env , jName );
    int type;
    void * pUnknown = ctrl->getEventOut(NULL, name, &type);
    if (!pUnknown) 
    {
        return NULL;
    }

    // convert to java
    struct java_lang_Class * eventClass = class_vrml_external_field_EventOut( env );
    struct vrml_external_field_EventOut * event;
    event = vrml_external_field_EventOut_newEventOut(env, eventClass, (jint)type, (jint)ctrl, (jint)pUnknown );
    
    return event;
}
	native_Blender3DPlugin_blenderURL(
		JRIEnv* env, 
		Blender3DPlugin* self,
		struct java_lang_String * url
		)
{
	
	NPP npp = (NPP)netscape_plugin_Plugin_getPeer(env, self);
	BlenderPluginInstance* inst = NULL;
	char* tmp;

	B3D_log_entry("native_Blender3DPlugin_blenderURL");
	
	inst = (BlenderPluginInstance*) npp->pdata;

	if (inst) {
		/* use UTF because we get ascii text only  */
		tmp = NPN_MemAlloc(JRI_GetStringUTFLength(env, url) + 1);
		strcpy(inst->new_url, JRI_GetStringUTFChars(env, url));
		PLB_native_blenderURL_func(inst, tmp);
		NPN_MemFree(tmp);
	}
}
Пример #14
0
native_vrml_external_Browser_setNodeName(JRIEnv* env, struct vrml_external_Browser* self, struct vrml_external_Node *node, struct java_lang_String *jName)
{
    CJavaCtrl* ctrl = getController(env, self);
    if (!ctrl)
        return;

    LPUNKNOWN nodeHdl = 0;
    if (node)
    {
        nodeHdl = (LPUNKNOWN)get_vrml_external_Node_cNode(env, node);
        if (!ctrl->checkRef((void *)nodeHdl, TypeNode)) // invalid handle
            nodeHdl = 0;
    }
    if (!nodeHdl)
    {
        struct java_lang_Class * exClass = class_java_lang_IllegalArgumentException( env );
        JRI_ThrowNew ( env , exClass , "Invalid Parameter" );
        return;
    }
    const char * name = JRI_GetStringUTFChars( env , jName );

    ctrl->getCC3D()->setNodeName(nodeHdl, name);
    return;
}