diff --git a/ChangeLog b/ChangeLog index ced1216..c15288e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-08-07 release 1.14.1 + * mozplugger.c: + Added fix for mozdev bug #23007 + + * mozplugger.c: + Added further improvements for mozdev bug #22863 (patches provided + by Coretin Chary) + + * mozplugger.c: + Added support for javascript mozdev bug #22717 + + 2010-06-12 release 1.14.0 * mozplugger.c: Added code to check browser supports XEmbed, before reporting that diff --git a/Makefile b/Makefile index 2cceb64..c4a5933 100644 --- a/Makefile +++ b/Makefile @@ -98,8 +98,8 @@ auto: # No user servicable parts beyond this point # -#VERSION=CVS-2010-06-06 -VERSION=1.14.0 +#VERSION=CVS-2010-07-23 +VERSION=1.14.1 BASE_FILES=Makefile \ mozplugger.7 \ diff --git a/README b/README index 99be137..5df0b8c 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is MozPlugger version 1.14.0 +This is MozPlugger version 1.14.1 Originally written by Fredrik Hübinette (c) 1997-2001 Maintained by Louis Bavoil and Peter Leese (c) 2002-2010 Homepage : http://mozplugger.mozdev.org diff --git a/TODO b/TODO new file mode 100644 index 0000000..091336d --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +A/ Check new file caching works +B/ Delete temp file after shutdown +C/ Getting pipe working +D/ Update man page - include new location of mozpluggerrc, location of cache & new pipe command +E/ Move location of debug trace? +F/ Release code diff --git a/debian/changelog b/debian/changelog index 487782f..64c6de0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,25 @@ +mozplugger (1.14.1-1) unstable; urgency=low + + * New upstream bugfix-only release: + - Don't store temporary files in $HOME (Closes: #588130). + - Use NPP_StreamAsFile with webkit based browsers. + - Embedded objects now have a property called "isPlaying", which + return true if the application is running, false otherwise. + * Merge Ubuntu changelog entries. + * Update Standards to 3.9.1. + * Update watch file. + * Refresh debian/patches/01-manpages.patch patch. + + -- Alessio Treglia Sat, 07 Aug 2010 15:47:21 +0200 + +mozplugger (1.14.0-2ubuntu1) maverick; urgency=low + + * Merge with debian unstable, remaining changes: + - debian/mozplugger.links: Replace ice{weasel,ape} with + firefox,xulrunner-addons. + + -- Alessio Treglia Sun, 27 Jun 2010 19:36:04 +0200 + mozplugger (1.14.0-2) unstable; urgency=low * Add debian/source/format file. @@ -8,6 +30,14 @@ mozplugger (1.14.0-2) unstable; urgency=low -- Alessio Treglia Sat, 26 Jun 2010 16:28:00 +0200 +mozplugger (1.14.0-1ubuntu1) maverick; urgency=low + + * Merge with Debian unstable, Ubuntu remaining changes: + - debian/mozplugger.links: Replace ice{weasel,ape} with + firefox,xulrunner-addons. + + -- Alessio Treglia Thu, 17 Jun 2010 22:21:02 +0200 + mozplugger (1.14.0-1) unstable; urgency=low * Merge Ubuntu changelog entries. @@ -18,6 +48,15 @@ mozplugger (1.14.0-1) unstable; urgency=low -- Alessio Treglia Tue, 15 Jun 2010 09:58:58 +0200 +mozplugger (1.13.3-1ubuntu1) lucid; urgency=low + + * Merge from debian unstable, Ubuntu remaining changes: + - debian/mozplugger.links: + + Replace ice{weasel,ape} with firefox,xulrunner-addons. + - This closes LP: #439540. + + -- Alessio Treglia Sat, 17 Apr 2010 10:47:53 +0200 + mozplugger (1.13.3-1) unstable; urgency=low * New upstream release: diff --git a/debian/control b/debian/control index ad9ca21..dcae7c5 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: mozplugger Section: web Priority: optional Maintainer: Alessio Treglia -Standards-Version: 3.8.4 +Standards-Version: 3.9.1 Build-Depends: cdbs, debhelper (>= 5.0.0), libx11-dev, diff --git a/debian/patches/01-manpages.patch b/debian/patches/01-manpages.patch index 4c2cd52..420e03a 100644 --- a/debian/patches/01-manpages.patch +++ b/debian/patches/01-manpages.patch @@ -8,7 +8,7 @@ Description: Fix mistakes in mozplugger.7 manpage file. +++ mozplugger/mozplugger.7 @@ -1,4 +1,3 @@ -.PU - .TH mozplugger 7 "2010 Jun 12" + .TH mozplugger 7 "2010 Aug 07" .SH NAME mozplugger \- a streaming multimedia plugin for UNIX mozilla @@ -50,7 +49,7 @@ commands used to handle those mime types @@ -20,7 +20,7 @@ Description: Fix mistakes in mozplugger.7 manpage file. Each line describing a mime type has three fields: -@@ -123,7 +122,7 @@ and +@@ -123,7 +122,7 @@ and will be rejected if they do not match what is expected from the associated HTML code (see later for details). @@ -29,7 +29,7 @@ Description: Fix mistakes in mozplugger.7 manpage file. available. That is, MozPlugger will assume the first word of the command is the name of an application and search $PATH for that application. If that application is not found MozPlugger will skip that command line. -@@ -271,8 +270,8 @@ Quicktime objects sometimes use this mec +@@ -281,8 +280,8 @@ Quicktime objects sometimes use this mec .TP .B needs_xembed Some applications when embedded requires the Xembed protocol, other applications @@ -40,7 +40,7 @@ Description: Fix mistakes in mozplugger.7 manpage file. applications require this flag. .SH ENVIRONMENT VARIABLES There are some envirnoment variables that control the behaviour of Mozplugger. -@@ -381,12 +380,12 @@ If using behind a non-transparent HTTP p +@@ -390,12 +389,12 @@ If using behind a non-transparent HTTP p using the .B stream flag do not work. This is because the proxy settings are not passed to the diff --git a/debian/watch b/debian/watch index 26d766d..7d2bcec 100644 --- a/debian/watch +++ b/debian/watch @@ -1,7 +1,2 @@ -# Watch control file for uscan -# Run the "uscan" command to check for upstream updates and more. -version=2 - -# Site Directory Pattern Version -# Script -http://mozplugger.mozdev.org/ .*/mozplugger-(.*)\.tar\.gz debian uupdate +version=3 +http://mozplugger.mozdev.org/ .*/mozplugger-(.*)\.tar\.gz diff --git a/debug.c b/debug.c index 89f4495..6f3e916 100644 --- a/debug.c +++ b/debug.c @@ -59,7 +59,15 @@ static FILE *getout(void) return NULL; } - tmpdir = getenv("TMPDIR"); + tmpdir = getenv("MOZPLUGGER_TMP"); + if(tmpdir == NULL) + { + tmpdir = getenv("TMPDIR"); + debug_path = "$MOZPLUGGER_TMP"; + snprintf(debug_filename, sizeof(debug_filename), + "%s/%s", tmpdir, DEBUG_FILENAME); + } + if(tmpdir == NULL) { /* If (as on default Fedora 7 install) the environment variable diff --git a/mozplugger.7 b/mozplugger.7 index 7de1982..0e99c98 100644 --- a/mozplugger.7 +++ b/mozplugger.7 @@ -1,5 +1,5 @@ .PU -.TH mozplugger 7 "2010 Jun 12" +.TH mozplugger 7 "2010 Aug 07" .SH NAME mozplugger \- a streaming multimedia plugin for UNIX mozilla @@ -134,6 +134,16 @@ that has the flag set. If there is not such a command line, Mozplugger then downloads the file and picks the first (of the remaining) commands. +.SH WORKING WITH JAVA SCRIPT + +Mozplugger supports a JavaScript interface that allows the state of the +embedded object (i.e. mozplugger) to be queried from JavaScript. Currently +mozplugger supports the following properties. +.TP +.B isPlaying +This property has the value true if the application that mozplugger +launched to handle the embedded object is running and false if either no +application was launched or that application has now terminated. .SH WHEN IT DOESNT WORK @@ -278,16 +288,15 @@ applications require this flag. There are some envirnoment variables that control the behaviour of Mozplugger. .TP .B MOZPLUGGER_HOME -If defined any temporary files are placed here. Also this folder is checked -for the configuration file mozpluggerrc -.TP -.B HOME -If MOZPLUGGER_HOME is not defined and HOME is defined, then any temporary files -are placed in $HOME/.mozplugger. Also this folder is checked for the +If MOZPLUGGER_HOME is defined, the folder $MOZPLUGGER_HOME is checked for the configuration file mozpluggerrc .TP +.B MOZPLUGGER_TMP +If MOZPLUGGER_TMP is defined, then any temporary files +are placed in $MOZPLUGGER_TMP. +.TP .B TMPDIR -If neither MOZPLUGGER_HOME or HOME is defined, but TMPDIR is defined, then any +If MOZPLUGGER_TMP is not defined, but TMPDIR is defined, then any temporary files are placed in $TMPDIR/mozplugger-xxx/ where xxx = PID. .TP .B PATH diff --git a/mozplugger.c b/mozplugger.c index 1aeed40..ae8c011 100644 --- a/mozplugger.c +++ b/mozplugger.c @@ -122,6 +122,12 @@ typedef struct short exists; } cacheEntry_t; +typedef struct +{ + struct NPObject objHead; + NPP assocInstance; +} our_NPObject_t; + /***************************************************************************** * Global variables *****************************************************************************/ @@ -1359,6 +1365,57 @@ static int safeURL(const char* url) /*****************************************************************************/ /** + * Extract the file name from the HTTP Headers (if present). This is passed + * via the fragment environment variable to the helper application. Copy + * a suitable filename for the URL to be used for the cached temporay file + * name. + * + * @param[in] THIS Pointer to the instance data + * @param[in] headers The HTTP headers to parse + * @param[out] fileName The file Name extracted from the headers + * + * @return None + * + *****************************************************************************/ +static void parseHeaders(data_t * const THIS, const char * headers, char * fileName, + int maxFileNameLen) +{ + const char * p = headers; + + if (!headers) + { + return; + } + + while((p = strstr(p, "Content-Disposition:")) != NULL) + { + size_t len = strcspn(p, "\n\r"); + const char * start = strstr(p, "filename=\""); + + if (len == 0) + { + break; + } + + if((start ==0) || (start - p > len)) + { + p += len; + continue; + } + start += strlen("filename=\""); + len = len - (start - p) - 1; + + if(len > 0) + { + strncpy(fileName, start, len); + fileName[len] = '\0'; + } + p += len; + } +} + +/*****************************************************************************/ +/** * Extract the 'fragment' from the end of the URL if present. This is passed * via the fragment environment variable to the helper application. Copy * a suitable filename for the URL to be used for the cached temporay file @@ -1733,9 +1790,32 @@ char *NPP_GetMIMEDescription(void) * @return True if has that method * *****************************************************************************/ +static void debugLogIdentifier(NPIdentifier name) +{ + if(NPN_IdentifierIsString(name)) + { + char * str = NPN_UTF8FromIdentifier(name); + D("NPIdentifier = %s\n", str ? (char *)str : "NULL"); + NPN_MemFree(str); + } + else + { + D("NPIdentifier = %i\n", NPN_IntFromIdentifier(name)); + } +} + +/*****************************************************************************/ +/** + * Provides plugin HasMethod that can be called from broswer + * + * @return True if has that method + * + *****************************************************************************/ bool NPP_HasMethod(NPObject *npobj, NPIdentifier name) { - D("NPP_HasMethod called - %s\n", name ? (char *)name : "NULL"); + D("NPP_HasMethod called\n"); + debugLogIdentifier(name); + return 0; } @@ -1749,7 +1829,9 @@ bool NPP_HasMethod(NPObject *npobj, NPIdentifier name) bool NPP_Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { - D("NPP_Invoke called - %s\n", name ? (char *)name : "NULL"); + D("NPP_Invoke called\n"); + debugLogIdentifier(name); + return 0; } @@ -1762,8 +1844,21 @@ bool NPP_Invoke(NPObject *npobj, NPIdentifier name, *****************************************************************************/ bool NPP_HasProperty(NPObject *npobj, NPIdentifier name) { - D("NPP_HasProperty called - %s\n", name ? (char *)name : "NULL"); - return 0; + bool retVal = 0; + + D("NPP_HasProperty called\n"); + debugLogIdentifier(name); + + char * str = NPN_UTF8FromIdentifier(name); + if(str) + { + if (strcasecmp("isplaying", str) == 0) + { + retVal = 1; + } + NPN_MemFree(str); + } + return retVal; } /*****************************************************************************/ @@ -1775,8 +1870,42 @@ bool NPP_HasProperty(NPObject *npobj, NPIdentifier name) *****************************************************************************/ bool NPP_GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { - D("NPP_GetProperty called - %s\n", name ? (char *)name : "NULL"); - return 0; + bool retVal = 0; + + D("NPP_GetProperty called\n"); + debugLogIdentifier(name); + + char * str = NPN_UTF8FromIdentifier(name); + if(str) + { + if (strcasecmp("isplaying", str) == 0) + { + result->type = NPVariantType_Bool; + result->value.boolValue = 0; + retVal = 1; + + NPP instance = ((our_NPObject_t *)npobj)->assocInstance; + if(instance) + { + data_t * THIS = instance->pdata; + if (THIS) + { + if((THIS->commsPipeFd >= 0) || (THIS->pid > -1)) + { + int status; + if(waitpid(THIS->pid, &status, WNOHANG) == 0) + { + /* If no status available from child then child + * must still be running!? */ + result->value.boolValue = 1; + } + } + } + } + } + NPN_MemFree(str); + } + return retVal; } /*****************************************************************************/ @@ -1789,7 +1918,9 @@ bool NPP_GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) bool NPP_SetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { - D("NPP_SetProperty called - %s\n", name ? (char *)name : "NULL"); + D("NPP_SetProperty called\n"); + debugLogIdentifier(name); + return 0; } @@ -1885,6 +2016,20 @@ static NPBool getPluginNeedsXembed(NPP instance, NPError *pErr) /*****************************************************************************/ /** + * Create a JavaScript object + * + * @return Pointer to created object + * + *****************************************************************************/ +static NPObject * NPP_AllocateObj(NPP instance, NPClass * aClass) +{ + our_NPObject_t * pObj = NPN_MemAlloc(sizeof(our_NPObject_t)); + pObj->assocInstance = instance; + return (NPObject *) pObj; +} + +/*****************************************************************************/ +/** * Get plugin Scritable Object * * @return Returns True if Xembed required @@ -1903,6 +2048,7 @@ static NPObject * getPluginScritableObject(NPP instance, NPError * pErr) pluginClass.structVersion = NP_CLASS_STRUCT_VERSION; + pluginClass.allocate = NPP_AllocateObj; pluginClass.hasMethod = NPP_HasMethod; pluginClass.invoke = NPP_Invoke; pluginClass.hasProperty = NPP_HasProperty; @@ -2328,14 +2474,17 @@ NPError NPP_Destroy(NPP instance, NPSavedData** save) if (THIS->pid > 0) { my_kill(-THIS->pid); + THIS->pid = 0; } if (THIS->commsPipeFd >= 0) { close(THIS->commsPipeFd); + THIS->commsPipeFd = -1; } if(THIS->tmpFileFd >= 0) { close(THIS->tmpFileFd); + THIS->tmpFileFd = -1; } if(THIS->tmpFileName != 0) { @@ -2492,6 +2641,51 @@ static void new_child(NPP instance, const char* fname) /*****************************************************************************/ /** + * Guess a temporary file name + * + * @return file descriptor + * + *****************************************************************************/ +static int guessTmpFile(const char * fileName, int soFar, + char * tmpFilePath, int maxTmpFilePathLen) +{ + int i; + int fd = -1; + + for(i = 0; i <= 100; i++) + { + if(i == 0) + { + strncpy(&tmpFilePath[soFar], fileName, + maxTmpFilePathLen - soFar); + } + else if (i == 100) + { + strncpy(&tmpFilePath[soFar], "XXXXXX", + maxTmpFilePathLen - soFar); + fd = mkstemp(tmpFilePath); + break; + } + else + { + snprintf(&tmpFilePath[soFar], + maxTmpFilePathLen - soFar, + "%03i-%s", i, fileName); + } + + fd = open(tmpFilePath, O_CREAT | O_EXCL | O_WRONLY, + S_IRUSR | S_IWUSR); + if(fd >= 0) + { + break; + } + } + + return fd; +} + +/*****************************************************************************/ +/** * From the url create a temporary file to hold a copy of th URL contents. * * @param[in] url Pointer to url string @@ -2510,80 +2704,45 @@ static int createTmpFile(const char * fileName, D("Creating temp file for '%s'\n", fileName); - root = getenv("MOZPLUGGER_HOME"); - if(root == 0) - { - root = getenv("HOME"); - if(root) - { - snprintf(tmpFilePath, maxTmpFilePathLen, "%s/.mozplugger", root); - if((mkdir(tmpFilePath, S_IRWXU ) != 0) && (errno != EEXIST)) - { - root = NULL; - } - } - } - else - { - strncpy(tmpFilePath, root, maxTmpFilePathLen); - } - + root = getenv("MOZPLUGGER_TMP"); if(root) { - int soFar = strlen(tmpFilePath); + int soFar; + + strncpy(tmpFilePath, root, maxTmpFilePathLen); + soFar = strlen(tmpFilePath); + soFar += snprintf(&tmpFilePath[soFar], maxTmpFilePathLen-soFar, "/tmp-%i", pid); if( (mkdir(tmpFilePath, S_IRWXU) == 0) || (errno == EEXIST)) { + D("Creating temp file in '%s'\n", tmpFilePath); + tmpFilePath[soFar++] = '/'; - strncpy(&tmpFilePath[soFar], fileName, maxTmpFilePathLen - soFar); - fd = open(tmpFilePath, O_CREAT | O_EXCL | O_WRONLY, - S_IRUSR | S_IWUSR); - if(fd < 0) - { - strncpy(&tmpFilePath[soFar], "XXXXXX", - maxTmpFilePathLen - soFar); - fd = mkstemp(tmpFilePath); - } + fd = guessTmpFile(fileName, soFar, tmpFilePath, maxTmpFilePathLen); } } if(fd < 0) { root = getenv("TMPDIR"); - if(root) + if(!root) { - snprintf(tmpFilePath, maxTmpFilePathLen, "%s/mozplugger-%i", + root = "/tmp"; + } + + snprintf(tmpFilePath, maxTmpFilePathLen, "%s/mozplugger-%i", root, pid); - if((mkdir(tmpFilePath, S_IRWXU) == 0) || (errno == EEXIST)) - { - int i; - int soFar = strlen(tmpFilePath); - tmpFilePath[soFar++] = '/'; + if((mkdir(tmpFilePath, S_IRWXU) == 0) || (errno == EEXIST)) + { + int soFar = strlen(tmpFilePath); - for(i = 0; i < 100; i++) - { - if(i == 0) - { - strncpy(&tmpFilePath[soFar], fileName, - maxTmpFilePathLen - soFar); - } - else - { - snprintf(&tmpFilePath[soFar], - maxTmpFilePathLen - soFar, - "%03i-%s", i, fileName); - } + D("Creating temp file in '%s'\n", tmpFilePath); - fd = open(tmpFilePath, O_CREAT | O_EXCL | O_WRONLY, - S_IRUSR | S_IWUSR); - if(fd >= 0) - { - break; - } - } - } + tmpFilePath[soFar++] = '/'; + + fd = guessTmpFile(fileName, soFar, tmpFilePath, maxTmpFilePathLen); } } @@ -2683,6 +2842,9 @@ NPError NPP_NewStream(NPP instance, /* Extract from the URL the various additional information */ parseURL(THIS, stream->url, fileName, sizeof(fileName)/sizeof(char)-1); + /* Extract the fileName from HTTP headers, overide URL fileName */ + parseHeaders(THIS, stream->headers, fileName, sizeof(fileName)/sizeof(char)-1); + if(THIS->command == 0) { NPN_Status(instance, @@ -2856,9 +3018,16 @@ NPError NPP_SetWindow(NPP instance, NPWindow* window) if (THIS->commsPipeFd >= 0) { + ssize_t ret; D("Writing WIN 0x%x to fd %d\n", (unsigned) window->window, THIS->commsPipeFd); - write(THIS->commsPipeFd, (char *)window, sizeof(*window)); + ret = write(THIS->commsPipeFd, (char *)window, sizeof(*window)); + if(ret < sizeof(*window)) + { + D("Writing to comms pipe failed\n"); + close(THIS->commsPipeFd); + THIS->commsPipeFd = -1; + } } resize_window(instance); diff --git a/mozplugger.spec b/mozplugger.spec index db54b31..83a5bd9 100644 --- a/mozplugger.spec +++ b/mozplugger.spec @@ -1,5 +1,5 @@ %define name mozplugger -%define version 1.14.0 +%define version 1.14.1 %define release 1 Summary: A generic mozilla plug-in diff --git a/mozpluggerrc b/mozpluggerrc index 96328f3..74b8d8a 100644 --- a/mozpluggerrc +++ b/mozpluggerrc @@ -1,5 +1,5 @@ -# Configure file for MozPlugger 1.13.3 -# Version: April 17, 2010 +# Configure file for MozPlugger 1.14.1 +# Version: Aug 07, 2010 # # Commands which are not installed on your system will not be used. # diff --git a/npapi/include/npapi.h b/npapi/include/npapi.h old mode 100755 new mode 100644 diff --git a/npapi/include/npupp.h b/npapi/include/npupp.h old mode 100755 new mode 100644