commit much of the virtualization support, stubbed out
[moon.git] / plugin / plugin-class.h.in
bloba37d930070705318fc74af2a7ca073ccca2c56c0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * plugin-class.h: MoonLight browser plugin - autogenerated header classes
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007-2009 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #ifndef __PLUGIN_CLASS_H__
15 #define __PLUGIN_CLASS_H__
17 #include "moonlight.h"
18 #include "error.h"
19 #include "plugin.h"
21 // debug javascript
22 #define DEBUG_JAVASCRIPT 1
24 #define DEPENDENCY_OBJECT_FROM_VARIANT(obj) (((MoonlightDependencyObjectObject*) NPVARIANT_TO_OBJECT (obj))->GetDependencyObject ())
26 #define THROW_JS_EXCEPTION(meth) \
27 do { \
28 char *message = g_strdup_printf ("Error calling method: %s", meth); \
29 NPN_SetException (this, message); \
30 g_free (message); \
31 return true; \
32 } while (0); \
34 #define THROW_JS_EXCEPTION2(obj, meth) \
35 do { \
36 char *message = g_strdup_printf ("Error calling method: %s", meth); \
37 NPN_SetException (obj, message); \
38 g_free (message); \
39 } while (0); \
42 enum PluginPropertyId {
43 NoMapping = 0,
45 // property names
46 MoonId_ErrorCode = 0x4000,
47 MoonId_ErrorType,
48 MoonId_ErrorMessage,
49 MoonId_LineNumber,
50 MoonId_CharPosition,
51 MoonId_XamlFile,
52 MoonId_MethodName,
53 MoonId_X,
54 MoonId_Y,
55 MoonId_Left,
56 MoonId_Right,
57 MoonId_Top,
58 MoonId_Bottom,
59 MoonId_TopLeft,
60 MoonId_TopRight,
61 MoonId_BottomLeft,
62 MoonId_BottomRight,
63 MoonId_Width,
64 MoonId_Height,
65 MoonId_Seconds,
66 MoonId_Name,
67 MoonId_Shift,
68 MoonId_Ctrl,
69 MoonId_Marker,
70 MoonId_Key,
71 MoonId_PlatformKeyCode,
72 MoonId_Progress,
73 MoonId_Settings,
74 MoonId_Content,
75 MoonId_InitParams,
76 MoonId_Id,
77 MoonId_IsLoaded,
78 MoonId_Source,
79 MoonId_Background,
80 MoonId_EnableFramerateCounter,
81 MoonId_EnableRedrawRegions,
82 MoonId_EnableHtmlAccess,
83 MoonId_MaxFrameRate,
84 MoonId_Version,
85 MoonId_Windowless,
86 MoonId_ActualHeight,
87 MoonId_ActualWidth,
88 MoonId_FullScreen,
89 MoonId_Root,
90 MoonId_Count,
91 MoonId_ResponseText,
92 MoonId_DeviceType,
93 MoonId_IsInverted,
94 MoonId_Handled,
95 MoonId_GridUnitType,
96 MoonId_Value,
97 MoonId_Accessibility,
98 MoonId_MultiScaleImage_Source,
100 // event names (handled by the property setters)
101 MoonId_BufferingProgressChanged,
102 MoonId_Completed,
103 MoonId_CurrentStateChanged,
104 MoonId_DownloadProgressChanged,
105 MoonId_GotFocus,
106 MoonId_ImageFailed,
107 MoonId_KeyDown,
108 MoonId_KeyUp,
109 MoonId_LostFocus,
110 MoonId_Loaded,
111 MoonId_MarkerReached,
112 MoonId_MediaEnded,
113 MoonId_MediaFailed,
114 MoonId_MediaOpened,
115 MoonId_MouseEnter,
116 MoonId_MouseLeave,
117 MoonId_MouseMove,
118 MoonId_MouseLeftButtonDown,
119 MoonId_MouseLeftButtonUp,
120 MoonId_OnResize,
121 MoonId_OnFullScreenChange,
122 MoonId_OnError,
123 MoonId_OnLoad,
124 MoonId_OnSourceDownloadProgressChanged,
125 MoonId_OnSourceDownloadComplete,
127 // method names
128 MoonId_GetPosition = 0x8000,
129 MoonId_CreateObject,
130 MoonId_IsVersionSupported,
131 MoonId_FindName,
132 MoonId_CreateFromXaml,
133 MoonId_CreateFromXamlDownloader,
134 MoonId_Equals,
135 MoonId_GetHost,
136 MoonId_GetParent,
137 MoonId_GetStylusInfo,
138 MoonId_GetStylusPoints,
139 MoonId_CaptureMouse,
140 MoonId_ReleaseMouseCapture,
141 MoonId_AddEventListener,
142 MoonId_RemoveEventListener,
143 MoonId_SetValue,
144 MoonId_GetValue,
145 MoonId_ToString,
146 #if DEBUG_JAVASCRIPT
147 MoonId_Printf,
148 MoonId_DumpNameScope,
149 #endif
150 MoonId_Add,
151 MoonId_Remove,
152 MoonId_RemoveAt,
153 MoonId_Insert,
154 MoonId_Clear,
155 MoonId_GetItem,
156 MoonId_GetItemByName,
157 MoonId_Begin,
158 MoonId_Pause,
159 MoonId_Resume,
160 MoonId_Seek,
161 MoonId_Stop,
162 MoonId_Play,
163 MoonId_SetSource,
164 MoonId_SetFontSource,
165 MoonId_Abort,
166 MoonId_Open,
167 MoonId_GetResponseText,
168 MoonId_Send,
169 MoonId_AddStylusPoints,
170 MoonId_GetBounds,
171 MoonId_HitTest,
172 MoonId_UpdateLayout,
174 MoonId_StopPropagation,
175 MoonId_PreventDefault,
176 MoonId_Detail,
178 MoonId_Focus,
180 MoonId_Select,
181 MoonId_SelectAll,
183 MoonId_MultiScaleImage_GetIthSubImage,
184 MoonId_MultiScaleImage_GetSubImageCount,
185 MoonId_MultiScaleImage_LogicalToElementX,
186 MoonId_MultiScaleImage_LogicalToElementY,
187 MoonId_MultiScaleImage_ZoomAboutLogicalPoint,
188 /*MAP_IDS*/
192 #define MAPPING_FLAG_SL1 0x01
193 #define MAPPING_FLAG_SL2 0x02
195 struct MoonNameIdMapping {
196 const char *name;
197 int id;
200 #define IS_METHOD(id) (((id) & 0x8000) != 0)
201 #define IS_PROPERTY(id) (((id) & 0x4000) != 0)
204 G_BEGIN_DECLS
205 G_GNUC_INTERNAL bool npobject_is_dependency_object (NPObject *obj);
207 G_GNUC_INTERNAL bool check_arg_list (const char *arglist, guint32 argc, const NPVariant *argv);
209 G_GNUC_INTERNAL void plugin_init_classes (void);
210 G_GNUC_INTERNAL void plugin_destroy_classes (void);
212 G_GNUC_INTERNAL void event_object_add_xaml_listener (EventObject *obj, PluginInstance *instance, const char *event_name, const char *cb_name);
214 void string_to_npvariant (const char *value, NPVariant *result);
215 G_GNUC_INTERNAL void variant_to_value (const NPVariant *v, Value **result);
216 G_END_DECLS
219 class MoonlightObject;
221 /*** EventListenerProxy */
222 typedef void (*EventArgsWrapper)(NPP instance, EventArgs *calldata, NPVariant *value);
224 class EventListenerProxy : public EventObject {
225 static void on_handler_removed (gpointer closure);
227 EventObject *target_object;
228 MoonlightObject *owner;
230 PluginInstance *plugin;
231 bool is_func;
233 /* if @is_func == true, callback is an NPObject (the function object)
234 if @is_func == false, callback is a char* (the function name)
236 gpointer callback;
238 char *event_name;
239 int event_id;
240 int token;
242 bool one_shot;
244 public:
245 EventListenerProxy (PluginInstance *plugin, const char *event_name, const char *cb_name);
246 EventListenerProxy (PluginInstance *plugin, const char *event_name, const NPVariant *cb);
247 virtual ~EventListenerProxy ();
249 void SetOwner (MoonlightObject *owner);
251 int AddXamlHandler (EventObject *obj);
252 int AddHandler (EventObject *obj);
253 void RemoveHandler ();
254 const char *GetCallbackAsString ();
256 int GetEventId () { return event_id; }
257 int GetEventToken () { return token; }
259 void SetOneShot () { one_shot = true; }
260 gpointer GetCallback () { return callback; }
261 bool IsFunc () { return is_func; }
263 PluginInstance *GetPlugin () { return plugin; }
264 NPP GetInstance () { return plugin->GetInstance (); }
266 static void proxy_listener_to_javascript (EventObject *sender, EventArgs *calldata, gpointer closure);
270 /*** MoonlightObjectClass **************************************************************/
272 struct MoonlightObjectType : NPClass {
273 MoonlightObjectType ();
275 ~MoonlightObjectType() { g_free (mapping); }
277 void AddMapping (const MoonNameIdMapping *mapping, int count);
279 bool Enumerate (NPIdentifier **value, guint32 *count);
281 int LookupName (NPIdentifier name);
283 MoonNameIdMapping *mapping;
284 int mapping_count;
286 NPIdentifier last_lookup;
287 int last_id;
290 extern MoonlightObjectType *MoonlightObjectClass;
292 struct MoonlightObject : NPObject {
293 MoonlightObject (NPP instance)
295 #if SANITY
296 g_assert (instance->pdata != NULL); /* #if SANITY */
297 #endif
298 this->plugin = (PluginInstance *) instance->pdata;
299 if (this->plugin)
300 this->plugin->ref ();
301 this->moonlight_type = Type::INVALID;
302 this->event_listener_proxies = g_hash_table_new (g_direct_hash, g_direct_equal);
305 virtual void Invalidate () { }
306 virtual ~MoonlightObject ();
308 virtual bool HasProperty (NPIdentifier name);
309 virtual bool GetProperty (int id, NPIdentifier name, NPVariant *result);
310 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
312 virtual bool HasMethod (NPIdentifier unmapped);
313 virtual bool Invoke (int id, NPIdentifier name,
314 const NPVariant *args, guint32 argCount, NPVariant *result);
315 int LookupName (NPIdentifier name) { return ((MoonlightObjectType *)_class)->LookupName (name); }
317 void SetPlugin (PluginInstance *plugin)
319 if (this->plugin)
320 this->plugin->unref ();
321 this->plugin = plugin;
322 this->plugin->ref ();
325 EventListenerProxy *LookupEventProxy (int event_id);
326 void SetEventProxy (EventListenerProxy* proxy);
327 void ClearEventProxy (EventListenerProxy *proxy);
328 void ClearEventProxies ();
329 NPP GetInstance () { return plugin->GetInstance (); }
330 PluginInstance *GetPlugin () { return plugin; }
332 static void destroy_proxy (gpointer data);
333 static void invalidate_proxy (gpointer key, gpointer value, gpointer data);
335 PluginInstance *plugin;
336 Type::Kind moonlight_type;
337 GHashTable *event_listener_proxies;
341 /*** MoonlightEventObjectClass ***************************************************/
342 struct MoonlightEventObjectType : MoonlightObjectType {
343 MoonlightEventObjectType ();
346 extern MoonlightEventObjectType *MoonlightEventObjectClass;
348 struct MoonlightEventObjectObject : MoonlightObject {
349 MoonlightEventObjectObject (NPP instance) : MoonlightObject (instance)
351 moonlight_type = Type::EVENTOBJECT;
352 eo = NULL;
355 virtual ~MoonlightEventObjectObject ();
357 EventObject *eo;
360 extern MoonlightEventObjectObject *EventObjectCreateWrapper (PluginInstance *plugin, EventObject *obj);
362 /*** MoonlightDependencyObjectClass ***************************************************/
363 struct MoonlightDependencyObjectType : MoonlightEventObjectType {
364 MoonlightDependencyObjectType ();
368 struct MoonlightDependencyObjectObject : MoonlightEventObjectObject {
369 MoonlightDependencyObjectObject (NPP instance) : MoonlightEventObjectObject (instance)
371 moonlight_type = Type::DEPENDENCY_OBJECT;
374 DependencyObject *GetDependencyObject ()
376 if (eo == NULL || !eo->Is (Type::DEPENDENCY_OBJECT)) {
377 g_warning ("MoonlightDependencyObjectObject::GetDependencyObject (): Not a dependency object!");
378 return NULL;
381 return (DependencyObject*) eo;
384 virtual bool HasProperty (NPIdentifier unmapped);
385 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
386 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
388 virtual bool Invoke (int id, NPIdentifier name,
389 const NPVariant *args, guint32 argCount, NPVariant *result);
393 extern MoonlightDependencyObjectObject *DependencyObjectCreateWrapper (NPP instance, DependencyObject *obj);
396 /*************** AUTO GENERATED CLASSES ****************************/
398 /*MAP_HEADERS*/
400 /*************** END OF AUTO GENERATED CLASSES *********************/
402 /*** MoonlightPointClass **************************************************************/
403 struct MoonlightPointType : MoonlightObjectType {
404 MoonlightPointType ();
407 extern MoonlightPointType *MoonlightPointClass;
409 struct MoonlightPoint : MoonlightObject {
410 MoonlightPoint (NPP instance) : MoonlightObject(instance), point (Point())
412 moonlight_type = Type::POINT;
415 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
416 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
418 Point point;
421 /*** MoonlightRectClass **************************************************************/
422 struct MoonlightRectType : MoonlightObjectType {
423 MoonlightRectType ();
426 extern MoonlightRectType *MoonlightRectClass;
428 struct MoonlightRect : MoonlightObject {
429 MoonlightRect (NPP instance) : MoonlightObject(instance), rect (Rect())
431 moonlight_type = Type::RECT;
434 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
435 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
437 Rect rect;
441 /*** MoonlightDurationClass **************************************************************/
442 struct MoonlightDurationType : MoonlightObjectType {
443 MoonlightDurationType ();
446 extern MoonlightDurationType *MoonlightDurationClass;
448 struct MoonlightDuration : MoonlightObject {
449 MoonlightDuration (NPP instance) : MoonlightObject (instance)
451 moonlight_type = Type::DURATION;
452 parent_property = NULL;
453 parent_obj = NULL;
456 virtual ~MoonlightDuration ();
458 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
460 double GetValue ();
462 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
463 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
465 DependencyProperty *parent_property;
466 DependencyObject *parent_obj;
469 /*** MoonlightTimeSpanClass **************************************************************/
470 struct MoonlightTimeSpanType : MoonlightObjectType {
471 MoonlightTimeSpanType ();
474 extern MoonlightTimeSpanType *MoonlightTimeSpanClass;
476 struct MoonlightTimeSpan : MoonlightObject {
477 MoonlightTimeSpan (NPP instance) : MoonlightObject (instance)
479 moonlight_type = Type::TIMESPAN;
480 parent_property = NULL;
481 parent_obj = NULL;
484 virtual ~MoonlightTimeSpan ();
486 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
488 TimeSpan GetValue ();
490 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
491 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
493 DependencyProperty *parent_property;
494 DependencyObject *parent_obj;
497 /*** MoonlightKeyTimeClass ****************************************************************/
498 struct MoonlightKeyTimeType : MoonlightObjectType {
499 MoonlightKeyTimeType ();
502 extern MoonlightKeyTimeType *MoonlightKeyTimeClass;
504 struct MoonlightKeyTime : MoonlightObject {
505 MoonlightKeyTime (NPP instance) : MoonlightObject (instance)
507 moonlight_type = Type::KEYTIME;
508 parent_property = NULL;
509 parent_obj = NULL;
512 virtual ~MoonlightKeyTime ();
514 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
516 KeyTime* GetValue ();
518 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
519 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
521 DependencyProperty *parent_property;
522 DependencyObject *parent_obj;
525 /*** MoonlightThicknessClass ****************************************************************/
526 struct MoonlightThicknessType : MoonlightObjectType {
527 MoonlightThicknessType ();
530 extern MoonlightThicknessType *MoonlightThicknessClass;
532 struct MoonlightThickness : MoonlightObject {
533 MoonlightThickness (NPP instance) : MoonlightObject (instance)
535 moonlight_type = Type::THICKNESS;
536 parent_property = NULL;
537 parent_obj = NULL;
540 virtual ~MoonlightThickness ();
542 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
544 Thickness* GetValue ();
546 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
547 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
549 DependencyProperty *parent_property;
550 DependencyObject *parent_obj;
553 /*** MoonlightCornerRadiusClass ****************************************************************/
554 struct MoonlightCornerRadiusType : MoonlightObjectType {
555 MoonlightCornerRadiusType ();
558 extern MoonlightCornerRadiusType *MoonlightCornerRadiusClass;
560 struct MoonlightCornerRadius : MoonlightObject {
561 MoonlightCornerRadius (NPP instance) : MoonlightObject (instance)
563 moonlight_type = Type::CORNERRADIUS;
564 parent_property = NULL;
565 parent_obj = NULL;
568 virtual ~MoonlightCornerRadius ();
570 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
572 CornerRadius* GetValue ();
574 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
575 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
577 DependencyProperty *parent_property;
578 DependencyObject *parent_obj;
581 /*** MoonlightGridLengthClass ****************************************************************/
582 struct MoonlightGridLengthType : MoonlightObjectType {
583 MoonlightGridLengthType ();
586 extern MoonlightGridLengthType *MoonlightGridLengthClass;
588 struct MoonlightGridLength : MoonlightObject {
589 MoonlightGridLength (NPP instance) : MoonlightObject (instance)
591 moonlight_type = Type::GRIDLENGTH;
592 parent_property = NULL;
593 parent_obj = NULL;
596 virtual ~MoonlightGridLength ();
598 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
600 GridLength* GetValue ();
602 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
603 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
605 DependencyProperty *parent_property;
606 DependencyObject *parent_obj;
609 /*** MoonlightSettingsClass ***********************************************************/
611 struct MoonlightSettingsType : MoonlightObjectType {
612 MoonlightSettingsType ();
615 extern MoonlightSettingsType *MoonlightSettingsClass;
617 struct MoonlightSettingsObject : MoonlightObject {
618 MoonlightSettingsObject (NPP instance) : MoonlightObject (instance)
622 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
623 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
625 virtual bool Invoke (int id, NPIdentifier name,
626 const NPVariant *args, guint32 argCount, NPVariant *result);
630 /*** MoonlightContentClass ************************************************************/
632 struct MoonlightContentType : MoonlightObjectType {
633 MoonlightContentType ();
636 extern MoonlightContentType *MoonlightContentClass;
638 struct MoonlightContentObject : MoonlightObject {
639 MoonlightContentObject (NPP instance) : MoonlightObject (instance)
641 registered_scriptable_objects = g_hash_table_new (g_direct_hash, g_direct_equal);
642 accessibility = NULL;
645 virtual ~MoonlightContentObject ();
647 virtual bool HasProperty (NPIdentifier unmapped);
648 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
649 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
651 virtual bool Invoke (int id, NPIdentifier name,
652 const NPVariant *args, guint32 argCount, NPVariant *result);
654 DependencyObject *accessibility;
655 GHashTable *registered_scriptable_objects;
658 /*** MoonlightScriptControlClass **********************************************************/
660 struct MoonlightScriptControlType : MoonlightObjectType {
661 MoonlightScriptControlType ();
664 extern MoonlightScriptControlType *MoonlightScriptControlClass;
666 struct MoonlightScriptControlObject : MoonlightObject {
667 MoonlightScriptControlObject (NPP instance) : MoonlightObject (instance)
669 settings = (MoonlightSettingsObject *) NPN_CreateObject (instance, MoonlightSettingsClass);
670 content = (MoonlightContentObject *) NPN_CreateObject (instance, MoonlightContentClass);
673 virtual ~MoonlightScriptControlObject ();
675 virtual void Invalidate ();
677 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
678 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
680 virtual bool Invoke (int id, NPIdentifier name,
681 const NPVariant *args, guint32 argCount, NPVariant *result);
683 MoonlightSettingsObject *settings;
684 MoonlightContentObject *content;
686 /* store the current event handlers so that they survive PluginInstance destruction */
687 void PreSwitchPlugin (PluginInstance *old_plugin, PluginInstance *new_plugin);
688 /* restore the stored event handlers into the new PluginInstance */
689 void PostSwitchPlugin (PluginInstance *old_plugin, PluginInstance *new_plugin);
691 private:
692 /* fields for storing the data in PreSwitchPlugin */
693 int events_count;
694 int *events_to_switch;
695 MoonlightObject **events_object;
696 gpointer *events_callbacks;
697 bool *events_is_func;
701 /*** MoonlightEventArgsClass ******************************************************/
702 struct MoonlightEventArgsType : MoonlightDependencyObjectType {
703 MoonlightEventArgsType ();
706 struct MoonlightEventArgs : MoonlightDependencyObjectObject {
707 MoonlightEventArgs (NPP instance) : MoonlightDependencyObjectObject (instance)
709 moonlight_type = Type::EVENTARGS;
713 /*** MoonlightEventArgsClass ******************************************************/
714 struct MoonlightRoutedEventArgsType : MoonlightEventArgsType {
715 MoonlightRoutedEventArgsType ();
718 struct MoonlightRoutedEventArgs : MoonlightEventArgs {
719 MoonlightRoutedEventArgs (NPP instance) : MoonlightEventArgs (instance)
721 moonlight_type = Type::ROUTEDEVENTARGS;
724 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
726 RoutedEventArgs *GetRoutedEventArgs () { return (RoutedEventArgs *) eo; }
729 /*** MoonlightMouseEventArgsClass **************************************************************/
730 struct MoonlightMouseEventArgsType : MoonlightRoutedEventArgsType {
731 MoonlightMouseEventArgsType ();
734 struct MoonlightMouseEventArgsObject : MoonlightRoutedEventArgs {
735 MoonlightMouseEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
737 moonlight_type = Type::MOUSEEVENTARGS;
740 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
741 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
742 virtual bool Invoke (int id, NPIdentifier name,
743 const NPVariant *args, guint32 argCount, NPVariant *result);
745 MouseEventArgs *GetMouseEventArgs () { return (MouseEventArgs *) eo; };
748 /*** MoonlightMarkerReachedEventArgsClass ******************************************/
749 struct MoonlightTimelineMarkerRoutedEventArgsType : MoonlightRoutedEventArgsType {
750 MoonlightTimelineMarkerRoutedEventArgsType ();
753 extern MoonlightTimelineMarkerRoutedEventArgsType *MoonlightTimelineMarkerRoutedEventArgsClass;
755 struct MoonlightTimelineMarkerRoutedEventArgsObject : MoonlightRoutedEventArgs {
756 MoonlightTimelineMarkerRoutedEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
758 moonlight_type = Type::TIMELINEMARKERROUTEDEVENTARGS;
761 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
763 TimelineMarkerRoutedEventArgs *GetTimelineMarkerRoutedEventArgs () { return (TimelineMarkerRoutedEventArgs *) eo; }
766 /*** MoonlightKeyEventArgsClass **************************************************************/
767 struct MoonlightKeyEventArgsType : MoonlightEventArgsType {
768 MoonlightKeyEventArgsType ();
771 struct MoonlightKeyEventArgsObject : MoonlightEventArgs {
772 MoonlightKeyEventArgsObject (NPP instance) : MoonlightEventArgs (instance)
774 moonlight_type = Type::KEYEVENTARGS;
777 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
778 KeyEventArgs *GetKeyEventArgs () { return (KeyEventArgs *) eo; }
781 /*** MoonlightDownloadProgressEventArgsClass ******************************************************/
782 struct MoonlightDownloadProgressEventArgsType : MoonlightEventArgsType {
783 MoonlightDownloadProgressEventArgsType ();
786 struct MoonlightDownloadProgressEventArgs : MoonlightEventArgs {
787 MoonlightDownloadProgressEventArgs (NPP instance) : MoonlightEventArgs (instance)
789 moonlight_type = Type::DOWNLOADPROGRESSEVENTARGS;
792 DownloadProgressEventArgs *GetDownloadProgressEventArgs () { return (DownloadProgressEventArgs *) eo; }
793 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
796 /*** MoonlightErrorEventArgsClass ******************************************************/
797 struct MoonlightErrorEventArgsType : MoonlightEventArgsType {
798 MoonlightErrorEventArgsType ();
801 struct MoonlightErrorEventArgs : MoonlightEventArgs {
802 MoonlightErrorEventArgs (NPP instance) : MoonlightEventArgs (instance)
804 moonlight_type = Type::ERROREVENTARGS;
807 ErrorEventArgs *GetErrorEventArgs () { return (ErrorEventArgs *) eo; }
808 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
811 /*** MoonlightCollectionClass ***************************************************/
813 struct MoonlightCollectionType : MoonlightDependencyObjectType {
814 MoonlightCollectionType ();
817 struct MoonlightCollectionObject : MoonlightDependencyObjectObject {
818 MoonlightCollectionObject (NPP instance) : MoonlightDependencyObjectObject (instance)
820 moonlight_type = Type::COLLECTION;
823 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
825 virtual bool Invoke (int id, NPIdentifier name,
826 const NPVariant *args, guint32 argCount, NPVariant *result);
829 /*** MoonlightStoryboardClass ***************************************************/
831 struct MoonlightStoryboardType : MoonlightDependencyObjectType {
832 MoonlightStoryboardType ();
835 struct MoonlightStoryboardObject : MoonlightDependencyObjectObject {
836 MoonlightStoryboardObject (NPP instance) : MoonlightDependencyObjectObject (instance)
838 moonlight_type = Type::STORYBOARD;
841 virtual bool Invoke (int id, NPIdentifier name,
842 const NPVariant *args, guint32 argCount, NPVariant *result);
845 /*** MoonlightMediaElement ***************************************************/
847 struct MoonlightMediaElementType : MoonlightUIElementType {
848 MoonlightMediaElementType ();
852 struct MoonlightMediaElementObject : MoonlightUIElementObject {
853 MoonlightMediaElementObject (NPP instance) : MoonlightUIElementObject (instance)
855 moonlight_type = Type::MEDIAELEMENT;
858 virtual bool Invoke (int id, NPIdentifier name,
859 const NPVariant *args, guint32 argCount, NPVariant *result);
862 /*** MoonlightMultiScaleImage ***************************************************/
864 struct MoonlightMultiScaleImageType : MoonlightDependencyObjectType {
865 MoonlightMultiScaleImageType ();
868 struct MoonlightMultiScaleImageObject : MoonlightDependencyObjectObject {
869 MoonlightMultiScaleImageObject (NPP instance) : MoonlightDependencyObjectObject (instance)
871 moonlight_type = Type::MULTISCALEIMAGE;
874 virtual bool Invoke (int id, NPIdentifier name,
875 const NPVariant *args, guint32 argCount, NPVariant *result);
877 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
880 /*** MoonlightImage ***************************************************/
882 struct MoonlightImageType : MoonlightUIElementType {
883 MoonlightImageType ();
887 struct MoonlightImageObject : MoonlightUIElementObject {
888 MoonlightImageObject (NPP instance) : MoonlightUIElementObject (instance)
890 moonlight_type = Type::IMAGE;
893 virtual bool Invoke (int id, NPIdentifier name,
894 const NPVariant *args, guint32 argCount, NPVariant *result);
895 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
898 /*** MoonlightImageBrush ***************************************************/
900 struct MoonlightImageBrushType : MoonlightDependencyObjectType {
901 MoonlightImageBrushType ();
905 struct MoonlightImageBrushObject : MoonlightDependencyObjectObject {
906 MoonlightImageBrushObject (NPP instance) : MoonlightDependencyObjectObject (instance)
908 moonlight_type = Type::IMAGEBRUSH;
911 virtual bool Invoke (int id, NPIdentifier name,
912 const NPVariant *args, guint32 argCount, NPVariant *result);
913 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
916 /*** MoonlightDownloader ***************************************************/
918 struct MoonlightDownloaderType : MoonlightDependencyObjectType {
919 MoonlightDownloaderType ();
923 struct MoonlightDownloaderObject : MoonlightDependencyObjectObject {
924 MoonlightDownloaderObject (NPP instance) : MoonlightDependencyObjectObject (instance)
926 moonlight_type = Type::DOWNLOADER;
929 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
930 virtual bool Invoke (int id, NPIdentifier name,
931 const NPVariant *args, guint32 argCount, NPVariant *result);
934 /*** MoonlightTextBlock ***************************************************/
936 struct MoonlightTextBlockType : MoonlightUIElementType {
937 MoonlightTextBlockType ();
941 struct MoonlightTextBlockObject : MoonlightUIElementObject {
942 MoonlightTextBlockObject (NPP instance) : MoonlightUIElementObject (instance)
944 moonlight_type = Type::TEXTBLOCK;
947 virtual bool Invoke (int id, NPIdentifier name,
948 const NPVariant *args, guint32 argCount, NPVariant *result);
951 /*** MoonlightControl ***************************************************/
953 struct MoonlightControlType : MoonlightUIElementType {
954 MoonlightControlType ();
957 extern MoonlightControlType *MoonlightControlClass;
959 struct MoonlightControlObject : MoonlightUIElementObject {
960 MoonlightControlObject (NPP instance) : MoonlightUIElementObject (instance)
962 moonlight_type = Type::CONTROL;
965 virtual bool Invoke (int id, NPIdentifier name, const NPVariant *args, guint32 argCount, NPVariant *result);
968 /*** MoonlightTextBox ***************************************************/
970 struct MoonlightTextBoxType : MoonlightControlType {
971 MoonlightTextBoxType ();
975 struct MoonlightTextBoxObject : MoonlightControlObject {
976 MoonlightTextBoxObject (NPP instance) : MoonlightControlObject (instance)
978 moonlight_type = Type::TEXTBOX;
981 virtual bool Invoke (int id, NPIdentifier name,
982 const NPVariant *args, guint32 argCount, NPVariant *result);
986 /*** MoonlightPasswordBox ***************************************************/
988 struct MoonlightPasswordBoxType : MoonlightControlType {
989 MoonlightPasswordBoxType ();
993 struct MoonlightPasswordBoxObject : MoonlightControlObject {
994 MoonlightPasswordBoxObject (NPP instance) : MoonlightControlObject (instance)
996 moonlight_type = Type::PASSWORDBOX;
999 virtual bool Invoke (int id, NPIdentifier name,
1000 const NPVariant *args, guint32 argCount, NPVariant *result);
1003 /*** MoonlightStylusInfoType ***************************************************/
1005 struct MoonlightStylusInfoType : MoonlightDependencyObjectType {
1006 MoonlightStylusInfoType ();
1010 struct MoonlightStylusInfoObject : MoonlightDependencyObjectObject {
1011 MoonlightStylusInfoObject (NPP instance) : MoonlightDependencyObjectObject (instance)
1013 moonlight_type = Type::STYLUSINFO;
1016 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
1019 /*** MoonlightStylusPointCollectionType *************************************/
1021 struct MoonlightStylusPointCollectionType : MoonlightCollectionType {
1022 MoonlightStylusPointCollectionType ();
1026 struct MoonlightStylusPointCollectionObject : MoonlightCollectionObject {
1027 MoonlightStylusPointCollectionObject (NPP instance) : MoonlightCollectionObject (instance)
1029 moonlight_type = Type::STYLUSPOINT_COLLECTION;
1032 virtual bool Invoke (int id, NPIdentifier name,
1033 const NPVariant *args, guint32 argCount, NPVariant *result);
1037 /*** MoonlightStrokeCollectionType *************************************/
1039 struct MoonlightStrokeCollectionType : MoonlightCollectionType {
1040 MoonlightStrokeCollectionType ();
1044 struct MoonlightStrokeCollectionObject : MoonlightCollectionObject {
1046 MoonlightStrokeCollectionObject (NPP instance)
1047 : MoonlightCollectionObject (instance)
1049 moonlight_type = Type::STROKE_COLLECTION;
1052 virtual bool Invoke (int id, NPIdentifier name,
1053 const NPVariant *args, guint32 argCount, NPVariant *result);
1057 /*** MoonlightStrokeType *************************************/
1059 struct MoonlightStrokeType : MoonlightDependencyObjectType {
1060 MoonlightStrokeType ();
1064 struct MoonlightStrokeObject : MoonlightDependencyObjectObject {
1066 MoonlightStrokeObject (NPP instance)
1067 : MoonlightDependencyObjectObject (instance)
1069 moonlight_type = Type::STROKE;
1072 virtual bool Invoke (int id, NPIdentifier name,
1073 const NPVariant *args, guint32 argCount, NPVariant *result);
1076 /*** MoonlightScriptableObject ***************************************************/
1078 struct MoonlightScriptableObjectObject;
1080 typedef void (*InvokeDelegate) (gpointer managed_obj_handle, gpointer method_handle, char* name, Value** args, int arg_count, Value* return_value);
1081 typedef void (*SetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1082 typedef void (*GetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1083 typedef void (*EventHandlerDelegate) (gpointer managed_obj_handle, gpointer event_handle, MoonlightScriptableObjectObject* scriptable_obj, gpointer closure);
1085 struct MoonlightScriptableObjectType : MoonlightObjectType {
1086 MoonlightScriptableObjectType ();
1089 extern MoonlightScriptableObjectType *MoonlightScriptableObjectClass;
1091 struct MoonlightScriptableObjectObject : MoonlightObject {
1092 MoonlightScriptableObjectObject (NPP instance) : MoonlightObject (instance)
1094 managed_scriptable = NULL;
1095 properties = g_hash_table_new (g_direct_hash, g_direct_equal);
1096 methods = g_hash_table_new (g_direct_hash, g_direct_equal);
1097 events = g_hash_table_new (g_direct_hash, g_direct_equal);
1100 virtual ~MoonlightScriptableObjectObject ();
1102 virtual bool HasProperty (NPIdentifier name);
1103 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
1104 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
1106 virtual bool HasMethod (NPIdentifier name);
1107 virtual bool Invoke (int id, NPIdentifier name,
1108 const NPVariant *args, guint32 argCount, NPVariant *result);
1110 gpointer managed_scriptable;
1111 GHashTable *properties;
1112 GHashTable *methods;
1113 GHashTable *events;
1115 InvokeDelegate invoke;
1116 SetPropertyDelegate setprop;
1117 GetPropertyDelegate getprop;
1118 EventHandlerDelegate addevent;
1119 EventHandlerDelegate removeevent;
1123 G_BEGIN_DECLS
1125 // These are meant to be called by System.Silverlight.dll
1126 /* @GeneratePInvoke */
1127 NPObject * moonlight_object_to_npobject (MoonlightObject *obj);
1128 MoonlightObject * npobject_to_moonlight_object (NPObject *npobj);
1130 /* @GeneratePInvoke */
1131 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create_root (PluginInstance *plugin, gpointer scriptable,
1132 InvokeDelegate invoke,
1133 SetPropertyDelegate setprop,
1134 GetPropertyDelegate getprop,
1135 EventHandlerDelegate addevent,
1136 EventHandlerDelegate removeevent);
1138 /* @GeneratePInvoke */
1139 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create (NPObject *parent, gpointer scriptable,
1140 InvokeDelegate invoke,
1141 SetPropertyDelegate setprop,
1142 GetPropertyDelegate getprop,
1143 EventHandlerDelegate addevent,
1144 EventHandlerDelegate removeevent);
1146 /* @GeneratePInvoke */
1147 void moonlight_scriptable_object_add_property (PluginInstance *plugin,
1148 MoonlightScriptableObjectObject *obj,
1149 gpointer property_handle,
1150 char *property_name,
1151 /* @MarshalAs=TypeCode */ int property_type,
1152 bool can_read,
1153 bool can_write);
1155 /* @GeneratePInvoke */
1156 void moonlight_scriptable_object_add_event (PluginInstance *plugin,
1157 MoonlightScriptableObjectObject *obj,
1158 gpointer event_handle,
1159 char *event_name);
1161 /* @GeneratePInvoke */
1162 void moonlight_scriptable_object_add_method (PluginInstance *plugin,
1163 MoonlightScriptableObjectObject *obj,
1164 gpointer method_handle,
1165 char *method_name,
1166 /* @MarshalAs=TypeCode */ int method_return_type,
1167 /* @MarshalAs=TypeCode[] */ int *method_parameter_types,
1168 int parameter_count);
1170 /* @GeneratePInvoke */
1171 void moonlight_scriptable_object_register (PluginInstance *plugin,
1172 char *name,
1173 MoonlightScriptableObjectObject *obj);
1175 /* @GeneratePInvoke */
1176 void moonlight_scriptable_object_emit_event (PluginInstance *plugin,
1177 MoonlightScriptableObjectObject *obj,
1178 MoonlightScriptableObjectObject *event_args,
1179 NPObject *cb_obj);
1181 /*** HtmlObject ***************************************************/
1183 // int clientX, int clientY,
1185 typedef void callback_dom_event (gpointer context, char *name, int client_x, int client_y, int offset_x, int offset_y, gboolean alt_key,
1186 gboolean ctrl_key, gboolean shift_key, int mouse_button,
1187 int key_code, int char_code,
1188 gpointer domEvent);
1190 const char *html_get_element_text (PluginInstance *plugin, const char *element_id);
1192 // These are meant to be called by System.Silverlight.dll
1193 /* @GeneratePInvoke */
1194 bool html_object_has_property (PluginInstance *plugin, NPObject *npobj, char *name);
1195 /* @GeneratePInvoke */
1196 void html_object_get_property (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1197 /* @GeneratePInvoke */
1198 void html_object_set_property (PluginInstance *plugin, NPObject *npobj, char *name, Value *value);
1199 /* @GeneratePInvoke */
1200 bool html_object_invoke (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1201 /* @GeneratePInvoke */
1202 bool html_object_invoke_self (PluginInstance *plugin, NPObject *npobj, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1203 /* @GeneratePInvoke */
1204 gpointer html_object_attach_event (PluginInstance *plugin, NPObject *npobj, char *name, callback_dom_event *cb, gpointer context);
1205 /* @GeneratePInvoke */
1206 void html_object_detach_event (PluginInstance *plugin, const char *name, gpointer listener);
1207 /* @GeneratePInvoke */
1208 void html_object_release (PluginInstance *plugin, NPObject *npobj);
1209 /* @GeneratePInvoke */
1210 void html_object_retain (PluginInstance *plugin, NPObject *npobj);
1212 /*** Browser interaction utility classes ***/
1213 void browser_do_alert (PluginInstance *plugin, char *msg);
1216 G_END_DECLS
1218 #endif /* __PLUGIN_CLASS_H__ */