~woodrow-shen/totem/mybranch

« back to all changes in this revision

Viewing changes to browser-plugin/totemGMPPlaylist.cpp

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
 
/* Totem Basic Plugin
 
1
/* Totem GMP plugin
2
2
 *
3
 
 * Copyright (C) 2004 Bastien Nocera <hadess@hadess.net>
4
 
 * Copyright (C) 2002 David A. Schleef <ds@schleef.org>
5
 
 * Copyright (C) 2006 Christian Persch
 
3
 * Copyright © 2004 Bastien Nocera <hadess@hadess.net>
 
4
 * Copyright © 2002 David A. Schleef <ds@schleef.org>
 
5
 * Copyright © 2006, 2008 Christian Persch
6
6
 *
7
7
 * This library is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Library General Public
16
16
 *
17
17
 * You should have received a copy of the GNU Library General Public
18
18
 * License along with this library; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
21
 
 *
22
 
 * $Id: totemGMPPlugin.cpp 3790 2006-12-15 23:08:57Z chpe $
 
19
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
 * Boston, MA 02110-1301  USA.
23
21
 */
24
22
 
25
 
#include <mozilla-config.h>
26
 
#include "config.h"
27
 
 
28
 
#include <nsDOMError.h>
29
 
#include <nsIProgrammingLanguage.h>
30
 
#include <nsISupportsImpl.h>
31
 
#include <nsMemory.h>
32
 
#include <nsXPCOM.h>
33
 
 
34
 
#define GNOME_ENABLE_DEBUG 1
35
 
/* define GNOME_ENABLE_DEBUG for more debug spew */
36
 
#include "debug.h"
37
 
 
38
 
#include "totemDebug.h"
39
 
 
40
 
#include "totemGMPPlugin.h"
41
 
#include "totemClassInfo.h"
 
23
#include <config.h>
 
24
 
 
25
#include <string.h>
 
26
 
 
27
#include <glib.h>
42
28
 
43
29
#include "totemGMPPlaylist.h"
44
30
 
45
 
/* cf079ca3-c94f-4676-a9ae-6d9bffd765bd */
46
 
static const nsCID kClassID = 
47
 
  { 0xcf079ca3, 0xc94f, 0x4676, \
48
 
    { 0xa9, 0xae, 0x6d, 0x9b, 0xff, 0xd7, 0x65, 0xbd } };
49
 
 
50
 
static const char kClassDescription[] = "totemGMPPlaylist";
51
 
 
52
 
totemGMPPlaylist::totemGMPPlaylist (totemScriptablePlugin *aScriptable)
 
31
static const char *propertyNames[] = {
 
32
  "attributeCount",
 
33
  "count",
 
34
  "name"
 
35
};
 
36
 
 
37
static const char *methodNames[] = {
 
38
  "appendItem",
 
39
  "attributeName",
 
40
  "getAttributeName",
 
41
  "getItemInfo",
 
42
  "insertItem",
 
43
  "isIdentical",
 
44
  "item",
 
45
  "moveItem",
 
46
  "removeItem",
 
47
  "setItemInfo"
 
48
};
 
49
 
 
50
TOTEM_IMPLEMENT_NPCLASS (totemGMPPlaylist,
 
51
                         propertyNames, G_N_ELEMENTS (propertyNames),
 
52
                         methodNames, G_N_ELEMENTS (methodNames),
 
53
                         NULL);
 
54
 
 
55
totemGMPPlaylist::totemGMPPlaylist (NPP aNPP)
 
56
  : totemNPObject (aNPP),
 
57
    mName (NPN_StrDup ("Playlist"))
53
58
{
54
 
  D ("%s ctor [%p]", kClassDescription, (void*) this);
55
 
 
56
 
  /* We keep a reference to the main scriptable, so the code won't be unloaded unless it's ok to do so */
57
 
  mScriptable = aScriptable;
58
 
  NS_ADDREF (mScriptable);
 
59
  TOTEM_LOG_CTOR ();
59
60
}
60
61
 
61
62
totemGMPPlaylist::~totemGMPPlaylist ()
62
63
{
63
 
  D ("%s dtor [%p]", kClassDescription, (void*) this);
64
 
 
65
 
  NS_RELEASE (mScriptable);
66
 
  mScriptable = nsnull;
67
 
}
68
 
 
69
 
/* Interface implementations */
70
 
 
71
 
NS_IMPL_ISUPPORTS2 (totemGMPPlaylist,
72
 
                    totemIGMPPlaylist,
73
 
                    nsIClassInfo)
74
 
 
75
 
