mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Remove default plugins. b=533891 r=dolske sr=jst
This commit is contained in:
parent
d7b3a7ecaf
commit
eb08772da3
@ -536,9 +536,6 @@ pref("accessibility.typeaheadfind.timeout", 5000);
|
||||
pref("accessibility.typeaheadfind.linksonly", false);
|
||||
pref("accessibility.typeaheadfind.flashBar", 1);
|
||||
|
||||
// Disable the default plugin for firefox
|
||||
pref("plugin.default_plugin_disabled", true);
|
||||
|
||||
// plugin finder service url
|
||||
pref("pfs.datasource.url", "https://pfs.mozilla.org/plugins/PluginFinderService.php?mimetype=%PLUGIN_MIMETYPE%&appID=%APP_ID%&appVersion=%APP_VERSION%&clientOS=%CLIENT_OS%&chromeLocale=%CHROME_LOCALE%&appRelease=%APP_RELEASE%");
|
||||
|
||||
|
@ -79,17 +79,6 @@
|
||||
#endif
|
||||
@BINPATH@/application.ini
|
||||
@BINPATH@/platform.ini
|
||||
#ifdef XP_MACOSX
|
||||
@BINPATH@/plugins/DefaultPlugin.plugin/
|
||||
#elifdef XP_UNIX
|
||||
@BINPATH@/plugins/libnullplugin@DLL_SUFFIX@
|
||||
#elifdef XP_WIN32
|
||||
#ifndef WINCE
|
||||
@BINPATH@/plugins/npnul32.dll
|
||||
#endif
|
||||
#elifdef XP_OS2
|
||||
@BINPATH@/plugins/npnulos2.dll
|
||||
#endif
|
||||
#ifndef XP_OS2
|
||||
@BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@
|
||||
#else
|
||||
|
@ -708,6 +708,14 @@ xpicleanup@BIN_SUFFIX@
|
||||
plugins/Default Plugin.plugin/Contents/PkgInfo
|
||||
plugins/Default Plugin.plugin/Contents/Resources/Default Plugin.rsrc
|
||||
plugins/Default Plugin.plugin/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
plugins/DefaultPlugin.plugin/
|
||||
plugins/DefaultPlugin.plugin/Contents/Info.plist
|
||||
plugins/DefaultPlugin.plugin/Contents/MacOS/
|
||||
plugins/DefaultPlugin.plugin/Contents/MacOS/DefaultPlugin
|
||||
plugins/DefaultPlugin.plugin/Contents/Resources/
|
||||
plugins/DefaultPlugin.plugin/Contents/Resources/English.lproj/
|
||||
plugins/DefaultPlugin.plugin/Contents/Resources/English.lproj/InfoPlist.strings
|
||||
plugins/DefaultPlugin.plugin/Contents/Resources/plugin.png
|
||||
redo-prebinding.sh
|
||||
res/bloatcycle.html
|
||||
res/cursors/CVS/Entries
|
||||
@ -726,6 +734,7 @@ xpicleanup@BIN_SUFFIX@
|
||||
icons/mozicon16.xpm
|
||||
icons/mozicon50.xpm
|
||||
libjemalloc.so
|
||||
plugins/libnullplugin.so
|
||||
readme.txt
|
||||
#endif
|
||||
#endif
|
||||
@ -737,6 +746,7 @@ xpicleanup@BIN_SUFFIX@
|
||||
components/jsd3250.dll
|
||||
components/nsPostUpdateWin.js
|
||||
js3250.dll
|
||||
plugins/npnul32.dll
|
||||
#ifdef MOZ_MEMORY
|
||||
Microsoft.VC80.CRT.manifest
|
||||
msvcm80.dll
|
||||
|
@ -1718,14 +1718,6 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType)
|
||||
return eType_Plugin;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> thisContent =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
NS_ASSERTION(thisContent, "must be a content");
|
||||
|
||||
if (ShouldShowDefaultPlugin(thisContent, aMIMEType)) {
|
||||
return eType_Plugin;
|
||||
}
|
||||
|
||||
return eType_Null;
|
||||
}
|
||||
|
||||
@ -1948,17 +1940,6 @@ nsObjectLoadingContent::CheckClassifier(nsIChannel *aChannel)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ PRBool
|
||||
nsObjectLoadingContent::ShouldShowDefaultPlugin(nsIContent* aContent,
|
||||
const nsCString& aContentType)
|
||||
{
|
||||
if (nsContentUtils::GetBoolPref("plugin.default_plugin_disabled", PR_FALSE)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return GetPluginSupportState(aContent, aContentType) == ePluginUnsupported;
|
||||
}
|
||||
|
||||
/* static */ PluginSupportState
|
||||
nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
|
||||
const nsCString& aContentType)
|
||||
|
@ -335,14 +335,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
*/
|
||||
nsresult CheckClassifier(nsIChannel *aChannel);
|
||||
|
||||
/**
|
||||
* Whether to treat this content as a plugin, even though we can't handle
|
||||
* the type. This function impl should match the checks in the plugin host.
|
||||
* aContentType is the MIME type we ended up with.
|
||||
*/
|
||||
static PRBool ShouldShowDefaultPlugin(nsIContent* aContent,
|
||||
const nsCString& aContentType);
|
||||
|
||||
/**
|
||||
* Get the plugin support state for the given content node and MIME type.
|
||||
* This is used for purposes of determining whether to fire PluginNotFound
|
||||
|
@ -56,24 +56,6 @@ endif
|
||||
# These subdirs rely on GTK libraries and header files, it is not
|
||||
# buildable on other non-GTK unix builds
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
TOOL_DIRS += default/unix
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
TOOL_DIRS += default/windows
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
TOOL_DIRS += default/os2
|
||||
endif
|
||||
|
||||
ifdef PBBUILD_BIN
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
TOOL_DIRS += default/mac
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
ifneq (,$(filter WINNT Darwin Linux OS2 SunOS,$(OS_ARCH)))
|
||||
DIRS += test
|
||||
|
@ -48,7 +48,6 @@ GRE_MODULE = 1
|
||||
EXPORTS = \
|
||||
nsPluginLogging.h \
|
||||
nsPluginError.h \
|
||||
nsDefaultPlugin.h \
|
||||
nsPluginNativeWindow.h \
|
||||
nsPluginsCID.h \
|
||||
$(NULL)
|
||||
|
@ -1,46 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _DEFAULT_H_
|
||||
#define _DEFAULT_H_
|
||||
|
||||
// This mimetype is reserved for use with the Netscape
|
||||
// Default Plugin only. Using it in any other plugin will break
|
||||
// the basic functionality of the Mozilla based browsers
|
||||
#define NS_PLUGIN_DEFAULT_MIME_DESCRIPTION "*"
|
||||
|
||||
#endif // _DEFAULT_H_
|
@ -137,7 +137,6 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsPluginManifestLineReader.h"
|
||||
|
||||
#include "nsDefaultPlugin.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLObjectElement.h"
|
||||
@ -1513,24 +1512,10 @@ nsPluginHost::nsPluginHost()
|
||||
mOverrideInternalTypes = tmp;
|
||||
}
|
||||
|
||||
rv = mPrefService->GetBoolPref("plugin.allow_alien_star_handler", &tmp);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mAllowAlienStarHandler = tmp;
|
||||
}
|
||||
|
||||
rv = mPrefService->GetBoolPref("plugin.default_plugin_disabled", &tmp);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mDefaultPluginDisabled = tmp;
|
||||
}
|
||||
|
||||
rv = mPrefService->GetBoolPref("plugin.disable", &tmp);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mPluginsDisabled = tmp;
|
||||
}
|
||||
|
||||
#ifdef WINCE
|
||||
mDefaultPluginDisabled = PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
@ -2194,8 +2179,6 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
|
||||
}
|
||||
|
||||
// Look for even disabled plugins, because if the plugin for this type is
|
||||
// disabled, we don't want to go on and end up in SetUpDefaultPluginInstance.
|
||||
nsPluginTag* pluginTag = FindPluginForType(aMimeType, PR_FALSE);
|
||||
if (pluginTag) {
|
||||
if (!pluginTag->IsEnabled())
|
||||
@ -2245,37 +2228,10 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
|
||||
rv = SetUpPluginInstance(aMimeType, aURL, aOwner);
|
||||
|
||||
if (rv == NS_OK) {
|
||||
rv = aOwner->GetInstance(instance);
|
||||
} else {
|
||||
/* If we are here, it's time to either show the default plugin
|
||||
* or return failure so layout will replace us.
|
||||
*
|
||||
* Currently, the default plugin is shown for all EMBED and APPLET
|
||||
* tags and also any OBJECT tag that has a PLUGINURL PARAM tag name.
|
||||
*/
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool bHasPluginURL = PR_FALSE;
|
||||
nsCOMPtr<nsIPluginTagInfo> pti(do_QueryInterface(aOwner));
|
||||
|
||||
if (pti) {
|
||||
const char *value;
|
||||
bHasPluginURL = NS_SUCCEEDED(pti->GetParameter("PLUGINURL", &value));
|
||||
}
|
||||
|
||||
// if we didn't find a pluginURL param on the object tag,
|
||||
// there's nothing more to do here
|
||||
if (nsPluginTagType_Object == tagType && !bHasPluginURL)
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(SetUpDefaultPluginInstance(aMimeType, aURL, aOwner)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_FAILED(aOwner->GetInstance(instance)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = NS_OK;
|
||||
}
|
||||
rv = aOwner->GetInstance(instance);
|
||||
|
||||
// if we have a failure error, it means we found a plugin for the mimetype,
|
||||
// but we had a problem with the entry point
|
||||
@ -2283,7 +2239,6 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
return rv;
|
||||
|
||||
// if we are here then we have loaded a plugin for this mimetype
|
||||
// and it could be the Default plugin
|
||||
|
||||
NPWindow *window = nsnull;
|
||||
|
||||
@ -2458,8 +2413,7 @@ nsresult nsPluginHost::FindStoppedPluginForURL(nsIURI* aURL,
|
||||
|
||||
nsresult nsPluginHost::AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsIURI* aURL,
|
||||
PRBool aDefaultPlugin)
|
||||
nsIURI* aURL)
|
||||
{
|
||||
nsCAutoString url;
|
||||
// It's OK to not have a URL here, as is the case with the dummy
|
||||
@ -2476,7 +2430,7 @@ nsresult nsPluginHost::AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin,
|
||||
NS_ASSERTION(pluginTag, "Plugin tag not found");
|
||||
}
|
||||
|
||||
nsPluginInstanceTag *instanceTag = new nsPluginInstanceTag(pluginTag, aInstance, url.get(), aDefaultPlugin);
|
||||
nsPluginInstanceTag *instanceTag = new nsPluginInstanceTag(pluginTag, aInstance, url.get());
|
||||
if (!instanceTag)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -2616,7 +2570,7 @@ nsPluginHost::TrySetUpPluginInstance(const char *aMimeType,
|
||||
}
|
||||
|
||||
// instance and peer will be addreffed here
|
||||
result = AddInstanceToActiveList(plugin, instance, aURL, PR_FALSE);
|
||||
result = AddInstanceToActiveList(plugin, instance, aURL);
|
||||
|
||||
#ifdef PLUGIN_LOGGING
|
||||
nsCAutoString urlSpec2;
|
||||
@ -2633,59 +2587,6 @@ nsPluginHost::TrySetUpPluginInstance(const char *aMimeType,
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPluginHost::SetUpDefaultPluginInstance(const char *aMimeType,
|
||||
nsIURI *aURL,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
{
|
||||
if (mDefaultPluginDisabled) {
|
||||
// The default plugin is disabled, don't load it.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPluginInstance> instance;
|
||||
nsCOMPtr<nsIPlugin> plugin = NULL;
|
||||
const char* mimetype = aMimeType;
|
||||
|
||||
if (!aURL)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GetPlugin("*", getter_AddRefs(plugin));
|
||||
|
||||
nsresult result = NS_ERROR_OUT_OF_MEMORY;
|
||||
if (plugin)
|
||||
result = plugin->CreatePluginInstance(getter_AddRefs(instance));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
// it is adreffed here
|
||||
aOwner->SetInstance(instance);
|
||||
|
||||
// if we don't have a mimetype, check by file extension
|
||||
nsXPIDLCString mt;
|
||||
if (!mimetype || !*mimetype) {
|
||||
nsresult res = NS_OK;
|
||||
nsCOMPtr<nsIMIMEService> ms (do_GetService(NS_MIMESERVICE_CONTRACTID, &res));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = ms->GetTypeFromURI(aURL, mt);
|
||||
if (NS_SUCCEEDED(res))
|
||||
mimetype = mt.get();
|
||||
}
|
||||
}
|
||||
|
||||
// this should not addref the instance or owner
|
||||
result = instance->Initialize(aOwner, mimetype);
|
||||
if (NS_FAILED(result)) {
|
||||
aOwner->SetInstance(nsnull);
|
||||
return result;
|
||||
}
|
||||
|
||||
// instance will be addreffed here
|
||||
result = AddInstanceToActiveList(plugin, instance, aURL, PR_TRUE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginHost::IsPluginEnabledForType(const char* aMimeType)
|
||||
{
|
||||
@ -3241,44 +3142,6 @@ class nsDefaultComparator<pluginFileinDirectory, pluginFileinDirectory>
|
||||
|
||||
typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
|
||||
|
||||
static nsresult FixUpPluginInfo(nsPluginInfo &aInfo, nsPluginFile &aPluginFile)
|
||||
{
|
||||
#ifndef XP_WIN
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
||||
for (PRUint32 i = 0; i < aInfo.fVariantCount; i++) {
|
||||
if (PL_strcmp(aInfo.fMimeTypeArray[i], "*"))
|
||||
continue;
|
||||
|
||||
// we got "*" type
|
||||
// check if this is an alien plugin (not our default plugin)
|
||||
// by trying to find a special entry point
|
||||
PRLibrary *library = nsnull;
|
||||
if (NS_FAILED(aPluginFile.LoadPlugin(library)) || !library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NP_GETMIMEDESCRIPTION pf = (NP_GETMIMEDESCRIPTION)PR_FindFunctionSymbol(library, "NP_GetMIMEDescription");
|
||||
|
||||
if (pf) {
|
||||
// if we found it, this is the default plugin, return
|
||||
char * mimedescription = pf();
|
||||
if (!PL_strncmp(mimedescription, NS_PLUGIN_DEFAULT_MIME_DESCRIPTION, 1))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if we are here that means we have an alien plugin
|
||||
// which wants to take over "*" type
|
||||
|
||||
// change its "*" mime type to "[*]"
|
||||
PL_strfree(aInfo.fMimeTypeArray[i]);
|
||||
aInfo.fMimeTypeArray[i] = PL_strdup("[*]");
|
||||
|
||||
// continue the loop?
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
|
||||
nsIComponentManager * compManager,
|
||||
PRBool aCreatePluginList,
|
||||
@ -3424,12 +3287,6 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for any potential '*' mime type handlers which are not our
|
||||
// own default plugin and disable them as they will break the plugin
|
||||
// finder service, see Bugzilla bug 132430
|
||||
if (!mAllowAlienStarHandler)
|
||||
FixUpPluginInfo(info, pluginFile);
|
||||
|
||||
pluginTag = new nsPluginTag(&info);
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
@ -5130,15 +4987,8 @@ nsPluginHost::FindInstanceTag(nsIPluginInstance *instance)
|
||||
nsPluginInstanceTag*
|
||||
nsPluginHost::FindInstanceTag(const char *mimetype)
|
||||
{
|
||||
PRBool defaultplugin = (PL_strcmp(mimetype, "*") == 0);
|
||||
|
||||
for (PRUint32 i = 0; i < mInstanceTags.Length(); i++) {
|
||||
nsPluginInstanceTag* instanceTag = mInstanceTags[i];
|
||||
// give it some special treatment for the default plugin first
|
||||
// because we cannot tell the default plugin by asking instance for a mime type
|
||||
if (defaultplugin && instanceTag->mDefaultPlugin)
|
||||
return instanceTag;
|
||||
|
||||
if (!instanceTag->mInstance)
|
||||
continue;
|
||||
|
||||
|
@ -209,13 +209,10 @@ private:
|
||||
nsresult
|
||||
FindStoppedPluginForURL(nsIURI* aURL, nsIPluginInstanceOwner *aOwner);
|
||||
|
||||
nsresult
|
||||
SetUpDefaultPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner);
|
||||
|
||||
nsresult
|
||||
AddInstanceToActiveList(nsCOMPtr<nsIPlugin> aPlugin,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsIURI* aURL, PRBool aDefaultPlugin);
|
||||
nsIURI* aURL);
|
||||
|
||||
nsresult
|
||||
FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsChanged);
|
||||
@ -270,12 +267,6 @@ private:
|
||||
// set by pref plugin.override_internal_types
|
||||
PRPackedBool mOverrideInternalTypes;
|
||||
|
||||
// set by pref plugin.allow_alien_star_handler
|
||||
PRPackedBool mAllowAlienStarHandler;
|
||||
|
||||
// set by pref plugin.default_plugin_disabled
|
||||
PRPackedBool mDefaultPluginDisabled;
|
||||
|
||||
// set by pref plugin.disable
|
||||
PRPackedBool mPluginsDisabled;
|
||||
|
||||
|
@ -575,8 +575,7 @@ void nsPluginTag::TryUnloadPlugin()
|
||||
|
||||
nsPluginInstanceTag::nsPluginInstanceTag(nsPluginTag* aPluginTag,
|
||||
nsIPluginInstance* aInstance,
|
||||
const char * url,
|
||||
PRBool aDefaultPlugin)
|
||||
const char * url)
|
||||
{
|
||||
NS_ASSERTION(aInstance, "Must have a valid plugin instance when creating an nsPluginInstanceTag");
|
||||
NS_ADDREF(aInstance);
|
||||
@ -585,8 +584,6 @@ nsPluginInstanceTag::nsPluginInstanceTag(nsPluginTag* aPluginTag,
|
||||
mPluginTag = aPluginTag;
|
||||
|
||||
mURL = PL_strdup(url);
|
||||
|
||||
mDefaultPlugin = aDefaultPlugin;
|
||||
}
|
||||
|
||||
nsPluginInstanceTag::~nsPluginInstanceTag()
|
||||
|
@ -129,14 +129,12 @@ struct nsPluginInstanceTag
|
||||
char* mURL;
|
||||
nsRefPtr<nsPluginTag> mPluginTag;
|
||||
nsNPAPIPluginInstance* mInstance; // this must always be valid
|
||||
PRBool mDefaultPlugin;
|
||||
// Array holding all opened stream listeners for this entry
|
||||
nsCOMArray<nsIPluginStreamInfo> mStreams;
|
||||
|
||||
nsPluginInstanceTag(nsPluginTag* aPluginTag,
|
||||
nsIPluginInstance* aInstance,
|
||||
const char * url,
|
||||
PRBool aDefaultPlugin);
|
||||
const char * url);
|
||||
~nsPluginInstanceTag();
|
||||
};
|
||||
|
||||
|
@ -1,272 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Aas <josh@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
extern "C"
|
||||
{
|
||||
NPError NP_Initialize(NPNetscapeFuncs *browserFuncs);
|
||||
NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
|
||||
void NP_Shutdown(void);
|
||||
|
||||
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
|
||||
int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
NPError NPP_Destroy(NPP instance, NPSavedData** save);
|
||||
NPError NPP_SetWindow(NPP instance, NPWindow* window);
|
||||
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
|
||||
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
|
||||
int32_t NPP_WriteReady(NPP instance, NPStream* stream);
|
||||
int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
|
||||
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
|
||||
void NPP_Print(NPP instance, NPPrint* platformPrint);
|
||||
int16_t NPP_HandleEvent(NPP instance, void* event);
|
||||
void NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData);
|
||||
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
|
||||
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
// structure containing pointers to functions implemented by the browser
|
||||
static NPNetscapeFuncs* browser;
|
||||
|
||||
// data for each instance of this plugin
|
||||
typedef struct PluginInstance {
|
||||
NPP npp;
|
||||
NPWindow window;
|
||||
} PluginInstance;
|
||||
|
||||
void drawPlugin(NPP instance, NPCocoaEvent* event);
|
||||
|
||||
// Symbol called once by the browser to initialize the plugin
|
||||
NPError NP_Initialize(NPNetscapeFuncs* browserFuncs)
|
||||
{
|
||||
// save away browser functions
|
||||
browser = browserFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Symbol called by the browser to get the plugin's function list
|
||||
NPError NP_GetEntryPoints(NPPluginFuncs* pluginFuncs)
|
||||
{
|
||||
pluginFuncs->version = 11;
|
||||
pluginFuncs->size = sizeof(pluginFuncs);
|
||||
pluginFuncs->newp = NPP_New;
|
||||
pluginFuncs->destroy = NPP_Destroy;
|
||||
pluginFuncs->setwindow = NPP_SetWindow;
|
||||
pluginFuncs->newstream = NPP_NewStream;
|
||||
pluginFuncs->destroystream = NPP_DestroyStream;
|
||||
pluginFuncs->asfile = NPP_StreamAsFile;
|
||||
pluginFuncs->writeready = NPP_WriteReady;
|
||||
pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
|
||||
pluginFuncs->print = NPP_Print;
|
||||
pluginFuncs->event = NPP_HandleEvent;
|
||||
pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
pluginFuncs->getvalue = NPP_GetValue;
|
||||
pluginFuncs->setvalue = NPP_SetValue;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Symbol called once by the browser to shut down the plugin
|
||||
void NP_Shutdown(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Called to create a new instance of the plugin
|
||||
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
|
||||
int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
PluginInstance *newInstance = (PluginInstance*)malloc(sizeof(PluginInstance));
|
||||
bzero(newInstance, sizeof(PluginInstance));
|
||||
|
||||
newInstance->npp = instance;
|
||||
instance->pdata = newInstance;
|
||||
|
||||
// select the right drawing model if necessary
|
||||
NPBool supportsCoreGraphics = false;
|
||||
if ((browser->getvalue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) == NPERR_NO_ERROR) &&
|
||||
supportsCoreGraphics) {
|
||||
browser->setvalue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics);
|
||||
} else {
|
||||
printf("CoreGraphics drawing model not supported, can't create a plugin instance.\n");
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
|
||||
// select the Cocoa event model
|
||||
NPBool supportsCocoaEvents = false;
|
||||
if ((browser->getvalue(instance, NPNVsupportsCocoaBool, &supportsCocoaEvents) == NPERR_NO_ERROR) &&
|
||||
supportsCocoaEvents) {
|
||||
browser->setvalue(instance, NPPVpluginEventModel, (void*)NPEventModelCocoa);
|
||||
} else {
|
||||
printf("Cocoa event model not supported, can't create a plugin instance.\n");
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to destroy an instance of the plugin
|
||||
NPError NPP_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
free(instance->pdata);
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
// Called to update a plugin instances's NPWindow
|
||||
NPError NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PluginInstance* currentInstance = (PluginInstance*)(instance->pdata);
|
||||
|
||||
currentInstance->window = *window;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
|
||||
{
|
||||
*stype = NP_ASFILEONLY;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
|
||||
{
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t NPP_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NPP_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int16_t NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
NPCocoaEvent* cocoaEvent = (NPCocoaEvent*)event;
|
||||
if (cocoaEvent && (cocoaEvent->type == NPCocoaEventDrawRect)) {
|
||||
drawPlugin(instance, (NPCocoaEvent*)event);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
|
||||
{
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
void drawPlugin(NPP instance, NPCocoaEvent* event)
|
||||
{
|
||||
PluginInstance* currentInstance = (PluginInstance*)(instance->pdata);
|
||||
CGContextRef cgContext = event->data.draw.context;
|
||||
if (!cgContext)
|
||||
return;
|
||||
|
||||
float windowWidth = currentInstance->window.width;
|
||||
float windowHeight = currentInstance->window.height;
|
||||
|
||||
// save the cgcontext gstate
|
||||
CGContextSaveGState(cgContext);
|
||||
|
||||
// we get a flipped context
|
||||
CGContextTranslateCTM(cgContext, 0.0, windowHeight);
|
||||
CGContextScaleCTM(cgContext, 1.0, -1.0);
|
||||
|
||||
// draw a white background for the plugin
|
||||
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
|
||||
CGContextSetGrayFillColor(cgContext, 1.0, 1.0);
|
||||
CGContextDrawPath(cgContext, kCGPathFill);
|
||||
|
||||
// draw the broken plugin icon
|
||||
CFBundleRef bundle = ::CFBundleGetBundleWithIdentifier(CFSTR("org.mozilla.DefaultPlugin"));
|
||||
CFURLRef imageURL = ::CFBundleCopyResourceURL(bundle, CFSTR("plugin"), CFSTR("png"), NULL);
|
||||
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithURL(imageURL);
|
||||
::CFRelease(imageURL);
|
||||
CGImageRef imageRef = ::CGImageCreateWithPNGDataProvider(dataProvider, NULL, TRUE,
|
||||
kCGRenderingIntentDefault);
|
||||
::CGDataProviderRelease(dataProvider);
|
||||
float imageWidth = ::CGImageGetWidth(imageRef);
|
||||
float imageHeight = ::CGImageGetHeight(imageRef);
|
||||
CGRect drawRect = ::CGRectMake(windowWidth / 2 - imageWidth / 2,
|
||||
windowHeight / 2 - imageHeight / 2,
|
||||
imageWidth,
|
||||
imageHeight);
|
||||
::CGContextDrawImage(cgContext, drawRect, imageRef);
|
||||
::CGImageRelease(imageRef);
|
||||
|
||||
// draw a blue frame around the plugin
|
||||
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
|
||||
CGContextSetRGBStrokeColor(cgContext, 0.0, 0.0, 0.5, 1.0);
|
||||
CGContextSetLineWidth(cgContext, 2.0);
|
||||
CGContextStrokePath(cgContext);
|
||||
|
||||
// restore the cgcontext gstate
|
||||
CGContextRestoreGState(cgContext);
|
||||
}
|
Binary file not shown.
@ -1,248 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
032267660EAFA4C40059A1E6 /* DefaultPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */; };
|
||||
032267840EAFA62E0059A1E6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 032267830EAFA62E0059A1E6 /* Carbon.framework */; };
|
||||
032268110EAFB8720059A1E6 /* plugin.png in Resources */ = {isa = PBXBuildFile; fileRef = 032268100EAFB8720059A1E6 /* plugin.png */; };
|
||||
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; };
|
||||
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DefaultPlugin.mm; sourceTree = "<group>"; };
|
||||
032267830EAFA62E0059A1E6 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
032268100EAFB8720059A1E6 /* plugin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = plugin.png; sourceTree = "<group>"; };
|
||||
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
|
||||
8D576316048677EA00EA77CD /* DefaultPlugin.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DefaultPlugin.plugin; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8D576313048677EA00EA77CD /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */,
|
||||
032267840EAFA62E0059A1E6 /* Carbon.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
089C166AFE841209C02AAC07 /* DefaultPlugin */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
08FB77AFFE84173DC02AAC07 /* Source */,
|
||||
089C167CFE841241C02AAC07 /* Resources */,
|
||||
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
|
||||
19C28FB6FE9D52B211CA2CBB /* Products */,
|
||||
);
|
||||
name = DefaultPlugin;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
032267830EAFA62E0059A1E6 /* Carbon.framework */,
|
||||
0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */,
|
||||
);
|
||||
name = "External Frameworks and Libraries";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
089C167CFE841241C02AAC07 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
032268100EAFB8720059A1E6 /* plugin.png */,
|
||||
8D576317048677EA00EA77CD /* Info.plist */,
|
||||
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB77AFFE84173DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
032267650EAFA4C40059A1E6 /* DefaultPlugin.mm */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FB6FE9D52B211CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D576316048677EA00EA77CD /* DefaultPlugin.plugin */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8D57630D048677EA00EA77CD /* DefaultPlugin */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB911A08733D790010E9CD /* Build configuration list for PBXNativeTarget "DefaultPlugin" */;
|
||||
buildPhases = (
|
||||
8D57630F048677EA00EA77CD /* Resources */,
|
||||
8D576311048677EA00EA77CD /* Sources */,
|
||||
8D576313048677EA00EA77CD /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = DefaultPlugin;
|
||||
productInstallPath = "$(HOME)/Library/Bundles";
|
||||
productName = DefaultPlugin;
|
||||
productReference = 8D576316048677EA00EA77CD /* DefaultPlugin.plugin */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
089C1669FE841209C02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "DefaultPlugin" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 089C166AFE841209C02AAC07 /* DefaultPlugin */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8D57630D048677EA00EA77CD /* DefaultPlugin */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
8D57630F048677EA00EA77CD /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,
|
||||
032268110EAFB8720059A1E6 /* plugin.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8D576311048677EA00EA77CD /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
032267660EAFA4C40059A1E6 /* DefaultPlugin.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
089C167EFE841241C02AAC07 /* English */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1DEB911B08733D790010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Library/Bundles";
|
||||
PRODUCT_NAME = DefaultPlugin;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB911C08733D790010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_MODEL_TUNING = G5;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Library/Bundles";
|
||||
PRODUCT_NAME = DefaultPlugin;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
1DEB911F08733D790010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = "";
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB912008733D790010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "XP_MACOSX=1";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = ../../../../dist/include;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = "";
|
||||
SEPARATE_SYMBOL_EDIT = NO;
|
||||
STRIP_INSTALLED_PRODUCT = YES;
|
||||
WRAPPER_EXTENSION = plugin;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB911A08733D790010E9CD /* Build configuration list for PBXNativeTarget "DefaultPlugin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB911B08733D790010E9CD /* Debug */,
|
||||
1DEB911C08733D790010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "DefaultPlugin" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB911F08733D790010E9CD /* Debug */,
|
||||
1DEB912008733D790010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
|
||||
}
|
Binary file not shown.
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WebPluginMIMETypes</key>
|
||||
<dict>
|
||||
<key>*</key>
|
||||
<dict>
|
||||
<key>WebPluginExtensions</key>
|
||||
<array>
|
||||
<string>*</string>
|
||||
</array>
|
||||
<key>WebPluginTypeDescription</key>
|
||||
<string>All types</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>WebPluginDescription</key>
|
||||
<string>Gecko default plugin</string>
|
||||
<key>WebPluginName</key>
|
||||
<string>Default Plugin</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.mozilla.DefaultPlugin</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>NSPL</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0</string>
|
||||
</dict>
|
||||
</plist>
|
@ -1,89 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
MODULE = plugin
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef MOZ_DEBUG
|
||||
BUILDSTYLE = Debug
|
||||
else
|
||||
BUILDSTYLE = Release
|
||||
endif
|
||||
|
||||
PROJECT=DefaultPlugin.xcodeproj
|
||||
PROJECT_ARG=-project $(PROJECT)
|
||||
PBBUILD_ARG=$(PBBUILD_SETTINGS)
|
||||
|
||||
TARGET = "DefaultPlugin"
|
||||
|
||||
unexport CC CXX
|
||||
|
||||
# for objdir builds, copy the project, and symlink the sources
|
||||
ABS_topsrcdir := $(shell cd $(topsrcdir); pwd)
|
||||
ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
|
||||
export::
|
||||
rsync -a --exclude .DS_Store --exclude "CVS/" $(srcdir)/$(PROJECT) .
|
||||
ln -fs $(srcdir)/English.lproj
|
||||
ln -fs $(srcdir)/DefaultPlugin.mm
|
||||
ln -fs $(srcdir)/Info.plist
|
||||
ln -fs $(srcdir)/plugin.png
|
||||
|
||||
GARBAGE_DIRS += $(PROJECT)
|
||||
GARBAGE += \
|
||||
English.lproj \
|
||||
DefaultPlugin.mm \
|
||||
Info.plist \
|
||||
plugin.png \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
GARBAGE_DIRS += build
|
||||
|
||||
libs install:: install-plugin
|
||||
|
||||
install-plugin: build-plugin
|
||||
$(INSTALL) "$(XCODE_PRODUCT_DIR)/DefaultPlugin.plugin" $(DIST)/bin/plugins
|
||||
|
||||
build-plugin:
|
||||
$(PBBUILD) $(PROJECT_ARG) -target $(TARGET) -configuration $(BUILDSTYLE) $(PBBUILD_ARG)
|
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB |
@ -1,82 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# IBM Corp.
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
LIBRARY_NAME = npnulos2
|
||||
RESFILE = npnulos2.res
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
maindll.cpp \
|
||||
plugin.cpp \
|
||||
dbg.cpp \
|
||||
dialogs.cpp \
|
||||
npshell.cpp \
|
||||
npos2.cpp \
|
||||
utils.cpp \
|
||||
$(NULL)
|
||||
|
||||
# plugins should always be shared, even in the "static" build
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
NO_DIST_INSTALL = 1
|
||||
NO_INSTALL = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
install-plugin: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
|
||||
endif
|
||||
|
||||
libs:: install-plugin
|
||||
|
||||
install:: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
|
||||
endif
|
@ -1,60 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <os2.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
extern char szAppName[];
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void dbgOut(PSZ format, ...) {
|
||||
static char buf[1024];
|
||||
strcpy(buf, szAppName);
|
||||
strcat(buf, ": ");
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsprintf(&buf[strlen(buf)], format, va);
|
||||
va_end(va);
|
||||
strcat(buf, "\n");
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __DBG_HPP_
|
||||
#define __DBG_HPP_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void dbgOut(PSZ format, ...);
|
||||
#define dbgOut1(x) dbgOut(x)
|
||||
#define dbgOut2(x,y) dbgOut(x, y)
|
||||
#define dbgOut3(x,y,z) dbgOut(x, y, z)
|
||||
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
|
||||
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
|
||||
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
|
||||
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
|
||||
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
|
||||
|
||||
#else
|
||||
|
||||
#define dbgOut1(x) ((void)0)
|
||||
#define dbgOut2(x,y) ((void)0)
|
||||
#define dbgOut3(x,y,z) ((void)0)
|
||||
#define dbgOut4(x,y,z,t) ((void)0)
|
||||
#define dbgOut5(x,y,z,t,u) ((void)0)
|
||||
#define dbgOut6(x,y,z,t,u,v) ((void)0)
|
||||
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
|
||||
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,198 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define INCL_WIN
|
||||
#include <os2.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "npnulos2.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)WinQueryWindowPtr(hWnd, QWL_USER);
|
||||
switch (id)
|
||||
{
|
||||
case IDC_GET_PLUGIN:
|
||||
WinDismissDlg(hWnd, IDC_GET_PLUGIN);
|
||||
if(pPlugin !=NULL)
|
||||
pPlugin->m_hWndDialog = NULL;
|
||||
break;
|
||||
case DID_CANCEL:
|
||||
WinDismissDlg(hWnd, DID_CANCEL);
|
||||
if(pPlugin !=NULL)
|
||||
pPlugin->m_hWndDialog = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, MPARAM mParam)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)mParam;
|
||||
assert(pPlugin != NULL);
|
||||
if(pPlugin == NULL)
|
||||
return TRUE;
|
||||
|
||||
WinSetWindowPtr(hWnd, QWL_USER, (PVOID)pPlugin);
|
||||
|
||||
pPlugin->m_hWndDialog = hWnd;
|
||||
|
||||
char szString[512];
|
||||
WinLoadString((HAB)0, hInst, IDS_TITLE, sizeof(szString), szString);
|
||||
WinSetWindowText(hWnd, szString);
|
||||
|
||||
WinLoadString((HAB)0, hInst, IDS_INFO, sizeof(szString), szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
|
||||
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, pPlugin->m_pNPMIMEType);
|
||||
|
||||
WinLoadString((HAB)0, hInst, IDS_LOCATION, sizeof(szString), szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
|
||||
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != pPlugin->m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
pPlugin->m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
|
||||
WinLoadString((HAB)0, hInst, IDS_FINDER_PAGE, sizeof(szString), szString);
|
||||
else
|
||||
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
|
||||
|
||||
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
|
||||
|
||||
WinLoadString((HAB)0, hInst, IDS_QUESTION, sizeof(szString), szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
|
||||
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
|
||||
|
||||
if(!pPlugin->m_bOnline)
|
||||
{
|
||||
WinEnableWindow(WinWindowFromID(hWnd, IDC_GET_PLUGIN), FALSE);
|
||||
WinLoadString((HAB)0, hInst, IDS_WARNING_OFFLINE, sizeof(szString), szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if((!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
|
||||
{
|
||||
WinLoadString((HAB)0, hInst, IDS_WARNING_JS, sizeof(szString), szString);
|
||||
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WinShowWindow(WinWindowFromID(hWnd, IDC_STATIC_WARNING), FALSE);
|
||||
|
||||
RECTL rc;
|
||||
|
||||
WinQueryWindowRect(WinWindowFromID(hWnd, IDC_STATIC_WARNING), &rc);
|
||||
int iHeight = rc.yTop - rc.yBottom;
|
||||
WinQueryWindowRect(hWnd, &rc);
|
||||
WinSetWindowPos(hWnd, 0, 0, 0, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom - iHeight, SWP_SIZE);
|
||||
|
||||
HWND hWndQuestion = WinWindowFromID(hWnd, IDC_STATIC_QUESTION);
|
||||
HWND hWndButtonGetPlugin = WinWindowFromID(hWnd, IDC_GET_PLUGIN);
|
||||
HWND hWndButtonCancel = WinWindowFromID(hWnd, IDC_BUTTON_CANCEL);
|
||||
|
||||
POINTL pt;
|
||||
|
||||
WinQueryWindowRect(hWndQuestion, &rc);
|
||||
pt.x = rc.xLeft;
|
||||
pt.y = rc.yBottom;
|
||||
// ScreenToClient(hWnd, &pt);
|
||||
WinSetWindowPos(hWndQuestion, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
|
||||
|
||||
WinQueryWindowRect(hWndButtonGetPlugin, &rc);
|
||||
pt.x = rc.xLeft;
|
||||
pt.y = rc.yBottom;
|
||||
// ScreenToClient(hWnd, &pt);
|
||||
WinSetWindowPos(hWndButtonGetPlugin, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
|
||||
|
||||
WinQueryWindowRect(hWndButtonCancel, &rc);
|
||||
pt.x = rc.xLeft;
|
||||
pt.y = rc.yBottom;
|
||||
// ScreenToClient(hWnd, &pt);
|
||||
WinSetWindowPos(hWndButtonCancel, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
|
||||
|
||||
if(pPlugin->m_bHidden)
|
||||
WinSetActiveWindow(HWND_DESKTOP, hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void onClose(HWND hWnd)
|
||||
{
|
||||
WinDismissDlg(hWnd, DID_CANCEL);
|
||||
CPlugin * pPlugin = (CPlugin *)WinQueryWindowPtr(hWnd, QWL_USER);
|
||||
if(pPlugin !=NULL)
|
||||
pPlugin->m_hWndDialog = NULL;
|
||||
}
|
||||
|
||||
static void onDestroy(HWND hWnd)
|
||||
{
|
||||
}
|
||||
|
||||
MRESULT EXPENTRY NP_LOADDS GetPluginDialogProc(HWND hWnd, ULONG uMsg, MPARAM mp1, MPARAM mp2)
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDLG:
|
||||
onInitDialog(hWnd,0,mp2);
|
||||
return (MRESULT)FALSE;
|
||||
case WM_COMMAND:
|
||||
onCommand(hWnd, SHORT1FROMMP(mp1),0,0);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
onDestroy(hWnd);
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
onClose(hWnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return WinDefDlgProc(hWnd, uMsg, mp1, mp2);
|
||||
}
|
||||
return (MRESULT)TRUE;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __DIALOGS_H__
|
||||
#define __DIALOGS_H__
|
||||
|
||||
MRESULT EXPENTRY NP_LOADDS GetPluginDialogProc(HWND hWnd, ULONG uMsg, MPARAM mp1, MPARAM mp2);
|
||||
|
||||
#endif /* __DIALOGS_H__ */
|
@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
HMODULE hInst; // global
|
||||
|
||||
// Compiler run-time functions.
|
||||
extern "C" {
|
||||
int _CRT_init( void );
|
||||
void _CRT_term( void );
|
||||
void __ctordtorInit( void );
|
||||
void __ctordtorTerm( void );
|
||||
}
|
||||
|
||||
extern "C" unsigned long _System _DLL_InitTerm(unsigned long hModule,
|
||||
unsigned long ulFlag)
|
||||
{
|
||||
switch (ulFlag) {
|
||||
case 0 :
|
||||
// Init: Prime compiler run-time and construct static C++ objects.
|
||||
if ( _CRT_init() == -1 ) {
|
||||
return 0UL;
|
||||
} else {
|
||||
__ctordtorInit();
|
||||
hInst = hModule;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
__ctordtorTerm();
|
||||
_CRT_term();
|
||||
hInst = NULLHANDLE;
|
||||
break;
|
||||
|
||||
default :
|
||||
return 0UL;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* RC_DATA types for version info - required */
|
||||
#define NP_INFO_ProductVersion 1
|
||||
#define NP_INFO_MIMEType 2
|
||||
#define NP_INFO_FileOpenName 3
|
||||
#define NP_INFO_FileExtents 4
|
||||
|
||||
/* RC_DATA types for version info - used if found */
|
||||
#define NP_INFO_FileDescription 5
|
||||
#define NP_INFO_ProductName 6
|
||||
|
||||
/* RC_DATA types for version info - optional */
|
||||
#define NP_INFO_CompanyName 7
|
||||
#define NP_INFO_FileVersion 8
|
||||
#define NP_INFO_InternalName 9
|
||||
#define NP_INFO_LegalCopyright 10
|
||||
#define NP_INFO_OriginalFilename 11
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Npnul32.rc
|
||||
//
|
||||
#define IDD_PLUGIN_DOWNLOAD 301
|
||||
#define IDI_PLUGICON 302
|
||||
#define IDS_INFO 303
|
||||
#define IDS_DEFAULT_URL 304
|
||||
#define IDS_INSTALL_COMMAND 305
|
||||
#define IDS_GET_PLUGIN_MSG2 306
|
||||
#define IDS_LOCATION 306
|
||||
#define IDS_TITLE 307
|
||||
#define IDS_QUESTION 308
|
||||
#define IDS_JS_DISABLED 309
|
||||
#define IDS_ASDFINDER 310
|
||||
#define IDS_ASDSIMP 311
|
||||
#define IDS_QUERY_TEST 312
|
||||
#define IDS_BLANK_JS 313
|
||||
#define IDS_GOING2HTML 314
|
||||
#define IDS_WARNING_JS 315
|
||||
#define IDS_WARNING_OFFLINE 316
|
||||
#define IDS_DEFAULT_URL_OLD 317
|
||||
#define IDS_FINDER_PAGE 317
|
||||
#define IDS_CLICK_TO_GET 318
|
||||
#define IDS_CLICK_WHEN_DONE 319
|
||||
#define IDC_JS_DIS_TEXT 2003
|
||||
#define IDC_CONTINUE 2004
|
||||
#define IDC_CONT_NOJS 2005
|
||||
#define IDC_STATIC_INFO 2009
|
||||
#define IDC_STATIC_LOCATION 2010
|
||||
#define IDC_STATIC_QUESTION 2011
|
||||
#define IDC_GET_PLUGIN 2012
|
||||
#define IDC_BUTTON_CANCEL 2013
|
||||
#define IDC_STATIC_URL 2014
|
||||
#define IDC_STATIC_INFOTYPE 2015
|
||||
#define IDC_STATIC_WARNING 2016
|
||||
#define IDC_EDIT_URL 2017
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 308
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 2018
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
Binary file not shown.
@ -1,108 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define INCL_NOBASEAPI
|
||||
#include <os2.h>
|
||||
#include "npnulos2.h"
|
||||
|
||||
RCDATA NP_INFO_ProductVersion { 1,0,0,15, }
|
||||
|
||||
RCDATA NP_INFO_MIMEType { "*\0" }
|
||||
RCDATA NP_INFO_FileExtents { "*\0" }
|
||||
RCDATA NP_INFO_FileOpenName{ "Mozilla Default Plug-in (*.*)\0" }
|
||||
|
||||
RCDATA NP_INFO_FileVersion { 1,0,0,15, }
|
||||
RCDATA NP_INFO_CompanyName { "mozilla.org\0" }
|
||||
RCDATA NP_INFO_FileDescription { "Default Plug-in file\0" }
|
||||
RCDATA NP_INFO_InternalName { "DEFPLUGIN\0" }
|
||||
RCDATA NP_INFO_LegalCopyright { "Copyright (C) 1995-2000\0" }
|
||||
RCDATA NP_INFO_OriginalFilename { "NPNULOS2.DLL\0" }
|
||||
RCDATA NP_INFO_ProductName { "Mozilla Default Plug-in\0" }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
DLGTEMPLATE IDD_PLUGIN_DOWNLOAD DISCARDABLE
|
||||
BEGIN
|
||||
DIALOG "Title", IDD_PLUGIN_DOWNLOAD, 0, 125, 225, 122,
|
||||
WS_VISIBLE | FS_DLGBORDER | FS_SCREENALIGN,
|
||||
FCF_TITLEBAR | FCF_SYSMENU | FCF_NOMOVEWITHOWNER
|
||||
PRESPARAMS PP_FONTNAMESIZE, "8.Helv"
|
||||
BEGIN
|
||||
LTEXT "Information on this page requires a plug-in for:",IDC_STATIC_INFO, 7, 108, 211, 8,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
LTEXT "Communicator can retrieve the plug-in for you from:",IDC_STATIC_LOCATION, 7, 89, 211, 7,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
CTEXT "What would you like to do?",IDC_STATIC_QUESTION, 7, 21, 211, 7,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN, 41, 6, 64, 12,
|
||||
PUSHBUTTON "Cancel", DID_CANCEL, 109, 6, 64, 12,
|
||||
CTEXT "type/x-type",IDC_STATIC_INFOTYPE, 7, 100, 211, 7, SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",IDC_STATIC_WARNING, 7, 32, 211, 29,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",IDC_STATIC_URL, 7, 67, 211, 20,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
|
||||
END
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
ICON IDI_PLUGICON DISCARDABLE "npnulos2.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_INFO "Information on this page requires a plug-in for:"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LOCATION "You can retrieve the plug-in from:"
|
||||
IDS_TITLE "Plug-in Not Loaded"
|
||||
IDS_QUESTION "What would you like to do?"
|
||||
IDS_WARNING_JS "To retrieve the plug-in now, click the Get the Plug-in button and then select the plug-in you need from the page that appears."
|
||||
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Work Online"" from the File menu, then click the plug-in icon on the page."
|
||||
IDS_FINDER_PAGE "Plug-in Finder page"
|
||||
IDS_CLICK_TO_GET "Click here to get the plugin"
|
||||
IDS_CLICK_WHEN_DONE "After installing the plugin, click here."
|
||||
END
|
@ -1,338 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include "nsDefaultPlugin.h"
|
||||
|
||||
//\\// DEFINE
|
||||
#define NP_EXPORT
|
||||
|
||||
//\\// GLOBAL DATA
|
||||
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// PLUGIN DLL entry points
|
||||
//
|
||||
// These are the Windows specific DLL entry points. They must be exoprted
|
||||
//
|
||||
|
||||
// we need these to be global since we have to fill one of its field
|
||||
// with a data (class) which requires knowlwdge of the navigator
|
||||
// jump-table. This jump table is known at Initialize time (NP_Initialize)
|
||||
// which is called after NP_GetEntryPoint
|
||||
static NPPluginFuncs* g_pluginFuncs;
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_GetEntryPoints
|
||||
//
|
||||
// fills in the func table used by Navigator to call entry points in
|
||||
// plugin DLL. Note that these entry points ensure that DS is loaded
|
||||
// by using the NP_LOADDS macro, when compiling for OS/2.
|
||||
//
|
||||
NPError OSCALL NP_EXPORT
|
||||
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
// if the plugin's function table is smaller than the plugin expects,
|
||||
// then they are incompatible, and should return an error
|
||||
|
||||
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
pFuncs->newp = NPP_New;
|
||||
pFuncs->destroy = NPP_Destroy;
|
||||
pFuncs->setwindow = NPP_SetWindow;
|
||||
pFuncs->newstream = NPP_NewStream;
|
||||
pFuncs->destroystream = NPP_DestroyStream;
|
||||
pFuncs->asfile = NPP_StreamAsFile;
|
||||
pFuncs->writeready = NPP_WriteReady;
|
||||
pFuncs->write = NPP_Write;
|
||||
pFuncs->print = NPP_Print;
|
||||
pFuncs->event = 0; /// reserved
|
||||
|
||||
g_pluginFuncs = pFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Initialize
|
||||
//
|
||||
// called immediately after the plugin DLL is loaded
|
||||
//
|
||||
NPError OSCALL NP_EXPORT
|
||||
NP_Initialize(NPNetscapeFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
g_pNavigatorFuncs = pFuncs; // save it for future reference
|
||||
|
||||
// if the plugin's major ver level is lower than the Navigator's,
|
||||
// then they are incompatible, and should return an error
|
||||
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
// We have to defer these assignments until g_pNavigatorFuncs is set
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
g_pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
|
||||
g_pluginFuncs->javaClass = NULL;
|
||||
}
|
||||
// NPP_Initialize is a standard (cross-platform) initialize function.
|
||||
return NPP_Initialize();
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Shutdown
|
||||
//
|
||||
// called immediately before the plugin DLL is unloaded.
|
||||
// This function should check for some ref count on the dll to see if it is
|
||||
// unloadable or it needs to stay in memory.
|
||||
//
|
||||
NPError OSCALL NP_EXPORT
|
||||
NP_Shutdown()
|
||||
{
|
||||
NPP_Shutdown();
|
||||
g_pNavigatorFuncs = NULL;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
char*
|
||||
NP_GetMIMEDescription()
|
||||
{
|
||||
static char mimetype[] = NS_PLUGIN_DEFAULT_MIME_DESCRIPTION;
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
// END - PLUGIN DLL entry points
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
|
||||
/* NAVIGATOR Entry points */
|
||||
|
||||
/* These entry points expect to be called from within the plugin. The
|
||||
noteworthy assumption is that DS has already been set to point to the
|
||||
plugin's DLL data segment. Don't call these functions from outside
|
||||
the plugin without ensuring DS is set to the DLLs data segment first,
|
||||
typically using the NP_LOADDS macro
|
||||
*/
|
||||
|
||||
/* returns the major/minor version numbers of the Plugin API for the plugin
|
||||
and the Navigator
|
||||
*/
|
||||
void
|
||||
NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major,
|
||||
int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
|
||||
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetValue(NPP instance, NPNVariable variable, void *result)
|
||||
{
|
||||
return g_pNavigatorFuncs->getvalue(instance, variable, result);
|
||||
}
|
||||
|
||||
|
||||
/* causes the specified URL to be fetched and streamed in
|
||||
*/
|
||||
NPError
|
||||
NPN_GetURLNotify(NPP instance, const char *url, const char *target,
|
||||
void* notifyData)
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPN_GetURL(NPP instance, const char *url, const char *target)
|
||||
{
|
||||
return g_pNavigatorFuncs->geturl(instance, url, target);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURLNotify(NPP instance, const char* url, const char* window,
|
||||
uint32_t len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len,
|
||||
const char* buf, NPBool file)
|
||||
{
|
||||
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
/* Requests that a number of bytes be provided on a stream. Typically
|
||||
this would be used if a stream was in "pull" mode. An optional
|
||||
position can be provided for streams which are seekable.
|
||||
*/
|
||||
NPError
|
||||
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return g_pNavigatorFuncs->requestread(stream, rangeList);
|
||||
}
|
||||
|
||||
/* Creates a new stream of data from the plug-in to be interpreted
|
||||
by Netscape in the current window.
|
||||
*/
|
||||
NPError
|
||||
NPN_NewStream(NPP instance, NPMIMEType type, const char* target,
|
||||
NPStream** stream)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides len bytes of data.
|
||||
*/
|
||||
int32_t
|
||||
NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
int32_t result;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Closes a stream object.
|
||||
reason indicates why the stream was closed.
|
||||
*/
|
||||
NPError
|
||||
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides a text status message in the Netscape client user interface
|
||||
*/
|
||||
void
|
||||
NPN_Status(NPP instance, const char *message)
|
||||
{
|
||||
g_pNavigatorFuncs->status(instance, message);
|
||||
}
|
||||
|
||||
/* returns the user agent string of Navigator, which contains version info
|
||||
*/
|
||||
const char*
|
||||
NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->uagent(instance);
|
||||
}
|
||||
|
||||
/* allocates memory from the Navigator's memory space. Necessary so that
|
||||
saved instance data may be freed by Navigator when exiting.
|
||||
*/
|
||||
void*
|
||||
NPN_MemAlloc(uint32_t size)
|
||||
{
|
||||
return g_pNavigatorFuncs->memalloc(size);
|
||||
}
|
||||
|
||||
/* reciprocal of MemAlloc() above
|
||||
*/
|
||||
void
|
||||
NPN_MemFree(void* ptr)
|
||||
{
|
||||
g_pNavigatorFuncs->memfree(ptr);
|
||||
}
|
||||
|
||||
/* private function to Netscape. do not use!
|
||||
*/
|
||||
void
|
||||
NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
g_pNavigatorFuncs->reloadplugins(reloadPages);
|
||||
}
|
@ -1,331 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <os2.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "npnulos2.h"
|
||||
|
||||
#include "plugin.h" // this includes npapi.h
|
||||
#include "utils.h"
|
||||
#include "dbg.h"
|
||||
|
||||
char szAppName[] = "NPNULL";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Initialize:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NPP_Initialize(void)
|
||||
{
|
||||
RegisterNullPluginWindowClass();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Shutdown:
|
||||
//---------------------------------------------------------------------------
|
||||
void NPP_Shutdown(void)
|
||||
{
|
||||
UnregisterNullPluginWindowClass();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_New:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
|
||||
NPP pInstance,
|
||||
uint16_t mode,
|
||||
int16_t argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
// See if the content provider specified from where to fetch the plugin
|
||||
char * szPageURL = NULL;
|
||||
char * szFileURL = NULL;
|
||||
char * szFileExtension = NULL;
|
||||
char * buf = NULL;
|
||||
BOOL bHidden = FALSE;
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if(stricmp(argn[i],"pluginspage") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(stricmp(argn[i],"codebase") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(stricmp(argn[i],"pluginurl") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(stricmp(argn[i],"classid") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(stricmp(argn[i],"SRC") == 0 && argv[i] != NULL)
|
||||
buf = (char *)argv[i];
|
||||
else if(stricmp(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
|
||||
bHidden = (strcmp((char *)argv[i], "TRUE") == 0);
|
||||
}
|
||||
|
||||
/* some post-processing on the filename to attempt to extract the extension: */
|
||||
if(buf != NULL)
|
||||
{
|
||||
buf = strrchr(buf, '.');
|
||||
if(buf)
|
||||
szFileExtension = ++buf;
|
||||
}
|
||||
|
||||
CPlugin * pPlugin = new CPlugin(hInst,
|
||||
pInstance,
|
||||
mode,
|
||||
pluginType,
|
||||
szPageURL,
|
||||
szFileURL,
|
||||
szFileExtension,
|
||||
bHidden);
|
||||
if(pPlugin == NULL)
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
|
||||
if(bHidden)
|
||||
{
|
||||
if(!pPlugin->init(NULL))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pInstance->pdata = (void *)pPlugin;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Destroy:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_Destroy(NPP pInstance, NPSavedData** save)
|
||||
{
|
||||
dbgOut1("NPP_Destroy");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
if(pPlugin != NULL)
|
||||
{
|
||||
pPlugin->shut();
|
||||
delete pPlugin;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_SetWindow:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
}
|
||||
|
||||
if(pNPWindow == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
HWND hWnd = (HWND)pNPWindow->window;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if(pPlugin == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
|
||||
{
|
||||
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
|
||||
{ // window went away
|
||||
dbgOut1("NPP_SetWindow, going away...");
|
||||
pPlugin->shut();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
|
||||
{ // First time in -- no window created by plugin yet
|
||||
dbgOut1("NPP_SetWindow, first time");
|
||||
|
||||
if(!pPlugin->init(hWnd))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
|
||||
{ // Netscape window has been resized
|
||||
dbgOut1("NPP_SetWindow, resizing");
|
||||
pPlugin->resize();
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_NewStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_NewStream(NPP pInstance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16_t *stype)
|
||||
{
|
||||
dbgOut1("NPP_NewStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if (!pPlugin)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
return pPlugin->newStream(type, stream, seekable, stype);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_WriteReady:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32_t NP_LOADDS
|
||||
NPP_WriteReady(NPP pInstance, NPStream *stream)
|
||||
{
|
||||
dbgOut1("NPP_WriteReady");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
// We don't want any data, kill the stream
|
||||
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
|
||||
|
||||
return -1L; // don't accept any bytes in NPP_Write()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Write:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32_t NP_LOADDS
|
||||
NPP_Write(NPP pInstance, NPStream *stream, int32_t offset, int32_t len,
|
||||
void *buffer)
|
||||
{
|
||||
//dbgOut1("NPP_Write");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
// We don't want any data, kill the stream
|
||||
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
|
||||
|
||||
return -1; // tell the browser to abort the stream, don't need it
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_DestroyStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
|
||||
{
|
||||
dbgOut1("NPP_DestroyStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if (!pPlugin)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
return pPlugin->destroyStream(stream, reason);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_StreamAsFile:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
dbgOut1("NPP_StreamAsFile");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Print:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
|
||||
{
|
||||
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->print(printInfo);
|
||||
}
|
||||
|
||||
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
dbgOut2("NPP_URLNotify, URL '%s'", url);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->URLNotify(url);
|
||||
}
|
@ -1,773 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define INCL_GPI
|
||||
#define INCL_WIN
|
||||
#include <os2.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "npnulos2.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
#include "dialogs.h"
|
||||
#include "dbg.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
nsIServiceManager * gServiceManager = NULL;
|
||||
|
||||
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
|
||||
|
||||
MRESULT EXPENTRY PluginWndProc(HWND, ULONG, MPARAM, MPARAM);
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
|
||||
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
|
||||
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
|
||||
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
|
||||
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
|
||||
|
||||
BOOL RegisterNullPluginWindowClass()
|
||||
{
|
||||
return WinRegisterClass( (HAB)0, szNullPluginWindowClassName, (PFNWP)PluginWndProc, 0, sizeof(ULONG));
|
||||
}
|
||||
|
||||
void UnregisterNullPluginWindowClass()
|
||||
{
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
/* */
|
||||
/* CPlugin class implementation */
|
||||
/* */
|
||||
/*********************************************/
|
||||
|
||||
CPlugin::CPlugin(HMODULE hInst,
|
||||
NPP pNPInstance,
|
||||
SHORT wMode,
|
||||
NPMIMEType pluginType,
|
||||
PSZ szPageURL,
|
||||
PSZ szFileURL,
|
||||
PSZ szFileExtension,
|
||||
BOOL bHidden) :
|
||||
m_hInst(hInst),
|
||||
m_pNPInstance(pNPInstance),
|
||||
m_wMode(wMode),
|
||||
m_hWnd(NULL),
|
||||
m_hWndParent(NULL),
|
||||
m_hIcon(NULL),
|
||||
m_szURLString(NULL),
|
||||
m_szCommandMessage(NULL),
|
||||
m_bWaitingStreamFromPFS(FALSE),
|
||||
m_PFSStream(NULL),
|
||||
m_bHidden(bHidden),
|
||||
m_pNPMIMEType(NULL),
|
||||
m_szPageURL(NULL),
|
||||
m_szFileURL(NULL),
|
||||
m_szFileExtension(NULL),
|
||||
m_hWndDialog(NULL),
|
||||
m_bOnline(TRUE),
|
||||
m_bJavaScript(TRUE),
|
||||
m_bSmartUpdate(TRUE)
|
||||
{
|
||||
dbgOut1("CPlugin::CPlugin()");
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
if(pluginType && *pluginType)
|
||||
{
|
||||
m_pNPMIMEType = (NPMIMEType)new char[strlen((PSZ)pluginType) + 1];
|
||||
if(m_pNPMIMEType != NULL)
|
||||
strcpy((PSZ)m_pNPMIMEType, pluginType);
|
||||
}
|
||||
|
||||
if(szPageURL && *szPageURL)
|
||||
{
|
||||
m_szPageURL = new char[strlen(szPageURL) + 1];
|
||||
if(m_szPageURL != NULL)
|
||||
strcpy(m_szPageURL, szPageURL);
|
||||
}
|
||||
|
||||
if(szFileURL && *szFileURL)
|
||||
{
|
||||
m_szFileURL = new char[strlen(szFileURL) + 1];
|
||||
if(m_szFileURL != NULL)
|
||||
strcpy(m_szFileURL, szFileURL);
|
||||
}
|
||||
|
||||
if(szFileExtension && *szFileExtension)
|
||||
{
|
||||
m_szFileExtension = new char[strlen(szFileExtension) + 1];
|
||||
if(m_szFileExtension != NULL)
|
||||
strcpy(m_szFileExtension, szFileExtension);
|
||||
}
|
||||
|
||||
m_hIcon = WinLoadPointer(HWND_DESKTOP, m_hInst, IDI_PLUGICON);
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
WinLoadString((HAB)0, m_hInst, IDS_CLICK_TO_GET, sizeof(szString), szString);
|
||||
if(*szString)
|
||||
{
|
||||
m_szCommandMessage = new char[strlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
strcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
dbgOut1("CPlugin::~CPlugin()");
|
||||
|
||||
if(m_pNPMIMEType != NULL)
|
||||
{
|
||||
delete [] m_pNPMIMEType;
|
||||
m_pNPMIMEType = NULL;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL)
|
||||
{
|
||||
delete [] m_szPageURL;
|
||||
m_szPageURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
delete [] m_szFileURL;
|
||||
m_szFileURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileExtension != NULL)
|
||||
{
|
||||
delete [] m_szFileExtension;
|
||||
m_szFileExtension = NULL;
|
||||
}
|
||||
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
if(m_hIcon != NULL)
|
||||
{
|
||||
WinDestroyPointer(m_hIcon);
|
||||
m_hIcon = NULL;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CPlugin::init(HWND hWndParent)
|
||||
{
|
||||
dbgOut1("CPlugin::init()");
|
||||
|
||||
nsISupports * sm = NULL;
|
||||
nsIPrefBranch * prefBranch = NULL;
|
||||
PRBool bSendUrls = PR_FALSE; // default to false if problem getting pref
|
||||
|
||||
// note that Mozilla will add reference, so do not forget to release
|
||||
NPN_GetValue(NULL, NPNVserviceManager, &sm);
|
||||
|
||||
// do a QI on the service manager we get back to ensure it's the one we are expecting
|
||||
if(sm) {
|
||||
sm->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&gServiceManager);
|
||||
NS_RELEASE(sm);
|
||||
}
|
||||
|
||||
if (gServiceManager) {
|
||||
// get service using its contract id and use it to allocate the memory
|
||||
gServiceManager->GetServiceByContractID(NS_PREFSERVICE_CONTRACTID,
|
||||
NS_GET_IID(nsIPrefBranch),
|
||||
(void **)&prefBranch);
|
||||
if(prefBranch) {
|
||||
prefBranch->GetBoolPref("application.use_ns_plugin_finder", &bSendUrls);
|
||||
NS_RELEASE(prefBranch);
|
||||
}
|
||||
}
|
||||
m_bSmartUpdate = bSendUrls;
|
||||
|
||||
if(!m_bHidden)
|
||||
{
|
||||
assert(WinIsWindow((HAB)0, hWndParent));
|
||||
|
||||
if(WinIsWindow((HAB)0, hWndParent))
|
||||
m_hWndParent = hWndParent;
|
||||
|
||||
RECTL rcParent;
|
||||
WinQueryWindowRect(m_hWndParent, &rcParent);
|
||||
|
||||
m_hWnd = WinCreateWindow(m_hWndParent,
|
||||
szNullPluginWindowClassName,
|
||||
"NULL Plugin",
|
||||
0,
|
||||
0,0, rcParent.xRight, rcParent.yTop,
|
||||
m_hWndParent,
|
||||
HWND_TOP,
|
||||
255,
|
||||
(PVOID)this,
|
||||
0);
|
||||
|
||||
WinSetPresParam(m_hWnd, PP_FONTNAMESIZE, 10, (PVOID)"9.WarpSans");
|
||||
|
||||
assert(m_hWnd != NULL);
|
||||
if((m_hWnd == NULL) || (!WinIsWindow((HAB)0, m_hWnd)))
|
||||
return FALSE;
|
||||
|
||||
// UpdateWindow(m_hWnd);
|
||||
WinShowWindow(m_hWnd, TRUE);
|
||||
}
|
||||
|
||||
if(IsNewMimeType((PSZ)m_pNPMIMEType) || m_bHidden)
|
||||
showGetPluginDialog();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::shut()
|
||||
{
|
||||
dbgOut1("CPlugin::shut()");
|
||||
|
||||
if(m_hWndDialog != NULL)
|
||||
{
|
||||
WinDismissDlg(m_hWndDialog, DID_CANCEL);
|
||||
m_hWndDialog = NULL;
|
||||
}
|
||||
|
||||
if(m_hWnd != NULL)
|
||||
{
|
||||
WinDestroyWindow(m_hWnd);
|
||||
m_hWnd = NULL;
|
||||
}
|
||||
|
||||
// we should release the service manager
|
||||
NS_IF_RELEASE(gServiceManager);
|
||||
gServiceManager = NULL;
|
||||
}
|
||||
|
||||
HWND CPlugin::getWindow()
|
||||
{
|
||||
return m_hWnd;
|
||||
}
|
||||
|
||||
BOOL CPlugin::useDefaultURL_P()
|
||||
{
|
||||
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CPlugin::doSmartUpdate_P()
|
||||
{
|
||||
// due to current JavaScript problems never do it smart for now 5.1.98
|
||||
return FALSE;
|
||||
|
||||
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
PSZ CPlugin::createURLString()
|
||||
{
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
// check if there is file URL first
|
||||
if(!m_bSmartUpdate && m_szFileURL != NULL)
|
||||
{
|
||||
m_szURLString = new char[strlen(m_szFileURL) + 1];
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
strcpy(m_szURLString, m_szFileURL);
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
// if not get the page URL
|
||||
char * szAddress = NULL;
|
||||
char *urlToOpen = NULL;
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava)
|
||||
{
|
||||
szAddress = new char[strlen(m_szPageURL) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
strcpy(szAddress, m_szPageURL);
|
||||
|
||||
m_szURLString = new char[strlen(szAddress) + 1 +
|
||||
strlen((PSZ)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
sprintf(m_szURLString, "%s?%s", szAddress, (PSZ)m_pNPMIMEType);
|
||||
}
|
||||
else // default
|
||||
{
|
||||
if(!m_bSmartUpdate)
|
||||
{
|
||||
urlToOpen = szDefaultPluginFinderURL;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
szAddress = new char[strlen(urlToOpen) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
strcpy(szAddress, urlToOpen);
|
||||
|
||||
m_szURLString = new char[strlen(szAddress) + 10 +
|
||||
strlen((PSZ)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
sprintf(m_szURLString, "%s?mimetype=%s",
|
||||
szAddress, (PSZ)m_pNPMIMEType);
|
||||
}
|
||||
else
|
||||
{
|
||||
urlToOpen = szPageUrlForJavaScript;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
// wsprintf doesn't like null pointers on NT or 98, so
|
||||
// change any null string pointers to null strings
|
||||
if (!m_szPageURL) {
|
||||
m_szPageURL = new char[1];
|
||||
m_szPageURL[0] = '\0';
|
||||
}
|
||||
|
||||
if (!m_szFileURL) {
|
||||
m_szFileURL = new char[1];
|
||||
m_szFileURL[0] = '\0';
|
||||
}
|
||||
|
||||
m_szURLString = new char[strlen(szPluginFinderCommandBeginning) + strlen(urlToOpen) + 10 +
|
||||
strlen((PSZ)m_pNPMIMEType) + 13 +
|
||||
strlen((PSZ)m_szPageURL) + 11 +
|
||||
strlen((PSZ)m_szFileURL) +
|
||||
strlen(szPluginFinderCommandEnd) + 1];
|
||||
sprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
|
||||
szPluginFinderCommandBeginning, urlToOpen,
|
||||
(PSZ)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd);
|
||||
}
|
||||
}
|
||||
|
||||
if(szAddress != NULL)
|
||||
delete [] szAddress;
|
||||
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginRegular()
|
||||
{
|
||||
assert(m_bOnline);
|
||||
|
||||
char * szURL = createURLString();
|
||||
|
||||
assert(szURL != NULL);
|
||||
if(szURL == NULL)
|
||||
return;
|
||||
|
||||
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szURL, NULL);
|
||||
m_bWaitingStreamFromPFS = TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginSmart()
|
||||
{
|
||||
/*
|
||||
static char szJSString[2048];
|
||||
|
||||
sprintf(szJSString,
|
||||
szPluginFinderCommandFormatString,
|
||||
szDefaultPluginFinderURL,
|
||||
m_pNPMIMEType,
|
||||
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
|
||||
|
||||
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
|
||||
|
||||
assert(*szJSString);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
|
||||
*/
|
||||
}
|
||||
|
||||
void CPlugin::showGetPluginDialog()
|
||||
{
|
||||
assert(m_pNPMIMEType != NULL);
|
||||
if(m_pNPMIMEType == NULL)
|
||||
return;
|
||||
|
||||
// Get environment
|
||||
BOOL bOffline = FALSE;
|
||||
|
||||
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
|
||||
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
|
||||
//NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
|
||||
|
||||
m_bOnline = !bOffline;
|
||||
|
||||
dbgOut1("Environment:");
|
||||
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
|
||||
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
|
||||
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
|
||||
|
||||
if((!m_bSmartUpdate && (m_szPageURL != NULL) || (m_szFileURL != NULL)) || !m_bJavaScript)
|
||||
{
|
||||
int iRet = WinDlgBox(HWND_DESKTOP, m_hWnd, (PFNWP)GetPluginDialogProc, m_hInst,
|
||||
IDD_PLUGIN_DOWNLOAD, (PVOID)this);
|
||||
if(iRet != IDC_GET_PLUGIN)
|
||||
return;
|
||||
}
|
||||
else
|
||||
getPlugin();
|
||||
}
|
||||
|
||||
void CPlugin::getPlugin()
|
||||
{
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
WinLoadString((HAB)0, m_hInst, IDS_CLICK_WHEN_DONE, sizeof(szString), szString);
|
||||
if(*szString)
|
||||
{
|
||||
m_szCommandMessage = new char[strlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
strcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
|
||||
WinInvalidateRect(m_hWnd, NULL, TRUE);
|
||||
// UpdateWindow(m_hWnd);
|
||||
|
||||
getPluginRegular();
|
||||
}
|
||||
|
||||
//*******************
|
||||
// NP API handles
|
||||
//*******************
|
||||
void CPlugin::resize()
|
||||
{
|
||||
dbgOut1("CPlugin::resize()");
|
||||
}
|
||||
|
||||
void CPlugin::print(NPPrint * pNPPrint)
|
||||
{
|
||||
dbgOut1("CPlugin::print()");
|
||||
|
||||
if(pNPPrint == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
void CPlugin::URLNotify(const char * szURL)
|
||||
{
|
||||
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
|
||||
|
||||
NPStream * pStream = NULL;
|
||||
char buf[256];
|
||||
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
int iSize = WinLoadString((HAB)0, m_hInst, IDS_GOING2HTML, sizeof(buf), buf);
|
||||
|
||||
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
|
||||
if (rc != NPERR_NO_ERROR)
|
||||
return;
|
||||
|
||||
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
|
||||
|
||||
NPN_Write(m_pNPInstance, pStream, iSize, buf);
|
||||
|
||||
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
|
||||
}
|
||||
|
||||
NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype)
|
||||
{
|
||||
if (!m_bWaitingStreamFromPFS)
|
||||
return NPERR_NO_ERROR;
|
||||
|
||||
m_bWaitingStreamFromPFS = FALSE;
|
||||
m_PFSStream = stream;
|
||||
|
||||
if (stream) {
|
||||
if (type && !strcmp(type, "application/x-xpinstall"))
|
||||
NPN_GetURL(m_pNPInstance, stream->url, "_self");
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, stream->url, "_blank");
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError CPlugin::destroyStream(NPStream *stream, NPError reason)
|
||||
{
|
||||
if (stream == m_PFSStream)
|
||||
m_PFSStream = NULL;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
BOOL CPlugin::readyToRefresh()
|
||||
{
|
||||
char szString[1024] = {'\0'};
|
||||
WinLoadString((HAB)0, m_hInst, IDS_CLICK_WHEN_DONE, sizeof(szString), szString);
|
||||
if(m_szCommandMessage == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (strcmp(m_szCommandMessage, szString) == 0);
|
||||
}
|
||||
|
||||
//***************************
|
||||
// Windows message handlers
|
||||
//***************************
|
||||
void CPlugin::onCreate(HWND hWnd)
|
||||
{
|
||||
m_hWnd = hWnd;
|
||||
}
|
||||
|
||||
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
static void DrawCommandMessage(HPS hPS, PSZ szString, PRECTL lprc)
|
||||
{
|
||||
if(szString == NULL)
|
||||
return;
|
||||
|
||||
POINTL ptls[5];
|
||||
GpiQueryTextBox(hPS, strlen(szString), szString, 5, ptls);
|
||||
|
||||
/* If the text won't fit, don't draw anything */
|
||||
if (ptls[TXTBOX_CONCAT].x > lprc->xRight)
|
||||
return;
|
||||
|
||||
RECTL rcText = rcText = *lprc;
|
||||
|
||||
/* Reduce top of rectangle by twice the icon size so the */
|
||||
/* text draws below the icon */
|
||||
rcText.yTop -= 80;
|
||||
|
||||
WinDrawText(hPS, strlen(szString), szString, &rcText, 0, 0,
|
||||
DT_TEXTATTRS | DT_CENTER | DT_VCENTER);
|
||||
}
|
||||
|
||||
#define INSET 1
|
||||
|
||||
void CPlugin::onPaint(HWND hWnd)
|
||||
{
|
||||
RECTL rc;
|
||||
HDC hPS;
|
||||
int x, y;
|
||||
|
||||
hPS = WinBeginPaint(hWnd, NULLHANDLE, NULL);
|
||||
GpiErase(hPS);
|
||||
WinQueryWindowRect(hWnd, &rc);
|
||||
|
||||
x = (rc.xRight / 2) - (40 / 2);
|
||||
y = (rc.yTop / 2) - ((40) / 2);
|
||||
|
||||
/* Only draw the icon if it fits */
|
||||
if(rc.xRight > (40 + 6 + INSET) && rc.yTop > (40 + 6 + INSET) )
|
||||
{
|
||||
if(m_hIcon != NULL)
|
||||
WinDrawPointer(hPS, x, y, m_hIcon, DP_NORMAL);
|
||||
}
|
||||
|
||||
POINTL pt[5];
|
||||
|
||||
// white piece
|
||||
GpiSetColor(hPS, CLR_WHITE);
|
||||
|
||||
pt[0].x = 1 + INSET;
|
||||
pt[0].y = 1 + INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = rc.xRight - 2 - INSET;
|
||||
pt[0].y = 1 + INSET;
|
||||
pt[1].x = rc.xRight - 2 - INSET;
|
||||
pt[1].y = rc.yTop -1 - INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
pt[0].x = 2 + INSET;
|
||||
pt[0].y = 3 + INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = 2 + INSET;
|
||||
pt[0].y = rc.yTop - 3 - INSET;
|
||||
pt[1].x = rc.xRight - 4 - INSET;
|
||||
pt[1].y = rc.yTop - 3 - INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
// pale gray pieces
|
||||
GpiSetColor(hPS, CLR_PALEGRAY);
|
||||
pt[0].x = INSET;
|
||||
pt[0].y = 1 + INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = INSET;
|
||||
pt[0].y = rc.yTop - 1 - INSET;
|
||||
pt[1].x = rc.xRight - 2 - INSET;
|
||||
pt[1].y = rc.yTop - 1 - INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
pt[0].x = rc.xRight - 3 - INSET;
|
||||
pt[0].y = rc.yTop - 2 - INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = rc.xRight - 3 - INSET;
|
||||
pt[0].y = 2 + INSET;
|
||||
pt[1].x = 2 + INSET;
|
||||
pt[1].y = 2 + INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
// dark gray piece
|
||||
GpiSetColor(hPS, CLR_DARKGRAY);
|
||||
|
||||
pt[0].x = 1 + INSET;
|
||||
pt[0].y = 2 + INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = 1 + INSET;
|
||||
pt[0].y = rc.yTop - 2 - INSET;
|
||||
pt[1].x = rc.xRight - 4 - INSET;
|
||||
pt[1].y = rc.yTop - 2 - INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
// black piece
|
||||
GpiSetColor(hPS, CLR_BLACK);
|
||||
|
||||
pt[0].x = rc.xRight - 1 - INSET;
|
||||
pt[0].y = rc.yTop - 1 - INSET;
|
||||
GpiMove(hPS, &pt[0]);
|
||||
|
||||
pt[0].x = rc.xRight - 1 - INSET;
|
||||
pt[0].y = 0 + INSET;
|
||||
pt[1].x = 0 + INSET;
|
||||
pt[1].y = 0 + INSET;
|
||||
|
||||
GpiPolyLine(hPS, 2, pt);
|
||||
|
||||
/* Offset rectangle by size of highlight(3) + 1 as well as inset */
|
||||
/* so that text is not drawn over the border */
|
||||
rc.xLeft += 4+INSET;
|
||||
rc.xRight -= 4+INSET;
|
||||
rc.yTop -= 4+INSET;
|
||||
rc.yBottom += 4+INSET;
|
||||
|
||||
DrawCommandMessage(hPS, m_szCommandMessage, &rc);
|
||||
|
||||
WinEndPaint (hPS);
|
||||
}
|
||||
|
||||
//**************************
|
||||
// Plugin window procedure
|
||||
//**************************
|
||||
MRESULT EXPENTRY NP_LOADDS PluginWndProc(HWND hWnd, ULONG message, MPARAM mp1, MPARAM mp2)
|
||||
{
|
||||
CPlugin *pPlugin = (CPlugin *)WinQueryWindowULong(hWnd, QWL_USER);
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
pPlugin = (CPlugin *)(((PCREATESTRUCT)mp2)->pCtlData);
|
||||
assert(pPlugin != NULL);
|
||||
WinSetWindowULong(hWnd, QWL_USER, (ULONG)pPlugin);
|
||||
pPlugin->onCreate(hWnd);
|
||||
return 0L;
|
||||
case WM_BUTTON1UP:
|
||||
pPlugin->onLButtonUp(hWnd,0,0,0);
|
||||
return 0L;
|
||||
case WM_BUTTON2UP:
|
||||
pPlugin->onRButtonUp(hWnd,0,0,0);
|
||||
return 0L;
|
||||
case WM_PAINT:
|
||||
pPlugin->onPaint(hWnd);
|
||||
return 0L;
|
||||
case WM_MOUSEMOVE:
|
||||
dbgOut1("MouseMove");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(WinDefWindowProc(hWnd, message, mp1, mp2));
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __PLUGIN_HPP__
|
||||
#define __PLUGIN_HPP__
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
private:
|
||||
HMODULE m_hInst;
|
||||
NPP m_pNPInstance;
|
||||
SHORT m_wMode;
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndParent;
|
||||
HPOINTER m_hIcon;
|
||||
char * m_szURLString;
|
||||
|
||||
char * m_szCommandMessage;
|
||||
BOOL m_bWaitingStreamFromPFS;
|
||||
NPStream* m_PFSStream;
|
||||
|
||||
public:
|
||||
BOOL m_bHidden;
|
||||
NPMIMEType m_pNPMIMEType;
|
||||
PSZ m_szPageURL; // Location of plug-in HTML page
|
||||
PSZ m_szFileURL; // Location of plug-in JAR file
|
||||
PSZ m_szFileExtension; // File extension associated with the of the unknown mimetype
|
||||
HWND m_hWndDialog;
|
||||
|
||||
// environment
|
||||
BOOL m_bOnline;
|
||||
BOOL m_bJavaScript;
|
||||
BOOL m_bSmartUpdate;
|
||||
|
||||
private:
|
||||
BOOL useDefaultURL_P();
|
||||
BOOL doSmartUpdate_P();
|
||||
PSZ createURLString();
|
||||
void getPluginSmart();
|
||||
void getPluginRegular();
|
||||
|
||||
public:
|
||||
CPlugin(HMODULE hInst,
|
||||
NPP pNPInstance,
|
||||
SHORT wMode,
|
||||
NPMIMEType pluginType,
|
||||
PSZ szPageURL,
|
||||
PSZ szFileURL,
|
||||
PSZ szFileExtension,
|
||||
BOOL bHidden);
|
||||
~CPlugin();
|
||||
|
||||
BOOL init(HWND hWnd);
|
||||
void shut();
|
||||
HWND getWindow();
|
||||
void showGetPluginDialog();
|
||||
void getPlugin();
|
||||
BOOL readyToRefresh();
|
||||
|
||||
// NP API handlers
|
||||
void print(NPPrint * pNPPrint);
|
||||
void URLNotify(const char * szURL);
|
||||
NPError newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype);
|
||||
NPError destroyStream(NPStream *stream, NPError reason);
|
||||
|
||||
// Windows message handlers
|
||||
void onCreate(HWND hWnd);
|
||||
void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onPaint(HWND hWnd);
|
||||
|
||||
void resize();
|
||||
};
|
||||
|
||||
|
||||
#define PAGE_URL_FOR_JAVASCRIPT "http://plugindoc.mozdev.org/winmime.html"
|
||||
|
||||
#define PLUGINFINDER_COMMAND_BEGINNING "javascript:window.open(\""
|
||||
#define PLUGINFINDER_COMMAND_END "\",\"plugin\",\"toolbar=no,status=no,resizable=no,scrollbars=no,height=252,width=626\");"
|
||||
#define DEFAULT_PLUGINFINDER_URL "http://plugindoc.mozdev.org/OS2.html"
|
||||
#define JVM_SMARTUPDATE_URL "http://plugindoc.mozdev.org/OS2.html"
|
||||
|
||||
#define OS2INI_PLACE "Mozilla Default Plugin"
|
||||
#define GWL_USERDATA 0
|
||||
#define COLOR_3DSHADOW COLOR_BTNFACE
|
||||
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
|
||||
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
|
||||
|
||||
#define CLASS_NULL_PLUGIN "NullPluginClass"
|
||||
|
||||
BOOL RegisterNullPluginWindowClass();
|
||||
void UnregisterNullPluginWindowClass();
|
||||
|
||||
extern HMODULE hInst;
|
||||
|
||||
#endif // __PLUGIN_HPP__
|
@ -1,156 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define INCL_GPI
|
||||
#define INCL_WIN
|
||||
#include <os2.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
// return TRUE if we've never seen this MIME type before
|
||||
BOOL IsNewMimeType(PSZ mime)
|
||||
{
|
||||
ULONG keysize = 512;
|
||||
char keybuf[512];
|
||||
|
||||
PrfQueryProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "", keybuf, keysize);
|
||||
if (keybuf[0] != '\0') {
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(PrfWriteProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "(none)")))
|
||||
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Error adding MIME type value", "Default Plugin", 0, MB_OK);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// string length in pixels for the specific window (selected font)
|
||||
static int getWindowStringLength(HWND hWnd, PSZ lpsz)
|
||||
{
|
||||
HPS hPS = WinGetPS(hWnd);
|
||||
|
||||
POINTL ptls[5];
|
||||
GpiQueryTextBox(hPS, strlen(lpsz), lpsz, 5, ptls);
|
||||
POINTL pt;
|
||||
pt.x = ptls[TXTBOX_CONCAT].x;
|
||||
pt.y = ptls[TXTBOX_TOPLEFT].y - ptls[TXTBOX_BOTTOMLEFT].y;
|
||||
WinReleasePS(hPS);
|
||||
return (int)pt.x;
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
/* */
|
||||
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText) */
|
||||
/* */
|
||||
/* helper to wrap long lines in a static control, which do not */
|
||||
/* wrap automatically if they do not have space characters */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText)
|
||||
{
|
||||
HWND hWndStatic = WinWindowFromID(hWnd, iID);
|
||||
if(!szText || !*szText)
|
||||
{
|
||||
WinSetDlgItemText(hWnd, iID, "");
|
||||
return;
|
||||
}
|
||||
|
||||
RECTL rc;
|
||||
WinQueryWindowRect(hWndStatic, &rc);
|
||||
|
||||
int iStaticLength = rc.xRight - rc.xLeft;
|
||||
int iStringLength = getWindowStringLength(hWndStatic, szText);
|
||||
|
||||
if(iStringLength <= iStaticLength)
|
||||
{
|
||||
WinSetDlgItemText(hWnd, iID, szText);
|
||||
return;
|
||||
}
|
||||
|
||||
int iBreaks = iStringLength/iStaticLength;
|
||||
if(iBreaks <= 0)
|
||||
return;
|
||||
|
||||
char * pBuf = new char[iStringLength + iBreaks + 1];
|
||||
if(pBuf == NULL)
|
||||
return;
|
||||
|
||||
strcpy(pBuf, "");
|
||||
|
||||
int iStart = 0;
|
||||
int iLines = 0;
|
||||
for(int i = 0; i < iStringLength; i++)
|
||||
{
|
||||
char * sz = &szText[iStart];
|
||||
int iIndex = i - iStart;
|
||||
char ch = sz[iIndex + 1];
|
||||
|
||||
sz[iIndex + 1] = '\0';
|
||||
|
||||
int iLength = getWindowStringLength(hWndStatic, sz);
|
||||
|
||||
if(iLength < iStaticLength)
|
||||
{
|
||||
sz[iIndex + 1] = ch;
|
||||
if(iLines == iBreaks)
|
||||
{
|
||||
strcat(pBuf, sz);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sz[iIndex + 1] = ch; // restore zeroed element
|
||||
i--; // go one step back
|
||||
|
||||
ch = sz[iIndex];
|
||||
sz[iIndex] = '\0'; // terminate string one char shorter
|
||||
|
||||
strcat(pBuf, sz); // append the string
|
||||
strcat(pBuf, " "); // append space character for successful wrapping
|
||||
|
||||
iStart += strlen(sz);// shift new start position
|
||||
sz[iIndex] = ch; // restore zeroed element
|
||||
iLines++; // count lines
|
||||
}
|
||||
|
||||
WinSetDlgItemText(hWnd, iID, pBuf);
|
||||
|
||||
delete [] pBuf;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
BOOL IsNewMimeType(PSZ szMimeType);
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText);
|
||||
|
||||
#endif // __UTILS_H__
|
@ -1,92 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
LIBRARY_NAME = nullplugin
|
||||
GRE_MODULE = 1
|
||||
|
||||
|
||||
CSRCS = \
|
||||
npshell.c\
|
||||
nullplugin.c\
|
||||
npunix.c\
|
||||
$(NULL)
|
||||
|
||||
# plugins should always be shared, even in the "static" build
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
NO_DIST_INSTALL = 1
|
||||
NO_INSTALL = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(XT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS)
|
||||
CXXFLAGS += $(MOZ_GTK2_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK2_CFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), OpenVMS)
|
||||
DEFINES += -DGENERIC_MOTIF_REDEFINES
|
||||
OS_CXXFLAGS += -Wc,warn=disa=NOSIMPINT
|
||||
endif
|
||||
|
||||
install-plugin: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
|
||||
endif
|
||||
|
||||
libs:: install-plugin
|
||||
|
||||
ifdef SHARED_LIBRARY
|
||||
install:: $(SHARED_LIBRARY)
|
||||
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
|
||||
endif
|
||||
|
@ -1,383 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* npshell.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Function that need to be implemented by plugin developers
|
||||
*
|
||||
* This file defines a "shell" plugin that plugin developers can use
|
||||
* as the basis for a real plugin. This shell just provides empty
|
||||
* implementations of all functions that the plugin can implement
|
||||
* that will be called by Netscape (the NPP_xxx methods defined in
|
||||
* npapi.h).
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
#include "strings.h"
|
||||
#include "plstr.h"
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Implementations of plugin API functions
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
char*
|
||||
NPP_GetMIMEDescription(void)
|
||||
{
|
||||
return(MIME_TYPES_HANDLED);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_GetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
switch (variable) {
|
||||
case NPPVpluginNameString:
|
||||
*((char **)value) = PLUGIN_NAME;
|
||||
break;
|
||||
case NPPVpluginDescriptionString:
|
||||
*((char **)value) = PLUGIN_DESCRIPTION;
|
||||
break;
|
||||
default:
|
||||
err = NPERR_GENERIC_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_Initialize(void)
|
||||
{
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
NPP_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_New(NPMIMEType pluginType,
|
||||
NPP instance,
|
||||
uint16_t mode,
|
||||
int16_t argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
instance->pdata = NPN_MemAlloc(sizeof(PluginInstance));
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
{
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
memset(This, 0, sizeof(PluginInstance));
|
||||
|
||||
/* mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h) */
|
||||
This->mode = mode;
|
||||
This->type = dupMimeType(pluginType);
|
||||
This->instance = instance;
|
||||
This->pluginsPageUrl = NULL;
|
||||
This->exists = FALSE;
|
||||
|
||||
/* Parse argument list passed to plugin instance */
|
||||
/* We are interested in these arguments
|
||||
* PLUGINSPAGE = <url>
|
||||
*/
|
||||
while (argc > 0)
|
||||
{
|
||||
argc --;
|
||||
if (argv[argc] != NULL)
|
||||
{
|
||||
if (!PL_strcasecmp(argn[argc], "PLUGINSPAGE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!PL_strcasecmp(argn[argc], "PLUGINURL"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!PL_strcasecmp(argn[argc], "CODEBASE"))
|
||||
This->pluginsPageUrl = strdup(argv[argc]);
|
||||
else if (!PL_strcasecmp(argn[argc], "CLASSID"))
|
||||
This->pluginsFileUrl = strdup(argv[argc]);
|
||||
else if (!PL_strcasecmp(argn[argc], "HIDDEN"))
|
||||
This->pluginsHidden = (!PL_strcasecmp(argv[argc],
|
||||
"TRUE"));
|
||||
}
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPP_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
|
||||
PluginInstance* This;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This != NULL) {
|
||||
if (This->dialogBox)
|
||||
destroyWidget(This);
|
||||
if (This->type)
|
||||
NPN_MemFree(This->type);
|
||||
if (This->pluginsPageUrl)
|
||||
NPN_MemFree(This->pluginsPageUrl);
|
||||
if (This->pluginsFileUrl)
|
||||
NPN_MemFree(This->pluginsFileUrl);
|
||||
NPN_MemFree(instance->pdata);
|
||||
instance->pdata = NULL;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
PluginInstance* This;
|
||||
NPSetWindowCallbackStruct *ws_info;
|
||||
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
|
||||
if (This == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
if (This->window == (Window) window->window) {
|
||||
/* The page with the plugin is being resized.
|
||||
Save any UI information because the next time
|
||||
around expect a SetWindow with a new window
|
||||
id.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Nullplugin: plugin received window resize.\n");
|
||||
fprintf(stderr, "Window=(%i)\n", (int)window);
|
||||
fprintf(stderr, "W=(%i) H=(%i)\n",
|
||||
(int)window->width, (int)window->height);
|
||||
#endif
|
||||
return NPERR_NO_ERROR;
|
||||
} else {
|
||||
|
||||
This->window = (Window) window->window;
|
||||
This->x = window->x;
|
||||
This->y = window->y;
|
||||
This->width = window->width;
|
||||
This->height = window->height;
|
||||
This->display = ws_info->display;
|
||||
This->visual = ws_info->visual;
|
||||
This->depth = ws_info->depth;
|
||||
This->colormap = ws_info->colormap;
|
||||
makePixmap(This);
|
||||
makeWidget(This);
|
||||
}
|
||||
#endif /* #ifdef MOZ_X11 */
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16_t *stype)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
/* We don't want any data, kill the stream */
|
||||
NPN_DestroyStream(instance, stream, NPRES_DONE);
|
||||
|
||||
/* Number of bytes ready to accept in NPP_Write() */
|
||||
return -1L; /* don't accept any bytes in NPP_Write() */
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
NPP_Write(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buffer)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
/* We don't want any data, kill the stream */
|
||||
NPN_DestroyStream(instance, stream, NPRES_DONE);
|
||||
|
||||
return -1L; /* don't accept any bytes in NPP_Write() */
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
/***** Insert NPP_DestroyStream code here *****\
|
||||
PluginInstance* This;
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\**********************************************/
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
/***** Insert NPP_StreamAsFile code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*********************************************/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_URLNotify(NPP instance, const char* url,
|
||||
NPReason reason, void* notifyData)
|
||||
{
|
||||
/***** Insert NPP_URLNotify code here *****\
|
||||
PluginInstance* This;
|
||||
if (instance != NULL)
|
||||
This = (PluginInstance*) instance->pdata;
|
||||
\*********************************************/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
if(printInfo == NULL)
|
||||
return;
|
||||
|
||||
if (instance != NULL) {
|
||||
/***** Insert NPP_Print code here *****\
|
||||
PluginInstance* This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
if (printInfo->mode == NP_FULL) {
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin would like to take over
|
||||
* printing completely when it is in full-screen mode,
|
||||
* set printInfo->pluginPrinted to TRUE and print your
|
||||
* plugin as you see fit. If your plugin wants Netscape
|
||||
* to handle printing in this case, set
|
||||
* printInfo->pluginPrinted to FALSE (the default) and
|
||||
* do nothing. If you do want to handle printing
|
||||
* yourself, printOne is true if the print button
|
||||
* (as opposed to the print menu) was clicked.
|
||||
* On the Macintosh, platformPrint is a THPrint; on
|
||||
* Windows, platformPrint is a structure
|
||||
* (defined in npapi.h) containing the printer name, port,
|
||||
* etc.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
void* platformPrint =
|
||||
printInfo->print.fullPrint.platformPrint;
|
||||
NPBool printOne =
|
||||
printInfo->print.fullPrint.printOne;
|
||||
\**************************************/
|
||||
|
||||
/* Do the default*/
|
||||
printInfo->print.fullPrint.pluginPrinted = FALSE;
|
||||
}
|
||||
else { /* If not fullscreen, we must be embedded */
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
* If your plugin is embedded, or is full-screen
|
||||
* but you returned false in pluginPrinted above, NPP_Print
|
||||
* will be called with mode == NP_EMBED. The NPWindow
|
||||
* in the printInfo gives the location and dimensions of
|
||||
* the embedded plugin on the printed page. On the
|
||||
* Macintosh, platformPrint is the printer port; on
|
||||
* Windows, platformPrint is the handle to the printing
|
||||
* device context.
|
||||
*/
|
||||
|
||||
/***** Insert NPP_Print code here *****\
|
||||
NPWindow* printWindow =
|
||||
&(printInfo->print.embedPrint.window);
|
||||
void* platformPrint =
|
||||
printInfo->print.embedPrint.platformPrint;
|
||||
\**************************************/
|
||||
}
|
||||
}
|
||||
}
|
@ -1,654 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* npunix.c
|
||||
*
|
||||
* Netscape Client Plugin API
|
||||
* - Wrapper function to interface with the Netscape Navigator
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* PLUGIN DEVELOPERS:
|
||||
* YOU WILL NOT NEED TO EDIT THIS FILE.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define XP_UNIX 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
/*
|
||||
* Define PLUGIN_TRACE to have the wrapper functions print
|
||||
* messages to stderr whenever they are called.
|
||||
*/
|
||||
|
||||
#ifdef PLUGIN_TRACE
|
||||
#include <stdio.h>
|
||||
#define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
|
||||
#else
|
||||
#define PLUGINDEBUGSTR(msg)
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Globals
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : plugin calling Netscape Navigator
|
||||
*
|
||||
* These functions let the plugin developer just call the APIs
|
||||
* as documented and defined in npapi.h, without needing to know
|
||||
* about the function table and call macros in npupp.h.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
void
|
||||
NPN_Version(int* plugin_major, int* plugin_minor,
|
||||
int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
|
||||
/* Major version is in high byte */
|
||||
*netscape_major = gNetscapeFuncs.version >> 8;
|
||||
/* Minor version is in low byte */
|
||||
*netscape_minor = gNetscapeFuncs.version & 0xFF;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
|
||||
{
|
||||
return (*gNetscapeFuncs.getvalue)(instance, variable, r_value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
|
||||
{
|
||||
return (*gNetscapeFuncs.setvalue)(instance, variable, value);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURL(NPP instance, const char* url, const char* window)
|
||||
{
|
||||
return (*gNetscapeFuncs.geturl)(instance, url, window);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
|
||||
{
|
||||
return (*gNetscapeFuncs.geturlnotify)(instance, url, window, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURL(NPP instance, const char* url, const char* window,
|
||||
uint32_t len, const char* buf, NPBool file)
|
||||
{
|
||||
return (*gNetscapeFuncs.posturl)(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len,
|
||||
const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
return (*gNetscapeFuncs.posturlnotify)(instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return (*gNetscapeFuncs.requestread)(stream, rangeList);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
|
||||
NPStream** stream_ptr)
|
||||
{
|
||||
return (*gNetscapeFuncs.newstream)(instance, type, window, stream_ptr);
|
||||
}
|
||||
|
||||
int32_t
|
||||
NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
|
||||
{
|
||||
return (*gNetscapeFuncs.write)(instance, stream, len, buffer);
|
||||
}
|
||||
|
||||
NPError
|
||||
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
return (*gNetscapeFuncs.destroystream)(instance, stream, reason);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_Status(NPP instance, const char* message)
|
||||
{
|
||||
(*gNetscapeFuncs.status)(instance, message);
|
||||
}
|
||||
|
||||
const char*
|
||||
NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return (*gNetscapeFuncs.uagent)(instance);
|
||||
}
|
||||
|
||||
void*
|
||||
NPN_MemAlloc(uint32_t size)
|
||||
{
|
||||
return (*gNetscapeFuncs.memalloc)(size);
|
||||
}
|
||||
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
(*gNetscapeFuncs.memfree)(ptr);
|
||||
}
|
||||
|
||||
uint32_t NPN_MemFlush(uint32_t size)
|
||||
{
|
||||
return (*gNetscapeFuncs.memflush)(size);
|
||||
}
|
||||
|
||||
void NPN_ReloadPlugins(NPBool reloadPages)
|
||||
{
|
||||
(*gNetscapeFuncs.reloadplugins)(reloadPages);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
|
||||
{
|
||||
(*gNetscapeFuncs.invalidaterect)(instance, invalidRect);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
|
||||
{
|
||||
(*gNetscapeFuncs.invalidateregion)(instance, invalidRegion);
|
||||
}
|
||||
|
||||
void
|
||||
NPN_ForceRedraw(NPP instance)
|
||||
{
|
||||
(*gNetscapeFuncs.forceredraw)(instance);
|
||||
}
|
||||
|
||||
void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
|
||||
{
|
||||
(*gNetscapeFuncs.pushpopupsenabledstate)(instance, enabled);
|
||||
}
|
||||
|
||||
void NPN_PopPopupsEnabledState(NPP instance)
|
||||
{
|
||||
(*gNetscapeFuncs.poppopupsenabledstate)(instance);
|
||||
}
|
||||
|
||||
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
|
||||
{
|
||||
return (*gNetscapeFuncs.getstringidentifier)(name);
|
||||
}
|
||||
|
||||
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
|
||||
NPIdentifier *identifiers)
|
||||
{
|
||||
(*gNetscapeFuncs.getstringidentifiers)(names, nameCount, identifiers);
|
||||
}
|
||||
|
||||
NPIdentifier NPN_GetIntIdentifier(int32_t intid)
|
||||
{
|
||||
return (*gNetscapeFuncs.getintidentifier)(intid);
|
||||
}
|
||||
|
||||
bool NPN_IdentifierIsString(NPIdentifier identifier)
|
||||
{
|
||||
return (*gNetscapeFuncs.identifierisstring)(identifier);
|
||||
}
|
||||
|
||||
NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
|
||||
{
|
||||
return (*gNetscapeFuncs.utf8fromidentifier)(identifier);
|
||||
}
|
||||
|
||||
int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
|
||||
{
|
||||
return (*gNetscapeFuncs.intfromidentifier)(identifier);
|
||||
}
|
||||
|
||||
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
|
||||
{
|
||||
return (*gNetscapeFuncs.createobject)(npp, aClass);
|
||||
}
|
||||
|
||||
NPObject *NPN_RetainObject(NPObject *obj)
|
||||
{
|
||||
return (*gNetscapeFuncs.retainobject)(obj);
|
||||
}
|
||||
|
||||
void NPN_ReleaseObject(NPObject *obj)
|
||||
{
|
||||
(*gNetscapeFuncs.releaseobject)(obj);
|
||||
}
|
||||
|
||||
bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
|
||||
const NPVariant *args, uint32_t argCount, NPVariant *result)
|
||||
{
|
||||
return (*gNetscapeFuncs.invoke)(npp, obj, methodName, args, argCount, result);
|
||||
}
|
||||
|
||||
bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
|
||||
uint32_t argCount, NPVariant *result)
|
||||
{
|
||||
return (*gNetscapeFuncs.invokeDefault)(npp, obj, args, argCount, result);
|
||||
}
|
||||
|
||||
bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
|
||||
NPVariant *result)
|
||||
{
|
||||
return (*gNetscapeFuncs.evaluate)(npp, obj, script, result);
|
||||
}
|
||||
|
||||
bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
|
||||
NPVariant *result)
|
||||
{
|
||||
return (*gNetscapeFuncs.getproperty)(npp, obj, propertyName, result);
|
||||
}
|
||||
|
||||
bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
|
||||
const NPVariant *value)
|
||||
{
|
||||
return (*gNetscapeFuncs.setproperty)(npp, obj, propertyName, value);
|
||||
}
|
||||
|
||||
bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
|
||||
{
|
||||
return (*gNetscapeFuncs.removeproperty)(npp, obj, propertyName);
|
||||
}
|
||||
|
||||
bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
|
||||
{
|
||||
return (*gNetscapeFuncs.hasproperty)(npp, obj, propertyName);
|
||||
}
|
||||
|
||||
bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
|
||||
{
|
||||
return (*gNetscapeFuncs.hasmethod)(npp, obj, methodName);
|
||||
}
|
||||
|
||||
void NPN_ReleaseVariantValue(NPVariant *variant)
|
||||
{
|
||||
(*gNetscapeFuncs.releasevariantvalue)(variant);
|
||||
}
|
||||
|
||||
void NPN_SetException(NPObject* obj, const NPUTF8 *message)
|
||||
{
|
||||
(*gNetscapeFuncs.setexception)(obj, message);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Wrapper functions : Netscape Navigator -> plugin
|
||||
*
|
||||
* These functions let the plugin developer just create the APIs
|
||||
* as documented and defined in npapi.h, without needing to
|
||||
* install those functions in the function table or worry about
|
||||
* setting up globals for 68K plugins.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
NPError
|
||||
Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
|
||||
int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
|
||||
{
|
||||
NPError ret;
|
||||
PLUGINDEBUGSTR("New");
|
||||
ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
return ret;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_Destroy(NPP instance, NPSavedData** save)
|
||||
{
|
||||
PLUGINDEBUGSTR("Destroy");
|
||||
return NPP_Destroy(instance, save);
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("SetWindow");
|
||||
err = NPP_SetWindow(instance, window);
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError
|
||||
Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
|
||||
NPBool seekable, uint16_t* stype)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("NewStream");
|
||||
err = NPP_NewStream(instance, type, stream, seekable, stype);
|
||||
return err;
|
||||
}
|
||||
|
||||
int32_t
|
||||
Private_WriteReady(NPP instance, NPStream* stream)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("WriteReady");
|
||||
result = NPP_WriteReady(instance, stream);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
Private_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len,
|
||||
void* buffer)
|
||||
{
|
||||
unsigned int result;
|
||||
PLUGINDEBUGSTR("Write");
|
||||
result = NPP_Write(instance, stream, offset, len, buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
||||
{
|
||||
PLUGINDEBUGSTR("StreamAsFile");
|
||||
NPP_StreamAsFile(instance, stream, fname);
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
NPError err;
|
||||
PLUGINDEBUGSTR("DestroyStream");
|
||||
err = NPP_DestroyStream(instance, stream, reason);
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
Private_URLNotify(NPP instance, const char* url,
|
||||
NPReason reason, void* notifyData)
|
||||
|
||||
{
|
||||
PLUGINDEBUGSTR("URLNotify");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
Private_Print(NPP instance, NPPrint* platformPrint)
|
||||
{
|
||||
PLUGINDEBUGSTR("Print");
|
||||
NPP_Print(instance, platformPrint);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* These functions are located automagically by netscape.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* - Netscape uses the return value to identify when an object instance
|
||||
* of this plugin should be created.
|
||||
*/
|
||||
char *
|
||||
NP_GetMIMEDescription(void)
|
||||
{
|
||||
return NPP_GetMIMEDescription();
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_GetValue [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - Interfaces with plugin to get values for predefined variables
|
||||
* that the navigator needs.
|
||||
*/
|
||||
NPError
|
||||
NP_GetValue(void* future, NPPVariable variable, void *value)
|
||||
{
|
||||
return NPP_GetValue(future, variable, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Initialize
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol before it
|
||||
* is about to create the first ever object of this kind.
|
||||
*
|
||||
* PARAMETERS
|
||||
* nsTable - The netscape function table. If developers just use these
|
||||
* wrappers, they don't need to worry about all these function
|
||||
* tables.
|
||||
* RETURN
|
||||
* pluginFuncs
|
||||
* - This functions needs to fill the plugin function table
|
||||
* pluginFuncs and return it. Netscape Navigator plugin
|
||||
* library will use this function table to call the plugin.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
{
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
PLUGINDEBUGSTR("NP_Initialize");
|
||||
|
||||
/* validate input parameters */
|
||||
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
/*
|
||||
* Check the major version passed in Netscape's function table.
|
||||
* We won't load if the major version is newer than what we expect.
|
||||
* Also check that the function tables passed in are big enough for
|
||||
* all the functions we need (they could be bigger, if Netscape added
|
||||
* new APIs, but that's OK with us -- we'll just ignore them).
|
||||
*
|
||||
*/
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
if (nsTable->size < ((char *)&nsTable->posturlnotify - (char *)nsTable))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
/*
|
||||
* Copy all the fields of Netscape function table into our
|
||||
* copy so we can call back into Netscape later. Note that
|
||||
* we need to copy the fields one by one, rather than assigning
|
||||
* the whole structure, because the Netscape function table
|
||||
* could actually be bigger than what we expect.
|
||||
*/
|
||||
gNetscapeFuncs.version = nsTable->version;
|
||||
gNetscapeFuncs.size = nsTable->size;
|
||||
gNetscapeFuncs.posturl = nsTable->posturl;
|
||||
gNetscapeFuncs.geturl = nsTable->geturl;
|
||||
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
|
||||
gNetscapeFuncs.requestread = nsTable->requestread;
|
||||
gNetscapeFuncs.newstream = nsTable->newstream;
|
||||
gNetscapeFuncs.write = nsTable->write;
|
||||
gNetscapeFuncs.destroystream = nsTable->destroystream;
|
||||
gNetscapeFuncs.status = nsTable->status;
|
||||
gNetscapeFuncs.uagent = nsTable->uagent;
|
||||
gNetscapeFuncs.memalloc = nsTable->memalloc;
|
||||
gNetscapeFuncs.memfree = nsTable->memfree;
|
||||
gNetscapeFuncs.memflush = nsTable->memflush;
|
||||
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
|
||||
gNetscapeFuncs.getvalue = nsTable->getvalue;
|
||||
gNetscapeFuncs.setvalue = nsTable->setvalue;
|
||||
gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
|
||||
|
||||
if (nsTable->size >= ((char *)&nsTable->setexception - (char *)nsTable))
|
||||
{
|
||||
gNetscapeFuncs.invalidaterect = nsTable->invalidaterect;
|
||||
gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
|
||||
gNetscapeFuncs.forceredraw = nsTable->forceredraw;
|
||||
gNetscapeFuncs.getstringidentifier = nsTable->getstringidentifier;
|
||||
gNetscapeFuncs.getstringidentifiers = nsTable->getstringidentifiers;
|
||||
gNetscapeFuncs.getintidentifier = nsTable->getintidentifier;
|
||||
gNetscapeFuncs.identifierisstring = nsTable->identifierisstring;
|
||||
gNetscapeFuncs.utf8fromidentifier = nsTable->utf8fromidentifier;
|
||||
gNetscapeFuncs.intfromidentifier = nsTable->intfromidentifier;
|
||||
gNetscapeFuncs.createobject = nsTable->createobject;
|
||||
gNetscapeFuncs.retainobject = nsTable->retainobject;
|
||||
gNetscapeFuncs.releaseobject = nsTable->releaseobject;
|
||||
gNetscapeFuncs.invoke = nsTable->invoke;
|
||||
gNetscapeFuncs.invokeDefault = nsTable->invokeDefault;
|
||||
gNetscapeFuncs.evaluate = nsTable->evaluate;
|
||||
gNetscapeFuncs.getproperty = nsTable->getproperty;
|
||||
gNetscapeFuncs.setproperty = nsTable->setproperty;
|
||||
gNetscapeFuncs.removeproperty = nsTable->removeproperty;
|
||||
gNetscapeFuncs.hasproperty = nsTable->hasproperty;
|
||||
gNetscapeFuncs.hasmethod = nsTable->hasmethod;
|
||||
gNetscapeFuncs.releasevariantvalue = nsTable->releasevariantvalue;
|
||||
gNetscapeFuncs.setexception = nsTable->setexception;
|
||||
}
|
||||
else
|
||||
{
|
||||
gNetscapeFuncs.invalidaterect = NULL;
|
||||
gNetscapeFuncs.invalidateregion = NULL;
|
||||
gNetscapeFuncs.forceredraw = NULL;
|
||||
gNetscapeFuncs.getstringidentifier = NULL;
|
||||
gNetscapeFuncs.getstringidentifiers = NULL;
|
||||
gNetscapeFuncs.getintidentifier = NULL;
|
||||
gNetscapeFuncs.identifierisstring = NULL;
|
||||
gNetscapeFuncs.utf8fromidentifier = NULL;
|
||||
gNetscapeFuncs.intfromidentifier = NULL;
|
||||
gNetscapeFuncs.createobject = NULL;
|
||||
gNetscapeFuncs.retainobject = NULL;
|
||||
gNetscapeFuncs.releaseobject = NULL;
|
||||
gNetscapeFuncs.invoke = NULL;
|
||||
gNetscapeFuncs.invokeDefault = NULL;
|
||||
gNetscapeFuncs.evaluate = NULL;
|
||||
gNetscapeFuncs.getproperty = NULL;
|
||||
gNetscapeFuncs.setproperty = NULL;
|
||||
gNetscapeFuncs.removeproperty = NULL;
|
||||
gNetscapeFuncs.hasproperty = NULL;
|
||||
gNetscapeFuncs.releasevariantvalue = NULL;
|
||||
gNetscapeFuncs.setexception = NULL;
|
||||
}
|
||||
if (nsTable->size >=
|
||||
((char *)&nsTable->poppopupsenabledstate - (char *)nsTable))
|
||||
{
|
||||
gNetscapeFuncs.pushpopupsenabledstate = nsTable->pushpopupsenabledstate;
|
||||
gNetscapeFuncs.poppopupsenabledstate = nsTable->poppopupsenabledstate;
|
||||
}
|
||||
else
|
||||
{
|
||||
gNetscapeFuncs.pushpopupsenabledstate = NULL;
|
||||
gNetscapeFuncs.poppopupsenabledstate = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the plugin function table that Netscape will use to
|
||||
* call us. Netscape needs to know about our version and size
|
||||
* and have a UniversalProcPointer for every function we
|
||||
* implement.
|
||||
*/
|
||||
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||
pluginFuncs->size = sizeof(NPPluginFuncs);
|
||||
pluginFuncs->newp = (NPP_NewProcPtr)(Private_New);
|
||||
pluginFuncs->destroy = (NPP_DestroyProcPtr)(Private_Destroy);
|
||||
pluginFuncs->setwindow = (NPP_SetWindowProcPtr)(Private_SetWindow);
|
||||
pluginFuncs->newstream = (NPP_NewStreamProcPtr)(Private_NewStream);
|
||||
pluginFuncs->destroystream = (NPP_DestroyStreamProcPtr)(Private_DestroyStream);
|
||||
pluginFuncs->asfile = (NPP_StreamAsFileProcPtr)(Private_StreamAsFile);
|
||||
pluginFuncs->writeready = (NPP_WriteReadyProcPtr)(Private_WriteReady);
|
||||
pluginFuncs->write = (NPP_WriteProcPtr)(Private_Write);
|
||||
pluginFuncs->print = (NPP_PrintProcPtr)(Private_Print);
|
||||
pluginFuncs->urlnotify = (NPP_URLNotifyProcPtr)(Private_URLNotify);
|
||||
pluginFuncs->event = NULL;
|
||||
pluginFuncs->javaClass = NULL;
|
||||
|
||||
/* This function is supposedly loaded magically, but that doesn't
|
||||
* seem to be true.
|
||||
*/
|
||||
pluginFuncs->getvalue = (NPP_GetValueProcPtr)(NP_GetValue);
|
||||
|
||||
err = NPP_Initialize();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* NP_Shutdown [optional]
|
||||
* - Netscape needs to know about this symbol.
|
||||
* - It calls this function after looking up its symbol after
|
||||
* the last object of this kind has been destroyed.
|
||||
*
|
||||
*/
|
||||
NPError
|
||||
NP_Shutdown(void)
|
||||
{
|
||||
PLUGINDEBUGSTR("NP_Shutdown");
|
||||
NPP_Shutdown();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
@ -1,506 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* nullplugin.c
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
/* Xlib/Xt stuff */
|
||||
#ifdef MOZ_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#endif
|
||||
|
||||
#include "npapi.h"
|
||||
#include "nullplugin.h"
|
||||
#include "prprf.h"
|
||||
|
||||
/* Global data */
|
||||
static MimeTypeElement *head = NULL;
|
||||
|
||||
/* destroy the dialog box */
|
||||
void
|
||||
destroyWidget(PluginInstance *This)
|
||||
{
|
||||
if (This && This->dialogBox)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET(This->dialogBox));
|
||||
}
|
||||
}
|
||||
|
||||
/* callback function for the OK button */
|
||||
static void
|
||||
DialogOKClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
PluginInstance* This = (PluginInstance*) data;
|
||||
char *url;
|
||||
|
||||
if (This->pluginsFileUrl != NULL)
|
||||
{
|
||||
/* Get the JavaScript command string */
|
||||
static const char buf[] =
|
||||
"javascript:netscape.softupdate.Trigger.StartSoftwareUpdate(\"%s\")";
|
||||
|
||||
url = NPN_MemAlloc(strlen(This->pluginsFileUrl) + (sizeof(buf) - 2));
|
||||
if (url != NULL)
|
||||
{
|
||||
/* Insert the file URL into the JavaScript command */
|
||||
sprintf(url, buf, This->pluginsFileUrl);
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
NPN_MemFree(url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If necessary, get the default plug-ins page resource */
|
||||
char* address = This->pluginsPageUrl;
|
||||
if (address == NULL || *address == 0)
|
||||
{
|
||||
address = PLUGINSPAGE_URL;
|
||||
}
|
||||
|
||||
url = NPN_MemAlloc(strlen(address) + 1 + strlen(This->type)+1);
|
||||
if (url != NULL)
|
||||
{
|
||||
NPN_PushPopupsEnabledState(This->instance, TRUE);
|
||||
/* Append the MIME type to the URL */
|
||||
sprintf(url, "%s?%s", address, This->type);
|
||||
if (strcmp (This->type, JVM_MINETYPE) == 0)
|
||||
{
|
||||
NPN_GetURL(This->instance, JVM_SMARTUPDATE_URL , TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
NPN_GetURL(This->instance, url, TARGET);
|
||||
}
|
||||
NPN_MemFree(url);
|
||||
NPN_PopPopupsEnabledState(This->instance);
|
||||
}
|
||||
}
|
||||
destroyWidget(This);
|
||||
}
|
||||
|
||||
/* the call back function for cancel button */
|
||||
static void
|
||||
DialogCancelClicked (GtkButton *button, gpointer data)
|
||||
{
|
||||
destroyWidget((PluginInstance*) data);
|
||||
}
|
||||
|
||||
/* function that closes the dialog if ESC is pressed */
|
||||
static gboolean
|
||||
DialogEscapePressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
if (event->keyval == GDK_Escape)
|
||||
{
|
||||
g_signal_stop_emission_by_name (GTK_OBJECT (widget), "key_press_event");
|
||||
gtk_object_destroy (GTK_OBJECT (widget));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* a handy procedure to add a widget and pack it as well */
|
||||
static GtkWidget *
|
||||
AddWidget (GtkWidget *widget, GtkWidget *packingbox)
|
||||
{
|
||||
gtk_box_pack_start(GTK_BOX(packingbox), widget, TRUE, TRUE, 2);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* MIMETypeList maintenance routines */
|
||||
|
||||
static gboolean
|
||||
isEqual(NPMIMEType t1, NPMIMEType t2)
|
||||
{
|
||||
return (t1 && t2) ? (strcmp(t1, t2) == 0) : FALSE;
|
||||
}
|
||||
|
||||
static MimeTypeElement *
|
||||
isExist(MimeTypeElement **typelist, NPMIMEType type)
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
|
||||
ele = *typelist;
|
||||
while (ele != NULL) {
|
||||
if (isEqual(ele->pinst->type, type))
|
||||
return ele;
|
||||
ele = ele->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NPMIMEType
|
||||
dupMimeType(NPMIMEType type)
|
||||
{
|
||||
NPMIMEType mimetype = NPN_MemAlloc(strlen(type)+1);
|
||||
if (mimetype)
|
||||
strcpy(mimetype, type);
|
||||
return(mimetype);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
addToList(MimeTypeElement **typelist, PluginInstance *This)
|
||||
{
|
||||
if (This && This->type && !isExist(typelist, This->type))
|
||||
{
|
||||
MimeTypeElement *ele;
|
||||
if ((ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement))))
|
||||
{
|
||||
ele->pinst = This;
|
||||
ele->next = *typelist;
|
||||
*typelist = ele;
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
delFromList(MimeTypeElement **typelist, PluginInstance *This)
|
||||
{
|
||||
if (typelist && This)
|
||||
{
|
||||
MimeTypeElement *ele_prev;
|
||||
MimeTypeElement *ele = *typelist;
|
||||
while (ele)
|
||||
{
|
||||
if (isEqual(ele->pinst->type, This->type))
|
||||
{
|
||||
if (*typelist == ele)
|
||||
{
|
||||
*typelist = ele->next;
|
||||
} else {
|
||||
ele_prev->next = ele->next;
|
||||
}
|
||||
NPN_MemFree(ele);
|
||||
return(TRUE);
|
||||
}
|
||||
ele_prev = ele;
|
||||
ele = ele->next;
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
onDestroyWidget(GtkWidget *w, gpointer data)
|
||||
{
|
||||
PluginInstance* This = (PluginInstance*) data;
|
||||
if (This && This->dialogBox && This->dialogBox == w)
|
||||
{
|
||||
This->dialogBox = 0;
|
||||
delFromList(&head, This);
|
||||
}
|
||||
}
|
||||
|
||||
/* create and display the dialog box */
|
||||
void
|
||||
makeWidget(PluginInstance *This)
|
||||
{
|
||||
GtkWidget *dialogWindow;
|
||||
GtkWidget *dialogMessage;
|
||||
GtkWidget *okButton;
|
||||
GtkWidget *cancelButton;
|
||||
char message[1024];
|
||||
MimeTypeElement *ele;
|
||||
|
||||
if (!This) return;
|
||||
|
||||
/* need to check whether we already pop up a dialog box for previous
|
||||
minetype in the same web page. It's require otherwise there will
|
||||
be 2 dialog boxes pop if there are 2 plugin in the same web page
|
||||
*/
|
||||
if ((ele = isExist(&head, This->type)))
|
||||
{
|
||||
if (ele->pinst && ele->pinst->dialogBox)
|
||||
{
|
||||
GtkWidget *top_window = gtk_widget_get_toplevel(ele->pinst->dialogBox);
|
||||
if (top_window && GTK_WIDGET_VISIBLE(top_window))
|
||||
{ /* this will raise the toplevel window */
|
||||
gdk_window_show(top_window->window);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
dialogWindow = gtk_dialog_new();
|
||||
This->dialogBox = dialogWindow;
|
||||
This->exists = TRUE;
|
||||
This->dialogBox = dialogWindow;
|
||||
addToList(&head, This);
|
||||
gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME);
|
||||
gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_modal(GTK_WINDOW(dialogWindow), FALSE);
|
||||
gtk_window_set_wmclass(GTK_WINDOW(dialogWindow), "Mozilla", "DefaultPlugin");
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 20);
|
||||
gtk_window_set_resizable(GTK_WINDOW(dialogWindow), FALSE);
|
||||
|
||||
PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type);
|
||||
dialogMessage = AddWidget(gtk_label_new (message),
|
||||
GTK_DIALOG(dialogWindow)->vbox);
|
||||
|
||||
okButton= AddWidget(gtk_button_new_with_label (OK_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (okButton, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default(okButton);
|
||||
|
||||
cancelButton= AddWidget(gtk_button_new_with_label (CANCEL_BUTTON),
|
||||
GTK_DIALOG(dialogWindow)->action_area);
|
||||
|
||||
g_signal_connect (GTK_OBJECT(okButton), "clicked",
|
||||
G_CALLBACK(DialogOKClicked), This);
|
||||
|
||||
g_signal_connect (GTK_OBJECT(cancelButton), "clicked",
|
||||
G_CALLBACK(DialogCancelClicked), This);
|
||||
|
||||
g_signal_connect(GTK_OBJECT(dialogWindow), "key_press_event",
|
||||
G_CALLBACK(DialogEscapePressed), NULL);
|
||||
|
||||
/* hookup to when the dialog is destroyed */
|
||||
g_signal_connect(GTK_OBJECT(dialogWindow), "destroy",
|
||||
G_CALLBACK(onDestroyWidget), This);
|
||||
|
||||
gtk_widget_show_all(dialogWindow);
|
||||
}
|
||||
|
||||
/* XPM */
|
||||
static char * npnul320_xpm[] = {
|
||||
"32 32 6 1",
|
||||
" c None",
|
||||
". c #808080",
|
||||
"+ c #F8F8F8",
|
||||
"@ c #C0C0C0",
|
||||
"# c #000000",
|
||||
"$ c #00F8F8",
|
||||
"........................++++++++",
|
||||
".++++++++++++++++++++++..+++++++",
|
||||
".+++++++++++++++++++++@.@.++++++",
|
||||
".++@@@@@@@@@@@@@@@@@@@@.+@.+++++",
|
||||
".++@@@@@@@@@.....@@@@@@.++@.++++",
|
||||
".++@@@@@@@@.+++++#@@@@@.+++@.+++",
|
||||
".++@@@@@@@.++$$$$$#@@@@.++++@.++",
|
||||
".++@@@@@@@.+$$$$$$#.@@@.+++++@.+",
|
||||
".++@@@...@@.+$$$$#..###.#######+",
|
||||
".++@@.+++$$++$$$$$##++$#......#+",
|
||||
".++@@.+$$$++$$$$$$$+$$$#......#+",
|
||||
".++@@.+$$$$$$$$$$$$$$$$#..@@++#+",
|
||||
".++@@@$$$$$$$$$$$$$$$$#...@@++#+",
|
||||
".++@@@$#$##.$$$$$$##$$#...@@++#+",
|
||||
".++@@@@##...$$$$$#..##...@@@++#+",
|
||||
".++@@@@@....+$$$$#.......@@@++#+",
|
||||
".++@@@@@@...+$$$$#.@@@..@@@@++#+",
|
||||
".++@@@@..@@.+$$$$#.@##@@@@@@++#+",
|
||||
".++@@@.++$$++$$$$$##$$#@@@@@++#+",
|
||||
".++@@@.+$$++$$$$$$$$$$#@@@@@++#+",
|
||||
".++@@.++$$$$$$$$$$$$$$$#@@@@++#+",
|
||||
".++@@.+$$$$$$$$$$$$$$$$#.@@@++#+",
|
||||
".++@@.+$$##$$$$$$$##$$$#..@@++#+",
|
||||
".++@@@###...$$$$$#.@###...@@++#+",
|
||||
".++@@@@....$$$$$$$#.@.....@@++#+",
|
||||
".++@@@@@...$$$$$$$#..@...@@@++#+",
|
||||
".++@@@@@@@@#$$$$$#...@@@@@@@++#+",
|
||||
".++@@@@@@@@@#####...@@@@@@@@++#+",
|
||||
".++@@@@@@@@@@......@@@@@@@@@++#+",
|
||||
".+++++++++++++....++++++++++++#+",
|
||||
".+++++++++++++++++++++++++++++#+",
|
||||
"###############################+"};
|
||||
|
||||
|
||||
static GdkPixmap *nullPluginGdkPixmap = 0;
|
||||
|
||||
static GdkWindow *getGdkWindow(PluginInstance *This)
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
GdkWindow *gdk_window;
|
||||
Window xwin = (Window) This->window;
|
||||
Widget xt_w = XtWindowToWidget(This->display, xwin);
|
||||
|
||||
if (xt_w) {
|
||||
xt_w = XtParent(xt_w);
|
||||
if (xt_w) {
|
||||
xwin = XtWindow(xt_w);
|
||||
/* xwin = xt_w->core.window; */
|
||||
}
|
||||
}
|
||||
gdk_window = gdk_window_lookup(xwin);
|
||||
return gdk_window;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
createPixmap(PluginInstance *This)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (nullPluginGdkPixmap == 0)
|
||||
{
|
||||
GtkStyle *style;
|
||||
GdkBitmap *mask;
|
||||
GdkWindow *gdk_window = getGdkWindow(This);
|
||||
if (gdk_window)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
#ifndef MOZ_WIDGET_GTK2
|
||||
widget = (GtkWidget *)gdk_window->user_data;
|
||||
#else
|
||||
gpointer user_data = NULL;
|
||||
gdk_window_get_user_data( gdk_window, &user_data);
|
||||
widget = GTK_WIDGET(user_data);
|
||||
#endif
|
||||
style = gtk_widget_get_style(widget);
|
||||
nullPluginGdkPixmap = gdk_pixmap_create_from_xpm_d(gdk_window , &mask,
|
||||
&style->bg[GTK_STATE_NORMAL], npnul320_xpm);
|
||||
#ifdef MOZ_X11
|
||||
/* Pixmap is created on original X session but used by new session */
|
||||
XSync(GDK_DISPLAY(), False);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
drawPixmap(PluginInstance *This)
|
||||
{
|
||||
if (nullPluginGdkPixmap)
|
||||
{
|
||||
int pixmap_with, pixmap_height, dest_x, dest_y;
|
||||
gdk_drawable_get_size((GdkWindow *)nullPluginGdkPixmap, &pixmap_with, &pixmap_height);
|
||||
dest_x = This->width/2 - pixmap_with/2;
|
||||
dest_y = This->height/2 - pixmap_height/2;
|
||||
if (dest_x >= 0 && dest_y >= 0)
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
GC gc;
|
||||
gc = XCreateGC(This->display, This->window, 0, NULL);
|
||||
XCopyArea(This->display, GDK_WINDOW_XWINDOW(nullPluginGdkPixmap) , This->window, gc,
|
||||
0, 0, pixmap_with, pixmap_height, dest_x, dest_y);
|
||||
XFreeGC(This->display, gc);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setCursor (PluginInstance *This)
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
static Cursor nullPluginCursor = 0;
|
||||
if (!nullPluginCursor)
|
||||
{
|
||||
nullPluginCursor = XCreateFontCursor(This->display, XC_hand2);
|
||||
}
|
||||
if (nullPluginCursor)
|
||||
{
|
||||
XDefineCursor(This->display, This->window, nullPluginCursor);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
static void
|
||||
xt_event_handler(Widget xt_w, PluginInstance *This, XEvent *xevent, Boolean *b)
|
||||
{
|
||||
switch (xevent->type)
|
||||
{
|
||||
case Expose:
|
||||
/* get rid of all other exposure events */
|
||||
do {
|
||||
} while (XCheckTypedWindowEvent(This->display, This->window,
|
||||
Expose, xevent));
|
||||
drawPixmap(This);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (xevent->xbutton.button == Button1)
|
||||
{
|
||||
makeWidget(This);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
addXtEventHandler(PluginInstance *This)
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
Display *dpy = (Display*) This->display;
|
||||
Window xwin = (Window) This->window;
|
||||
Widget xt_w = XtWindowToWidget(dpy, xwin);
|
||||
if (xt_w)
|
||||
{
|
||||
long event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask;
|
||||
XSelectInput(dpy, xwin, event_mask);
|
||||
XtAddEventHandler(xt_w, event_mask, False, (XtEventHandler)xt_event_handler, This);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
makePixmap(PluginInstance *This)
|
||||
{
|
||||
createPixmap(This);
|
||||
drawPixmap(This);
|
||||
setCursor(This);
|
||||
addXtEventHandler(This);
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Mak <smak@sun.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* nullplugin.h
|
||||
*
|
||||
* Implementation of the null plugins for Unix.
|
||||
*
|
||||
* dp <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
* updated 9/2000 <smak@sun.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#define TARGET "_blank"
|
||||
#define MIME_TYPES_HANDLED "*:.*:All types"
|
||||
#define PLUGIN_NAME "Default Plugin"
|
||||
#define PLUGIN_DESCRIPTION "The default plugin handles plugin data for mimetypes and extensions that are not specified and facilitates downloading of new plugins."
|
||||
#define CLICK_TO_GET "Click here to get the plugin"
|
||||
#define CLICK_WHEN_DONE "Click here after installing the plugin"
|
||||
|
||||
#define REFRESH_PLUGIN_LIST "javascript:navigator.plugins.refresh(true)"
|
||||
#define PLUGINSPAGE_URL "http://plugindoc.mozdev.org/winmime.html" /* XXX Branding: make configurable via .properties or prefs */
|
||||
#define OK_BUTTON "OK"
|
||||
#define CANCEL_BUTTON "CANCEL"
|
||||
#if defined(HPUX)
|
||||
#define JVM_SMARTUPDATE_URL "http://www.hp.com/go/java"
|
||||
#elif defined(VMS)
|
||||
#define JVM_SMARTUPDATE_URL "http://www.openvms.compaq.com/openvms/products/ips/mozilla_relnotes.html#java"
|
||||
#else
|
||||
#define JVM_SMARTUPDATE_URL "http://java.com/download" /* XXX Branding: see above */
|
||||
#endif /* HPUX */
|
||||
#define JVM_MINETYPE "application/x-java-vm"
|
||||
#define MESSAGE "\
|
||||
This page contains information of a type (%s) that can\n\
|
||||
only be viewed with the appropriate Plug-in.\n\
|
||||
\n\
|
||||
Click OK to download Plugin."
|
||||
|
||||
#define GET 1
|
||||
#define REFRESH 2
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _PluginInstance
|
||||
{
|
||||
uint16_t mode;
|
||||
#ifdef MOZ_X11
|
||||
Window window;
|
||||
Display *display;
|
||||
#endif
|
||||
uint32_t x, y;
|
||||
uint32_t width, height;
|
||||
NPMIMEType type;
|
||||
char *message;
|
||||
|
||||
NPP instance;
|
||||
char *pluginsPageUrl;
|
||||
char *pluginsFileUrl;
|
||||
NPBool pluginsHidden;
|
||||
#ifdef MOZ_X11
|
||||
Visual* visual;
|
||||
Colormap colormap;
|
||||
#endif
|
||||
unsigned int depth;
|
||||
GtkWidget* dialogBox;
|
||||
|
||||
NPBool exists; /* Does the widget already exist? */
|
||||
int action; /* What action should we take? (GET or REFRESH) */
|
||||
|
||||
} PluginInstance;
|
||||
|
||||
|
||||
typedef struct _MimeTypeElement
|
||||
{
|
||||
PluginInstance *pinst;
|
||||
struct _MimeTypeElement *next;
|
||||
} MimeTypeElement;
|
||||
|
||||
/* Extern functions */
|
||||
extern void makeWidget(PluginInstance *This);
|
||||
extern NPMIMEType dupMimeType(NPMIMEType type);
|
||||
extern void destroyWidget(PluginInstance *This);
|
||||
extern void makePixmap(PluginInstance *This);
|
||||
extern void destroyPixmap();
|
||||
|
||||
|
@ -1,104 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = plugin
|
||||
LIBRARY_NAME = npnul32
|
||||
RESFILE = npnul32.res
|
||||
DEFFILE = $(win_srcdir)/npnul32.def
|
||||
GRE_MODULE = 1
|
||||
|
||||
|
||||
CPPSRCS = \
|
||||
maindll.cpp \
|
||||
plugin.cpp \
|
||||
dbg.cpp \
|
||||
dialogs.cpp \
|
||||
npshell.cpp \
|
||||
npwin.cpp \
|
||||
utils.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)
|
||||
|
||||
DEFINES += -DXPCOM_GLUE
|
||||
|
||||
# plugins should always be shared, even in the "static" build
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
# Force use of PIC
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
# must link statically with the CRT to avoid problems with VC8
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
NO_DIST_INSTALL = 1
|
||||
NO_INSTALL = 1
|
||||
|
||||
ifndef WINCE
|
||||
ENABLE_CXX_EXCEPTIONS = 1
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifndef WINCE
|
||||
_OS_LIBS = version
|
||||
endif
|
||||
|
||||
ifdef GNU_CC
|
||||
_OS_LIBS += gdi32
|
||||
endif
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
|
||||
|
||||
install-plugin: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
|
||||
endif
|
||||
|
||||
libs:: install-plugin
|
||||
|
||||
install:: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
|
||||
endif
|
||||
|
@ -1,157 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="Npnul32" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Npnul32 - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Npnul32.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Npnul32.mak" CFG="Npnul32 - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Npnul32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Npnul32 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Npnul32 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\WinRel"
|
||||
# PROP BASE Intermediate_Dir ".\WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /I "..\..\..\..\..\dist\include\xpcom" /I "..\..\..\..\..\dist\include\pref" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "Npnul32 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\WinDebug"
|
||||
# PROP BASE Intermediate_Dir ".\WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /I "..\..\..\..\..\dist\include\xpcom" /I "..\..\..\..\..\dist\include\pref" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib libc.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib /out:"..\..\..\..\..\dist\bin\Plugins\Npnul32.dll"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Npnul32 - Win32 Release"
|
||||
# Name "Npnul32 - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\maindll.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npnul32.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npshell.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\npwin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dbg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\utils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plugicon.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@ -1,59 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern char szAppName[];
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...) {
|
||||
static char buf[1024];
|
||||
lstrcpy(buf, szAppName);
|
||||
lstrcat(buf, ": ");
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
wvsprintf(&buf[lstrlen(buf)], format, va);
|
||||
va_end(va);
|
||||
lstrcat(buf, "\n");
|
||||
OutputDebugString(buf);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __DBG_HPP_
|
||||
#define __DBG_HPP_
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...);
|
||||
#define dbgOut1(x) dbgOut(x)
|
||||
#define dbgOut2(x,y) dbgOut(x, y)
|
||||
#define dbgOut3(x,y,z) dbgOut(x, y, z)
|
||||
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
|
||||
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
|
||||
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
|
||||
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
|
||||
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
|
||||
|
||||
#else
|
||||
|
||||
#define dbgOut1(x) ((void)0)
|
||||
#define dbgOut2(x,y) ((void)0)
|
||||
#define dbgOut3(x,y,z) ((void)0)
|
||||
#define dbgOut4(x,y,z,t) ((void)0)
|
||||
#define dbgOut5(x,y,z,t,u) ((void)0)
|
||||
#define dbgOut6(x,y,z,t,u,v) ((void)0)
|
||||
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
|
||||
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,196 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)GetWindowLongPtr(hWnd, DWLP_USER);
|
||||
switch (id)
|
||||
{
|
||||
case IDC_GET_PLUGIN:
|
||||
DestroyWindow(hWnd);
|
||||
if(pPlugin !=NULL)
|
||||
{
|
||||
pPlugin->m_hWndDialog = NULL;
|
||||
pPlugin->getPlugin();
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
case IDC_BUTTON_CANCEL:
|
||||
DestroyWindow(hWnd);
|
||||
if(pPlugin !=NULL)
|
||||
pPlugin->m_hWndDialog = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)lParam;
|
||||
assert(pPlugin != NULL);
|
||||
if(pPlugin == NULL)
|
||||
return TRUE;
|
||||
|
||||
SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)pPlugin);
|
||||
|
||||
pPlugin->m_hWndDialog = hWnd;
|
||||
|
||||
char szString[512];
|
||||
LoadString(hInst, IDS_TITLE, szString, sizeof(szString));
|
||||
SetWindowText(hWnd, szString);
|
||||
|
||||
LoadString(hInst, IDS_INFO, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType);
|
||||
|
||||
LoadString(hInst, IDS_LOCATION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
|
||||
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != pPlugin->m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
pPlugin->m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
|
||||
LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
|
||||
else
|
||||
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
|
||||
|
||||
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
|
||||
|
||||
LoadString(hInst, IDS_QUESTION, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
|
||||
|
||||
if(!pPlugin->m_bOnline)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE);
|
||||
LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if((!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
|
||||
{
|
||||
LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString));
|
||||
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_WARNING), SW_HIDE);
|
||||
|
||||
RECT rc;
|
||||
GetWindowRect(GetDlgItem(hWnd, IDC_STATIC_WARNING), &rc);
|
||||
int iHeight = rc.bottom - rc.top;
|
||||
GetWindowRect(hWnd, &rc);
|
||||
SetWindowPos(hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - iHeight, SWP_NOZORDER | SWP_NOMOVE);
|
||||
|
||||
HWND hWndQuestion = GetDlgItem(hWnd, IDC_STATIC_QUESTION);
|
||||
HWND hWndButtonGetPlugin = GetDlgItem(hWnd, IDC_GET_PLUGIN);
|
||||
HWND hWndButtonCancel = GetDlgItem(hWnd, IDC_BUTTON_CANCEL);
|
||||
|
||||
POINT pt;
|
||||
|
||||
GetWindowRect(hWndQuestion, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndQuestion, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonGetPlugin, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonGetPlugin, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
GetWindowRect(hWndButtonCancel, &rc);
|
||||
pt.x = rc.left;
|
||||
pt.y = rc.top;
|
||||
ScreenToClient(hWnd, &pt);
|
||||
SetWindowPos(hWndButtonCancel, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||
|
||||
if(pPlugin->m_bHidden)
|
||||
SetForegroundWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void onClose(HWND hWnd)
|
||||
{
|
||||
DestroyWindow(hWnd);
|
||||
}
|
||||
|
||||
static void onDestroy(HWND hWnd)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
HANDLE_WM_CLOSE(hWnd, wParam, lParam, onClose);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __DIALOGS_H__
|
||||
#define __DIALOGS_H__
|
||||
|
||||
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif __DIALOGS_H__
|
@ -1,46 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HINSTANCE hInst; // global
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
hInst = hDLL;
|
||||
return TRUE;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
LIBRARY NPNUL32
|
||||
|
||||
EXPORTS
|
||||
NP_GetEntryPoints @1
|
||||
NP_Initialize @2
|
||||
NP_Shutdown @3
|
||||
NP_GetMIMEDescription @4
|
@ -1,29 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Npnul32"=.\Npnul32.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
@ -1,187 +0,0 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winresrc.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winresrc.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_PLUGIN_DOWNLOAD DIALOG DISCARDABLE 0, 0, 225, 165
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Title"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Information on this page requires a plug-in for:",
|
||||
IDC_STATIC_INFO,7,7,211,10
|
||||
LTEXT "Communicator can retrieve the plug-in for you from:",
|
||||
IDC_STATIC_LOCATION,7,32,211,8
|
||||
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN,41,144,64,14
|
||||
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,109,144,64,14
|
||||
CTEXT "type/x-type",IDC_STATIC_INFOTYPE,7,18,211,8
|
||||
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",
|
||||
IDC_STATIC_WARNING,7,74,211,61
|
||||
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",
|
||||
IDC_STATIC_URL,7,43,211,24
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,15
|
||||
PRODUCTVERSION 1,0,0,15
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "mozilla.org\0"
|
||||
VALUE "FileDescription", "Default Plug-in\0"
|
||||
VALUE "FileExtents", "*\0"
|
||||
VALUE "FileOpenName", "Mozilla Default Plug-in (*.*)\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 15\0"
|
||||
VALUE "InternalName", "DEFPLUGIN\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1995-2000\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "MIMEType", "*\0"
|
||||
VALUE "OriginalFilename", "NPNUL32.DLL\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Mozilla Default Plug-in\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 15\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_PLUGICON ICON DISCARDABLE "plugicon.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_PLUGIN_DOWNLOAD, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 218
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 158
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_INFO "Information on this page requires a plug-in for:"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_LOCATION "You can retrieve the plug-in from:"
|
||||
IDS_TITLE "Plug-in Not Loaded"
|
||||
IDS_QUESTION "What would you like to do?"
|
||||
IDS_WARNING_JS "To retrieve the plug-in now, click the Get the Plug-in button and then select the plug-in you need from the page that appears."
|
||||
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Work Online"" from the File menu, then click the plug-in icon on the page."
|
||||
IDS_FINDER_PAGE "Plug-in Finder page"
|
||||
IDS_CLICK_TO_GET "Click here to get the plugin"
|
||||
IDS_CLICK_WHEN_DONE "After installing the plugin, click here."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
@ -1,329 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h" // this includes npapi.h
|
||||
#include "utils.h"
|
||||
#include "dbg.h"
|
||||
|
||||
char szAppName[] = "NPNULL";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Initialize:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NPP_Initialize(void)
|
||||
{
|
||||
RegisterNullPluginWindowClass();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Shutdown:
|
||||
//---------------------------------------------------------------------------
|
||||
void NPP_Shutdown(void)
|
||||
{
|
||||
UnregisterNullPluginWindowClass();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_New:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
|
||||
NPP pInstance,
|
||||
uint16_t mode,
|
||||
int16_t argc,
|
||||
char* argn[],
|
||||
char* argv[],
|
||||
NPSavedData* saved)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
// See if the content provider specified from where to fetch the plugin
|
||||
char * szPageURL = NULL;
|
||||
char * szFileURL = NULL;
|
||||
char * szFileExtension = NULL;
|
||||
char * buf = NULL;
|
||||
BOOL bHidden = false;
|
||||
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
|
||||
szPageURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
|
||||
szFileURL = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
|
||||
buf = (char *)argv[i];
|
||||
else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
|
||||
bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0);
|
||||
}
|
||||
|
||||
/* some post-processing on the filename to attempt to extract the extension: */
|
||||
if(buf != NULL)
|
||||
{
|
||||
buf = strrchr(buf, '.');
|
||||
if(buf)
|
||||
szFileExtension = ++buf;
|
||||
}
|
||||
|
||||
CPlugin * pPlugin = new CPlugin(hInst,
|
||||
pInstance,
|
||||
mode,
|
||||
pluginType,
|
||||
szPageURL,
|
||||
szFileURL,
|
||||
szFileExtension,
|
||||
bHidden);
|
||||
if(pPlugin == NULL)
|
||||
return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
|
||||
if(bHidden)
|
||||
{
|
||||
if(!pPlugin->init(NULL))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pInstance->pdata = (void *)pPlugin;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_Destroy:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_Destroy(NPP pInstance, NPSavedData** save)
|
||||
{
|
||||
dbgOut1("NPP_Destroy");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
if(pPlugin != NULL)
|
||||
{
|
||||
pPlugin->shut();
|
||||
delete pPlugin;
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// NPP_SetWindow:
|
||||
//---------------------------------------------------------------------------
|
||||
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
|
||||
{
|
||||
if(pInstance == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
}
|
||||
|
||||
if(pNPWindow == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
HWND hWnd = (HWND)(DWORD)pNPWindow->window;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if(pPlugin == NULL)
|
||||
{
|
||||
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
|
||||
{
|
||||
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
|
||||
{ // window went away
|
||||
dbgOut1("NPP_SetWindow, going away...");
|
||||
pPlugin->shut();
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
|
||||
{ // First time in -- no window created by plugin yet
|
||||
dbgOut1("NPP_SetWindow, first time");
|
||||
|
||||
if(!pPlugin->init(hWnd))
|
||||
{
|
||||
delete pPlugin;
|
||||
pPlugin = NULL;
|
||||
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
|
||||
{ // Netscape window has been resized
|
||||
dbgOut1("NPP_SetWindow, resizing");
|
||||
pPlugin->resize();
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_NewStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_NewStream(NPP pInstance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
uint16_t *stype)
|
||||
{
|
||||
dbgOut1("NPP_NewStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if (!pPlugin)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
return pPlugin->newStream(type, stream, seekable, stype);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_WriteReady:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32_t NP_LOADDS
|
||||
NPP_WriteReady(NPP pInstance, NPStream *stream)
|
||||
{
|
||||
dbgOut1("NPP_WriteReady");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
// We don't want any data, kill the stream
|
||||
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
|
||||
|
||||
return -1L; // don't accept any bytes in NPP_Write()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Write:
|
||||
//------------------------------------------------------------------------------------
|
||||
int32_t NP_LOADDS
|
||||
NPP_Write(NPP pInstance, NPStream *stream, int32_t offset, int32_t len, void *buffer)
|
||||
{
|
||||
//dbgOut1("NPP_Write");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
// We don't want any data, kill the stream
|
||||
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
|
||||
|
||||
return -1; // tell the browser to abort the stream, don't need it
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_DestroyStream:
|
||||
//------------------------------------------------------------------------------------
|
||||
NPError NP_LOADDS
|
||||
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
|
||||
{
|
||||
dbgOut1("NPP_DestroyStream");
|
||||
if(pInstance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
if (!pPlugin)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
return pPlugin->destroyStream(stream, reason);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_StreamAsFile:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
dbgOut1("NPP_StreamAsFile");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// NPP_Print:
|
||||
//------------------------------------------------------------------------------------
|
||||
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
|
||||
{
|
||||
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->print(printInfo);
|
||||
}
|
||||
|
||||
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
dbgOut2("NPP_URLNotify, URL '%s'", url);
|
||||
|
||||
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
|
||||
assert(pPlugin != NULL);
|
||||
|
||||
pPlugin->URLNotify(url);
|
||||
}
|
@ -1,312 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include "nsDefaultPlugin.h"
|
||||
|
||||
//\\// DEFINE
|
||||
#define NP_EXPORT
|
||||
|
||||
//\\// GLOBAL DATA
|
||||
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// PLUGIN DLL entry points
|
||||
//
|
||||
// These are the Windows specific DLL entry points. They must be exoprted
|
||||
//
|
||||
|
||||
// we need these to be global since we have to fill one of its field
|
||||
// with a data (class) which requires knowlwdge of the navigator
|
||||
// jump-table. This jump table is known at Initialize time (NP_Initialize)
|
||||
// which is called after NP_GetEntryPoint
|
||||
static NPPluginFuncs* g_pluginFuncs;
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_GetEntryPoints
|
||||
//
|
||||
// fills in the func table used by Navigator to call entry points in
|
||||
// plugin DLL. Note that these entry points ensure that DS is loaded
|
||||
// by using the NP_LOADDS macro, when compiling for OS/2.
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
// if the plugin's function table is smaller than the plugin expects,
|
||||
// then they are incompatible, and should return an error
|
||||
|
||||
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
pFuncs->newp = NPP_New;
|
||||
pFuncs->destroy = NPP_Destroy;
|
||||
pFuncs->setwindow = NPP_SetWindow;
|
||||
pFuncs->newstream = NPP_NewStream;
|
||||
pFuncs->destroystream = NPP_DestroyStream;
|
||||
pFuncs->asfile = NPP_StreamAsFile;
|
||||
pFuncs->writeready = NPP_WriteReady;
|
||||
pFuncs->write = NPP_Write;
|
||||
pFuncs->print = NPP_Print;
|
||||
pFuncs->event = 0; /// reserved
|
||||
|
||||
g_pluginFuncs = pFuncs;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Initialize
|
||||
//
|
||||
// called immediately after the plugin DLL is loaded
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Initialize(NPNetscapeFuncs* pFuncs)
|
||||
{
|
||||
// trap a NULL ptr
|
||||
if(pFuncs == NULL)
|
||||
return NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
g_pNavigatorFuncs = pFuncs; // save it for future reference
|
||||
|
||||
// if the plugin's major ver level is lower than the Navigator's,
|
||||
// then they are incompatible, and should return an error
|
||||
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
|
||||
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
|
||||
// We have to defer these assignments until g_pNavigatorFuncs is set
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
g_pluginFuncs->urlnotify = NPP_URLNotify;
|
||||
}
|
||||
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
|
||||
g_pluginFuncs->javaClass = NULL;
|
||||
}
|
||||
// NPP_Initialize is a standard (cross-platform) initialize function.
|
||||
return NPP_Initialize();
|
||||
}
|
||||
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
// NP_Shutdown
|
||||
//
|
||||
// called immediately before the plugin DLL is unloaded.
|
||||
// This function should check for some ref count on the dll to see if it is
|
||||
// unloadable or it needs to stay in memory.
|
||||
//
|
||||
NPError WINAPI NP_EXPORT
|
||||
NP_Shutdown()
|
||||
{
|
||||
NPP_Shutdown();
|
||||
g_pNavigatorFuncs = NULL;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
char * NP_GetMIMEDescription()
|
||||
{
|
||||
static char mimetype[] = NS_PLUGIN_DEFAULT_MIME_DESCRIPTION;
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
// END - PLUGIN DLL entry points
|
||||
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
|
||||
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
|
||||
|
||||
/* NAVIGATOR Entry points */
|
||||
|
||||
/* These entry points expect to be called from within the plugin. The
|
||||
noteworthy assumption is that DS has already been set to point to the
|
||||
plugin's DLL data segment. Don't call these functions from outside
|
||||
the plugin without ensuring DS is set to the DLLs data segment first,
|
||||
typically using the NP_LOADDS macro
|
||||
*/
|
||||
|
||||
/* returns the major/minor version numbers of the Plugin API for the plugin
|
||||
and the Navigator
|
||||
*/
|
||||
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
|
||||
{
|
||||
*plugin_major = NP_VERSION_MAJOR;
|
||||
*plugin_minor = NP_VERSION_MINOR;
|
||||
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
|
||||
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
|
||||
}
|
||||
|
||||
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
|
||||
{
|
||||
return g_pNavigatorFuncs->getvalue(instance, variable, result);
|
||||
}
|
||||
|
||||
|
||||
/* causes the specified URL to be fetched and streamed in
|
||||
*/
|
||||
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
|
||||
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
|
||||
{
|
||||
return g_pNavigatorFuncs->geturl(instance, url, target);
|
||||
}
|
||||
|
||||
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
|
||||
{
|
||||
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
|
||||
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
|
||||
{
|
||||
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
|
||||
}
|
||||
|
||||
/* Requests that a number of bytes be provided on a stream. Typically
|
||||
this would be used if a stream was in "pull" mode. An optional
|
||||
position can be provided for streams which are seekable.
|
||||
*/
|
||||
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
||||
{
|
||||
return g_pNavigatorFuncs->requestread(stream, rangeList);
|
||||
}
|
||||
|
||||
/* Creates a new stream of data from the plug-in to be interpreted
|
||||
by Netscape in the current window.
|
||||
*/
|
||||
NPError NPN_NewStream(NPP instance, NPMIMEType type,
|
||||
const char* target, NPStream** stream)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides len bytes of data.
|
||||
*/
|
||||
int32_t NPN_Write(NPP instance, NPStream *stream,
|
||||
int32_t len, void *buffer)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
int32_t result;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Closes a stream object.
|
||||
reason indicates why the stream was closed.
|
||||
*/
|
||||
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
{
|
||||
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
|
||||
NPError err;
|
||||
|
||||
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
|
||||
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
|
||||
}
|
||||
else {
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Provides a text status message in the Netscape client user interface
|
||||
*/
|
||||
void NPN_Status(NPP instance, const char *message)
|
||||
{
|
||||
g_pNavigatorFuncs->status(instance, message);
|
||||
}
|
||||
|
||||
/* returns the user agent string of Navigator, which contains version info
|
||||
*/
|
||||
const char* NPN_UserAgent(NPP instance)
|
||||
{
|
||||
return g_pNavigatorFuncs->uagent(instance);
|
||||
}
|
||||
|
||||
/* allocates memory from the Navigator's memory space. Necessary so that
|
||||
saved instance data may be freed by Navigator when exiting.
|
||||
*/
|
||||
|
||||
|
||||
void* NPN_MemAlloc(uint32_t size)
|
||||
{
|
||||
return g_pNavigatorFuncs->memalloc(size);
|
||||
}
|
||||
|
||||
/* reciprocal of MemAlloc() above
|
||||
*/
|
||||
void NPN_MemFree(void* ptr)
|
||||
{
|
||||
g_pNavigatorFuncs->memfree(ptr);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 766 B |
@ -1,757 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
#include "dialogs.h"
|
||||
#include "dbg.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
nsIServiceManager * gServiceManager = NULL;
|
||||
|
||||
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
|
||||
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
|
||||
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
|
||||
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
|
||||
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
|
||||
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
|
||||
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
|
||||
|
||||
BOOL RegisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
|
||||
WNDCLASS wc;
|
||||
|
||||
memset(&wc, 0, sizeof(wc));
|
||||
|
||||
wc.lpfnWndProc = (WNDPROC)PluginWndProc;
|
||||
wc.cbWndExtra = sizeof(DWORD);
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
|
||||
wc.hCursor = NULL;
|
||||
wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
|
||||
wc.lpszClassName = szNullPluginWindowClassName;
|
||||
|
||||
ATOM aRet = RegisterClass(&wc);
|
||||
return (aRet != NULL);
|
||||
}
|
||||
|
||||
void UnregisterNullPluginWindowClass()
|
||||
{
|
||||
assert(hInst != NULL);
|
||||
UnregisterClass(szNullPluginWindowClassName, hInst);
|
||||
}
|
||||
|
||||
/*********************************************/
|
||||
/* */
|
||||
/* CPlugin class implementation */
|
||||
/* */
|
||||
/*********************************************/
|
||||
|
||||
CPlugin::CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden) :
|
||||
m_pNPInstance(pNPInstance),
|
||||
m_wMode(wMode),
|
||||
m_hInst(hInst),
|
||||
m_hWnd(NULL),
|
||||
m_hWndParent(NULL),
|
||||
m_hWndDialog(NULL),
|
||||
m_hIcon(NULL),
|
||||
m_pNPMIMEType(NULL),
|
||||
m_szPageURL(NULL),
|
||||
m_szFileURL(NULL),
|
||||
m_szFileExtension(NULL),
|
||||
m_bOnline(TRUE),
|
||||
m_bJavaScript(TRUE),
|
||||
m_bSmartUpdate(TRUE),
|
||||
m_szURLString(NULL),
|
||||
m_szCommandMessage(NULL),
|
||||
m_bWaitingStreamFromPFS(FALSE),
|
||||
m_PFSStream(NULL),
|
||||
m_bHidden(bHidden)
|
||||
{
|
||||
dbgOut1("CPlugin::CPlugin()");
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
if(pluginType && *pluginType)
|
||||
{
|
||||
m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1];
|
||||
if(m_pNPMIMEType != NULL)
|
||||
lstrcpy((LPSTR)m_pNPMIMEType, pluginType);
|
||||
}
|
||||
|
||||
if(szPageURL && *szPageURL)
|
||||
{
|
||||
m_szPageURL = new char[lstrlen(szPageURL) + 1];
|
||||
if(m_szPageURL != NULL)
|
||||
lstrcpy(m_szPageURL, szPageURL);
|
||||
}
|
||||
|
||||
if(szFileURL && *szFileURL)
|
||||
{
|
||||
m_szFileURL = new char[lstrlen(szFileURL) + 1];
|
||||
if(m_szFileURL != NULL)
|
||||
lstrcpy(m_szFileURL, szFileURL);
|
||||
}
|
||||
|
||||
if(szFileExtension && *szFileExtension)
|
||||
{
|
||||
m_szFileExtension = new char[lstrlen(szFileExtension) + 1];
|
||||
if(m_szFileExtension != NULL)
|
||||
lstrcpy(m_szFileExtension, szFileExtension);
|
||||
}
|
||||
|
||||
m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON));
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
|
||||
if(*szString)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
}
|
||||
|
||||
CPlugin::~CPlugin()
|
||||
{
|
||||
dbgOut1("CPlugin::~CPlugin()");
|
||||
|
||||
if(m_pNPMIMEType != NULL)
|
||||
{
|
||||
delete [] m_pNPMIMEType;
|
||||
m_pNPMIMEType = NULL;
|
||||
}
|
||||
|
||||
if(m_szPageURL != NULL)
|
||||
{
|
||||
delete [] m_szPageURL;
|
||||
m_szPageURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileURL != NULL)
|
||||
{
|
||||
delete [] m_szFileURL;
|
||||
m_szFileURL = NULL;
|
||||
}
|
||||
|
||||
if(m_szFileExtension != NULL)
|
||||
{
|
||||
delete [] m_szFileExtension;
|
||||
m_szFileExtension = NULL;
|
||||
}
|
||||
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
if(m_hIcon != NULL)
|
||||
{
|
||||
DestroyIcon(m_hIcon);
|
||||
m_hIcon = NULL;
|
||||
}
|
||||
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CPlugin::init(HWND hWndParent)
|
||||
{
|
||||
dbgOut1("CPlugin::init()");
|
||||
|
||||
nsISupports * sm = NULL;
|
||||
nsIPrefBranch * prefBranch = NULL;
|
||||
PRBool bSendUrls = PR_FALSE; // default to false if problem getting pref
|
||||
|
||||
// note that Mozilla will add reference, so do not forget to release
|
||||
NPN_GetValue(NULL, NPNVserviceManager, &sm);
|
||||
|
||||
// do a QI on the service manager we get back to ensure it's the one we are expecting
|
||||
if(sm) {
|
||||
sm->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&gServiceManager);
|
||||
NS_RELEASE(sm);
|
||||
}
|
||||
|
||||
if (gServiceManager) {
|
||||
// get service using its contract id and use it to allocate the memory
|
||||
gServiceManager->GetServiceByContractID(NS_PREFSERVICE_CONTRACTID,
|
||||
NS_GET_IID(nsIPrefBranch),
|
||||
(void **)&prefBranch);
|
||||
if(prefBranch) {
|
||||
prefBranch->GetBoolPref("application.use_ns_plugin_finder", &bSendUrls);
|
||||
NS_RELEASE(prefBranch);
|
||||
}
|
||||
}
|
||||
m_bSmartUpdate = bSendUrls;
|
||||
|
||||
if(!m_bHidden)
|
||||
{
|
||||
assert(IsWindow(hWndParent));
|
||||
|
||||
if(IsWindow(hWndParent))
|
||||
m_hWndParent = hWndParent;
|
||||
|
||||
RECT rcParent;
|
||||
GetClientRect(m_hWndParent, &rcParent);
|
||||
|
||||
CreateWindow(szNullPluginWindowClassName,
|
||||
"NULL Plugin",
|
||||
WS_CHILD,
|
||||
0,0, rcParent.right, rcParent.bottom,
|
||||
m_hWndParent,
|
||||
(HMENU)NULL,
|
||||
m_hInst,
|
||||
(LPVOID)this);
|
||||
|
||||
assert(m_hWnd != NULL);
|
||||
if((m_hWnd == NULL) || (!IsWindow(m_hWnd)))
|
||||
return FALSE;
|
||||
|
||||
UpdateWindow(m_hWnd);
|
||||
ShowWindow(m_hWnd, SW_SHOW);
|
||||
}
|
||||
|
||||
if(IsNewMimeType((LPSTR)m_pNPMIMEType) || m_bHidden)
|
||||
showGetPluginDialog();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::shut()
|
||||
{
|
||||
dbgOut1("CPlugin::shut()");
|
||||
|
||||
if(m_hWndDialog != NULL)
|
||||
{
|
||||
DestroyWindow(m_hWndDialog);
|
||||
m_hWndDialog = NULL;
|
||||
}
|
||||
|
||||
if(m_hWnd != NULL)
|
||||
{
|
||||
DestroyWindow(m_hWnd);
|
||||
m_hWnd = NULL;
|
||||
}
|
||||
|
||||
// we should release the service manager
|
||||
NS_IF_RELEASE(gServiceManager);
|
||||
gServiceManager = NULL;
|
||||
}
|
||||
|
||||
HWND CPlugin::getWindow()
|
||||
{
|
||||
return m_hWnd;
|
||||
}
|
||||
|
||||
BOOL CPlugin::useDefaultURL_P()
|
||||
{
|
||||
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CPlugin::doSmartUpdate_P()
|
||||
{
|
||||
// due to current JavaScript problems never do it smart for now 5.1.98
|
||||
return FALSE;
|
||||
|
||||
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPSTR CPlugin::createURLString()
|
||||
{
|
||||
if(m_szURLString != NULL)
|
||||
{
|
||||
delete [] m_szURLString;
|
||||
m_szURLString = NULL;
|
||||
}
|
||||
|
||||
// check if there is file URL first
|
||||
if(!m_bSmartUpdate && m_szFileURL != NULL)
|
||||
{
|
||||
m_szURLString = new char[lstrlen(m_szFileURL) + 1];
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
lstrcpy(m_szURLString, m_szFileURL);
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
// if not get the page URL
|
||||
char * szAddress = NULL;
|
||||
char *urlToOpen = NULL;
|
||||
char contentTypeIsJava = 0;
|
||||
|
||||
if (NULL != m_pNPMIMEType) {
|
||||
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
|
||||
m_pNPMIMEType)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava)
|
||||
{
|
||||
szAddress = new char[lstrlen(m_szPageURL) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, m_szPageURL);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else // default
|
||||
{
|
||||
if(!m_bSmartUpdate)
|
||||
{
|
||||
urlToOpen = szDefaultPluginFinderURL;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
szAddress = new char[lstrlen(urlToOpen) + 1];
|
||||
if(szAddress == NULL)
|
||||
return NULL;
|
||||
lstrcpy(szAddress, urlToOpen);
|
||||
|
||||
m_szURLString = new char[lstrlen(szAddress) + 10 +
|
||||
lstrlen((LPSTR)m_pNPMIMEType) + 1];
|
||||
|
||||
if(m_szURLString == NULL)
|
||||
return NULL;
|
||||
|
||||
// Append the MIME type to the URL
|
||||
wsprintf(m_szURLString, "%s?mimetype=%s",
|
||||
szAddress, (LPSTR)m_pNPMIMEType);
|
||||
}
|
||||
else
|
||||
{
|
||||
urlToOpen = szPageUrlForJavaScript;
|
||||
|
||||
if (contentTypeIsJava) {
|
||||
urlToOpen = szPageUrlForJVM;
|
||||
}
|
||||
|
||||
// wsprintf doesn't like null pointers on NT or 98, so
|
||||
// change any null string pointers to null strings
|
||||
if (!m_szPageURL) {
|
||||
m_szPageURL = new char[1];
|
||||
m_szPageURL[0] = '\0';
|
||||
}
|
||||
|
||||
if (!m_szFileURL) {
|
||||
m_szFileURL = new char[1];
|
||||
m_szFileURL[0] = '\0';
|
||||
}
|
||||
|
||||
m_szURLString = new char[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 +
|
||||
lstrlen((LPSTR)m_pNPMIMEType) + 13 +
|
||||
lstrlen((LPSTR)m_szPageURL) + 11 +
|
||||
lstrlen((LPSTR)m_szFileURL) +
|
||||
lstrlen(szPluginFinderCommandEnd) + 1];
|
||||
wsprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
|
||||
szPluginFinderCommandBeginning, urlToOpen,
|
||||
(LPSTR)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(szAddress != NULL)
|
||||
delete [] szAddress;
|
||||
|
||||
return m_szURLString;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginRegular()
|
||||
{
|
||||
assert(m_bOnline);
|
||||
|
||||
char * szURL = createURLString();
|
||||
|
||||
assert(szURL != NULL);
|
||||
if(szURL == NULL)
|
||||
return;
|
||||
|
||||
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szURL, NULL);
|
||||
m_bWaitingStreamFromPFS = TRUE;
|
||||
}
|
||||
|
||||
void CPlugin::getPluginSmart()
|
||||
{
|
||||
/*
|
||||
static char szJSString[2048];
|
||||
|
||||
wsprintf(szJSString,
|
||||
szPluginFinderCommandFormatString,
|
||||
szDefaultPluginFinderURL,
|
||||
m_pNPMIMEType,
|
||||
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
|
||||
|
||||
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
|
||||
|
||||
assert(*szJSString);
|
||||
|
||||
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
|
||||
*/
|
||||
}
|
||||
|
||||
void CPlugin::showGetPluginDialog()
|
||||
{
|
||||
assert(m_pNPMIMEType != NULL);
|
||||
if(m_pNPMIMEType == NULL)
|
||||
return;
|
||||
|
||||
// Get environment
|
||||
BOOL bOffline = FALSE;
|
||||
|
||||
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
|
||||
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
|
||||
//NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
|
||||
|
||||
m_bOnline = !bOffline;
|
||||
|
||||
dbgOut1("Environment:");
|
||||
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
|
||||
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
|
||||
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
|
||||
|
||||
if((!m_bSmartUpdate && (m_szPageURL != NULL) || (m_szFileURL != NULL)) || !m_bJavaScript)
|
||||
{
|
||||
// we don't want it more than once
|
||||
if(m_hWndDialog == NULL)
|
||||
CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_PLUGIN_DOWNLOAD), m_hWnd,
|
||||
(DLGPROC)GetPluginDialogProc, (LPARAM)this);
|
||||
}
|
||||
else
|
||||
getPlugin();
|
||||
}
|
||||
|
||||
void CPlugin::getPlugin()
|
||||
{
|
||||
if(m_szCommandMessage != NULL)
|
||||
{
|
||||
delete [] m_szCommandMessage;
|
||||
m_szCommandMessage = NULL;
|
||||
}
|
||||
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(*szString)
|
||||
{
|
||||
m_szCommandMessage = new char[lstrlen(szString) + 1];
|
||||
if(m_szCommandMessage != NULL)
|
||||
lstrcpy(m_szCommandMessage, szString);
|
||||
}
|
||||
|
||||
InvalidateRect(m_hWnd, NULL, TRUE);
|
||||
UpdateWindow(m_hWnd);
|
||||
|
||||
getPluginRegular();
|
||||
}
|
||||
|
||||
//*******************
|
||||
// NP API handles
|
||||
//*******************
|
||||
void CPlugin::resize()
|
||||
{
|
||||
dbgOut1("CPlugin::resize()");
|
||||
}
|
||||
|
||||
void CPlugin::print(NPPrint * pNPPrint)
|
||||
{
|
||||
dbgOut1("CPlugin::print()");
|
||||
|
||||
if(pNPPrint == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
void CPlugin::URLNotify(const char * szURL)
|
||||
{
|
||||
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
|
||||
|
||||
NPStream * pStream = NULL;
|
||||
char buf[256];
|
||||
|
||||
assert(m_hInst != NULL);
|
||||
assert(m_pNPInstance != NULL);
|
||||
|
||||
int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
|
||||
|
||||
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
|
||||
if (rc != NPERR_NO_ERROR)
|
||||
return;
|
||||
|
||||
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
|
||||
|
||||
NPN_Write(m_pNPInstance, pStream, iSize, buf);
|
||||
|
||||
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
|
||||
}
|
||||
|
||||
NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype)
|
||||
{
|
||||
if (!m_bWaitingStreamFromPFS)
|
||||
return NPERR_NO_ERROR;
|
||||
|
||||
m_bWaitingStreamFromPFS = FALSE;
|
||||
m_PFSStream = stream;
|
||||
|
||||
if (stream) {
|
||||
if (type && !strcmp(type, "application/x-xpinstall"))
|
||||
NPN_GetURL(m_pNPInstance, stream->url, "_self");
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, stream->url, "_blank");
|
||||
}
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError CPlugin::destroyStream(NPStream *stream, NPError reason)
|
||||
{
|
||||
if (stream == m_PFSStream)
|
||||
m_PFSStream = NULL;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
BOOL CPlugin::readyToRefresh()
|
||||
{
|
||||
char szString[1024] = {'\0'};
|
||||
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
|
||||
if(m_szCommandMessage == NULL)
|
||||
return FALSE;
|
||||
|
||||
return (lstrcmp(m_szCommandMessage, szString) == 0);
|
||||
}
|
||||
|
||||
//***************************
|
||||
// Windows message handlers
|
||||
//***************************
|
||||
void CPlugin::onCreate(HWND hWnd)
|
||||
{
|
||||
m_hWnd = hWnd;
|
||||
}
|
||||
|
||||
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
|
||||
{
|
||||
if(!readyToRefresh())
|
||||
showGetPluginDialog();
|
||||
else
|
||||
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
|
||||
}
|
||||
|
||||
static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc)
|
||||
{
|
||||
if(szString == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFont = GetStockFont(DEFAULT_GUI_FONT);
|
||||
if(hFont == NULL)
|
||||
return;
|
||||
|
||||
HFONT hFontOld = SelectFont(hDC, hFont);
|
||||
SIZE sz;
|
||||
GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
|
||||
int iY = (lprc->bottom / 2) - ((32) / 2) + 36;
|
||||
int iX = 0;
|
||||
|
||||
if(lprc->right > pt.x)
|
||||
iX = lprc->right/2 - pt.x/2;
|
||||
else
|
||||
iX = 1;
|
||||
|
||||
RECT rcText;
|
||||
rcText.left = iX;
|
||||
rcText.right = rcText.left + pt.x;
|
||||
rcText.top = iY;
|
||||
rcText.bottom = rcText.top + pt.y;
|
||||
|
||||
int iModeOld = SetBkMode(hDC, TRANSPARENT);
|
||||
COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0));
|
||||
DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER);
|
||||
SetTextColor(hDC, crColorOld);
|
||||
SetBkMode(hDC, iModeOld);
|
||||
SelectFont(hDC, hFontOld);
|
||||
}
|
||||
|
||||
void CPlugin::onPaint(HWND hWnd)
|
||||
{
|
||||
RECT rc;
|
||||
HDC hDC;
|
||||
PAINTSTRUCT ps;
|
||||
int x, y;
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rc);
|
||||
|
||||
x = (rc.right / 2) - (32 / 2);
|
||||
y = (rc.bottom / 2) - ((32) / 2);
|
||||
|
||||
if(rc.right > 34 && rc.bottom > 34)
|
||||
{
|
||||
if(m_hIcon != NULL)
|
||||
DrawIcon(hDC, x, y, m_hIcon);
|
||||
|
||||
POINT pt[5];
|
||||
|
||||
// left vert and top horiz highlight
|
||||
pt[0].x = 1; pt[0].y = rc.bottom-1;
|
||||
pt[1].x = 1; pt[1].y = 1;
|
||||
pt[2].x = rc.right-1; pt[2].y = 1;
|
||||
|
||||
HPEN hPen3DLight = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT));
|
||||
HPEN hPen3DShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
|
||||
HPEN hPen3DDKShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW));
|
||||
|
||||
HPEN hPenOld = SelectPen(hDC, hPen3DLight);
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// left vert and top horiz shadow
|
||||
pt[0].x = 2; pt[0].y = rc.bottom-3;
|
||||
pt[1].x = 2; pt[1].y = 2;
|
||||
pt[2].x = rc.right-2; pt[2].y = 2;
|
||||
SelectPen(hDC, hPen3DShadow);
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz highlight
|
||||
pt[0].x = rc.right-3; pt[0].y = 2;
|
||||
pt[1].x = rc.right-3; pt[1].y = rc.bottom-3;
|
||||
pt[2].x = 2; pt[2].y = rc.bottom-3;
|
||||
SelectPen(hDC, hPen3DLight);
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// right vert and bottom horiz shadow
|
||||
pt[0].x = rc.right-1; pt[0].y = 1;
|
||||
pt[1].x = rc.right-1; pt[1].y = rc.bottom-1;
|
||||
pt[2].x = 0; pt[2].y = rc.bottom-1;
|
||||
SelectPen(hDC, hPen3DDKShadow);
|
||||
Polyline(hDC, pt, 3);
|
||||
|
||||
// restore the old pen
|
||||
SelectPen(hDC, hPenOld);
|
||||
|
||||
DeletePen(hPen3DDKShadow);
|
||||
DeletePen(hPen3DShadow);
|
||||
DeletePen(hPen3DLight);
|
||||
|
||||
DrawCommandMessage(hDC, m_szCommandMessage, &rc);
|
||||
}
|
||||
else
|
||||
if(m_hIcon != NULL)
|
||||
DrawIconEx(hDC, x, y, m_hIcon, rc.right - rc.left, rc.bottom - rc.top, 0, NULL, DI_NORMAL);
|
||||
|
||||
EndPaint (hWnd, &ps);
|
||||
}
|
||||
|
||||
//**************************
|
||||
// Plugin window procedure
|
||||
//**************************
|
||||
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CPlugin *pPlugin = (CPlugin *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
|
||||
switch(message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
pPlugin = (CPlugin *)(((CREATESTRUCT FAR*)lParam)->lpCreateParams);
|
||||
assert(pPlugin != NULL);
|
||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pPlugin);
|
||||
pPlugin->onCreate(hWnd);
|
||||
return 0L;
|
||||
case WM_LBUTTONUP:
|
||||
HANDLE_WM_LBUTTONUP(hWnd, wParam, lParam, pPlugin->onLButtonUp);
|
||||
return 0L;
|
||||
case WM_RBUTTONUP:
|
||||
HANDLE_WM_RBUTTONUP(hWnd, wParam, lParam, pPlugin->onRButtonUp);
|
||||
return 0L;
|
||||
case WM_PAINT:
|
||||
HANDLE_WM_PAINT(hWnd, wParam, lParam, pPlugin->onPaint);
|
||||
return 0L;
|
||||
case WM_MOUSEMOVE:
|
||||
dbgOut1("MouseMove");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __PLUGIN_HPP__
|
||||
#define __PLUGIN_HPP__
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
class CPlugin
|
||||
{
|
||||
private:
|
||||
HINSTANCE m_hInst;
|
||||
NPP m_pNPInstance;
|
||||
WORD m_wMode;
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndParent;
|
||||
HICON m_hIcon;
|
||||
char* m_szURLString;
|
||||
|
||||
char* m_szCommandMessage;
|
||||
BOOL m_bWaitingStreamFromPFS;
|
||||
NPStream* m_PFSStream;
|
||||
|
||||
public:
|
||||
BOOL m_bHidden;
|
||||
NPMIMEType m_pNPMIMEType;
|
||||
LPSTR m_szPageURL; // Location of plug-in HTML page
|
||||
LPSTR m_szFileURL; // Location of plug-in JAR file
|
||||
LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype
|
||||
HWND m_hWndDialog;
|
||||
|
||||
// environment
|
||||
BOOL m_bOnline;
|
||||
BOOL m_bJavaScript;
|
||||
BOOL m_bSmartUpdate;
|
||||
|
||||
private:
|
||||
BOOL useDefaultURL_P();
|
||||
BOOL doSmartUpdate_P();
|
||||
LPSTR createURLString();
|
||||
void getPluginSmart();
|
||||
void getPluginRegular();
|
||||
|
||||
public:
|
||||
CPlugin(HINSTANCE hInst,
|
||||
NPP pNPInstance,
|
||||
WORD wMode,
|
||||
NPMIMEType pluginType,
|
||||
LPSTR szPageURL,
|
||||
LPSTR szFileURL,
|
||||
LPSTR szFileExtension,
|
||||
BOOL bHidden);
|
||||
~CPlugin();
|
||||
|
||||
BOOL init(HWND hWnd);
|
||||
void shut();
|
||||
HWND getWindow();
|
||||
void showGetPluginDialog();
|
||||
void getPlugin();
|
||||
BOOL readyToRefresh();
|
||||
|
||||
// NP API handlers
|
||||
void print(NPPrint * pNPPrint);
|
||||
void URLNotify(const char * szURL);
|
||||
NPError newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype);
|
||||
NPError destroyStream(NPStream *stream, NPError reason);
|
||||
|
||||
// Windows message handlers
|
||||
void onCreate(HWND hWnd);
|
||||
void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
|
||||
void onPaint(HWND hWnd);
|
||||
|
||||
void resize();
|
||||
};
|
||||
|
||||
|
||||
#define PAGE_URL_FOR_JAVASCRIPT "http://plugindoc.mozdev.org/winmime.html"
|
||||
|
||||
#define PLUGINFINDER_COMMAND_BEGINNING ""
|
||||
#define PLUGINFINDER_COMMAND_END ""
|
||||
#define DEFAULT_PLUGINFINDER_URL "http://plugindoc.mozdev.org/winmime.html"
|
||||
#define JVM_SMARTUPDATE_URL "http://java.com/download"
|
||||
|
||||
#ifdef WIN32
|
||||
#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin"
|
||||
#else
|
||||
#define GWL_USERDATA 0
|
||||
#define COLOR_3DSHADOW COLOR_BTNFACE
|
||||
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
|
||||
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
|
||||
#endif
|
||||
|
||||
#define CLASS_NULL_PLUGIN "NullPluginClass"
|
||||
|
||||
BOOL RegisterNullPluginWindowClass();
|
||||
void UnregisterNullPluginWindowClass();
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
#endif // __PLUGIN_HPP__
|
@ -1,48 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Npnul32.rc
|
||||
//
|
||||
#define IDD_PLUGIN_DOWNLOAD 301
|
||||
#define IDI_PLUGICON 302
|
||||
#define IDS_INFO 303
|
||||
#define IDS_DEFAULT_URL 304
|
||||
#define IDS_INSTALL_COMMAND 305
|
||||
#define IDS_GET_PLUGIN_MSG2 306
|
||||
#define IDS_LOCATION 306
|
||||
#define IDS_TITLE 307
|
||||
#define IDS_QUESTION 308
|
||||
#define IDS_JS_DISABLED 309
|
||||
#define IDS_ASDFINDER 310
|
||||
#define IDS_ASDSIMP 311
|
||||
#define IDS_QUERY_TEST 312
|
||||
#define IDS_BLANK_JS 313
|
||||
#define IDS_GOING2HTML 314
|
||||
#define IDS_WARNING_JS 315
|
||||
#define IDS_WARNING_OFFLINE 316
|
||||
#define IDS_DEFAULT_URL_OLD 317
|
||||
#define IDS_FINDER_PAGE 317
|
||||
#define IDS_CLICK_TO_GET 318
|
||||
#define IDS_CLICK_WHEN_DONE 319
|
||||
#define IDC_JS_DIS_TEXT 2003
|
||||
#define IDC_CONTINUE 2004
|
||||
#define IDC_CONT_NOJS 2005
|
||||
#define IDC_STATIC_INFO 2009
|
||||
#define IDC_STATIC_LOCATION 2010
|
||||
#define IDC_STATIC_QUESTION 2011
|
||||
#define IDC_GET_PLUGIN 2012
|
||||
#define IDC_BUTTON_CANCEL 2013
|
||||
#define IDC_STATIC_URL 2014
|
||||
#define IDC_STATIC_INFOTYPE 2015
|
||||
#define IDC_STATIC_WARNING 2016
|
||||
#define IDC_EDIT_URL 2017
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 308
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 2018
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
@ -1,171 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
// open the registry, create if necessary
|
||||
HKEY openRegistry()
|
||||
{
|
||||
HKEY phkResult;
|
||||
|
||||
if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);
|
||||
|
||||
return phkResult;
|
||||
}
|
||||
|
||||
// return TRUE if we've never seen this MIME type before
|
||||
BOOL IsNewMimeType(LPSTR mime)
|
||||
{
|
||||
HKEY hkey = openRegistry();
|
||||
DWORD dwType, keysize = 512;
|
||||
char keybuf[512];
|
||||
|
||||
if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
|
||||
{
|
||||
// key exists, must have already been here...
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS)
|
||||
MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// string length in pixels for the specific window (selected font)
|
||||
static int getWindowStringLength(HWND hWnd, LPSTR lpsz)
|
||||
{
|
||||
SIZE sz;
|
||||
HDC hDC = GetDC(hWnd);
|
||||
HFONT hWindowFont = GetWindowFont(hWnd);
|
||||
HFONT hFontOld = SelectFont(hDC, hWindowFont);
|
||||
GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz);
|
||||
POINT pt;
|
||||
pt.x = sz.cx;
|
||||
pt.y = sz.cy;
|
||||
LPtoDP(hDC, &pt, 1);
|
||||
SelectFont(hDC, hFontOld);
|
||||
ReleaseDC(hWnd, hDC);
|
||||
return (int)pt.x;
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
/* */
|
||||
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */
|
||||
/* */
|
||||
/* helper to wrap long lines in a static control, which do not */
|
||||
/* wrap automatically if they do not have space characters */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText)
|
||||
{
|
||||
HWND hWndStatic = GetDlgItem(hWnd, iID);
|
||||
if((szText == NULL) || (lstrlen(szText) == 0))
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, "");
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rc;
|
||||
GetClientRect(hWndStatic, &rc);
|
||||
|
||||
int iStaticLength = rc.right - rc.left;
|
||||
int iStringLength = getWindowStringLength(hWndStatic, szText);
|
||||
|
||||
if(iStringLength <= iStaticLength)
|
||||
{
|
||||
SetDlgItemText(hWnd, iID, szText);
|
||||
return;
|
||||
}
|
||||
|
||||
int iBreaks = iStringLength/iStaticLength;
|
||||
if(iBreaks <= 0)
|
||||
return;
|
||||
|
||||
char * pBuf = new char[iStringLength + iBreaks + 1];
|
||||
if(pBuf == NULL)
|
||||
return;
|
||||
|
||||
lstrcpy(pBuf, "");
|
||||
|
||||
int iStart = 0;
|
||||
int iLines = 0;
|
||||
for(int i = 0; i < iStringLength; i++)
|
||||
{
|
||||
char * sz = &szText[iStart];
|
||||
int iIndex = i - iStart;
|
||||
char ch = sz[iIndex + 1];
|
||||
|
||||
sz[iIndex + 1] = '\0';
|
||||
|
||||
int iLength = getWindowStringLength(hWndStatic, sz);
|
||||
|
||||
if(iLength < iStaticLength)
|
||||
{
|
||||
sz[iIndex + 1] = ch;
|
||||
if(iLines == iBreaks)
|
||||
{
|
||||
lstrcat(pBuf, sz);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sz[iIndex + 1] = ch; // restore zeroed element
|
||||
i--; // go one step back
|
||||
|
||||
ch = sz[iIndex];
|
||||
sz[iIndex] = '\0'; // terminate string one char shorter
|
||||
|
||||
lstrcat(pBuf, sz); // append the string
|
||||
lstrcat(pBuf, " "); // append space character for successful wrapping
|
||||
|
||||
iStart += lstrlen(sz);// shift new start position
|
||||
sz[iIndex] = ch; // restore zeroed element
|
||||
iLines++; // count lines
|
||||
}
|
||||
|
||||
SetDlgItemText(hWnd, iID, pBuf);
|
||||
|
||||
delete [] pBuf;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
HKEY openRegistry();
|
||||
BOOL IsNewMimeType(LPSTR szMimeType);
|
||||
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText);
|
||||
|
||||
#endif // __UTILS_H__
|
Loading…
Reference in New Issue
Block a user