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

Comparing:
SteeringWheelRemote/Audacious.cpp (file contents), Revision 6 by douglas, 2007-05-06T21:04:16-07: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 < }
13 > #include "GPS.hpp"
14  
15 < int Audacious::GetVersion() const
15 > namespace GPS
16   {
18        return ::xmms_remote_get_version(session);
19 }
17  
18 < int Audacious::GetMainVolume() const
18 > Error::Error()
19   {
20 <        return ::xmms_remote_get_main_volume(session);
24 < }
20 >        std::ostringstream message;
21  
22 < void Audacious::SetMainVolume(int volume)
23 < {
24 <        ::xmms_remote_set_main_volume(session, volume);
22 >        message << _B("GPS[#") << errno << _B("] ");
23 >
24 >        switch (errno)
25 >        {
26 >        case NL_NOSERVICE:
27 >                message << _B("can't get service entry");
28 >
29 >                break;
30 >        case NL_NOHOST:
31 >                message << _B("can't get host entry");
32 >
33 >                break;
34 >        case NL_NOPROTO:
35 >                message << _B("can't get protocol entry");
36 >
37 >                break;
38 >        case NL_NOSOCK:
39 >                message << _B("can't create socket");
40 >
41 >                break;
42 >        case NL_NOSOCKOPT:
43 >                message << _B("error SETSOCKOPT SO_REUSEADDR");
44 >
45 >                break;
46 >        case NL_NOCONNECT:
47 >                message << _B("can't connect to host");
48 >
49 >                break;
50 >        }
51 >
52 >        this->message = message.str();
53   }
54  
55 < void Audacious::PlaylistPrevious()
55 > GPS::GPS(const std::string &host, const std::string &port) : gps(::gps_open(host.c_str(), port.c_str()))
56   {
57 <        ::xmms_remote_playlist_prev(session);
57 >        if (gps == NULL)
58 >                throw Error();
59   }
60  
61 < void Audacious::PlaylistNext()
61 > void GPS::Poll()
62   {
63 <        ::xmms_remote_playlist_next(session);
63 >        Posix::CheckError(::gps_poll(gps));
64   }
65  
66 < bool Audacious::IsRunning() const
66 > void GPS::Query(const std::string &query)
67   {
68 <        return ::xmms_remote_is_running(session);
68 >        Posix::CheckError(::gps_query(gps, query.c_str()));
69   }
70  
46 void Audacious::PlayPause()
47 {
48        ::xmms_remote_play_pause(session);
71   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines