~woodrow-shen/totem/mybranch

« back to all changes in this revision

Viewing changes to browser-plugin/totemGMPControls.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 GMP plugin
 
2
 *
 
3
 * Copyright © 2004 Bastien Nocera <hadess@hadess.net>
 
4
 * Copyright © 2002 David A. Schleef <ds@schleef.org>
 
5
 * Copyright © 2006, 2008 Christian Persch
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Library General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Library General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Library General Public
 
18
 * License along with this library; if not, write to the
 
19
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
 * Boston, MA 02110-1301  USA.
 
21
 */
 
22
 
 
23
#include <config.h>
 
24
 
 
25
#include <string.h>
 
26
 
 
27
#include <glib.h>
 
28
 
 
29
#include "totemPlugin.h"
 
30
#include "totemGMPControls.h"
 
31
 
 
32
static const char *propertyNames[] = {
 
33
  "audioLanguageCount",
 
34
  "currentAudioLanguage",
 
35
  "currentAudioLanguageIndex",
 
36
  "currentItem",
 
37
  "currentMarker",
 
38
  "currentPosition",
 
39
  "currentPositionString",
 
40
  "currentPositionTimecode"
 
41
};
 
42
 
 
43
static const char *methodNames[] = {
 
44
  "fastForward",
 
45
  "fastReverse",
 
46
  "getAudioLanguageDescription",
 
47
  "getAudioLanguageID",
 
48
  "getLanguageName",
 
49
  "isAvailable",
 
50
  "next",
 
51
  "pause",
 
52
  "play",
 
53
  "playItem",
 
54
  "previous",
 
55
  "step",
 
56
  "stop"
 
57
};
 
58
 
 
59
TOTEM_IMPLEMENT_NPCLASS (totemGMPControls,
 
60
                         propertyNames, G_N_ELEMENTS (propertyNames),
 
61
                         methodNames, G_N_ELEMENTS (methodNames),
 
62
                         NULL);
 
63
 
 
64
totemGMPControls::totemGMPControls (NPP aNPP)
 
65
  : totemNPObject (aNPP)
 
66
{
 
67
  TOTEM_LOG_CTOR ();
 
68
}
 
69
 
 
70
totemGMPControls::~totemGMPControls ()
 
71
{
 
72
  TOTEM_LOG_DTOR ();
 
73
}
 
74
 
 
75
bool
 
76
totemGMPControls::InvokeByIndex (int aIndex,
 
77
                                 const NPVariant *argv,
 
78
                                 uint32_t argc,
 
79
                                 NPVariant *_result)
 
80
{
 
81
  TOTEM_LOG_INVOKE (aIndex, totemGMPControls);
 
82
 
 
83
  switch (Methods (aIndex)) {
 
84
    case ePause:
 
85
      /* void pause (); */
 
86
      Plugin()->Command (TOTEM_COMMAND_PAUSE);
 
87
      return VoidVariant (_result);
 
88
 
 
89
    case ePlay:
 
90
      /* void play (); */
 
91
      Plugin()->Command (TOTEM_COMMAND_PLAY);
 
92
      return VoidVariant (_result);
 
93
 
 
94
    case eStop:
 
95
      /* void stop (); */
 
96
      Plugin()->Command (TOTEM_COMMAND_PAUSE);
 
97
      return VoidVariant (_result);
 
98
 
 
99
    case eGetAudioLanguageDescription:
 
100
      /* AUTF8String getAudioLanguageDescription (in long index); */
 
101
      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
 
102
      return StringVariant (_result, "English");
 
103
 
 
104
    case eGetLanguageName:
 
105
      /* AUTF8String getLanguageName (in long LCID); */
 
106
      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
 
107
      return StringVariant (_result, "English");
 
108
 
 
109
    case eIsAvailable:
 
110
      /* boolean isAvailable (in ACString name); */
 
111
      const char *name;
 
112
      if (!GetStringFromArguments (argv, argc, 0, name))
 
113
        return false;
 
114
      if (g_ascii_strcasecmp (name, "currentItem") == 0
 
115
          || g_ascii_strcasecmp (name, "next") == 0
 
116
          || g_ascii_strcasecmp (name, "pause") == 0
 
117
          || g_ascii_strcasecmp (name, "play") == 0
 
118
          || g_ascii_strcasecmp (name, "previous") == 0
 
119
          || g_ascii_strcasecmp (name, "stop") == 0)
 
120
          return BoolVariant (_result, true);
 
121
      return BoolVariant (_result, false);
 
122
 
 
123
    case eFastForward:
 
124
      /* void fastForward (); */
 
125
    case eFastReverse:
 
126
      /* void fastReverse (); */
 
127
    case eGetAudioLanguageID:
 
128
      /* long getAudioLanguageID (in long index); */
 
129
    case eNext:
 
130
      /* void next (); */
 
131
    case ePlayItem:
 
132
      /* void playItem (in totemIGMPMedia theMediaItem); */
 
133
    case ePrevious:
 
134
      /* void previous (); */
 
135
    case eStep:
 
136
      /* void step (in long frameCount); */
 
137
      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
 
138
      return VoidVariant (_result);
 
139
  }
 
140
 
 
141
  return false;
 
142
}
 
