diff --git a/mozilla/mailnews/import/text/src/nsTextFactory.cpp b/mozilla/mailnews/import/text/src/nsTextFactory.cpp index d47799f9ae0..b32d658f447 100644 --- a/mozilla/mailnews/import/text/src/nsTextFactory.cpp +++ b/mozilla/mailnews/import/text/src/nsTextFactory.cpp @@ -33,7 +33,7 @@ #include "TextDebugLog.h" -NS_IMPL_LOG(TextDebugLogLog, 0) +NS_IMPL_LOG(TextDebugLogLog) static NS_DEFINE_CID(kTextImportCID, NS_TEXTIMPORT_CID); diff --git a/mozilla/mailnews/mime/src/mimefilt.cpp b/mozilla/mailnews/mime/src/mimefilt.cpp index 2375fd51f14..491a3cf2257 100644 --- a/mozilla/mailnews/mime/src/mimefilt.cpp +++ b/mozilla/mailnews/mime/src/mimefilt.cpp @@ -63,7 +63,7 @@ #include "nsMimeStringResources.h" #include "nslog.h" -NS_IMPL_LOG(mimefiltLog, 0) +NS_IMPL_LOG(mimefiltLog) #define PRINTF NS_LOG_PRINTF(mimefiltLog) #define FLUSH NS_LOG_FLUSH(mimefiltLog) diff --git a/mozilla/modules/plugin/bad/badapter.cpp b/mozilla/modules/plugin/bad/badapter.cpp index f75c867662d..6f0577ea229 100644 --- a/mozilla/modules/plugin/bad/badapter.cpp +++ b/mozilla/modules/plugin/bad/badapter.cpp @@ -42,7 +42,7 @@ #include "nsDebug.h" #include "nslog.h" -NS_IMPL_LOG(badapterLog, 0) +NS_IMPL_LOG(badapterLog) #define PRINTF NS_LOG_PRINTF(badapterLog) #define FLUSH NS_LOG_FLUSH(badapterLog) diff --git a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp index 17d7b6fd777..4069e1e850b 100644 --- a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp @@ -39,7 +39,7 @@ #include "nsIPref.h" #include "nslog.h" -NS_IMPL_LOG(ns4xPluginLog, 0) +NS_IMPL_LOG(ns4xPluginLog) #define PRINTF NS_LOG_PRINTF(ns4xPluginLog) #define FLUSH NS_LOG_FLUSH(ns4xPluginLog) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 5171c5b027e..df4f76d0e35 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -52,7 +52,7 @@ #include "nsIDocument.h" #include "nslog.h" -NS_IMPL_LOG(nsPluginHostImplLog, 0) +NS_IMPL_LOG(nsPluginHostImplLog) #define PRINTF NS_LOG_PRINTF(nsPluginHostImplLog) #define FLUSH NS_LOG_FLUSH(nsPluginHostImplLog) diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index c1c4a12206b..13e0f138ac1 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -46,7 +46,7 @@ #include "nslog.h" -NS_IMPL_LOG(nsPluginInstancePeerLog, 0) +NS_IMPL_LOG(nsPluginInstancePeerLog) #define PRINTF NS_LOG_PRINTF(nsPluginInstancePeerLog) #define FLUSH NS_LOG_FLUSH(nsPluginInstancePeerLog) diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index f0d7ecb3ed3..f51d235ac55 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -45,7 +45,7 @@ #include "nsPluginViewer.h" #include "nslog.h" -NS_IMPL_LOG(nsPluginViewerLog, 0) +NS_IMPL_LOG(nsPluginViewerLog) #define PRINTF NS_LOG_PRINTF(nsPluginViewerLog) #define FLUSH NS_LOG_FLUSH(nsPluginViewerLog) diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp index 4d04267d7ba..52e3a8d4860 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp @@ -34,7 +34,7 @@ #include "prmem.h" #include "nslog.h" -NS_IMPL_LOG(nsPluginsDirBeOSLog, 0) +NS_IMPL_LOG(nsPluginsDirBeOSLog) #define PRINTF NS_LOG_PRINTF(nsPluginsDirBeOSLog) #define FLUSH NS_LOG_FLUSH(nsPluginsDirBeOSLog) diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirUNIX.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirUNIX.cpp new file mode 100644 index 00000000000..edc9b77345a --- /dev/null +++ b/mozilla/modules/plugin/base/src/nsPluginsDirUNIX.cpp @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + nsPluginsDirUNIX.cpp + + UNIX implementation of the nsPluginsDir/nsPluginsFile classes. + + by Alex Musil + */ + +#include "xp_core.h" +#include "nsplugin.h" +#include "ns4xPlugin.h" +#include "ns4xPluginInstance.h" +#include "nsIServiceManager.h" +#include "nsIMemory.h" +#include "nsIPluginStreamListener.h" +#include "nsPluginsDir.h" +#include "nsSpecialSystemDirectory.h" +#include "prmem.h" +#include "nslog.h" + +NS_IMPL_LOG(nsPluginsDirUNIXLog, 0) +#define PRINTF NS_LOG_PRINTF(nsPluginsDirUNIXLog) +#define FLUSH NS_LOG_FLUSH(nsPluginsDirUNIXLog) + +/* Local helper functions */ + +static PRUint32 CalculateVariantCount(const char* mimeTypes) +{ + PRUint32 variants = 0; + const char* ptr = mimeTypes; + while (*ptr) + { + if (*ptr == ';') + variants++; + + ++ptr; + } + return variants; +} + +/////////////////////////////////////////////////////////////////////////// + +/* nsPluginsDir implementation */ + +nsPluginsDir::nsPluginsDir(PRUint16 location) +{ + // this is somewhat lacking, in that it doesn't fall back to any + // other directories. then again, I'm not sure we should be falling + // back at all. plugins have been (and probably should continue to be) + // loaded from both /plugins and ~/.mozilla/plugins. There + // doesn't seem to be any way to do this in the current nsPluginsDir + // code, which is disheartening. + + // use MOZILLA_FIVE_HOME/plugins + + nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); + sysdir += "plugins"; + const char *pluginsDir = sysdir.GetCString(); // native path + if (pluginsDir != NULL) + { + *(nsFileSpec*)this = pluginsDir; + } +} + +nsPluginsDir::~nsPluginsDir() +{ + // do nothing +} + +PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) +{ + const char* pathname = fileSpec.GetCString(); + + + PRINTF("IsPluginFile(%s)\n", pathname); + + return PR_TRUE; +} + +/////////////////////////////////////////////////////////////////////////// + +/* nsPluginFile implementation */ + +nsPluginFile::nsPluginFile(const nsFileSpec& spec) + : nsFileSpec(spec) +{ + // nada +} + +nsPluginFile::~nsPluginFile() +{ + // nada +} + +/** + * Loads the plugin into memory using NSPR's shared-library loading + * mechanism. Handles platform differences in loading shared libraries. + */ +nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) +{ + PRLibSpec libSpec; + PRLibSpec tempSpec; + PRLibrary * handle; + + /////////////////////////////////////////////////////////// + // Normally, Mozilla isn't linked against libXt and libXext + // since it's a Gtk/Gdk application. On the other hand, + // legacy plug-ins expect the libXt and libXext symbols + // to already exist in the global name space. This plug-in + // wrapper is linked against libXt and libXext, but since + // we never call on any of these libraries, plug-ins still + // fail to resolve Xt symbols when trying to do a dlopen + // at runtime. Explicitly opening Xt/Xext into the global + // namespace before attempting to load the plug-in seems to + // work fine. + + tempSpec.type = PR_LibSpec_Pathname; + tempSpec.value.pathname = "libXt.so"; + handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL); + + tempSpec.value.pathname = "libXext.so"; + handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL); + + libSpec.type = PR_LibSpec_Pathname; + libSpec.value.pathname = this->GetCString(); + pLibrary = outLibrary = PR_LoadLibraryWithFlags(libSpec, 0); + + PRINTF("LoadPlugin() %s returned %lx\n", + libSpec.value.pathname, (unsigned long)pLibrary); + + return NS_OK; +} + +/** + * Obtains all of the information currently available for this plugin. + */ +nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) +{ + nsresult rv; + const char* mimedescr, *name, *description; + char *mdesc,*start,*nexttoc,*mtype,*exten,*descr; + int i,num; + + // No, this doesn't leak. GetGlobalServiceManager() doesn't addref + // it's out pointer. Maybe it should. + nsIServiceManager* mgr; + nsServiceManager::GetGlobalServiceManager(&mgr); + + nsFactoryProc nsGetFactory = + (nsFactoryProc) PR_FindSymbol(pLibrary, "NSGetFactory"); + + nsCOMPtr plugin; + + if (nsGetFactory) { + // It's an almost-new-style plugin. The "truly new" plugins + // are just XPCOM components, but there are some Mozilla + // Classic holdovers that live in the plugins directory but + // implement nsIPlugin and the factory stuff. + static NS_DEFINE_CID(kPluginCID, NS_PLUGIN_CID); + + nsCOMPtr factory; + rv = nsGetFactory(mgr, kPluginCID, nsnull, nsnull, getter_AddRefs(factory)); + if (NS_FAILED(rv)) return rv; + + plugin = do_QueryInterface(factory); + } + else { + // It's old sk00l + rv = ns4xPlugin::CreatePlugin(mgr, this->GetCString(), pLibrary, getter_AddRefs(plugin)); + if (NS_FAILED(rv)) return rv; + } + + if (plugin) { + plugin->GetValue(nsPluginVariable_NameString, &name); + info.fName = PL_strdup(name); + + plugin->GetValue(nsPluginVariable_DescriptionString, &description); + info.fDescription = PL_strdup(description); + + plugin->GetMIMEDescription(&mimedescr); + } + else { + info.fName = PL_strdup(this->GetCString()); + info.fDescription = PL_strdup(""); + } + + PRINTF("GetMIMEDescription() returned \"%s\"\n", mimedescr); + + // copy string + + mdesc = (char *)PR_Malloc(strlen(mimedescr)+1); + strcpy(mdesc,mimedescr); + num=CalculateVariantCount(mimedescr)+1; + info.fVariantCount = num; + + info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *)); + info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *)); + info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *)); + + start=mdesc; + for(i=0;i/plugins and ~/.mozilla/plugins. There + // doesn't seem to be any way to do this in the current nsPluginsDir + // code, which is disheartening. + + // use MOZILLA_FIVE_HOME/plugins + + nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); + sysdir += "plugins"; + const char *pluginsDir = sysdir.GetCString(); // native path + if (pluginsDir != NULL) + { + *(nsFileSpec*)this = pluginsDir; + } +} + +nsPluginsDir::~nsPluginsDir() +{ + // do nothing +} + +PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec) +{ + const char* pathname = fileSpec.GetCString(); + + + PRINTF("IsPluginFile(%s)\n", pathname); + + return PR_TRUE; +} + +/////////////////////////////////////////////////////////////////////////// + +/* nsPluginFile implementation */ + +nsPluginFile::nsPluginFile(const nsFileSpec& spec) + : nsFileSpec(spec) +{ + // nada +} + +nsPluginFile::~nsPluginFile() +{ + // nada +} + +/** + * Loads the plugin into memory using NSPR's shared-library loading + * mechanism. Handles platform differences in loading shared libraries. + */ +nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary) +{ + PRLibSpec libSpec; + PRLibSpec tempSpec; + PRLibrary * handle; + + /////////////////////////////////////////////////////////// + // Normally, Mozilla isn't linked against libXt and libXext + // since it's a Gtk/Gdk application. On the other hand, + // legacy plug-ins expect the libXt and libXext symbols + // to already exist in the global name space. This plug-in + // wrapper is linked against libXt and libXext, but since + // we never call on any of these libraries, plug-ins still + // fail to resolve Xt symbols when trying to do a dlopen + // at runtime. Explicitly opening Xt/Xext into the global + // namespace before attempting to load the plug-in seems to + // work fine. + + tempSpec.type = PR_LibSpec_Pathname; + tempSpec.value.pathname = "libXt.so"; + handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL); + + tempSpec.value.pathname = "libXext.so"; + handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL); + + libSpec.type = PR_LibSpec_Pathname; + libSpec.value.pathname = this->GetCString(); + pLibrary = outLibrary = PR_LoadLibraryWithFlags(libSpec, 0); + + PRINTF("LoadPlugin() %s returned %lx\n", + libSpec.value.pathname, (unsigned long)pLibrary); + + return NS_OK; +} + +/** + * Obtains all of the information currently available for this plugin. + */ +nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) +{ + nsresult rv; + const char* mimedescr, *name, *description; + char *mdesc,*start,*nexttoc,*mtype,*exten,*descr; + int i,num; + + // No, this doesn't leak. GetGlobalServiceManager() doesn't addref + // it's out pointer. Maybe it should. + nsIServiceManager* mgr; + nsServiceManager::GetGlobalServiceManager(&mgr); + + nsFactoryProc nsGetFactory = + (nsFactoryProc) PR_FindSymbol(pLibrary, "NSGetFactory"); + + nsCOMPtr plugin; + + if (nsGetFactory) { + // It's an almost-new-style plugin. The "truly new" plugins + // are just XPCOM components, but there are some Mozilla + // Classic holdovers that live in the plugins directory but + // implement nsIPlugin and the factory stuff. + static NS_DEFINE_CID(kPluginCID, NS_PLUGIN_CID); + + nsCOMPtr factory; + rv = nsGetFactory(mgr, kPluginCID, nsnull, nsnull, getter_AddRefs(factory)); + if (NS_FAILED(rv)) return rv; + + plugin = do_QueryInterface(factory); + } + else { + // It's old sk00l + rv = ns4xPlugin::CreatePlugin(mgr, this->GetCString(), pLibrary, getter_AddRefs(plugin)); + if (NS_FAILED(rv)) return rv; + } + + if (plugin) { + plugin->GetValue(nsPluginVariable_NameString, &name); + info.fName = PL_strdup(name); + + plugin->GetValue(nsPluginVariable_DescriptionString, &description); + info.fDescription = PL_strdup(description); + + plugin->GetMIMEDescription(&mimedescr); + } + else { + info.fName = PL_strdup(this->GetCString()); + info.fDescription = PL_strdup(""); + } + + PRINTF("GetMIMEDescription() returned \"%s\"\n", mimedescr); + + // copy string + + mdesc = (char *)PR_Malloc(strlen(mimedescr)+1); + strcpy(mdesc,mimedescr); + num=CalculateVariantCount(mimedescr)+1; + info.fVariantCount = num; + + info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *)); + info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *)); + info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *)); + + start=mdesc; + for(i=0;i #include "nslog.h" -NS_IMPL_LOG(nsExternalProtocolWinLog, 0) +NS_IMPL_LOG(nsExternalProtocolWinLog) #define PRINTF NS_LOG_PRINTF(nsExternalProtocolWinLog) #define FLUSH NS_LOG_FLUSH(nsExternalProtocolWinLog) diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 2816496a4aa..9f8c63de337 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -36,7 +36,7 @@ #include "nsCOMPtr.h" #include "nslog.h" -NS_IMPL_LOG(nsViewManagerLog, 0) +NS_IMPL_LOG(nsViewManagerLog) #define PRINTF NS_LOG_PRINTF(nsViewManagerLog) #define FLUSH NS_LOG_FLUSH(nsViewManagerLog) diff --git a/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp b/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp index 13dfd49c126..e5b77a60622 100644 --- a/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp +++ b/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp @@ -39,7 +39,7 @@ extern "C" { #include "xlibrgb.h" #include "nslog.h" -NS_IMPL_LOG(nsEmbedXlibIntoGtkLog, 0) +NS_IMPL_LOG(nsEmbedXlibIntoGtkLog) #define PRINTF NS_LOG_PRINTF(nsEmbedXlibIntoGtkLog) #define FLUSH NS_LOG_FLUSH(nsEmbedXlibIntoGtkLog) diff --git a/mozilla/webshell/embed/xlib/motif/EmbedMozilla.c b/mozilla/webshell/embed/xlib/motif/EmbedMozilla.c index ca1f7e51d20..93fe1d0261f 100644 --- a/mozilla/webshell/embed/xlib/motif/EmbedMozilla.c +++ b/mozilla/webshell/embed/xlib/motif/EmbedMozilla.c @@ -27,7 +27,7 @@ #include "EmbedMozillaP.h" #include "nslog.h" -NS_IMPL_LOG(EmbedMozillaLog, 0) +NS_IMPL_LOG(EmbedMozillaLog) #define PRINTF NS_LOG_PRINTF(EmbedMozillaLog) #define FLUSH NS_LOG_FLUSH(EmbedMozillaLog) diff --git a/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp b/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp index fd2659f3634..04866bccf31 100644 --- a/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp +++ b/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp @@ -15,7 +15,7 @@ #include "xlibrgb.h" #include "nslog.h" -NS_IMPL_LOG(nsEmbedXlibIntoMotifLog, 0) +NS_IMPL_LOG(nsEmbedXlibIntoMotifLog) #define PRINTF NS_LOG_PRINTF(nsEmbedXlibIntoMotifLog) #define FLUSH NS_LOG_FLUSH(nsEmbedXlibIntoMotifLog) diff --git a/mozilla/webshell/embed/xlib/qt/MainWidget.cpp b/mozilla/webshell/embed/xlib/qt/MainWidget.cpp index 674bf307dd9..ac09f8f8fc6 100644 --- a/mozilla/webshell/embed/xlib/qt/MainWidget.cpp +++ b/mozilla/webshell/embed/xlib/qt/MainWidget.cpp @@ -25,7 +25,7 @@ #include "MainWidget.h" #include "nslog.h" -NS_IMPL_LOG(MainWidgetLog, 0) +NS_IMPL_LOG(MainWidgetLog) #define PRINTF NS_LOG_PRINTF(MainWidgetLog) #define FLUSH NS_LOG_FLUSH(MainWidgetLog) diff --git a/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp b/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp index 42afd981b39..d1aaf33c4a4 100644 --- a/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp +++ b/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp @@ -36,7 +36,7 @@ #include #include "nslog.h" -NS_IMPL_LOG(QMozillaContainerLog, 0) +NS_IMPL_LOG(QMozillaContainerLog) #define PRINTF NS_LOG_PRINTF(QMozillaContainerLog) #define FLUSH NS_LOG_FLUSH(QMozillaContainerLog)