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