143
 
 
144
bool
 
145
totemGMPControls::GetPropertyByIndex (int aIndex,
 
146
                                      NPVariant *_result)
 
147
{
 
148
  TOTEM_LOG_SETTER (aIndex, totemGMPControls);
 
149
 
 
150
  switch (Properties (aIndex)) {
 
151
    case eCurrentPosition:
 
152
      /* attribute double currentPosition; */
 
153
      return DoubleVariant (_result, double (Plugin()->Time()) / 1000.0);
 
154
 
 
155
    case eCurrentItem:
 
156
      /* attribute totemIGMPMedia currentItem; */
 
157
    case eCurrentPositionTimecode:
 
158
      /* attribute ACString currentPositionTimecode; */
 
159
    case eCurrentPositionString:
 
160
      /* readonly attribute ACString currentPositionString; */
 
161
      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPControls);
 
162
      return StringVariant (_result, "");
 
163
 
 
164
    case eAudioLanguageCount:
 
165
      /* readonly attribute long audioLanguageCount; */
 
166
    case eCurrentAudioLanguage:
 
167
      /* attribute long currentAudioLanguage; */
 
168
    case eCurrentAudioLanguageIndex:
 
169
      /* attribute long currentAudioLanguageIndex; */
 
170
    case eCurrentMarker:
 
171
      /* attribute long currentMarker; */
 
172
      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPControls);
 
173
      return Int32Variant (_result, 0);
 
174
  }
 
175
 
 
176
  return false;
 
177
}
 
178
 
 
179
bool
 
180
totemGMPControls::SetPropertyByIndex (int aIndex,
 
181
                                      const NPVariant *aValue)
 
182
{
 
183
  TOTEM_LOG_SETTER (aIndex, totemGMPControls);
 
184
 
 
185
  switch (Properties (aIndex)) {
 
186
    case eCurrentAudioLanguage:
 
187
      /* attribute long currentAudioLanguage; */
 
188
    case eCurrentAudioLanguageIndex:
 
189
      /* attribute long currentAudioLanguageIndex; */
 
190
    case eCurrentItem:
 
191
      /* attribute totemIGMPMedia currentItem; */
 
192
    case eCurrentMarker:
 
193
      /* attribute long currentMarker; */
 
194
    case eCurrentPosition:
 
195
      /* attribute double currentPosition; */
 
196
    case eCurrentPositionTimecode:
 
197
      /* attribute ACString currentPositionTimecode; */
 
198
      TOTEM_WARN_SETTER_UNIMPLEMENTED(aIndex, totemGMPControls);
 
199
      return true;
 
200
 
 
201
    case eAudioLanguageCount:
 
202
      /* readonly attribute long audioLanguageCount; */
 
203
    case eCurrentPositionString:
 
204
      /* readonly attribute ACString currentPositionString; */
 
205
      return ThrowPropertyNotWritable ();
 
206
  }
 
207
 
 
208
  return false;
 
209
}