Make plugins work on BeOS
Thanks to Makoto Hamanaka <VYA04230@nifty.com> for the patch Bug #68907 r=av git-svn-id: svn://10.0.0.236/trunk@98266 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -428,6 +428,45 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
|
||||
NS_ADDREF(*aResult);
|
||||
#endif
|
||||
|
||||
#ifdef XP_BEOS
|
||||
// I just copied UNIX version.
|
||||
// Makoto Hamanaka <VYA04230@nifty.com>
|
||||
|
||||
ns4xPlugin *plptr;
|
||||
|
||||
NPPluginFuncs callbacks;
|
||||
memset((void*) &callbacks, 0, sizeof(callbacks));
|
||||
callbacks.size = sizeof(callbacks);
|
||||
|
||||
NP_PLUGINSHUTDOWN pfnShutdown =
|
||||
(NP_PLUGINSHUTDOWN)PR_FindSymbol(aLibrary, "NP_Shutdown");
|
||||
|
||||
// create the new plugin handler
|
||||
*aResult = plptr = new ns4xPlugin(&callbacks, aLibrary, pfnShutdown, aServiceMgr);
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
// we must init here because the plugin may call NPN functions
|
||||
// when we call into the NP_Initialize entry point - NPN functions
|
||||
// require that mBrowserManager be set up
|
||||
plptr->Initialize();
|
||||
|
||||
NP_PLUGINUNIXINIT pfnInitialize =
|
||||
(NP_PLUGINUNIXINIT)PR_FindSymbol(aLibrary, "NP_Initialize");
|
||||
|
||||
if (pfnInitialize == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (pfnInitialize(&(ns4xPlugin::CALLBACKS),&callbacks) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// now copy function table back to ns4xPlugin instance
|
||||
memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Musil
|
||||
* Makoto Hamanaka <VYA04230@nifty.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -35,6 +37,13 @@
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include <File.h>
|
||||
#include <AppFileInfo.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
|
||||
//#define NS_PLUGIN_BEOS_DEBUG
|
||||
|
||||
/* Local helper functions */
|
||||
|
||||
static char* GetFileName(const char* pathname)
|
||||
@@ -51,18 +60,40 @@ static char* GetFileName(const char* pathname)
|
||||
return PL_strdup(filename);
|
||||
}
|
||||
|
||||
static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||
static nsresult GetMimeExtensions(const char *mimeType, char *extensions, int extLen)
|
||||
{
|
||||
PRUint32 variants = 0;
|
||||
char* ptr = mimeTypes;
|
||||
while (*ptr)
|
||||
{
|
||||
if (*ptr == ';')
|
||||
variants++;
|
||||
|
||||
++ptr;
|
||||
// check variables
|
||||
if (!mimeType || !extensions || extLen < 1) return NS_ERROR_FAILURE;
|
||||
extensions[0] = '\0';
|
||||
|
||||
// make mime object
|
||||
BMimeType mime(mimeType) ;
|
||||
if (mime.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get extensions : comma separated (if multiple extensions in a mime-type)
|
||||
// ex) "jpg,jpeg"
|
||||
BString extStr("");
|
||||
BMessage extMsg;
|
||||
mime.GetFileExtensions(&extMsg);
|
||||
uint32 type;
|
||||
int32 types_num;
|
||||
if (extMsg.GetInfo("extensions", &type, &types_num) != B_OK
|
||||
|| type != B_STRING_TYPE || types_num == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
for (int i = 0 ; i < types_num ; i ++) {
|
||||
const char *ext;
|
||||
if (extMsg.FindString("extensions", i, &ext) != B_OK) {
|
||||
break;
|
||||
}
|
||||
return variants;
|
||||
if (i > 0)
|
||||
extStr.Append(",");
|
||||
extStr.Append(ext);
|
||||
}
|
||||
PL_strncpyz(extensions, extStr.String(), extLen) ;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -144,82 +175,116 @@ typedef char* (*BeOS_Plugin_GetMIMEDescription)();
|
||||
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
const char *path = this->GetCString();
|
||||
char *mimedescr,*mdesc,*start,*nexttoc,*mtype,*exten,*descr;
|
||||
int i,num;
|
||||
int i;
|
||||
|
||||
BeOS_Plugin_GetMIMEDescription procedure = nsnull;
|
||||
mimedescr=(char *)"";
|
||||
|
||||
if((procedure = (BeOS_Plugin_GetMIMEDescription)PR_FindSymbol(pLibrary,"NP_GetMIMEDescription")) != 0) {
|
||||
mimedescr = procedure();
|
||||
} else {
|
||||
#ifdef NS_DEBUG
|
||||
printf("Cannot get plugin info: no GetMIMEDescription procedure!\n");
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf("nsPluginFile::GetPluginInfo() an attempt to load MIME String\n");
|
||||
printf("path = <%s>\n", path);
|
||||
#endif
|
||||
|
||||
// get supported mime types
|
||||
BFile file(path, B_READ_ONLY);
|
||||
if (file.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
info.fName = GetFileName(path);
|
||||
BAppFileInfo appinfo(&file);
|
||||
if (appinfo.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("GetMIMEDescription() %lx returned \"%s\"\n",
|
||||
(unsigned long)procedure, mimedescr);
|
||||
#endif
|
||||
BMessage msg;
|
||||
if (appinfo.GetSupportedTypes(&msg) != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// copy string
|
||||
|
||||
mdesc = (char *)PR_Malloc(strlen(mimedescr)+1);
|
||||
strcpy(mdesc,mimedescr);
|
||||
num=CalculateVariantCount(mimedescr)+1;
|
||||
info.fVariantCount = num;
|
||||
uint32 type;
|
||||
int32 types_num;
|
||||
if (msg.GetInfo("types", &type, &types_num) != B_OK
|
||||
|| type != B_STRING_TYPE)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
// set mime types to plugin info
|
||||
info.fMimeTypeArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
info.fMimeDescriptionArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
info.fExtensionArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
|
||||
start=mdesc;
|
||||
for(i=0;i<num && *start;i++) {
|
||||
// search start of next token (separator is ';')
|
||||
|
||||
if(i+1 < num) {
|
||||
if((nexttoc=PL_strchr(start, ';')) != 0)
|
||||
*nexttoc++=0;
|
||||
else
|
||||
nexttoc=start+strlen(start);
|
||||
} else
|
||||
nexttoc=start+strlen(start);
|
||||
|
||||
// split string into: mime type ':' extensions ':' description
|
||||
|
||||
mtype=start;
|
||||
exten=PL_strchr(start, ':');
|
||||
if(exten) {
|
||||
*exten++=0;
|
||||
descr=PL_strchr(exten, ':');
|
||||
} else
|
||||
descr=NULL;
|
||||
|
||||
if(descr)
|
||||
*descr++=0;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("Registering plugin for: \"%s\",\"%s\",\"%s\"\n", mtype,descr ? descr : "null",exten ? exten : "null");
|
||||
#endif
|
||||
|
||||
if(!*mtype && !descr && !exten) {
|
||||
i--;
|
||||
info.fVariantCount--;
|
||||
} else {
|
||||
info.fMimeTypeArray[i] = mtype ? mtype : (char *)"";
|
||||
info.fMimeDescriptionArray[i] = descr ? descr : (char *)"";
|
||||
info.fExtensionArray[i] = exten ? exten : (char *)"";
|
||||
for (i = 0 ; i < types_num ; i ++) {
|
||||
// get mime string
|
||||
const char *mtype;
|
||||
if (msg.FindString("types", i, &mtype) != B_OK) {
|
||||
types_num = i;
|
||||
break;
|
||||
}
|
||||
start=nexttoc;
|
||||
|
||||
// get (short)description for the mime
|
||||
char desc[B_MIME_TYPE_LENGTH+1] = "";
|
||||
BMimeType mime(mtype) ;
|
||||
if (mime.InitCheck() == B_OK)
|
||||
mime.GetShortDescription(desc);
|
||||
|
||||
// get file extensions for the mime
|
||||
char extensions[B_MIME_TYPE_LENGTH+1] = "";
|
||||
GetMimeExtensions(mtype, extensions, B_MIME_TYPE_LENGTH+1);
|
||||
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf(" mime = %30s | %10s | %15s |\n",
|
||||
mtype, extensions, desc);
|
||||
#endif
|
||||
|
||||
info.fMimeTypeArray[i] = PL_strdup( mtype ? mtype : (char *)"" ) ;
|
||||
info.fMimeDescriptionArray[i] = PL_strdup( desc ) ;
|
||||
info.fExtensionArray[i] = PL_strdup( extensions );
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// get name and description of this plugin
|
||||
version_info vinfo;
|
||||
if (appinfo.GetVersionInfo(&vinfo, B_APP_VERSION_KIND) == B_OK
|
||||
&& strlen(vinfo.short_info) > 0) {
|
||||
// XXX convert UTF-8 2byte chars to 1 byte chars, to avoid string corruption
|
||||
info.fName = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.short_info).ToNewCString());
|
||||
info.fDescription = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.long_info).ToNewCString());
|
||||
} else {
|
||||
// use filename as its name
|
||||
info.fName = GetFileName(path);
|
||||
info.fDescription = PL_strdup("");
|
||||
}
|
||||
|
||||
info.fVariantCount = types_num;
|
||||
info.fFileName = PL_strdup(path);
|
||||
|
||||
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf("info.fFileName = %s\n", info.fFileName);
|
||||
printf("info.fName = %s\n", info.fName);
|
||||
printf("info.fDescription = %s\n", info.fDescription);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
if (info.fName)
|
||||
PL_strfree(info.fName);
|
||||
|
||||
if (info.fDescription)
|
||||
PL_strfree(info.fDescription);
|
||||
|
||||
for (PRUint32 i = 0; i < info.fVariantCount; i++) {
|
||||
if (info.fMimeTypeArray[i])
|
||||
PL_strfree(info.fMimeTypeArray[i]);
|
||||
|
||||
if (info.fMimeDescriptionArray[i])
|
||||
PL_strfree(info.fMimeDescriptionArray[i]);
|
||||
|
||||
if (info.fExtensionArray[i])
|
||||
PL_strfree(info.fExtensionArray[i]);
|
||||
}
|
||||
|
||||
PR_FREEIF(info.fMimeTypeArray);
|
||||
PR_FREEIF(info.fMimeDescriptionArray);
|
||||
PR_FREEIF(info.fExtensionArray);
|
||||
|
||||
if (info.fFileName)
|
||||
PL_strfree(info.fFileName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -428,6 +428,45 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
|
||||
NS_ADDREF(*aResult);
|
||||
#endif
|
||||
|
||||
#ifdef XP_BEOS
|
||||
// I just copied UNIX version.
|
||||
// Makoto Hamanaka <VYA04230@nifty.com>
|
||||
|
||||
ns4xPlugin *plptr;
|
||||
|
||||
NPPluginFuncs callbacks;
|
||||
memset((void*) &callbacks, 0, sizeof(callbacks));
|
||||
callbacks.size = sizeof(callbacks);
|
||||
|
||||
NP_PLUGINSHUTDOWN pfnShutdown =
|
||||
(NP_PLUGINSHUTDOWN)PR_FindSymbol(aLibrary, "NP_Shutdown");
|
||||
|
||||
// create the new plugin handler
|
||||
*aResult = plptr = new ns4xPlugin(&callbacks, aLibrary, pfnShutdown, aServiceMgr);
|
||||
|
||||
if (*aResult == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
// we must init here because the plugin may call NPN functions
|
||||
// when we call into the NP_Initialize entry point - NPN functions
|
||||
// require that mBrowserManager be set up
|
||||
plptr->Initialize();
|
||||
|
||||
NP_PLUGINUNIXINIT pfnInitialize =
|
||||
(NP_PLUGINUNIXINIT)PR_FindSymbol(aLibrary, "NP_Initialize");
|
||||
|
||||
if (pfnInitialize == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (pfnInitialize(&(ns4xPlugin::CALLBACKS),&callbacks) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// now copy function table back to ns4xPlugin instance
|
||||
memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alex Musil
|
||||
* Makoto Hamanaka <VYA04230@nifty.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -35,6 +37,13 @@
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include <File.h>
|
||||
#include <AppFileInfo.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
|
||||
//#define NS_PLUGIN_BEOS_DEBUG
|
||||
|
||||
/* Local helper functions */
|
||||
|
||||
static char* GetFileName(const char* pathname)
|
||||
@@ -51,18 +60,40 @@ static char* GetFileName(const char* pathname)
|
||||
return PL_strdup(filename);
|
||||
}
|
||||
|
||||
static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||
static nsresult GetMimeExtensions(const char *mimeType, char *extensions, int extLen)
|
||||
{
|
||||
PRUint32 variants = 0;
|
||||
char* ptr = mimeTypes;
|
||||
while (*ptr)
|
||||
{
|
||||
if (*ptr == ';')
|
||||
variants++;
|
||||
|
||||
++ptr;
|
||||
// check variables
|
||||
if (!mimeType || !extensions || extLen < 1) return NS_ERROR_FAILURE;
|
||||
extensions[0] = '\0';
|
||||
|
||||
// make mime object
|
||||
BMimeType mime(mimeType) ;
|
||||
if (mime.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get extensions : comma separated (if multiple extensions in a mime-type)
|
||||
// ex) "jpg,jpeg"
|
||||
BString extStr("");
|
||||
BMessage extMsg;
|
||||
mime.GetFileExtensions(&extMsg);
|
||||
uint32 type;
|
||||
int32 types_num;
|
||||
if (extMsg.GetInfo("extensions", &type, &types_num) != B_OK
|
||||
|| type != B_STRING_TYPE || types_num == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
for (int i = 0 ; i < types_num ; i ++) {
|
||||
const char *ext;
|
||||
if (extMsg.FindString("extensions", i, &ext) != B_OK) {
|
||||
break;
|
||||
}
|
||||
return variants;
|
||||
if (i > 0)
|
||||
extStr.Append(",");
|
||||
extStr.Append(ext);
|
||||
}
|
||||
PL_strncpyz(extensions, extStr.String(), extLen) ;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -144,82 +175,116 @@ typedef char* (*BeOS_Plugin_GetMIMEDescription)();
|
||||
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
const char *path = this->GetCString();
|
||||
char *mimedescr,*mdesc,*start,*nexttoc,*mtype,*exten,*descr;
|
||||
int i,num;
|
||||
int i;
|
||||
|
||||
BeOS_Plugin_GetMIMEDescription procedure = nsnull;
|
||||
mimedescr=(char *)"";
|
||||
|
||||
if((procedure = (BeOS_Plugin_GetMIMEDescription)PR_FindSymbol(pLibrary,"NP_GetMIMEDescription")) != 0) {
|
||||
mimedescr = procedure();
|
||||
} else {
|
||||
#ifdef NS_DEBUG
|
||||
printf("Cannot get plugin info: no GetMIMEDescription procedure!\n");
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf("nsPluginFile::GetPluginInfo() an attempt to load MIME String\n");
|
||||
printf("path = <%s>\n", path);
|
||||
#endif
|
||||
|
||||
// get supported mime types
|
||||
BFile file(path, B_READ_ONLY);
|
||||
if (file.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
info.fName = GetFileName(path);
|
||||
BAppFileInfo appinfo(&file);
|
||||
if (appinfo.InitCheck() != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("GetMIMEDescription() %lx returned \"%s\"\n",
|
||||
(unsigned long)procedure, mimedescr);
|
||||
#endif
|
||||
BMessage msg;
|
||||
if (appinfo.GetSupportedTypes(&msg) != B_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// copy string
|
||||
|
||||
mdesc = (char *)PR_Malloc(strlen(mimedescr)+1);
|
||||
strcpy(mdesc,mimedescr);
|
||||
num=CalculateVariantCount(mimedescr)+1;
|
||||
info.fVariantCount = num;
|
||||
uint32 type;
|
||||
int32 types_num;
|
||||
if (msg.GetInfo("types", &type, &types_num) != B_OK
|
||||
|| type != B_STRING_TYPE)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *));
|
||||
// set mime types to plugin info
|
||||
info.fMimeTypeArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
info.fMimeDescriptionArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
info.fExtensionArray =(char **)PR_Malloc(types_num * sizeof(char *));
|
||||
|
||||
start=mdesc;
|
||||
for(i=0;i<num && *start;i++) {
|
||||
// search start of next token (separator is ';')
|
||||
|
||||
if(i+1 < num) {
|
||||
if((nexttoc=PL_strchr(start, ';')) != 0)
|
||||
*nexttoc++=0;
|
||||
else
|
||||
nexttoc=start+strlen(start);
|
||||
} else
|
||||
nexttoc=start+strlen(start);
|
||||
|
||||
// split string into: mime type ':' extensions ':' description
|
||||
|
||||
mtype=start;
|
||||
exten=PL_strchr(start, ':');
|
||||
if(exten) {
|
||||
*exten++=0;
|
||||
descr=PL_strchr(exten, ':');
|
||||
} else
|
||||
descr=NULL;
|
||||
|
||||
if(descr)
|
||||
*descr++=0;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("Registering plugin for: \"%s\",\"%s\",\"%s\"\n", mtype,descr ? descr : "null",exten ? exten : "null");
|
||||
#endif
|
||||
|
||||
if(!*mtype && !descr && !exten) {
|
||||
i--;
|
||||
info.fVariantCount--;
|
||||
} else {
|
||||
info.fMimeTypeArray[i] = mtype ? mtype : (char *)"";
|
||||
info.fMimeDescriptionArray[i] = descr ? descr : (char *)"";
|
||||
info.fExtensionArray[i] = exten ? exten : (char *)"";
|
||||
for (i = 0 ; i < types_num ; i ++) {
|
||||
// get mime string
|
||||
const char *mtype;
|
||||
if (msg.FindString("types", i, &mtype) != B_OK) {
|
||||
types_num = i;
|
||||
break;
|
||||
}
|
||||
start=nexttoc;
|
||||
|
||||
// get (short)description for the mime
|
||||
char desc[B_MIME_TYPE_LENGTH+1] = "";
|
||||
BMimeType mime(mtype) ;
|
||||
if (mime.InitCheck() == B_OK)
|
||||
mime.GetShortDescription(desc);
|
||||
|
||||
// get file extensions for the mime
|
||||
char extensions[B_MIME_TYPE_LENGTH+1] = "";
|
||||
GetMimeExtensions(mtype, extensions, B_MIME_TYPE_LENGTH+1);
|
||||
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf(" mime = %30s | %10s | %15s |\n",
|
||||
mtype, extensions, desc);
|
||||
#endif
|
||||
|
||||
info.fMimeTypeArray[i] = PL_strdup( mtype ? mtype : (char *)"" ) ;
|
||||
info.fMimeDescriptionArray[i] = PL_strdup( desc ) ;
|
||||
info.fExtensionArray[i] = PL_strdup( extensions );
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
// get name and description of this plugin
|
||||
version_info vinfo;
|
||||
if (appinfo.GetVersionInfo(&vinfo, B_APP_VERSION_KIND) == B_OK
|
||||
&& strlen(vinfo.short_info) > 0) {
|
||||
// XXX convert UTF-8 2byte chars to 1 byte chars, to avoid string corruption
|
||||
info.fName = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.short_info).ToNewCString());
|
||||
info.fDescription = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.long_info).ToNewCString());
|
||||
} else {
|
||||
// use filename as its name
|
||||
info.fName = GetFileName(path);
|
||||
info.fDescription = PL_strdup("");
|
||||
}
|
||||
|
||||
info.fVariantCount = types_num;
|
||||
info.fFileName = PL_strdup(path);
|
||||
|
||||
|
||||
#ifdef NS_PLUGIN_BEOS_DEBUG
|
||||
printf("info.fFileName = %s\n", info.fFileName);
|
||||
printf("info.fName = %s\n", info.fName);
|
||||
printf("info.fDescription = %s\n", info.fDescription);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
if (info.fName)
|
||||
PL_strfree(info.fName);
|
||||
|
||||
if (info.fDescription)
|
||||
PL_strfree(info.fDescription);
|
||||
|
||||
for (PRUint32 i = 0; i < info.fVariantCount; i++) {
|
||||
if (info.fMimeTypeArray[i])
|
||||
PL_strfree(info.fMimeTypeArray[i]);
|
||||
|
||||
if (info.fMimeDescriptionArray[i])
|
||||
PL_strfree(info.fMimeDescriptionArray[i]);
|
||||
|
||||
if (info.fExtensionArray[i])
|
||||
PL_strfree(info.fExtensionArray[i]);
|
||||
}
|
||||
|
||||
PR_FREEIF(info.fMimeTypeArray);
|
||||
PR_FREEIF(info.fMimeDescriptionArray);
|
||||
PR_FREEIF(info.fExtensionArray);
|
||||
|
||||
if (info.fFileName)
|
||||
PL_strfree(info.fFileName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user