1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* ***** BEGIN LICENSE BLOCK ***** 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 4 * 5 * The contents of this file are subject to the Mozilla Public License Version 6 * 1.1 (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * http://www.mozilla.org/MPL/ 9 * 10 * Software distributed under the License is distributed on an "AS IS" basis, 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 * for the specific language governing rights and limitations under the 13 * License. 14 * 15 * The Original Code is mozilla.org code. 16 * 17 * The Initial Developer of the Original Code is 18 * Netscape Communications Corporation. 19 * Portions created by the Initial Developer are Copyright (C) 1998 20 * the Initial Developer. All Rights Reserved. 21 * 22 * Contributor(s): 23 * 24 * Alternatively, the contents of this file may be used under the terms of 25 * either the GNU General Public License Version 2 or later (the "GPL"), or 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 * in which case the provisions of the GPL or the LGPL are applicable instead 28 * of those above. If you wish to allow use of your version of this file only 29 * under the terms of either the GPL or the LGPL, and not to allow others to 30 * use your version of this file under the terms of the MPL, indicate your 31 * decision by deleting the provisions above and replace them with the notice 32 * and other provisions required by the GPL or the LGPL. If you do not delete 33 * the provisions above, a recipient may use your version of this file under 34 * the terms of any one of the MPL, the GPL or the LGPL. 35 * 36 * ***** END LICENSE BLOCK ***** */ 37 38 #ifndef __PLUGIN_H__ 39 #define __PLUGIN_H__ 40 #include <npapi.h> 41 #include <npruntime.h> 42 #include <npfunctions.h> 43 #include <X11/Xlib.h> 44 #include <dbus/dbus.h> 45 #include <dbus/dbus-glib-lowlevel.h> 46 #ifdef HAVE_CONFIG_H 47 #include <config.h> 48 #endif 49 50 #include <glib.h> 51 #include <glib/gstdio.h> 52 #include <glib/gi18n.h> 53 #include "plugin_list.h" 54 #ifdef ENABLE_NLS 55 #include <libintl.h> 56 #endif 57 58 #ifdef HAVE_CURL 59 #include <curl/curl.h> 60 #endif 61 62 #include <gmlib.h> 63 64 // JavaScript Playstates 65 #define STATE_UNDEFINED 0 66 #define STATE_STOPPED 1 67 #define STATE_PAUSED 2 68 #define STATE_PLAYING 3 69 #define STATE_SCANFORWARD 4 70 #define STATE_SCANREVERSE 5 71 #define STATE_BUFFERING 6 72 #define STATE_WAITING 7 73 #define STATE_MEDIAENDED 8 74 #define STATE_TRANSITIONING 9 75 #define STATE_READY 10 76 #define STATE_RECONNECTING 11 77 78 // config settings stored in gconf 79 #define DISABLE_QT "disable-qt" 80 #define DISABLE_REAL "disable-real" 81 #define DISABLE_WMP "disable-wmp" 82 #define DISABLE_DVX "disable-dvx" 83 #define DEBUG_LEVEL "debug-level" 84 #define DISABLE_MIDI "disable-midi" 85 #define PLAYER_BACKEND "player-backend" 86 87 typedef enum { 88 PLAYING, 89 PAUSED, 90 STOPPED, 91 QUIT 92 } PLAYSTATE; 93 94 void postDOMEvent(NPP mInstance, const gchar * id, const gchar * event); 95 void postPlayStateChange(NPP mInstance, const gint state); 96 const gchar *NPErrorToString(NPError error); 97 const gchar *NPReasonToString(NPReason reason); 98 99 class CPlugin { 100 private: 101 NPWindow * m_Window; 102 NPStream *m_pNPStream; 103 NPBool mInitialized; 104 NPObject *m_pScriptableObject; 105 NPObject *m_pScriptableObjectControls; 106 NPObject *m_pScriptableObjectSettings; 107 NPObject *m_pScriptableObjectMedia; 108 NPObject *m_pScriptableObjectError; 109 110 public: 111 CPlugin(NPP pNPInstance); 112 ~CPlugin(); 113 114 NPBool init(NPWindow * aWindow); 115 void shut(); 116 NPBool isInitialized(); 117 int16_t handleEvent(void *event); 118 119 NPObject *GetScriptableObject(); 120 NPObject *GetScriptableObjectControls(); 121 NPObject *GetScriptableObjectSettings(); 122 NPObject *GetScriptableObjectMedia(); 123 NPObject *GetScriptableObjectError(); 124 125 NPError GetValue(NPPVariable variable, void *value); 126 NPError SetWindow(NPWindow * aWindow); 127 NPError NewStream(NPMIMEType type, NPStream * stream, NPBool seekable, uint16_t * stype); 128 NPError DestroyStream(NPStream * stream, NPError reason); 129 void URLNotify(const char *url, NPReason reason, void *notifyData); 130 int32_t WriteReady(NPStream * stream); 131 int32_t Write(NPStream * stream, int32_t offset, int32_t len, void *buffer); 132 NPError GetURLNotify(NPP instance, const char *url, const char *target, void *notifyData); 133 134 135 136 void Play(); 137 void Pause(); 138 void PlayPause(); 139 void Stop(); 140 void FastForward(); 141 void FastReverse(); 142 void Seek(double counter); 143 void SetShowControls(bool value); 144 void SetFullScreen(bool value); 145 void SetVolume(double value); 146 void GetVolume(double *_retval); 147 void GetFullScreen(bool * _retval); 148 void GetShowControls(bool * _retval); 149 void GetTime(double *_retval); 150 void GetDuration(double *_retval); 151 void GetPercent(double *_retval); 152 void GetBitrate(int *_retval); 153 void GetPlayState(int32_t * playstate); 154 void SetFilename(const char *filename); 155 void GetFilename(char **filename); 156 void GetMIMEType(char **_retval); 157 void GetLoop(bool * _retval); 158 void SetLoop(bool value); 159 void SetOnClick(const char *event); 160 void SetOnMediaComplete(const char *event); 161 void SetOnMouseUp(const char *event); 162 void SetOnMouseDown(const char *event); 163 void SetOnMouseOut(const char *event); 164 void SetOnMouseOver(const char *event); 165 void SetOnDestroy(const char *event); 166 167 private: 168 169 gint mX, mY; 170 gint mWidth, mHeight; 171 172 public: 173 Window mWindow; 174 NPP mInstance; 175 gchar *page_url; 176 gboolean windowless; 177 gint nextid; 178 uint16_t mode; 179 gchar *mimetype; 180 GList *playlist; 181 gboolean acceptdata; 182 gchar *path; 183 gboolean player_launched; 184 gboolean playerready; 185 DBusConnection *connection; 186 GThread *dbus_dispatch; 187 ListItem *lastopened; 188 gint cache_size; 189 gboolean hidden; 190 gint controlid; 191 gint state; 192 gint autostart; 193 time_t lastupdate; 194 gboolean disable_context_menu; 195 gboolean disable_fullscreen; 196 gboolean debug; 197 gint show_controls; 198 gchar *name; 199 gchar *id; 200 gchar *console; 201 gchar *controls; 202 gchar *user_agent; 203 gchar *player_backend; 204 gboolean quicktime_emulation; 205 206 // events 207 gboolean post_dom_events; 208 gchar *event_mediacomplete; 209 gchar *event_destroy; 210 gchar *event_mousedown; 211 gchar *event_mouseup; 212 gchar *event_mouseclicked; 213 gchar *event_enterwindow; 214 gchar *event_leavewindow; 215 216 // options 217 gint debug_level; 218 219 // tv options 220 gchar *tv_device; 221 gchar *tv_driver; 222 gchar *tv_input; 223 gint tv_width; 224 gint tv_height; 225 226 227 }; 228 229 void pluginSpecific(CPlugin * instance); 230 void setPreference(CPlugin * instance, const gchar * name, const gchar * value); 231 232 #endif // __PLUGIN_H__ 233