[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12157: documentation moved to the h
From: |
Rob Savoye |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12157: documentation moved to the header files in doxygen format. |
Date: |
Thu, 15 Apr 2010 14:13:21 -0600 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12157
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Thu 2010-04-15 14:13:21 -0600
message:
documentation moved to the header files in doxygen format.
removed:
plugin/npapi/README
modified:
plugin/npapi/callbacks.cpp
plugin/npapi/callbacks.h
=== removed file 'plugin/npapi/README'
--- a/plugin/npapi/README 2010-04-10 18:33:53 +0000
+++ b/plugin/npapi/README 1970-01-01 00:00:00 +0000
@@ -1,156 +0,0 @@
- There is a simple, but crude interface between the plugin and Gnash
-running standalone, that supports the ExternalInterface ActionScript
-class. This is currently purely ASCII based, although it wouldn't be
-hard to change to a binary protocol. The bandwidth is minor, and XML
-would be overkill, so for now it's just text keywords, delimited by
-spaces. A CR is used to terminate each message.
-
-SetVariable( Name, Value )
- Sets the value of the Flash variable specified by Name to
- Value. The value is everything from the last delimiter to the end
- of the line.
-
- Sends:
- "Command Name Type value\n",
- ie... "SetVariable var1 string value1\n"
- Receives:
- nothing
-
-GetVariable( Name )
- Returns the value of the Flash variable specified by Name. Returns
- null if the variable does not exist.
-
- Sends:
- "Command Name\n", ie... "GetVariable var1\n"
-
- Receives:
- "Command Name Type value", ie... "GetVariable var1 string value1\n"
-
-PercentLoaded()
- Returns the percent of the Flash Player movie that has streamed
- into the browser so far; possible values are from 0 to 100.
-
- Sends:
- "Command\n", ie... "PercentLoaded\n"
-
- Receives:
- "Command number\n", ie... "PercentLoaded 23\n"
-
-Zoom( percent )
- Zooms the view by a relative scale factor specified by percent.
- Zoom(50) doubles the size of the objects in the view. Zoom(200)
- reduces the size of objects in the view by one half. Zoom(0) resets
- the view to 100%.
-
- Sends:
- "Command number\n", ie... "Zoom 200\n"
-
- Receives:
- nothing
-
-GotoFrame( frameNumber )
- Activates the frame number specified by frameNumber in the current
- movie. If the data for a requested frame is not yet available, the
- player goes to the last frame available and stops, causing
- unexpected results during playback. Use the PercentLoaded() method
- to determine if enough of the movie is available to execute the
- GotoFrame() method.
-
- Sends:
- "Command number\n", ie... "GotoFrame 77\n"
-
- Receives:
- nothing
-
-IsPlaying()
- Returns true if the movie is currently playing.
-
- Sends:
- "Command\n", ie... "IsPlaying\n"
-
- Receives:
- "Command Flag", ie... "IsPlaying true\n"
-
-Play();
- Starts the movie playing.
-
- Sends:
- "Command\n", ie... "Play\n"
-
- Receives:
- nothing
-
-Rewind();
- Goes to the first frame.
-
- Sends:
- "Command\n", ie... "Rewind\n"
-
- Receives:
- nothing
-
-SetZoomRect ( left, top, right, bottom )
- Zooms in on a rectangular area of the movie. The units of the
- coordinates are in twips (1440 units per inch). To calculate a
- rectangle in Flash, set the ruler units to Points and multiply the
- coordinates by 20 to get twips.
-
- Sends:
- "Command left top right bottom\n", ie... "SetZoomRect 0 0 10 10\n"
-
- Receives:
- nothing
-
-
-LoadMovie( layer, url )
- Loads the movie identified by url to the layer specified by
- layerNumber. The argument type is integer for layer and
- string for url.
-
- Sends:
- "Command Layer Url\n", ie... "LoadMovie 1 /foo.swf\n"
-
- Receives:
- nothing
-
- StopPlay()
- Stops playing the movie.
-
- Sends:
- "Command StopPlay\n", ie... "StopPlay\n"
-
- Receives:
- nothing
-
-TotalFrames()
- Returns the total number of frames in the movie.
-
- Sends:
- "Command TotalFrames\n", ie... "TotalFrames\n"
-
- Receives:
- "Command Num\n", ie... "TotalFrames 1234\n"
-
-Pan ( x, y, mode )
- Pans a zoomed-in movie to the coordinates specified by x and y. Use
- mode to specify whether the values for x and y are pixels or a
- percent of the window. When mode is either pixels or percent of the
- window.
-
- Sends:
- "Command Pan x y mode\n", ie... "Pan 10 10 pixels\n"
-
- Receives:
- nothing
-
----------------
-
- Many of the methods don't supposedly have a return value, so for now
-commands are sent blindy, and the only ones that expect a response at
-all are few. To be more tightly coupled, (I figured loosely coupled is
-ok for now) every command sent should get an boolean back stating
-whether the command worked correctly on the GNash side of things.
-
- For methods that don't appear to return anything, the result
-NPVariant data is set to true or false just in case.
-
=== modified file 'plugin/npapi/callbacks.cpp'
--- a/plugin/npapi/callbacks.cpp 2010-04-14 19:48:12 +0000
+++ b/plugin/npapi/callbacks.cpp 2010-04-15 20:13:21 +0000
@@ -28,6 +28,7 @@
#include <cstring>
#include <cstdlib>
#include "npapi.h"
+#include "external.h"
#include "npruntime.h"
#include "plugin.h"
#include "pluginScriptObject.h"
@@ -81,9 +82,15 @@
// volumnes of bogus warnings about not using them in the method.
// SetVariable( Name, Value )
-// Sends:
-// "Command Name Type value\n",
-// ie... "SetVariable var1 string value1\n"
+//
+// Sends something like this:
+// <invoke name="SetVariable" returntype="xml">
+// <arguments>
+// <string>var1</string>
+// <string>value1</string>
+// </arguments>
+// </invoke>
+//
// Receives:
// nothing
bool
@@ -109,11 +116,16 @@
}
// GetVariable( Name )
-// Sends:
-// "Command Name\n", ie... "GetVariable var1\n"
-//
-// Receives:
-// "Command Name Type value", ie... "GetVariable var1 string value1\n"
+//
+// Sends something like this:
+// <invoke name="GetVariable" returntype="xml">
+// <arguments>
+// <string>var1</string>
+// </arguments>
+// </invoke>
+//
+// Receives something like this:
+// <number>123</number>
bool
GetVariableCallback (NPObject *npobj, NPIdentifier /* name */,
const NPVariant *args,
@@ -160,8 +172,13 @@
}
// GotoFrame( frameNumber )
-// Sends:
-// "Command number\n", ie... "GotoFrame 77\n"
+//
+// Sends something like this:
+// <invoke name="GotoFrame" returntype="xml">
+// <arguments>
+// <number>123</number>
+// </arguments>
+// </invoke>
//
// Receives:
// nothing
@@ -173,16 +190,20 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
+ ExternalInterface ei;
+
std::string varname;
if (argCount == 1) {
- int value = NPVARIANT_TO_INT32(args[0]);
- std::stringstream ss;
- ss << "GotoFrame " << value << std::endl;
+ std::string str = ei.convertNPVariant(&args[0]);
+ std::vector<std::string> iargs;
+ iargs.push_back(str);
+ str = ei.makeInvoke("GotoFrame", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't goto the specified frame, network problems.");
return false;
}
@@ -196,11 +217,14 @@
}
// IsPlaying()
-// Sends:
-// "Command\n", ie... "IsPlaying\n"
-
-// Receives:
-// "Command Flag", ie... "IsPlaying true\n"
+//
+// Sends this:
+// <invoke name="IsPlaying" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives something like this:
+// </true/>
bool
IsPlaying (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args
*/,
uint32_t argCount, NPVariant *result)
@@ -210,42 +234,34 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
- std::stringstream ss;
- ss << "IsPlaying" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("IsPlaying", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't check if the movie is playing, network
problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
const char *data = 0;
- char *ptr = 0;
ret = gpso->readPlayer(gpso->getControlFD(), &data, 0);
if (ret == 0) {
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
- ptr = const_cast<char *>(data);
- if (strncmp(ptr, "IsPlaying ", 10) != 0) {
- log_error("Illegal response! %s", ptr);
- BOOLEAN_TO_NPVARIANT(false, *result);
- return false;
+ NPVariant *value = ei.parseXML(data);
+ if (NPVARIANT_TO_BOOLEAN(*value) == true) {
+ BOOLEAN_TO_NPVARIANT(true, *result);
} else {
- // A legit response has CR on the end already
- log_debug("Legit response: %s", ptr);
- }
- ptr += 10;
- bool flag = false;
- if (strncmp(ptr, "true", 4) == 0) {
- flag = true;
- } else if (strncmp(ptr, "false", 5) == 0) {
- flag = false;
+ BOOLEAN_TO_NPVARIANT(false, *result);
}
- BOOLEAN_TO_NPVARIANT(flag, *result);
- // gpso->IsPlaying(value);
+ // free the memory used for the data, as it was allocated in
readPlayer().
+ NPN_MemFree(reinterpret_cast<void *>(value));
+
return true;
}
@@ -254,8 +270,14 @@
}
// LoadMovie( Layer, Url )
-// Sends:
-// "Command Layer Url\n", ie... "LoadMovie 1 /foo.swf\n"
+//
+// Sends something like this:
+// <invoke name="LoadMovie" returntype="xml">
+// <arguments>
+// <number>2</number>
+// <string>bogus</string>
+// </arguments>
+// </invoke>
//
// Receives:
// nothing
@@ -266,17 +288,23 @@
log_debug(__PRETTY_FUNCTION__);
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
-
+
if (argCount == 2) {
- std::stringstream ss;
- int layer = NPVARIANT_TO_INT32(args[0]);
- std::string url = NPVARIANT_TO_STRING(args[1]).UTF8Characters;
- ss << "LoadMovie " << layer << " " << url << std::endl;
+ ExternalInterface ei;
+ // int layer = NPVARIANT_TO_INT32(args[0]);
+ // std::string url = NPVARIANT_TO_STRING(args[1]).UTF8Characters;
+ std::string str = ei.convertNPVariant(&args[0]);
+ std::vector<std::string> iargs;
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[1]);
+ iargs.push_back(str);
+ str = ei.makeInvoke("LoadMovie", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't load the movie, network problems.");
return false;
}
@@ -289,11 +317,18 @@
return false;
}
-// Pan ( x, y, mode )
-// Sends:
-// "Command Pan x y mode\n", ie... "Pan 10 10 pixels\n"
-//
-// Receives:
+// Pan ( x, y, mode )
+//
+// Sends something like this:
+// <invoke name="Pan" returntype="xml">
+// <arguments>
+// <number>1</number>
+// <number>2</number>
+// <number>0</number>
+// </arguments>
+// </invoke>
+//
+// Receives:
// nothing
bool
Pan (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
@@ -304,25 +339,21 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 3) {
- std::stringstream ss;
- NPVariant *value = const_cast<NPVariant *>(&args[0]);
- int x = NPVARIANT_TO_INT32(*value);
- value = const_cast<NPVariant *>(&args[1]);
- int y = NPVARIANT_TO_INT32(*value);
- value = const_cast<NPVariant *>(&args[2]);
- int mode = NPVARIANT_TO_INT32(*value);
- ss << "Pan " << x << y;
- if (mode) {
- ss << " pixels";
- } else {
- ss << " percent";
- }
- ss << std::endl;
+ ExternalInterface ei;
+ std::string str = ei.convertNPVariant(&args[0]);
+ std::vector<std::string> iargs;
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[1]);
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[2]);
+ iargs.push_back(str);
+ str = ei.makeInvoke("Pan", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't pan the movie, network problems.");
return false;
}
@@ -335,11 +366,14 @@
}
// PercentLoaded()
-// Sends:
-// "Command\n", ie... "PercentLoaded\n"
-//
-// Receives:
-// "Command number\n", ie... "PercentLoaded 23\n"
+//
+// Sends this:
+// <invoke name="PercentLoaded" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives something like this:
+// <number>33</number>
bool
PercentLoaded (NPObject *npobj, NPIdentifier /* name */, const NPVariant
*/*args */,
uint32_t argCount, NPVariant *result)
@@ -348,7 +382,7 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
-#if 1
+#if 0
static int counter = 0;
// log_error("%s: %d ; %d\n", __FUNCTION__, gpso->getControlFD(), counter);
INT32_TO_NPVARIANT(counter, *result);
@@ -360,40 +394,35 @@
return true;
#else
if (argCount == 0) {
- std::stringstream ss;
- ss << "PercentLoaded" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("PercentLoaded", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't check percent loaded, network problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
const char *data = 0;
- char *ptr = 0;
ret = gpso->readPlayer(gpso->getControlFD(), &data, 0);
if (ret == 0) {
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
- ptr = const_cast<char *>(data);
- if (strncmp(ptr, "PercentLoaded ", 15) != 0) {
- log_error("Illegal response! %s\n", ptr);
- BOOLEAN_TO_NPVARIANT(false, *result);
- return false;
- } else {
- // A legit response has CR on the end already
- log_debug("Legit response: %s", ptr);
- }
- ptr += 15;
- int percent = strtol(ptr, NULL, 0);
- if ((percent >= 0) && (percent <= 100)) {
- INT32_TO_NPVARIANT(percent, *result);
- } else {
- INT32_TO_NPVARIANT(-1, *result);
+
+ NPVariant *value = ei.parseXML(data);
+ if (NPVARIANT_IS_INT32(*value)) {
+ INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(*value), *result);
+ } else {
+ INT32_TO_NPVARIANT(0, *result);
}
+ // free the memory used for the data, as it was allocated in
readPlayer().
+ NPN_MemFree(reinterpret_cast<void *>(value));
+
return true;
}
@@ -403,10 +432,13 @@
}
// Play();
-// Sends:
-// "Command\n", ie... "Play\n"
-//
-// Receives:
+//
+// Sends this:
+// <invoke name="Play" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives:
// nothing
bool
Play (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
@@ -417,13 +449,15 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
- std::stringstream ss;
- ss << "Play" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("Play", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't play movie, network problems.");
return false;
}
@@ -437,10 +471,13 @@
}
// Rewind();
-// Sends:
-// "Command\n", ie... "Rewind\n"
-//
-// Receives:
+//
+// Sends this:
+// <invoke name="Rewind" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives:
// nothing
bool
Rewind (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
@@ -451,13 +488,15 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
- std::stringstream ss;
- ss << "Rewind" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("Rewind", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't rewind movie, network problems.");
return false;
}
@@ -471,10 +510,17 @@
}
// SetZoomRect ( left, top, right, bottom )
-// Sends:
-// "Command left top right bottom\n", ie... "SetZoomRect 0 0 10 10\n"
+// Sends something like this:
+// <invoke name="SetZoomRect" returntype="xml">
+// <arguments>
+// <number>1</number>
+// <number>2</number>
+// <number>3</number>
+// <number>4</number>
+// </arguments>
+// </invoke>
//
-// Receives:
+// Receives:
// nothing
bool
SetZoomRect (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
@@ -485,22 +531,23 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 4) {
- std::stringstream ss;
- NPVariant *value = const_cast<NPVariant *>(&args[0]);
- int left = NPVARIANT_TO_INT32(*value);
- value = const_cast<NPVariant *>(&args[1]);
- int top = NPVARIANT_TO_INT32(*value);
- value = const_cast<NPVariant *>(&args[2]);
- int right = NPVARIANT_TO_INT32(*value);
- value = const_cast<NPVariant *>(&args[3]);
- int bottom = NPVARIANT_TO_INT32(*value);
- ss << "SetZoomRect " << left << " " << top << " ";
- ss << right << " " << bottom << std::endl;
+ ExternalInterface ei;
+ std::string str = ei.convertNPVariant(&args[0]);
+ std::vector<std::string> iargs;
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[1]);
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[2]);
+ iargs.push_back(str);
+ str = ei.convertNPVariant(&args[3]);
+ iargs.push_back(str);
+ str = ei.makeInvoke("SetZoomRect", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't Set the Zoom Rect the movie, network
problems.");
return false;
}
@@ -513,10 +560,13 @@
}
// StopPlay()
-// Sends:
-// "Command StopPlay\n", ie... "StopPlay\n"
-
-// Receives:
+//
+// Sends this:
+// <invoke name="StopPlay" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives:
// nothing
bool
StopPlay (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args */,
@@ -527,13 +577,15 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
- std::stringstream ss;
- ss << "StopPlay" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("StopPlay", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't stop-play movie, network problems.");
return false;
}
@@ -547,10 +599,15 @@
}
// Zoom( percent )
-// Sends:
-// "Command number\n", ie... "Zoom 200\n"
-//
-// Receives:
+//
+// Sends something like this:
+// <invoke name="Zoom" returntype="xml">
+// <arguments>
+// <number>12</number>
+// </arguments>
+// </invoke>
+//
+// Receives:
// nothing
bool
Zoom (NPObject *npobj, NPIdentifier /* name */, const NPVariant *args,
@@ -561,15 +618,17 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 1) {
- std::stringstream ss;
- NPVariant *value = const_cast<NPVariant *>(&args[1]);
- int zoom = NPVARIANT_TO_INT32(*value);
- ss << "Zoom " << zoom << std::endl;
+ ExternalInterface ei;
+ std::string str = ei.convertNPVariant(&args[0]);
+ std::vector<std::string> iargs;
+ iargs.push_back(str);
+ str = ei.makeInvoke("Zoom", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't zoom movie, network problems.");
return false;
}
@@ -582,11 +641,14 @@
}
// TotalFrames()
-// Sends:
-// "Command TotalFrames\n", ie... "TotalFrames\n"
-//
-// Receives:
-// "Command Num\n", ie... "TotalFrames 1234\n"
+//
+// Sends something like this:
+// <invoke name="TotalFrames" returntype="xml">
+// <arguments></arguments>
+// </invoke>
+//
+// Receives:
+// <number>66</number>
bool
TotalFrames (NPObject *npobj, NPIdentifier /* name */, const NPVariant */*args
*/,
uint32_t argCount, NPVariant *result)
@@ -596,36 +658,34 @@
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
- std::stringstream ss;
- ss << "TotalFrames" << std::endl;
+ ExternalInterface ei;
+ std::vector<std::string> iargs;
+ std::string str = ei.makeInvoke("TotalFrames", iargs);
+
// Write the message to the Control FD.
- size_t ret = gpso->writePlayer(gpso->getControlFD(), ss.str());
+ size_t ret = gpso->writePlayer(gpso->getControlFD(), str);
// Unless we wrote the same amount of data as the message contained,
// something went wrong.
- if (ret != ss.str().size()) {
+ if (ret != str.size()) {
log_error("Couldn't check percent loaded, network problems.");
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
const char *data = 0;
- char *ptr = 0;
ret = gpso->readPlayer(gpso->getControlFD(), &data, 0);
if (ret == 0) {
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
}
- ptr = const_cast<char *>(data);
- if (strncmp(ptr, "TotalFrames ", 13) != 0) {
- log_error("Illegal response! %s\n", ptr);
- BOOLEAN_TO_NPVARIANT(false, *result);
- return false;
+ NPVariant *value = ei.parseXML(data);
+ if (NPVARIANT_IS_INT32(*value)) {
+ INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(*value), *result);
} else {
- // A legit response has CR on the end already
- log_debug("Legit response: %s", ptr);
- }
- ptr += 13;
- int frames = strtol(ptr, NULL, 0);
- INT32_TO_NPVARIANT(frames, *result);
+ INT32_TO_NPVARIANT(0, *result);
+ }
+ // free the memory used for the data, as it was allocated in
readPlayer().
+ NPN_MemFree(reinterpret_cast<void *>(value));
+
return true;
}
=== modified file 'plugin/npapi/callbacks.h'
--- a/plugin/npapi/callbacks.h 2010-04-14 19:48:12 +0000
+++ b/plugin/npapi/callbacks.h 2010-04-15 20:13:21 +0000
@@ -16,65 +16,271 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
+#ifndef GNASH_PLUGIN_CALLBACKS_H
+#define GNASH_PLUGIN_CALLBACKS_H
+
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
#endif
-// Todo:
+#include "npapi.h"
+#include "npruntime.h"
+
// Support the methods listed in
//
http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
-#ifndef GNASH_PLUGIN_CALLBACKS_H
-#define GNASH_PLUGIN_CALLBACKS_H
+/// \page XMLAPI ExternalInterface XML API
+/// \section whatis Whatis the External Interface
+/// a swf file being played in the flash player has an interactive
+/// protocol so the player and the browser can communicate. This is
+/// used as an XML-RPC operation, the browser often making requests to
+/// the player for information about it's status, or retrieving the
+/// values of a variable like "$version".
+///
+/// A plugin that supports this interface is called a Scriptable
+/// Plugin. There is luckily a short defined list of these remote
+/// methods that can be invoked.
+///
+/// \section proto callback prototypes
+/// As these callbacks use a generalized typedef for the signature, often some
+/// of the parameters can be ignored. These are commented out in the function
+/// definition to elimnate the volumnes of bogus warnings about not using them
+/// in the method.
+///
+/// \section codes return codes
+/// Although all these callbacks return a boolean value, this is not used by
+/// the API at all, just internally to the plugin. All return values are
+/// encoded into the "result" parameter. Many of the callbacks don't have a
+/// result at all, which is good as the flash player blocks after sending a
+/// request to the player while waiting for a response. So not having to wait
+/// can be a good thing to avoid issues.
+/// Set a variable in the flash player
+///
+/// @param npobj the NPObject to act on
+/// @param name the name of the variable to get
+/// @param args ignore for this method
+/// @param argCount the count of arguments, always 1
+/// @param result the value of the variable as returned by the standalone
player.
+///
+/// @example "GetVariable method invoke"
+///
+/// <pre>
+/// <invoke name="GetVariable" returntype="xml">
+/// <arguments>
+/// <string>var1</string>
+/// </arguments>
+/// </invoke>
+/// </pre>
+///
+/// @return nothing
extern bool GetVariableCallback (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Set a variable in the flash player
+///
+/// @param npobj the NPObject to act on
+/// @param name the name of the variable to set
+/// @param args the value of the variable
+/// @param argCount the count of arguments, always 2
+/// @param result not set for this method
+///
+/// @example "SetVariable method invoke"
+///
+/// <pre>
+/// <invoke name="SetVariable" returntype="xml">
+/// <arguments>
+/// <string>var1</string>
+/// <string>value1</string>
+/// </arguments>
+/// </invoke>
+/// </pre>
+///
+/// @return nothing
extern bool SetVariableCallback (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Goto the specified frame in the swf movie being played
+///
+/// @param npobj the NPObject to act on
+/// @param name ignored for this method
+/// @param args the frame number
+/// @param argCount the count of arguments, always 1
+/// @param result not set for this method
+///
+/// @example "GotoFrame method invoke"
+///
+/// <pre>
+/// <invoke name="GotoFrame" returntype="xml">
+/// <arguments>
+/// <number>123</number>
+/// </arguments>
+/// </invoke>
+/// </pre>
extern bool GotoFrame (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Check the standalone player to see if it's playing.
+///
+/// @param npobj the NPObject to act on
+/// @param name ignored for this method
+/// @param args ignored for this method
+/// @param argCount the count of arguments, always 0
+/// @param result a boolean fron the standalone player
+///
+/// @example "IsPlaying method invoke"
+///
+/// <pre>
+/// <invoke name="IsPlaying" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+/// </pre>
extern bool IsPlaying (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Load a swf movie into the standalone player
+///
+/// @param npobj the NPObject to act on
+/// @param name ignored for this method
+/// @param args the name of the file
+/// @param argCount the count of arguments, always 1
+/// @param result a boolean fron the standalone player
+///
+/// @example "LoadMovie method invoke"
+///
+/// <pre>
+/// <invoke name="LoadMovie" returntype="xml">
+/// <arguments>
+/// <number>2</number>
+/// <string>/tmp/bogus.swf</string>
+/// </arguments>
+/// </invoke>
+/// </pre>
extern bool LoadMovie (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Pan the movie being played
+///
+/// @param npobj the NPObject to act on
+/// @param name ignored for this method
+/// @param args[0] The X coordinate
+/// @param args[1] The Y coordinate
+/// @param args[2] The mode, 0 for pixels, 1 for percent
+/// @param argCount the count of arguments, always 3
+/// @param result no result from the player
+///
+/// @example "Pan method invoke"
+///
+/// <pre>
+/// <invoke name="Pan" returntype="xml">
+/// <arguments>
+/// <number>1</number>
+/// <number>2</number>
+/// <number>0</number>
+/// </arguments>
+/// </invoke>
+/// </pre>
extern bool Pan (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// Get the percentage of the movie that's been played so far.
+///
+/// @param npobj the NPObject to act on
+/// @param name ignored for this method
+/// @param args ignored for this method
+/// @param argCount the count of arguments, always 0
+/// @param result an integer fron the standalone player
+///
+/// @example "PercentLoaded method invoke"
+///
+/// <pre>
+/// <invoke name="PercentLoaded" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+///
+/// <number>33</number>
+/// </pre>
extern bool PercentLoaded (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "Play invoke method"
+///
+/// <pre>
+/// <invoke name="Play" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+/// </pre>
extern bool Play (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "Rewind invoke method"
+///
+/// <pre>
+/// <invoke name="Rewind" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+/// </pre>
extern bool Rewind (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "SetZoomRect invoke method"
+///
+/// <pre>
+/// <invoke name="SetZoomRect" returntype="xml">
+/// <arguments>
+/// <number>1</number>
+/// <number>2</number>
+/// <number>3</number>
+/// <number>4</number>
+/// </arguments>
+/// </invoke>
+/// </pre>
extern bool SetZoomRect (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "StopPlay invoke method"
+///
+/// <pre>
+/// <invoke name="StopPlay" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+/// </pre>
extern bool StopPlay (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "Zoom invoke method"
+///
+/// <pre>
+/// <invoke name="Zoom" returntype="xml">
+/// <arguments>
+/// <number>12</number>
+/// </arguments>
+/// </invoke>
+/// </pre>
extern bool Zoom (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
+/// @example "TotalFrames invoke method"
+///
+/// <pre>
+/// <invoke name="TotalFrames" returntype="xml">
+/// <arguments></arguments>
+/// </invoke>
+///
+/// <number>66</number>
+/// </pre>
extern bool TotalFrames (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12157: documentation moved to the header files in doxygen format.,
Rob Savoye <=