~woodrow-shen/totem/mybranch

« back to all changes in this revision

Viewing changes to browser-plugin/totemNPObject.h

Tags: 2.24.3-3
* totem-mozilla.docs: ship README.browser-plugin which explains how to 
  disable the plugin for some MIME types.
* rules: remove the hack that only let totem-xine support VCDs and 
  DVDs, now that GStreamer supports them. Closes: #370789.
* 01_fake_keypresses.patch: new patch. Completely disable the broken 
  XTEST code that generates fake keypresses. Closes: #500330.
* 90_autotools.patch: regenerated.
* Build-depend on nautilus 2.22 to be sure to build the extension for 
  the correct version.
* totem-xine depends on libxine1-x.
* Standards version is 3.8.1.
* Upload to unstable.
* 04_tracker_build.patch: new patch, stolen upstream. Fix build with 
  latest tracker version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2008 Christian Persch
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifndef __TOTEM_NPOBJECT_H__
 
21
#define __TOTEM_NPOBJECT_H__
 
22
 
 
23
#include <assert.h>
 
24
 
 
25
#include "npapi.h"
 
26
#include "npruntime.h"
 
27
 
 
28
//FIXME force debug on
 
29
#define GNOME_ENABLE_DEBUG 1
 
30
 
 
31
#include "debug.h"
 
32
 
 
33
class totemPlugin;
 
34
class totemNPObject;
 
35
class totemNPClass_base;
 
36
template<class T> class totemNPClass;
 