/* nsIClassInfo */
76
 
 
77
 
TOTEM_CLASSINFO_BEGIN (totemGMPPlaylist,
78
 
                       1,
79
 
                       kClassID,
80
 
                       kClassDescription)
81
 
  TOTEM_CLASSINFO_ENTRY (0, totemIGMPPlaylist)
82
 
TOTEM_CLASSINFO_END
83
 
 
84
 
/* totemIGMPPlayer */
85
 
 
86
 
#undef TOTEM_SCRIPTABLE_INTERFACE
87
 
#define TOTEM_SCRIPTABLE_INTERFACE "totemIGMPPlaylist"
88
 
 
89
 
/* void appendItem (in totemIGMPMedia item); */
90
 
NS_IMETHODIMP 
91
 
totemGMPPlaylist::AppendItem(totemIGMPMedia *item)
92
 
{
93
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
94
 
 
95
 
  return NS_OK;
96
 
}
97
 
 
98
 
/* readonly attribute long attributeCount; */
99
 
NS_IMETHODIMP 
100
 
totemGMPPlaylist::GetAttributeCount(PRInt32 *aAttributeCount)
101
 
{
102
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
103
 
 
104
 
  *aAttributeCount = 0;
105
 
  return NS_OK;
106
 
}
107
 
 
108
 
/* AUTF8String attributeName (in long index); */
109
 
NS_IMETHODIMP 
110
 
totemGMPPlaylist::AttributeName(PRInt32 index, nsACString & _retval)
111
 
{
112
 
  return GetAttributeName (index, _retval);
113
 
}
114
 
 
115
 
/* AUTF8String getattributeName (in long index); */
116
 
NS_IMETHODIMP 
117
 
totemGMPPlaylist::GetAttributeName(PRInt32 index, nsACString & _retval)
118
 
{
119
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
120
 
 
121
 
  _retval.Assign ("");
122
 
  return NS_OK;
123
 
}
124
 
 
125
 
/* readonly attribute long count; */
126
 
NS_IMETHODIMP 
127
 
totemGMPPlaylist::GetCount(PRInt32 *aCount)
128
 
{
129
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
130
 
 
131
 
  *aCount = 0;
132
 
  return NS_OK;
133
 
}
134
 
 
135
 
/* AUTF8String getItemInfo (in AUTF8String name); */
136
 
NS_IMETHODIMP 
137
 
totemGMPPlaylist::GetItemInfo(const nsACString & name, nsACString & _retval)
138
 
{
139
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
140
 
 
141
 
  _retval.Assign ("");
142
 
  return NS_OK;
143
 
}
144
 
 
145
 
/* void insertItem (in long index, in totemIGMPMedia item); */
146
 
NS_IMETHODIMP 
147
 
totemGMPPlaylist::InsertItem(PRInt32 index, totemIGMPMedia *item)
148
 
{
149
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
150
 
 
151
 
  return NS_OK;
152
 
}
153
 
 
154
 
/* boolean isIdentical (in totemIGMPPlaylist playlist); */
155
 
NS_IMETHODIMP 
156
 
totemGMPPlaylist::IsIdentical(totemIGMPPlaylist *playlist, PRBool *_retval)
157
 
{
158
 
  nsISupports *thisPlaylist = static_cast<nsISupports*>
159
 
                                         (static_cast<totemIGMPPlaylist*>(this));
160
 
 
161
 
  *_retval = thisPlaylist == playlist;
162
 
  return NS_OK;
163
 
}
164
 
 
165
 
/* totemIGMPMedia item (in long index); */
166
 
NS_IMETHODIMP 
167
 
totemGMPPlaylist::Item(PRInt32 index, totemIGMPMedia **_retval)
168
 
{
169
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
170
 
 
171
 
  return NS_ERROR_NOT_IMPLEMENTED;
172
 
}
173
 
 
174
 
/* void moveItem (in long oldIndex, in long newIndex); */
175
 
NS_IMETHODIMP 
176
 
totemGMPPlaylist::MoveItem(PRInt32 oldIndex, PRInt32 newIndex)
177
 
{
178
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
179
 
 
180
 
  return NS_OK;
181
 
}
182
 
 
183
 
/* attribute AUTF8String name; */
184
 
NS_IMETHODIMP 
185
 
totemGMPPlaylist::GetName(nsACString & aName)
186
 
{
187
 
  TOTEM_SCRIPTABLE_LOG_ACCESS ();
188
 
 
189
 
  aName = mName;
190
 
  return NS_OK;
191
 
}
192
 
 
193
 
NS_IMETHODIMP 
194
 
