check in (mostly) function nsPluginsDirUNIX, awaiting amusil's code to figure out mime types and stuff.
git-svn-id: svn://10.0.0.236/trunk@26701 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -29,11 +29,83 @@
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
/* Local helper functions */
|
||||
|
||||
static char* GetFileName(const char* pathname)
|
||||
{
|
||||
const char* filename = nsnull;
|
||||
|
||||
// this is most likely a path, so skip to the filename
|
||||
filename = PL_strrchr(pathname, '/');
|
||||
if(filename)
|
||||
++filename;
|
||||
else
|
||||
filename = pathname;
|
||||
|
||||
return PL_strdup(filename);
|
||||
}
|
||||
|
||||
static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||
{
|
||||
PRUint32 variants = 0;
|
||||
char* index = mimeTypes;
|
||||
while (*index)
|
||||
{
|
||||
if (*index == '|')
|
||||
variants++;
|
||||
|
||||
++index;
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
static char** MakeStringArray(PRUint32 variants, char* data)
|
||||
{
|
||||
char** buffer = NULL;
|
||||
char* index = data;
|
||||
PRUint32 count = 0;
|
||||
|
||||
buffer = (char **)PR_Malloc(variants * sizeof(char *));
|
||||
buffer[count++] = index;
|
||||
|
||||
while (*index && count<variants)
|
||||
{
|
||||
if (*index == '|')
|
||||
{
|
||||
buffer[count++] = index + 1;
|
||||
*index = 0;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* nsPluginsDir implementation */
|
||||
|
||||
nsPluginsDir::nsPluginsDir()
|
||||
{
|
||||
// this is somewhat lacking, in that it doesn't fall back to any other directories.
|
||||
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
|
||||
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
|
||||
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
|
||||
//
|
||||
|
||||
// use MOZILLA_FIVE_HOME/plugins
|
||||
|
||||
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
sysdir += "plugins";
|
||||
const char *pluginsDir = sysdir.GetCString(); // native path
|
||||
if (pluginsDir != NULL)
|
||||
{
|
||||
const char* allocPath;
|
||||
|
||||
allocPath = PL_strdup(pluginsDir);
|
||||
*(nsFileSpec*)this = allocPath;
|
||||
}
|
||||
}
|
||||
|
||||
nsPluginsDir::~nsPluginsDir()
|
||||
@@ -43,7 +115,11 @@ nsPluginsDir::~nsPluginsDir()
|
||||
|
||||
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
|
||||
{
|
||||
return PR_FALSE;
|
||||
const char* pathname = fileSpec.GetCString();
|
||||
|
||||
printf("IsPluginFile(%s)\n", pathname);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -67,7 +143,9 @@ nsPluginFile::~nsPluginFile()
|
||||
*/
|
||||
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
const char* path = this->GetCString();
|
||||
outLibrary = PR_LoadLibrary(path);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,5 +153,23 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
|
||||
*/
|
||||
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
/*
|
||||
** XXX this needs to change to probe the plugin for mime types/descriptions/etc.
|
||||
*/
|
||||
|
||||
const char *path = this->GetCString();
|
||||
|
||||
info.fName = GetFileName(path);
|
||||
info.fMimeType = "application/x-java-vm";
|
||||
info.fMimeDescription = "OJI Plugin";
|
||||
info.fExtensions = "class";
|
||||
|
||||
info.fVariantCount = CalculateVariantCount(info.fMimeType) + 1;
|
||||
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
||||
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
||||
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
||||
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,83 @@
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
/* Local helper functions */
|
||||
|
||||
static char* GetFileName(const char* pathname)
|
||||
{
|
||||
const char* filename = nsnull;
|
||||
|
||||
// this is most likely a path, so skip to the filename
|
||||
filename = PL_strrchr(pathname, '/');
|
||||
if(filename)
|
||||
++filename;
|
||||
else
|
||||
filename = pathname;
|
||||
|
||||
return PL_strdup(filename);
|
||||
}
|
||||
|
||||
static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||
{
|
||||
PRUint32 variants = 0;
|
||||
char* index = mimeTypes;
|
||||
while (*index)
|
||||
{
|
||||
if (*index == '|')
|
||||
variants++;
|
||||
|
||||
++index;
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
static char** MakeStringArray(PRUint32 variants, char* data)
|
||||
{
|
||||
char** buffer = NULL;
|
||||
char* index = data;
|
||||
PRUint32 count = 0;
|
||||
|
||||
buffer = (char **)PR_Malloc(variants * sizeof(char *));
|
||||
buffer[count++] = index;
|
||||
|
||||
while (*index && count<variants)
|
||||
{
|
||||
if (*index == '|')
|
||||
{
|
||||
buffer[count++] = index + 1;
|
||||
*index = 0;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* nsPluginsDir implementation */
|
||||
|
||||
nsPluginsDir::nsPluginsDir()
|
||||
{
|
||||
// this is somewhat lacking, in that it doesn't fall back to any other directories.
|
||||
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
|
||||
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
|
||||
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
|
||||
//
|
||||
|
||||
// use MOZILLA_FIVE_HOME/plugins
|
||||
|
||||
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
sysdir += "plugins";
|
||||
const char *pluginsDir = sysdir.GetCString(); // native path
|
||||
if (pluginsDir != NULL)
|
||||
{
|
||||
const char* allocPath;
|
||||
|
||||
allocPath = PL_strdup(pluginsDir);
|
||||
*(nsFileSpec*)this = allocPath;
|
||||
}
|
||||
}
|
||||
|
||||
nsPluginsDir::~nsPluginsDir()
|
||||
@@ -43,7 +115,11 @@ nsPluginsDir::~nsPluginsDir()
|
||||
|
||||
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
|
||||
{
|
||||
return PR_FALSE;
|
||||
const char* pathname = fileSpec.GetCString();
|
||||
|
||||
printf("IsPluginFile(%s)\n", pathname);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -67,7 +143,9 @@ nsPluginFile::~nsPluginFile()
|
||||
*/
|
||||
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
const char* path = this->GetCString();
|
||||
outLibrary = PR_LoadLibrary(path);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,5 +153,23 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
|
||||
*/
|
||||
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
#if 0
|
||||
/*
|
||||
** XXX this needs to change to probe the plugin for mime types/descriptions/etc.
|
||||
*/
|
||||
|
||||
const char *path = this->GetCString();
|
||||
|
||||
info.fName = GetFileName(path);
|
||||
info.fMimeType = "application/x-java-vm";
|
||||
info.fMimeDescription = "OJI Plugin";
|
||||
info.fExtensions = "class";
|
||||
|
||||
info.fVariantCount = CalculateVariantCount(info.fMimeType) + 1;
|
||||
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
||||
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
||||
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
||||
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user