Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser-plugin/scriptable.h
diff options
context:
space:
mode:
Diffstat (limited to 'browser-plugin/scriptable.h')
-rw-r--r--browser-plugin/scriptable.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/browser-plugin/scriptable.h b/browser-plugin/scriptable.h
new file mode 100644
index 0000000..325cf50
--- /dev/null
+++ b/browser-plugin/scriptable.h
@@ -0,0 +1,133 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2009 litl, LLC
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SCRIPTABLE_PLUGIN_H__
+#define __SCRIPTABLE_PLUGIN_H__
+
+#include <npapi.h>
+#include <npupp.h>
+
+NPObject *AllocateScriptablePluginObject (NPP npp, NPClass *aClass);
+NPObject *AllocateConstructablePluginObject (NPP npp, NPClass *aClass);
+
+class ScriptablePluginObjectBase : public NPObject
+{
+ public:
+ ScriptablePluginObjectBase (NPP npp) : mNpp(npp)
+ {
+ }
+
+ virtual ~ScriptablePluginObjectBase ()
+ {
+ }
+
+ virtual void Invalidate ();
+ virtual bool HasMethod (NPIdentifier name);
+ virtual bool Invoke (NPIdentifier name, const NPVariant *args,
+ uint32_t argCount, NPVariant *result);
+ virtual bool InvokeDefault (const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
+ virtual bool HasProperty (NPIdentifier name);
+ virtual bool GetProperty (NPIdentifier name, NPVariant *result);
+ virtual bool SetProperty (NPIdentifier name, const NPVariant *value);
+ virtual bool RemoveProperty (NPIdentifier name);
+ virtual bool Enumerate (NPIdentifier **identifier, uint32_t *count);
+ virtual bool Construct (const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
+
+ static void _Deallocate (NPObject *npobj);
+ static void _Invalidate (NPObject *npobj);
+ static bool _HasMethod (NPObject *npobj, NPIdentifier name);
+ static bool _Invoke (NPObject *npobj, NPIdentifier name,
+ const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
+ static bool _InvokeDefault (NPObject *npobj, const NPVariant *args,
+ uint32_t argCount, NPVariant *result);
+ static bool _HasProperty (NPObject * npobj, NPIdentifier name);
+ static bool _GetProperty (NPObject *npobj, NPIdentifier name,
+ NPVariant *result);
+ static bool _SetProperty (NPObject *npobj, NPIdentifier name,
+ const NPVariant *value);
+ static bool _RemoveProperty (NPObject *npobj, NPIdentifier name);
+ static bool _Enumerate (NPObject *npobj, NPIdentifier **identifier,
+ uint32_t *count);
+ static bool _Construct (NPObject *npobj, const NPVariant *args,
+ uint32_t argCount, NPVariant *result);
+
+ protected:
+ NPP mNpp;
+};
+
+class ScriptablePluginObject : public ScriptablePluginObjectBase
+{
+ public:
+ ScriptablePluginObject (NPP npp);
+
+ virtual bool HasMethod (NPIdentifier name);
+ virtual bool HasProperty (NPIdentifier name);
+ virtual bool GetProperty (NPIdentifier name, NPVariant *result);
+ virtual bool Invoke (NPIdentifier name, const NPVariant *args,
+ uint32_t argCount, NPVariant *result);
+ virtual bool InvokeDefault (const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
+
+ private:
+ NPIdentifier mZoomInID;
+ NPIdentifier mZoomOutID;
+ NPIdentifier mFindPreviousID;
+ NPIdentifier mFindNextID;
+};
+
+class ConstructablePluginObject : public ScriptablePluginObjectBase
+{
+ public:
+ ConstructablePluginObject (NPP npp) : ScriptablePluginObjectBase (npp)
+ {
+ }
+
+ virtual bool Construct (const NPVariant *args, uint32_t argCount,
+ NPVariant *result);
+};
+
+#define DECLARE_NPOBJECT_CLASS_WITH_BASE(_class, ctor) \
+static NPClass s##_class##_NPClass = { \
+ NP_CLASS_STRUCT_VERSION_CTOR, \
+ ctor, \
+ ScriptablePluginObjectBase::_Deallocate, \
+ ScriptablePluginObjectBase::_Invalidate, \
+ ScriptablePluginObjectBase::_HasMethod, \
+ ScriptablePluginObjectBase::_Invoke, \
+ ScriptablePluginObjectBase::_InvokeDefault, \
+ ScriptablePluginObjectBase::_HasProperty, \
+ ScriptablePluginObjectBase::_GetProperty, \
+ ScriptablePluginObjectBase::_SetProperty, \
+ ScriptablePluginObjectBase::_RemoveProperty, \
+ ScriptablePluginObjectBase::_Enumerate, \
+ ScriptablePluginObjectBase::_Construct \
+}
+
+#define GET_NPOBJECT_CLASS(_class) &s##_class##_NPClass
+
+DECLARE_NPOBJECT_CLASS_WITH_BASE (ScriptablePluginObject,
+ AllocateScriptablePluginObject);
+
+DECLARE_NPOBJECT_CLASS_WITH_BASE (ConstructablePluginObject,
+ AllocateConstructablePluginObject);
+
+#endif // __SCRIPTABLE_PLUGIN_H__