ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/DashInterface/Display.cpp
(Generate patch)

Comparing:
Audacious/Audacious.cpp (file contents), Revision 22 by douglas, 2008-02-08T06:19:12-08:00 vs.
GPS/GPS.cpp (file contents), Revision 25 by douglas, 2008-02-09T01:39:22-08:00

# Line 1 | Line 1
1 < // Beep Remote
1 > // GPS
2   //
3   // Douglas Thrift
4   //
5   // $Id$
6  
7 < #include <audacious/beepctrl.h>
7 > #include <cerrno>
8 > #include <iostream>
9 > #include <sstream>
10  
11 < #include "Audacious.hpp"
11 > #include <posix.hpp>
12  
13 < void Audacious::Playlist(char **list, int size, bool enqueue)
12 < {
13 <        ::xmms_remote_playlist(session, list, size, enqueue);
14 < }
15 <
16 < int Audacious::GetVersion() const
17 < {
18 <        return ::xmms_remote_get_version(session);
19 < }
20 <
21 < void Audacious::PlaylistAdd(::GList *list)
22 < {
23 <        ::xmms_remote_playlist_add(session, list);
24 < }
25 <
26 < void Audacious::PlaylistDelete(int position)
27 < {
28 <        ::xmms_remote_playlist_delete(session, position);
29 < }
30 <
31 < void Audacious::Play()
32 < {
33 <        ::xmms_remote_play(session);
34 < }
35 <
36 < void Audacious::Pause()
37 < {
38 <        ::xmms_remote_pause(session);
39 < }
40 <
41 < void Audacious::Stop()
42 < {
43 <        ::xmms_remote_stop(session);
44 < }
45 <
46 < bool Audacious::IsPlaying() const
47 < {
48 <        return ::xmms_remote_is_playing(session);
49 < }
50 <
51 < bool Audacious::IsPaused() const
52 < {
53 <        return ::xmms_remote_is_paused(session);
54 < }
55 <
56 < int Audacious::GetPlaylistPosition() const
57 < {
58 <        return ::xmms_remote_get_playlist_pos(session);
59 < }
60 <
61 < void Audacious::SetPlaylistPosition(int position)
62 < {
63 <        ::xmms_remote_set_playlist_pos(session, position);
64 < }
65 <
66 < int Audacious::GetPlaylistLength() const
67 < {
68 <        return ::xmms_remote_get_playlist_length(session);
69 < }
70 <
71 < void Audacious::PlaylistClear()
72 < {
73 <        return ::xmms_remote_playlist_clear(session);
74 < }
75 <
76 < int Audacious::GetOutputTime() const
77 < {
78 <        return ::xmms_remote_get_output_time(session);
79 < }
80 <
81 < void Audacious::JumpToTime(int position)
82 < {
83 <        ::xmms_remote_jump_to_time(session, position);
84 < }
85 <
86 < void Audacious::GetVolume(int& left, int& right) const
87 < {
88 <        ::xmms_remote_get_volume(session, &left, &right);
89 < }
90 <
91 < int Audacious::GetMainVolume() const
92 < {
93 <        return ::xmms_remote_get_main_volume(session);
94 < }
95 <
96 < int Audacious::GetBalance() const
97 < {
98 <        return ::xmms_remote_get_balance(session);
99 < }
100 <
101 < void Audacious::SetVolume(int left, int right)
102 < {
103 <        ::xmms_remote_set_volume(session, left, right);
104 < }
105 <
106 < void Audacious::SetMainVolume(int volume)
107 < {
108 <        ::xmms_remote_set_main_volume(session, volume);
109 < }
110 <
111 < void Audacious::SetBalance(int balance)
112 < {
113 <        ::xmms_remote_set_balance(session, balance);
114 < }
115 <
116 < std::string Audacious::GetSkin() const
117 < {
118 <        return ::xmms_remote_get_skin(session);
119 < }
120 <
121 < void Audacious::SetSkin(const std::string &skin)
122 < {
123 <        ::xmms_remote_set_skin(session, const_cast<char*>(skin.c_str()));
124 < }
125 <
126 < std::string Audacious::GetPlaylistFile(int position) const
127 < {
128 <        return ::xmms_remote_get_playlist_file(session, position);
129 < }
130 <
131 < std::string Audacious::GetPlaylistTitle(int position) const
132 < {
133 <        return ::xmms_remote_get_playlist_title(session, position);
134 < }
135 <
136 < int Audacious::GetPlaylistTime(int position) const
137 < {
138 <        return ::xmms_remote_get_playlist_time(session, position);
139 < }
140 <
141 < void Audacious::GetInfo(int &rate, int &frequency, int &channels) const
142 < {
143 <        ::xmms_remote_get_info(session, &rate, &frequency, &channels);
144 < }
145 <
146 < void Audacious::MainWindowToggle(bool show)
147 < {
148 <        ::xmms_remote_main_win_toggle(session, show);
149 < }
150 <
151 < void Audacious::PlaylistWindowToggle(bool show)
152 < {
153 <        ::xmms_remote_pl_win_toggle(session, show);
154 < }
155 <
156 < void Audacious::EqualizerWindowToggle(bool show)
157 < {
158 <        ::xmms_remote_eq_win_toggle(session, show);
159 < }
160 <
161 < bool Audacious::IsMainWindow() const
162 < {
163 <        return ::xmms_remote_is_main_win(session);
164 < }
13 > #include "GPS.hpp"
14  
15 < bool Audacious::IsPlaylistWindow() const
15 > namespace GPS
16   {
168        return ::xmms_remote_is_pl_win(session);
169 }
170
171 bool Audacious::IsEqualizerWindow() const
172 {
173        return ::xmms_remote_is_eq_win(session);
174 }
175
176 void Audacious::ShowPreferencesBox()
177 {
178        ::xmms_remote_show_prefs_box(session);
179 }
180
181 void Audacious::ToggleAlwaysOnTop(bool always)
182 {
183        ::xmms_remote_toggle_aot(session, always);
184 }
185
186 void Audacious::Eject()
187 {
188        ::xmms_remote_eject(session);
189 }
190
191 void Audacious::PlaylistPrevious()
192 {
193        ::xmms_remote_playlist_prev(session);
194 }
195
196 void Audacious::PlaylistNext()
197 {
198        ::xmms_remote_playlist_next(session);
199 }
200
201 void Audacious::PlaylistAddUrl(const std::string &url)
202 {
203        ::xmms_remote_playlist_add_url_string(session, const_cast<char*>(url.c_str()));
204 }
205
206 bool Audacious::IsRunning() const
207 {
208        return ::xmms_remote_is_running(session);
209 }
210
211 void Audacious::ToggleRepeat()
212 {
213        ::xmms_remote_toggle_repeat(session);
214 }
215
216 void Audacious::ToggleShuffle()
217 {
218        ::xmms_remote_toggle_shuffle(session);
219 }
220
221 bool Audacious::IsRepeat() const
222 {
223        return ::xmms_remote_is_repeat(session);
224 }
225
226 bool Audacious::IsShuffle() const
227 {
228        return ::xmms_remote_is_shuffle(session);
229 }
230
231 void Audacious::GetEqualizer(float& preamp, float bands[10]) const
232 {
233        float* bands_;
234
235        ::xmms_remote_get_eq(session, &preamp, &bands_);
236
237        _forall (uint8_t, index, 0, 10)
238                bands[index] = bands[index];
239
240        ::g_free(bands_);
241 }
242
243 float Audacious::GetEqualizerPreamp() const
244 {
245        return ::xmms_remote_get_eq_preamp(session);
246 }
17  
18 < float Audacious::GetEqualizerBand(int band) const
18 > Error::Error()
19   {
20 <        return ::xmms_remote_get_eq_band(session, band);
251 < }
252 <
253 < void Audacious::SetEqualizer(float preamp, float bands[10])
254 < {
255 <        ::xmms_remote_set_eq(session, preamp, bands);
256 < }
257 <
258 < void Audacious::SetEqualizerPreamp(float preamp)
259 < {
260 <        ::xmms_remote_set_eq_preamp(session, preamp);
261 < }
262 <
263 < void Audacious::SetEqualizerBand(int band, float value)
264 < {
265 <        ::xmms_remote_set_eq_band(session, band, value);
266 < }
267 <
268 < // XMMS 1.2.1
269 < void Audacious::Quit()
270 < {
271 <        ::xmms_remote_quit(session);
272 < }
273 <
274 < // XMMS 1.2.6
275 < void Audacious::PlayPause()
276 < {
277 <        ::xmms_remote_play_pause(session);
278 < }
279 <
280 < void Audacious::PlaylistInsertUrl(const std::string &url, int position)
281 < {
282 <        ::xmms_remote_playlist_ins_url_string(session, const_cast<char*>(url.c_str()), position);
283 < }
284 <
285 < // XMMS 1.2.11
286 < void Audacious::PlayqueueAdd(int position)
287 < {
288 <        ::xmms_remote_playqueue_add(session, position);
289 < }
290 <
291 < void Audacious::PlayqueueRemove(int position)
292 < {
293 <        ::xmms_remote_playqueue_remove(session, position);
294 < }
20 >        std::ostringstream message;
21  
22 < int Audacious::GetPlayqueueLength() const
297 < {
298 <        return ::xmms_remote_get_playqueue_length(session);
299 < }
22 >        message << _B("GPS[#") << errno << _B("] ");
23  
24 < void Audacious::ToggleAdvance()
25 < {
26 <        ::xmms_remote_toggle_advance(session);
27 < }
24 >        switch (errno)
25 >        {
26 >        case NL_NOSERVICE:
27 >                message << _B("can't get service entry");
28  
29 < bool Audacious::IsAdvance() const
30 < {
31 <        return ::xmms_remote_is_advance(session);
309 < }
29 >                break;
30 >        case NL_NOHOST:
31 >                message << _B("can't get host entry");
32  
33 < // BMP 0.9.7
34 < void Audacious::Activate()
35 < {
314 <        ::xmms_remote_activate(session);
315 < }
33 >                break;
34 >        case NL_NOPROTO:
35 >                message << _B("can't get protocol entry");
36  
37 < // Audacious 1.1
38 < void Audacious::ShowJumpToFileBox()
39 < {
320 <        ::xmms_remote_show_jtf_box(session);
321 < }
37 >                break;
38 >        case NL_NOSOCK:
39 >                message << _B("can't create socket");
40  
41 < void Audacious::PlayqueueClear()
42 < {
43 <        ::xmms_remote_playqueue_clear(session);
326 < }
41 >                break;
42 >        case NL_NOSOCKOPT:
43 >                message << _B("error SETSOCKOPT SO_REUSEADDR");
44  
45 < bool Audacious::PlayqueueIsQueued(int position) const
46 < {
47 <        return ::xmms_remote_playqueue_is_queued(session, position);
331 < }
45 >                break;
46 >        case NL_NOCONNECT:
47 >                message << _B("can't connect to host");
48  
49 < int Audacious::GetPlayqueuePosition(int position) const
50 < {
335 <        return ::xmms_remote_get_playqueue_position(session, position);
336 < }
49 >                break;
50 >        }
51  
52 < int Audacious::GetPlayqueueQueuePosition(int position) const
339 < {
340 <        return ::xmms_remote_get_playqueue_queue_position(session, position);
52 >        this->message = message.str();
53   }
54  
55 < // Audacious 1.2
344 < void Audacious::SetSessionUri(const std::string &uri)
55 > GPS::GPS(const std::string &host, const std::string &port) : gps(::gps_open(host.c_str(), port.c_str()))
56   {
57 <        ::audacious_set_session_uri(const_cast<char *>(uri.c_str()));
57 >        if (gps == NULL)
58 >                throw Error();
59   }
60  
61 < std::string Audacious::GetSessionUri() const
61 > void GPS::Poll()
62   {
63 <        return ::audacious_get_session_uri(session);
63 >        Posix::CheckError(::gps_poll(gps));
64   }
65  
66 < void Audacious::SetSessionType(Type type)
66 > void GPS::Query(const std::string &query)
67   {
68 <        ::audacious_set_session_type(type);
68 >        Posix::CheckError(::gps_query(gps, query.c_str()));
69   }
70  
359 // Audacious 1.3
360 void Audacious::PlaylistEnqueueToTemp(const std::string &string)
361 {
362        ::xmms_remote_playlist_enqueue_to_temp(session, const_cast<char *>(string.c_str()));
363 }
364
365 std::string Audacious::GetTupleFieldData(const std::string &field, int position)
366 {
367        return ::audacious_get_tuple_field_data(session, const_cast<char *>(field.c_str()), position);
71   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines