Forward port of rev 17335. Implement versionInfo() method
authorJean-Paul Saman <jpsaman@videolan.org>
Sun, 29 Oct 2006 09:33:30 +0000 (09:33 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Sun, 29 Oct 2006 09:33:30 +0000 (09:33 +0000)
mozilla/control/npolibvlc.cpp
mozilla/control/npolibvlc.h
mozilla/vlcshell.cpp

index 40ef5d0..8a7f9a4 100755 (executable)
@@ -97,11 +97,46 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVaria
 \r
 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =\r
 {\r
-    /* no methods */\r
+    "versionInfo",\r
 };\r
 \r
 const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNames)/sizeof(NPUTF8 *);\r
 \r
+enum LibvlcRootNPObjectMethodIds\r
+{\r
+    ID_version,\r
+};\r
+\r
+RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)\r
+{\r
+    VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);\r
+    if( p_plugin )\r
+    {\r
+        libvlc_exception_t ex;\r
+        libvlc_exception_init(&ex);\r
+\r
+        switch( index )\r
+        {\r
+            case ID_version:\r
+                if( argCount == 0 )\r
+                {\r
+                    NPUTF8 *versionStr = NULL;\r
+\r
+                    versionStr = strdup( VLC_Version() );\r
+                    if (!versionStr)\r
+                        return INVOKERESULT_GENERIC_ERROR;\r
+\r
+                    STRINGZ_TO_NPVARIANT(versionStr, result);\r
+                    return INVOKERESULT_NO_ERROR;\r
+                }\r
+                return INVOKERESULT_NO_SUCH_METHOD;\r
+            default:\r
+                return INVOKERESULT_NO_SUCH_METHOD;\r
+        }\r
+    }\r
+    return INVOKERESULT_GENERIC_ERROR;\r
+}\r
+\r
 /*\r
 ** implementation of libvlc audio object\r
 */\r
index 4beb637..80c7673 100755 (executable)
@@ -43,6 +43,8 @@ protected:
     static const int methodCount;\r
     static const NPUTF8 * const methodNames[];\r
 \r
+    InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);\r
+\r
     NPObject *audioObj;\r
     NPObject *inputObj;\r
     NPObject *logObj;\r
index 039a40d..6f4313f 100644 (file)
@@ -177,7 +177,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
             }
 
             const NPWindow *npwindow = p_plugin->getWindow();
-                
+
             if( needsDisplay && npwindow->window )
             {
                 /* draw the beautiful "No Picture" */