1 |
douglas |
23 |
// Audacious |
2 |
douglas |
6 |
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#ifndef _Audacious_hpp_ |
8 |
|
|
#define _Audacious_hpp_ |
9 |
|
|
|
10 |
douglas |
14 |
#include <cstdlib> |
11 |
|
|
#include <string> |
12 |
douglas |
6 |
|
13 |
douglas |
34 |
#include <dbus/dbus-glib.h> |
14 |
douglas |
6 |
#include <glib.h> |
15 |
|
|
|
16 |
douglas |
14 |
#include <foreach.hpp> |
17 |
|
|
|
18 |
douglas |
34 |
namespace Audacious |
19 |
|
|
{ |
20 |
|
|
|
21 |
|
|
class Error : public std::exception |
22 |
|
|
{ |
23 |
|
|
::GError *error; |
24 |
|
|
public: |
25 |
|
|
Error(::GError *error) : error(error) {} |
26 |
|
|
virtual ~Error() throw() { ::g_error_free(error); } |
27 |
|
|
virtual const char *what() const throw() { return error->message; } |
28 |
|
|
}; |
29 |
|
|
|
30 |
douglas |
6 |
class Audacious |
31 |
|
|
{ |
32 |
douglas |
34 |
::DBusGProxy *session; |
33 |
douglas |
6 |
public: |
34 |
douglas |
34 |
Audacious(); |
35 |
douglas |
6 |
|
36 |
|
|
template <typename Type_> |
37 |
douglas |
7 |
inline void Playlist(const Type_ &list, bool enqueue = false) |
38 |
douglas |
6 |
{ |
39 |
|
|
char **list_(NULL); |
40 |
|
|
int size(0); |
41 |
|
|
|
42 |
|
|
_tforeach (const Type_, item, list) |
43 |
|
|
{ |
44 |
douglas |
14 |
list_ = list_ ? std::realloc(list_, ++size) : std::malloc(++size); |
45 |
|
|
list_[_index] = const_cast<char *>(item->c_str()); |
46 |
douglas |
6 |
} |
47 |
|
|
|
48 |
|
|
Playlist(list_, size, enqueue); |
49 |
|
|
|
50 |
|
|
if (list_) |
51 |
douglas |
14 |
std::free(list_); |
52 |
douglas |
6 |
} |
53 |
|
|
|
54 |
|
|
void Playlist(char **list, int size, bool enqueue = false); |
55 |
douglas |
34 |
std::string GetVersion() const; |
56 |
douglas |
6 |
|
57 |
|
|
template <typename Type_> |
58 |
douglas |
7 |
inline void PlaylistAdd(const Type_ &list) |
59 |
douglas |
6 |
{ |
60 |
|
|
::GList *list_(NULL); |
61 |
|
|
|
62 |
|
|
_tforeach (const Type_, item, list) |
63 |
douglas |
14 |
list_ = ::g_list_append(list_, const_cast<char *>(item->c_str())); |
64 |
douglas |
6 |
|
65 |
|
|
PlaylistAdd(list_); |
66 |
|
|
::g_list_free(list_); |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
void PlaylistAdd(::GList *list); |
70 |
douglas |
34 |
void PlaylistDelete(unsigned position); |
71 |
douglas |
6 |
void Play(); |
72 |
|
|
void Pause(); |
73 |
|
|
void Stop(); |
74 |
|
|
bool IsPlaying() const; |
75 |
|
|
bool IsPaused() const; |
76 |
|
|
int GetPlaylistPosition() const; |
77 |
douglas |
34 |
void SetPlaylistPosition(unsigned position); |
78 |
douglas |
6 |
int GetPlaylistLength() const; |
79 |
|
|
void PlaylistClear(); |
80 |
|
|
int GetOutputTime() const; |
81 |
|
|
void JumpToTime(int position); |
82 |
douglas |
7 |
void GetVolume(int &left, int &right) const; |
83 |
douglas |
6 |
int GetMainVolume() const; |
84 |
|
|
int GetBalance() const; |
85 |
|
|
void SetVolume(int left, int right); |
86 |
|
|
void SetMainVolume(int volume); |
87 |
|
|
void SetBalance(int balance); |
88 |
douglas |
14 |
std::string GetSkin() const; |
89 |
|
|
void SetSkin(const std::string &skin); |
90 |
|
|
std::string GetPlaylistFile(int position) const; |
91 |
|
|
std::string GetPlaylistTitle(int position) const; |
92 |
douglas |
6 |
int GetPlaylistTime(int position) const; |
93 |
|
|
void GetInfo(int &rate, int &frequency, int &channels) const; |
94 |
|
|
void MainWindowToggle(bool show); |
95 |
|
|
void PlaylistWindowToggle(bool show); |
96 |
|
|
void EqualizerWindowToggle(bool show); |
97 |
|
|
bool IsMainWindow() const; |
98 |
|
|
bool IsPlaylistWindow() const; |
99 |
|
|
bool IsEqualizerWindow() const; |
100 |
|
|
void ShowPreferencesBox(); |
101 |
|
|
void ToggleAlwaysOnTop(bool always); |
102 |
|
|
void Eject(); |
103 |
|
|
void PlaylistPrevious(); |
104 |
|
|
void PlaylistNext(); |
105 |
douglas |
14 |
void PlaylistAddUrl(const std::string &url); |
106 |
douglas |
6 |
bool IsRunning() const; |
107 |
|
|
void ToggleRepeat(); |
108 |
|
|
void ToggleShuffle(); |
109 |
|
|
bool IsRepeat() const; |
110 |
|
|
bool IsShuffle() const; |
111 |
|
|
|
112 |
|
|
inline void ToggleRepeat(bool repeat) |
113 |
|
|
{ |
114 |
|
|
if (repeat != IsRepeat()) |
115 |
|
|
ToggleRepeat(); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
inline void ToggleShuffle(bool shuffle) |
119 |
|
|
{ |
120 |
|
|
if (shuffle != IsShuffle()) |
121 |
|
|
ToggleShuffle(); |
122 |
|
|
} |
123 |
|
|
|
124 |
douglas |
34 |
void GetEqualizer(double &preamp, double bands[10]) const; |
125 |
|
|
double GetEqualizerPreamp() const; |
126 |
|
|
double GetEqualizerBand(int band) const; |
127 |
|
|
void SetEqualizer(double preamp, double bands[10]); |
128 |
|
|
void SetEqualizerPreamp(double preamp); |
129 |
|
|
void SetEqualizerBand(int band, double value); |
130 |
douglas |
6 |
|
131 |
|
|
// XMMS 1.2.1 |
132 |
|
|
void Quit(); |
133 |
|
|
|
134 |
|
|
// XMMS 1.2.6 |
135 |
|
|
void PlayPause(); |
136 |
douglas |
14 |
void PlaylistInsertUrl(const std::string &url, int position); |
137 |
douglas |
6 |
|
138 |
|
|
// XMMS 1.2.11 |
139 |
|
|
void PlayqueueAdd(int position); |
140 |
|
|
void PlayqueueRemove(int position); |
141 |
douglas |
7 |
int GetPlayqueueLength() const; |
142 |
douglas |
6 |
void ToggleAdvance(); |
143 |
douglas |
7 |
bool IsAdvance() const; |
144 |
douglas |
6 |
|
145 |
|
|
inline void ToggleAdvance(bool advance) |
146 |
|
|
{ |
147 |
|
|
if (advance != IsAdvance()) |
148 |
|
|
ToggleAdvance(); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
// BMP 0.9.7 |
152 |
|
|
void Activate(); |
153 |
|
|
|
154 |
|
|
// Audacious 1.1 |
155 |
|
|
void ShowJumpToFileBox(); |
156 |
|
|
void PlayqueueClear(); |
157 |
|
|
bool PlayqueueIsQueued(int position) const; |
158 |
|
|
int GetPlayqueueQueuePosition(int position) const; |
159 |
|
|
|
160 |
|
|
// Audacious 1.3 |
161 |
douglas |
14 |
void PlaylistEnqueueToTemp(const std::string &string); |
162 |
|
|
std::string GetTupleFieldData(const std::string &field, int position); |
163 |
douglas |
34 |
|
164 |
|
|
// Audacious 1.4 |
165 |
|
|
void ShowAboutBox(); |
166 |
|
|
void ToggleAboutBox(bool show); |
167 |
|
|
void ToggleJumpToFileBox(bool show); |
168 |
|
|
void TogglePreferencesBox(bool show); |
169 |
|
|
void ToggleFileBrowser(bool show); |
170 |
|
|
void EqualizerActivate(bool active); |
171 |
douglas |
6 |
}; |
172 |
|
|
|
173 |
|
|
template <> |
174 |
douglas |
14 |
inline void Audacious::PlaylistAdd(const std::string &item) |
175 |
douglas |
7 |
{ |
176 |
douglas |
14 |
::GList list = { const_cast<char *>(item.c_str()), NULL, NULL }; |
177 |
douglas |
6 |
|
178 |
douglas |
7 |
PlaylistAdd(&list); |
179 |
|
|
} |
180 |
|
|
|
181 |
douglas |
34 |
} |
182 |
|
|
|
183 |
douglas |
6 |
#endif//_Audacious_hpp_ |