totemGMPPlaylist::SetName(const nsACString & aName)
195
 
{
196
 
  TOTEM_SCRIPTABLE_LOG_ACCESS ();
197
 
 
198
 
  mName = aName;
199
 
  return NS_OK;
200
 
}
201
 
 
202
 
/* void removeItem (in totemIGMPMedia item); */
203
 
NS_IMETHODIMP 
204
 
totemGMPPlaylist::RemoveItem(totemIGMPMedia *item)
205
 
{
206
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
207
 
 
208
 
  return NS_OK;
209
 
}
210
 
 
211
 
/* void setItemInfo (in AUTF8String name, in AUTF8String value); */
212
 
NS_IMETHODIMP 
213
 
totemGMPPlaylist::SetItemInfo(const nsACString & name, const nsACString & value)
214
 
{
215
 
  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
216
 
 
217
 
  return NS_OK;
 
64
  TOTEM_LOG_DTOR ();
 
65
 
 
66
  g_free (mName);
 
67
}
 
68
 
 
69
bool
 
70
totemGMPPlaylist::InvokeByIndex (int aIndex,
 
71
                                 const NPVariant *argv,
 
72
                                 uint32_t argc,
 
73
                                 NPVariant *_result)
 
74
{
 
75
  TOTEM_LOG_INVOKE (aIndex, totemGMPPlaylist);
 
76
 
 
77
  switch (Methods (aIndex)) {
 
78
    case eAttributeName:
 
79
      /* AUTF8String attributeName (in long index); */
 
80
    case eGetAttributeName:
 
81
      /* AUTF8String getAttributeName (in long index); */
 
82
    case eGetItemInfo:
 
83
      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
 
84
      /* AUTF8String getItemInfo (in AUTF8String name); */
 
85
      return StringVariant (_result, "");
 
86
 
 
87
    case eIsIdentical: {
 
88
      /* boolean isIdentical (in totemIGMPPlaylist playlist); */
 
89
      NPObject *other;
 
90
      if (!GetObjectFromArguments (argv, argc, 0, other))
 
91
        return false;
 
92
 
 
93
      return BoolVariant (_result, other == static_cast<NPObject*>(this));
 
94
    }
 
95
 
 
96
    case eItem:
 
97
      /* totemIGMPMedia item (in long index); */
 
98
      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
 
99
      return NullVariant (_result);
 
100
 
 
101
    case eAppendItem:
 
102
      /* void appendItem (in totemIGMPMedia item); */
 
103
    case eInsertItem:
 
104
      /* void insertItem (in long index, in totemIGMPMedia item); */
 
105
    case eMoveItem:
 
106
      /* void moveItem (in long oldIndex, in long newIndex); */
 
107
    case eRemoveItem:
 
108
      /* void removeItem (in totemIGMPMedia item); */
 
109
    case eSetItemInfo:
 
110
      /* void setItemInfo (in AUTF8String name, in AUTF8String value); */
 
111
      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
 
112
      return VoidVariant (_result);
 
113
  }
 
114
 
 
115
  return false;
 
116
}
 
117
 
 
118
bool
 
119
totemGMPPlaylist::GetPropertyByIndex (int aIndex,
 
120
                                      NPVariant *_result)
 
121
{
 
122
  TOTEM_LOG_GETTER (aIndex, totemGMPPlaylist);
 
123
 
 
124
  switch (Properties (aIndex)) {
 
125
    case eAttributeCount:
 
126
      /* readonly attribute long attributeCount; */
 
127
    case eCount:
 
128
      /* readonly attribute long count; */
 
129
      return Int32Variant (_result, 0);
 
130
 
 
131
    case eName:
 
132
      /* attribute AUTF8String name; */
 
133
      return StringVariant (_result, mName);
 
134
  }
 
135
 
 
136
  return false;
 
137
}
 
138
 
 
139
bool
 
140
totemGMPPlaylist::SetPropertyByIndex (int aIndex,
 
141
                                      const NPVariant *aValue)
 
142
{
 
143
  TOTEM_LOG_SETTER (aIndex, totemGMPPlaylist);
 
144
 
 
145
  switch (Properties (aIndex)) {
 
146
    case eName:
 
147
      /* attribute AUTF8String name; */
 
148
      return DupStringFromArguments (aValue, 1, 0, mName);
 
149
 
 
150
    case eAttributeCount:
 
151
      /* readonly attribute long attributeCount; */
 
152
    case eCount:
 
153
      /* readonly attribute long count; */
 
154
      return ThrowPropertyNotWritable ();
 
155
  }
 
156
 
 
157
  return false;
218
158
}