[android-developers] npapi plugin failed to load in android webview

2009-06-10 Thread MIND GAME

i am trying to load a npapi plugin using webview.
code is
webview.getSettings().setJavaScriptEnabled(true);
webview .getSettings().setPluginsEnabled(true);
webview.getSettings().setPluginsPath(/android_asset/web/);
System.out.println(Default plugin path
is :+webview .getSettings().getPluginsPath());
webview.loadUrl(file:///android_asset/web/test.html);
but plugin is failing to load...
please help me out.
thanks in advance...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] npapi plugin failed to load in android webview

2009-06-10 Thread MIND GAME

i am trying to load a npapi plugin using android api - webview.
code is
webview.getSettings().setJavaScriptEnabled(true);
webview .getSettings().setPluginsEnabled(true);
webview.getSettings().setPluginsPath(/android_asset/web/);
System.out.println(Default plugin path
is :+webview .getSettings().getPluginsPath());
webview.loadUrl(file:///android_asset/web/test.html);

i m using   simple example  npapi plugin.

code for plugin is given below and i place this plugin inside my
application's asset folder. and set pulgin path like this --
webview.getSettings().setPluginsPath
(/android_asset/web/);

but plugin is failing to load...

#include stdio.h
#include string.h
#if defined(OS_Darwin)
#include Webkit/npapi.h
#include WebKit/npfunctions.h
#include WebKit/npruntime.h
#define OSCALL
#endif
#if XULRUNNER_SDK
#include npapi.h
#include npupp.h
#include npruntime.h
#elif _WINDOWS /* WebKit SDK on Windows */
#ifndef PLATFORM
#define PLATFORM(x) defined(x)
#endif
#include npfunctions.h
#ifndef OSCALL
#define OSCALL WINAPI
#endif
#endif
char** charArray = NULL;
static NPObject *so  = NULL;
static NPNetscapeFuncs *npnfuncs = NULL;
/* NPN */
static void logmsg(const char *msg) {
#ifndef _WINDOWS
fputs(msg, stderr);
#else
static FILE *out = fopen(\\npsimple.log, a);
fputs(msg, out);
fclose(out);
#endif
}

static bool
hasMethod(NPObject* obj, NPIdentifier methodName) {
logmsg(npsimple: hasMethod\n);
return true;
}

static bool
invokeDefault(NPObject *obj, const NPVariant *args, uint32_t
argCount,
NPVariant *result) {
logmsg(npsimple: invokeDefault\n);
result-type = NPVariantType_Int32;
result-value.intValue = 42;
return true;
}

static bool
invoke(NPObject* obj, NPIdentifier methodName, const NPVariant *args,
uint32_t argCount, NPVariant *result) {
logmsg(npsimple: invoke\n);
invokeDefault(obj,args,argCount,result);
return true;
}

static bool
hasProperty(NPObject *obj, NPIdentifier propertyName) {
logmsg(npsimple: hasProperty\n);
return false;
}

static bool
getProperty(NPObject *obj, NPIdentifier propertyName, NPVariant
*result) {
logmsg(npsimple: getProperty\n);
return false;
}

static bool enumerate(NPObject *npobj, NPIdentifier **value,
 uint32_t *count){
}

static NPObject* allocate(NPP npp,NPClass* theClass){
logmsg(IN ALLOCATE\n);
NPObject* npObj = (NPObject*)malloc(sizeof(NPObject));
return npObj;
}

static void deallocate(NPObject* obj){
logmsg(IN DEALLOCATE\n);
free(obj);
}

static NPClass npcRefObject = {
NP_CLASS_STRUCT_VERSION,
allocate,
deallocate,
NULL,
hasMethod,
invoke,
invokeDefault,
hasProperty,
getProperty,
NULL,
NULL,enumerate,
};

/* NPP */
static NPError
nevv(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
char *argn[], char *argv[], NPSavedData *saved) {
logmsg(npsimple: new\n);
return NPERR_NO_ERROR;
}

static NPError
destroy(NPP instance, NPSavedData **save) {
if(so)
npnfuncs-releaseobject(so);
so = NULL;
logmsg(npsimple: destroy\n);
return NPERR_NO_ERROR;
}

static NPError
getValue(NPP instance, NPPVariable variable, void *value) {
switch(variable) {
default:
logmsg(npsimple: getvalue - default\n);
return NPERR_GENERIC_ERROR;
case NPPVpluginNameString:
logmsg(npsimple: getvalue - name string\n);
*((char **)value) = AplixFooPlugin;
break;
case NPPVpluginDescriptionString:
logmsg(npsimple: getvalue - description string\n);
*((char **)value) = a href=\http://
www.aplix.co.jp/
\AplixFooPlugin/a plugin.;
break;
case NPPVpluginScriptableNPObject:
logmsg(npsimple: getvalue - scriptable object\n);
if(!so)
so = npnfuncs-createobject(instance,
npcRefObject);
npnfuncs-retainobject(so);
*(NPObject **)value = so;
break;
#ifdef XULRUNNER_SDK
case NPPVpluginNeedsXEmbed:
logmsg(npsimple: getvalue - xembed\n);
/* *((PRBool *)value) = PR_FALSE; */
*((NPBool *)value) = FALSE;
break;
#endif
}
return NPERR_NO_ERROR;
}

static NPError /* expected by Safari on Darwin */
handleEvent(NPP instance, void *ev) {
logmsg(npsimple: handleEvent\n);
return NPERR_NO_ERROR;
}

static NPError /* expected by Opera */
setWindow(NPP instance, NPWindow* pNPWindow) {
logmsg(npsimple: setWindow\n);
return NPERR_NO_ERROR;
}

/* EXPORT */
#ifdef __cplusplus
extern C {
#endif
NPError OSCALL
NP_GetEntryPoints(NPPluginFuncs *nppfuncs) {
logmsg(npsimple: