Bug 427743: Expose file version of plugins. r+sr=jst

This commit is contained in:
Dave Townsend 2008-07-15 11:50:42 +01:00
Родитель de50ace5ca
Коммит 95e762fed9
14 изменённых файлов: 115 добавлений и 4 удалений

Просмотреть файл

@ -707,6 +707,7 @@ extern "C" {
/* plugin meta member functions */
NP_EXPORT(char*) NP_GetPluginVersion(void);
NP_EXPORT(char*) NP_GetMIMEDescription(void);
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*);
NP_EXPORT(NPError) NP_Shutdown(void);

Просмотреть файл

@ -38,11 +38,12 @@
#include "nsISupports.idl"
[scriptable, uuid(af36bf4d-5652-413f-a78c-745b702f2381)]
[scriptable, uuid(13a1b39e-72e5-442d-aa73-5905ffaf837b)]
interface nsIPluginTag : nsISupports
{
readonly attribute AUTF8String description;
readonly attribute AUTF8String filename;
readonly attribute AUTF8String version;
readonly attribute AUTF8String name;
attribute boolean disabled;
attribute boolean blocklisted;

Просмотреть файл

@ -202,7 +202,8 @@
// 0.07 changed nsIRegistry to flat file support for caching plugins info
// 0.08 mime entry point on MachO, bug 137535
// 0.09 the file encoding is changed to UTF-8, bug 420285
static const char *kPluginRegistryVersion = "0.09";
// 0.10 added plugin versions on appropriate platforms, bug 427743
static const char *kPluginRegistryVersion = "0.10";
////////////////////////////////////////////////////////////////////////
// CID's && IID's
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
@ -744,6 +745,7 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
mIsNPRuntimeEnabledJavaPlugin(aPluginTag->mIsNPRuntimeEnabledJavaPlugin),
mFileName(aPluginTag->mFileName),
mFullPath(aPluginTag->mFullPath),
mVersion(aPluginTag->mVersion),
mLastModifiedTime(0),
mFlags(NS_PLUGIN_FLAG_ENABLED)
{
@ -783,6 +785,7 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
mIsNPRuntimeEnabledJavaPlugin(PR_FALSE),
mFileName(aPluginInfo->fFileName),
mFullPath(aPluginInfo->fFullPath),
mVersion(aPluginInfo->fVersion),
mLastModifiedTime(0),
mFlags(NS_PLUGIN_FLAG_ENABLED)
{
@ -857,6 +860,7 @@ nsPluginTag::nsPluginTag(const char* aName,
const char* aDescription,
const char* aFileName,
const char* aFullPath,
const char* aVersion,
const char* const* aMimeTypes,
const char* const* aMimeDescriptions,
const char* const* aExtensions,
@ -878,6 +882,7 @@ nsPluginTag::nsPluginTag(const char* aName,
mIsNPRuntimeEnabledJavaPlugin(PR_FALSE),
mFileName(aFileName),
mFullPath(aFullPath),
mVersion(aVersion),
mLastModifiedTime(aLastModifiedTime),
mFlags(0) // Caller will read in our flags from cache
{
@ -1020,6 +1025,13 @@ nsPluginTag::GetFilename(nsACString& aFileName)
return NS_OK;
}
NS_IMETHODIMP
nsPluginTag::GetVersion(nsACString& aVersion)
{
aVersion = mVersion;
return NS_OK;
}
NS_IMETHODIMP
nsPluginTag::GetName(nsACString& aName)
{
@ -5588,12 +5600,15 @@ nsPluginHostImpl::WritePluginInfo()
// store each plugin info into the registry
// filename & fullpath are on separate line
// because they can contain field delimiter char
PR_fprintf(fd, "%s%c%c\n%s%c%c\n",
PR_fprintf(fd, "%s%c%c\n%s%c%c\n%s%c%c\n",
(!tag->mFileName.IsEmpty() ? tag->mFileName.get() : ""),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
(!tag->mFullPath.IsEmpty() ? tag->mFullPath.get() : ""),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
(!tag->mVersion.IsEmpty() ? tag->mVersion.get() : ""),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER);
// lastModifiedTimeStamp|canUnload|tag->mFlags
@ -5749,6 +5764,10 @@ nsPluginHostImpl::ReadPluginInfo()
if (!reader.NextLine())
return rv;
char *version = reader.LinePtr();
if (!reader.NextLine())
return rv;
// lastModifiedTimeStamp|canUnload|tag.mFlag
if (3 != reader.ParseLine(values, 3))
return rv;
@ -5810,6 +5829,7 @@ nsPluginHostImpl::ReadPluginInfo()
description,
filename,
(*fullpath ? fullpath : 0), // we have to pass 0 prt if it's empty str
version,
(const char* const*)mimetypes,
(const char* const*)mimedescriptions,
(const char* const*)extensions,

Просмотреть файл

@ -104,6 +104,7 @@ public:
const char* aDescription,
const char* aFileName,
const char* aFullPath,
const char* aVersion,
const char* const* aMimeTypes,
const char* const* aMimeDescriptions,
const char* const* aExtensions,
@ -166,6 +167,7 @@ public:
PRPackedBool mIsNPRuntimeEnabledJavaPlugin;
nsCString mFileName; // UTF-8
nsCString mFullPath; // UTF-8
nsCString mVersion; // UTF-8
PRInt64 mLastModifiedTime;
private:
PRUint32 mFlags;

Просмотреть файл

@ -66,6 +66,7 @@ struct nsPluginInfo {
char** fExtensionArray;
char* fFileName;
char* fFullPath;
char* fVersion;
#ifdef XP_MACOSX
PRBool fBundle;
#endif

Просмотреть файл

@ -163,6 +163,7 @@ typedef char* (*BeOS_Plugin_GetMIMEDescription)();
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
info.fVersion = nsnull;
nsCAutoString fpath;
nsresult rv = mPlugin->GetNativePath(fpath);
if (NS_OK != rv) {
@ -280,5 +281,8 @@ nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
if (info.fFileName)
PL_strfree(info.fFileName);
if (info.fVersion)
PL_strfree(info.fFileVersion);
return NS_OK;
}

Просмотреть файл

@ -325,9 +325,22 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
info.fFileName = p2cstrdup(spec.name);
info.fFullPath = PL_strdup(path.get());
info.fVersion = nsnull;
CFBundleRef bundle = getPluginBundle(path.get());
if (bundle) {
info.fBundle = PR_TRUE;
// Look for the release version first
CFStringRef version = (CFStringRef)::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("CFBundleShortVersionString"));
// If not try the build version
if (!version)
version = (CFStringRef)::CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey);
if (version) {
CFIndex versionLength = ::CFStringGetLength(version);
info.fVersion = (char*)malloc(versionLength + 1);
if (! ::CFStringGetCString(version, info.fVersion, versionLength + 1,
kCFStringEncodingUTF8))
delete[] info.fVersion;
}
CFRelease(bundle);
}
else {
@ -426,6 +439,7 @@ nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
delete[] info.fExtensionArray;
delete[] info.fFileName;
delete[] info.fFullPath;
delete[] info.fVersion;
}
return NS_OK;

Просмотреть файл

@ -195,6 +195,7 @@ nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
mPlugin->GetNativePath(temp);
path = temp.get();
ret = DosLoadModule( failure, CCHMAXPATH, path, &hPlug);
info.fVersion = nsnull;
while( ret == NO_ERROR)
{
@ -242,6 +243,12 @@ nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
if(info.fName != nsnull)
PL_strfree(info.fName);
if(info.fFileName != nsnull)
PL_strfree(info.fFileName);
if(info.fVersion != nsnull)
PL_strfree(info.fFileVersion);
if(info.fDescription != nsnull)
PL_strfree(info.fDescription);

Просмотреть файл

@ -441,6 +441,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
nsCOMPtr<nsIPlugin> plugin;
info.fVersion = nsnull;
if (nsGetFactory) {
// It's an almost-new-style plugin. The "truly new" plugins
// are just XPCOM components, but there are some Mozilla
@ -473,6 +474,11 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
}
if (plugin) {
const char* (*npGetPluginVersion)() =
(const char* (*)()) PR_FindFunctionSymbol(pLibrary, "NP_GetPluginVersion");
if (npGetPluginVersion)
info.fVersion = PL_strdup(npGetPluginVersion());
plugin->GetMIMEDescription(&mimedescr);
#ifdef NS_DEBUG
printf("GetMIMEDescription() returned \"%s\"\n", mimedescr);
@ -523,5 +529,8 @@ nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
if (info.fFileName != nsnull)
PL_strfree(info.fFileName);
if (info.fVersion != nsnull)
PL_strfree(info.fVersion);
return NS_OK;
}

Просмотреть файл

@ -82,6 +82,27 @@ static char* GetKeyValue(char* verbuf, char* key)
return nsnull;
}
static char* GetVersion(char* verbuf)
{
VS_FIXEDFILEINFO *fileInfo;
UINT fileInfoLen;
::VerQueryValue(verbuf,
"\\",
(void **)&fileInfo, &fileInfoLen);
if (fileInfo != NULL)
{
return PR_smprintf("%ld.%ld.%ld.%ld",
HIWORD(fileInfo->dwFileVersionMS),
LOWORD(fileInfo->dwFileVersionMS),
HIWORD(fileInfo->dwFileVersionLS),
LOWORD(fileInfo->dwFileVersionLS));
}
return nsnull;
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 1;
@ -287,6 +308,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
info.fFileName = PL_strdup(path);
info.fVersion = GetVersion(verbuf);
PL_strfree(mimeType);
PL_strfree(mimeDescription);
@ -321,6 +343,9 @@ nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
if(info.fFileName != NULL)
PL_strfree(info.fFileName);
if(info.fVersion != NULL)
PL_strfree(info.fVersion);
ZeroMemory((void *)&info, sizeof(info));
return NS_OK;

Просмотреть файл

@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>MOSS</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.0.0.15</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>

Просмотреть файл

@ -458,6 +458,17 @@ Private_Print(NPP instance, NPPrint* platformPrint)
*
***********************************************************************/
/*
* NP_GetPluginVersion [optional]
* - The browser uses the return value to indicate to the user what version of
* this plugin is installed.
*/
char *
NP_GetPluginVersion(void)
{
return "1.0.0.15";
}
/*
* NP_GetMIMEDescription
* - Netscape needs to know about this symbol

Просмотреть файл

@ -347,6 +347,17 @@ Private_Print(NPP instance, NPPrint* platformPrint)
*
***********************************************************************/
/*
* NP_GetPluginVersion [optional]
* - The browser uses the return value to indicate to the user what version of
* this plugin is installed.
*/
char *
NP_GetPluginVersion(void)
{
return "1.0.0";
}
/*
* NP_GetMIMEDescription
* - Netscape needs to know about this symbol

Просмотреть файл

@ -927,6 +927,7 @@ function rebuildPluginsDS()
homepageURL = /<A\s+HREF=["']?([^>"'\s]*)/i.exec(plugin.description)[1];
gPlugins[name][desc] = { filename : plugin.filename,
version : plugin.version,
homepageURL : homepageURL,
disabled : plugin.disabled,
blocklisted : plugin.blocklisted,
@ -944,6 +945,10 @@ function rebuildPluginsDS()
gRDF.GetResource(PREFIX_NS_EM + "name"),
gRDF.GetLiteral(pluginName),
true);
gPluginsDS.Assert(pluginNode,
gRDF.GetResource(PREFIX_NS_EM + "version"),
gRDF.GetLiteral(plugin.version),
true);
gPluginsDS.Assert(pluginNode,
gRDF.GetResource(PREFIX_NS_EM + "addonID"),
gRDF.GetLiteral(plugin.filename),