ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/Audacious/Audacious.hpp
Revision: 34
Committed: 2008-03-02T17:28:19-08:00 (14 years, 9 months ago) by douglas
File size: 4227 byte(s)
Log Message:
Welcome to the horrible Glib doom that is Audacious 1.4, die in a fire!

File Contents

# Content
1 // Audacious
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 <dbus/dbus-glib.h>
14 #include <glib.h>
15
16 #include <foreach.hpp>
17
18 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 class Audacious
31 {
32 ::DBusGProxy *session;
33 public:
34 Audacious();
35
36 template <typename Type_>
37 inline void Playlist(const Type_ &list, bool enqueue = false)
38 {
39 char **list_(NULL);
40 int size(0);
41
42 _tforeach (const Type_, item, list)
43 {
44 list_ = list_ ? std::realloc(list_, ++size) : std::malloc(++size);
45 list_[_index] = const_cast<char *>(item->c_str());
46 }
47
48 Playlist(list_, size, enqueue);
49
50 if (list_)
51 std::free(list_);
52 }
53
54 void Playlist(char **list, int size, bool enqueue = false);
55 std::string GetVersion() const;
56
57 template <typename Type_>
58 inline void PlaylistAdd(const Type_ &list)
59 {
60 ::GList *list_(NULL);
61
62 _tforeach (const Type_, item, list)
63 list_ = ::g_list_append(list_, const_cast<char *>(item->c_str()));
64
65 PlaylistAdd(list_);
66 ::g_list_free(list_);
67 }
68
69 void PlaylistAdd(::GList *list);
70 void PlaylistDelete(unsigned position);
71 void Play();
72 void Pause();
73 void Stop();
74 bool IsPlaying() const;
75 bool IsPaused() const;
76 int GetPlaylistPosition() const;
77 void SetPlaylistPosition(unsigned position);
78 int GetPlaylistLength() const;
79 void PlaylistClear();
80 int GetOutputTime() const;
81 void JumpToTime(int position);
82 void GetVolume(int &left, int &right) const;
83 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 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 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 void PlaylistAddUrl(const std::string &url);
106 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 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
131 // XMMS 1.2.1
132 void Quit();
133
134 // XMMS 1.2.6
135 void PlayPause();
136 void PlaylistInsertUrl(const std::string &url, int position);
137
138 // XMMS 1.2.11
139 void PlayqueueAdd(int position);
140 void PlayqueueRemove(int position);
141 int GetPlayqueueLength() const;
142 void ToggleAdvance();
143 bool IsAdvance() const;
144
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 void PlaylistEnqueueToTemp(const std::string &string);
162 std::string GetTupleFieldData(const std::string &field, int position);
163
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 };
172
173 template <>
174 inline void Audacious::PlaylistAdd(const std::string &item)
175 {
176 ::GList list = { const_cast<char *>(item.c_str()), NULL, NULL };
177
178 PlaylistAdd(&list);
179 }
180
181 }
182
183 #endif//_Audacious_hpp_

Properties

Name Value
svn:keywords Id