~woodrow-shen/totem/mybranch

« back to all changes in this revision

Viewing changes to browser-plugin/totemConeAudio.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 Cone 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 "totemConeAudio.h"
 
31
 
 
32
static const char *propertyNames[] = {
 
33
  "channel"
 
34
  "mute",
 
35
  "track",
 
36
  "volume",
 
37
};
 
38
 
 
39
static const char *methodNames[] = {
 
40
  "toggleMute"
 
41
};
 
42
 
 
43
TOTEM_IMPLEMENT_NPCLASS (totemConeAudio,
 
44
                         propertyNames, G_N_ELEMENTS (propertyNames),
 
45
                         methodNames, G_N_ELEMENTS (methodNames),
 
46
                         NULL);
 
47
 
 
48
totemConeAudio::totemConeAudio (NPP aNPP)
 
49
  : totemNPObject (aNPP),
 
50
    mMute (false),
 
51
    mSavedVolume (0.5)
 
52
{
 
53
  TOTEM_LOG_CTOR ();
 
54
}
 
55
 
 
56
totemConeAudio::~totemConeAudio ()
 
57
{
 
58
  TOTEM_LOG_DTOR ();
 
59
}
 
60
 
 
61
bool
 
62
totemConeAudio::InvokeByIndex (int aIndex,
 
63
                               const NPVariant *argv,
 
64
                               uint32_t argc,
 
65
                               NPVariant *_result)
 
66
{
 
67
  TOTEM_LOG_INVOKE (aIndex, totemConeAudio);
 
68
 
 
69
  switch (Methods (aIndex)) {
 
70
    case eToggleMute: {
 
71
      /* FIXMEchpe this sucks */
 
72
      NPVariant mute;
 
73
      BOOLEAN_TO_NPVARIANT (!mMute, mute);
 
74
      return SetPropertyByIndex (eMute, &mute);
 
75
    }
 
76
  }
 
77
 
 
78
  return false;
 
79
}
 
80
 
 
81
bool
 
82
totemConeAudio::GetPropertyByIndex (int aIndex,
 
83
                                    NPVariant *_result)
 
84
{
 
85
  TOTEM_LOG_GETTER (aIndex, totemConeAudio);
 
86
 
 
87
  switch (Properties (aIndex)) {
 
88
    case eMute:
 
89
      return BoolVariant (_result, Plugin()->IsMute());
 
90
      
 
91
    case eVolume:
 
92
      return Int32Variant (_result, Plugin()->Volume() * 200.0);
 
93
 
 
94
    case eChannel:
 
95
    case eTrack:
 
96
      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
 
97
      return VoidVariant (_result);
 
98
  }
 
99
 
 
100
  return false;
 
101
}
 
102
 
 
103
bool
 
104
totemConeAudio::SetPropertyByIndex (int aIndex,
 
105
                                    const NPVariant *aValue)
 
106
{
 
107
  TOTEM_LOG_SETTER (aIndex, totemConeAudio);
 
108
 
 
109
  switch (Properties (aIndex)) {
 
110
    case eVolume: {
 
111
      int32_t volume;
 
112
      if (!GetInt32FromArguments (aValue, 1, 0, volume))
 
113
        return false;
 
114
 
 
115
      Plugin()->SetVolume ((double) CLAMP (volume, 0, 200) / 200.0);
 
116
      return true;
 
117
    }
 
118
 
 
119
    case eMute: {
 
120
      if (!GetBoolFromArguments (aValue, 1, 0, mMute))
 
121
        return false;
 
122
 
 
123
      if (mMute) {
 
124
        mSavedVolume = Plugin()->Volume();
 
125
        Plugin()->SetVolume (0.0);
 
126
      } else {
 
127
        Plugin()->SetVolume (mSavedVolume);
 
128
      }
 
129
      return true;
 
130
    }
 
131
 
 
132
    case eChannel:
 
133
    case eTrack:
 
134
      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, _result);
 
135
      return true;
 
136
  }
 
137
 
 
138
  return false;
 
139
}