37
 
 
38
class totemNPObject : public NPObject {
 
39
  public:
 
40
    totemNPObject (NPP);
 
41
 
 
42
    virtual ~totemNPObject ();
 
43
 
 
44
    void* operator new (size_t aSize) throw ();
 
45
 
 
46
  protected:
 
47
    friend class totemNPClass_base;
 
48
 
 
49
    /* NPObject methods */
 
50
    virtual void Invalidate     ();
 
51
    virtual bool HasMethod      (NPIdentifier aName);
 
52
    virtual bool Invoke         (NPIdentifier aName, const NPVariant *argv, uint32_t argc, NPVariant *_result);
 
53
    virtual bool InvokeDefault  (const NPVariant *argv, uint32_t argc, NPVariant *_result);
 
54
    virtual bool HasProperty    (NPIdentifier aName);
 
55
    virtual bool GetProperty    (NPIdentifier aName, NPVariant *_result);
 
56
    virtual bool SetProperty    (NPIdentifier aName, const NPVariant *aValue);
 
57
    virtual bool RemoveProperty (NPIdentifier aName);
 
58
    virtual bool Enumerate      (NPIdentifier **_result, uint32_t *_count);
 
59
    virtual bool Construct      (const NPVariant *argv, uint32_t argc, NPVariant *_result);
 
60
 
 
61
    /* By Index methods */
 
62
    virtual bool InvokeByIndex         (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
 
63
    virtual bool GetPropertyByIndex    (int aIndex, NPVariant *_result);
 
64
    virtual bool SetPropertyByIndex    (int aIndex, const NPVariant *aValue);
 
65
    virtual bool RemovePropertyByIndex (int aIndex);
 
66
 
 
67
  private:
 
68
 
 
69
    NPP mNPP;
 
70
    totemPlugin *mPlugin;
 
71
 
 
72
  protected:
 
73
 
 
74
    bool IsValid () const { return mPlugin != 0; }
 
75
    totemPlugin* Plugin () const { assert (IsValid ()); return mPlugin; }
 
76
 
 
77
    bool Throw (const char*);
 
78
    bool ThrowPropertyNotWritable ();
 
79
    bool ThrowSecurityError ();
 
80
 
 
81
    bool CheckArgc (uint32_t, uint32_t, uint32_t = uint32_t(-1), bool = true);
 
82
    bool CheckArgType (NPVariantType, NPVariantType, uint32_t = 0);
 
83
    bool CheckArg (const NPVariant*, uint32_t, uint32_t, NPVariantType);
 
84
    bool CheckArgv (const NPVariant*, uint32_t, uint32_t, ...);
 
85
 
 
86
    bool GetBoolFromArguments (const NPVariant*, uint32_t, uint32_t, bool&);
 
87
    bool GetInt32FromArguments (const NPVariant*, uint32_t, uint32_t, int32_t&);
 
88
    bool GetDoubleFromArguments (const NPVariant*, uint32_t, uint32_t, double&);
 
89
    bool GetStringFromArguments (const NPVariant*, uint32_t, uint32_t, const char*&);
 
90
    bool DupStringFromArguments (const NPVariant*, uint32_t, uint32_t, char*&);
 
91
    bool GetObjectFromArguments (const NPVariant*, uint32_t, uint32_t, NPObject*&);
 
92
 
 
93
    bool VoidVariant (NPVariant*);
 
94
    bool NullVariant (NPVariant*);
 
95
    bool BoolVariant (NPVariant*, bool);
 
96
    bool Int32Variant (NPVariant*, int32_t);
 
97
    bool DoubleVariant (NPVariant*, double);
 
98
    bool StringVariant (NPVariant*, const char*, int32_t = -1);
 
99
    bool ObjectVariant (NPVariant*, NPObject*);
 
100
 
 
101
  private:
 
102
 
 
103
    totemNPClass_base* GetClass() const { return static_cast<totemNPClass_base*>(_class); }
 
104
};
 
105
 
 
106
/* Helper macros */
 
107
 
 
108
#ifdef GNOME_ENABLE_DEBUG
 
109
 
 
110
#define TOTEM_LOG_CTOR() D ("%s [%p]", __func__, (void*) this)
 
111
#define TOTEM_LOG_DTOR() D ("%s [%p]", __func__, (void*) this)
 
112
 
 
113
#define TOTEM_LOG_INVOKE(i, T) \
 
114
{\
 
115
  static bool logAccess[G_N_ELEMENTS (methodNames)];\
 
116
  if (!logAccess[i]) {\
 
117
    D ("NOTE: site calls function %s::%s", #T, methodNames[i]);\
 
118
    logAccess[i] = true;\
 
119
  }\
 
120
}
 
121
 
 
122
#define TOTEM_LOG_GETTER(i, T) \
 
123
{\
 
124
  static bool logAccess[G_N_ELEMENTS (propertyNames)];\
 
125
  if (!logAccess[i]) {\
 
126
    D ("NOTE: site gets property %s::%s", #T, propertyNames[i]);\
 
127
    logAccess[i] = true;\
 
128
  }\
 
129
}
 
130
 
 
131
#define TOTEM_LOG_SETTER(i, T) \
 
132
{\
 
133
  static bool logAccess[G_N_ELEMENTS (propertyNames)];\
 
134
  if (!logAccess[i]) {\
 
135
    D ("NOTE: site sets property %s::%s", #T, propertyNames[i]);\
 
136
    logAccess[i] = true;\
 
137
  }\
 
138
}
 
139
 
 
140
#else
 
141
 
 
142
#define TOTEM_LOG_CTOR()
 
143
#define TOTEM_LOG_DTOR()
 
144
#define TOTEM_LOG_INVOKE(i, T)
 
145
#define TOTEM_LOG_GETTER(i, T)
 
146
#define TOTEM_LOG_SETTER(i, T)
 
147
 
 
148
#endif /* GNOME_ENABLE_DEBUG */
 
149
 
 
150
#define TOTEM_WARN_INVOKE_UNIMPLEMENTED(i, T) \
 
151
{\
 
152
  static bool logWarning[G_N_ELEMENTS (methodNames)];\
 
153
  if (!logWarning[i]) {\
 
154
    D ("WARNING: function %s::%s is unimplemented", #T, methodNames[i]);\
 
155
    logWarning[i] = true;\
 
156
  }\
 
157
}
 
158
 
 
159
#define TOTEM_WARN_1_INVOKE_UNIMPLEMENTED(i, T) \
 
160
{\
 
161
  static bool logWarning;\
 
162
  if (!logWarning) {\
 
163
    D ("WARNING: function %s::%s is unimplemented", #T, methodNames[i]);\
 
164
    logWarning = true;\
 
165
  }\
 
166
}
 
167
 
 
168
#define TOTEM_WARN_GETTER_UNIMPLEMENTED(i, T) \
 
169
{\
 
170
  static bool logWarning[G_N_ELEMENTS (propertyNames)];\
 
171
  if (!logWarning[i]) {\
 
172
    D ("WARNING: getter for property %s::%s is unimplemented", #T, propertyNames[i]);\
 
173
    logWarning[i] = true;\
 
174
  }\
 
175
}
 
176
 
 
177
#define TOTEM_WARN_1_GETTER_UNIMPLEMENTED(i, T) \
 
178
{\
 
179
  static bool logWarning;\
 
180
  if (!logWarning) {\
 
181
    D ("WARNING: getter for property %s::%s is unimplemented", #T, propertyNames[i]);\
 
182
    logWarning = true;\
 
183
  }\
 
184
}
 
185
 
 
186
#define TOTEM_WARN_SETTER_UNIMPLEMENTED(i, T) \
 
187
{\
 
188
  static bool logWarning[G_N_ELEMENTS (propertyNames)];\
 
189
  if (!logWarning[i]) {\
 
190
    D ("WARNING: setter for property %s::%s is unimplemented", #T, propertyNames[i]);\
 
191
    logWarning[i] = true;\
 
192
  }\
 
193
}
 
194
 
 
195
#define TOTEM_WARN_1_SETTER_UNIMPLEMENTED(i, T) \
 
196
{\
 
197
  static bool logWarning;\
 
198
  if (!logWarning) {\
 
199
    D ("WARNING: setter for property %s::%s is unimplemented", #T, propertyNames[i]);\
 
200
    logWarning = true;\
 
201
  }\
 
202
}
 
203
 
 
204
#endif /* __TOTEM_NPOBJECT_H__ */