~ubuntu-branches/ubuntu/trusty/location-service/trusty

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/service/session/skeleton.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, thomas-voss
  • Date: 2014-02-04 12:36:02 UTC
  • mfrom: (1.1.17)
  • Revision ID: package-import@ubuntu.com-20140204123602-tges6gy8vtpa3oan
Tags: 0.0.2+14.04.20140204-0ubuntu1
[ thomas-voss ]
* * Fix a race when a session is created while another one ends. *
  Ensure a sensible minimum interval between consecutive location
  updates in the GPS provider. (LP: #1240878)
* Adjust to changes in new dbus-cpp version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
#include "com/ubuntu/location/service/session/skeleton.h"
19
19
 
20
 
#include <org/freedesktop/dbus/message.h>
21
 
#include <org/freedesktop/dbus/skeleton.h>
 
20
#include <core/dbus/message.h>
 
21
#include <core/dbus/object.h>
 
22
#include <core/dbus/skeleton.h>
22
23
 
23
24
#include <functional>
24
25
 
26
27
namespace culs = com::ubuntu::location::service;
27
28
namespace culss = com::ubuntu::location::service::session;
28
29
 
29
 
namespace dbus = org::freedesktop::dbus;
 
30
namespace dbus = core::dbus;
30
31
 
31
32
struct culss::Skeleton::Private
32
33
{
33
 
    void handle_start_position_updates(DBusMessage* msg);
34
 
    void handle_stop_position_updates(DBusMessage* msg);
35
 
 
36
 
    void handle_start_velocity_updates(DBusMessage* msg);
37
 
    void handle_stop_velocity_updates(DBusMessage* msg);
38
 
 
39
 
    void handle_start_heading_updates(DBusMessage* msg);
40
 
    void handle_stop_heading_updates(DBusMessage* msg);
 
34
    void handle_start_position_updates(const core::dbus::Message::Ptr& msg);
 
35
    void handle_stop_position_updates(const core::dbus::Message::Ptr& msg);
 
36
 
 
37
    void handle_start_velocity_updates(const core::dbus::Message::Ptr& msg);
 
38
    void handle_stop_velocity_updates(const core::dbus::Message::Ptr& msg);
 
39
 
 
40
    void handle_start_heading_updates(const core::dbus::Message::Ptr& msg);
 
41
    void handle_stop_heading_updates(const core::dbus::Message::Ptr& msg);
41
42
 
42
43
    Skeleton* parent;
43
44
    dbus::Bus::Ptr bus;
98
99
    return d->session_path;
99
100
}
100
101
 
101
 
void culss::Skeleton::Private::handle_start_position_updates(DBusMessage* msg)
 
102
void culss::Skeleton::Private::handle_start_position_updates(const core::dbus::Message::Ptr& msg)
102
103
{
103
104
    try
104
105
    {
105
106
        parent->start_position_updates();
106
107
        auto reply = dbus::Message::make_method_return(msg);
107
 
        bus->send(reply->get());
 
108
        bus->send(reply);
108
109
    } catch(const std::runtime_error& e)
109
110
    {
110
 
        auto error = org::freedesktop::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what());
111
 
        bus->send(error->get());
 
111
        auto error = core::dbus::Message::make_error(
 
112
                    msg,
 
113
                    Interface::Errors::ErrorStartingUpdate::name(),
 
114
                    e.what());
 
115
 
 
116
        bus->send(error);
112
117
    }
113
118
}
114
119
 
115
 
void culss::Skeleton::Private::handle_stop_position_updates(DBusMessage* msg)
 
120
void culss::Skeleton::Private::handle_stop_position_updates(const core::dbus::Message::Ptr& msg)
116
121
{
117
122
    parent->stop_position_updates();
118
 
    auto reply = org::freedesktop::dbus::Message::make_method_return(msg);
119
 
    bus->send(reply->get());
 
123
    auto reply = core::dbus::Message::make_method_return(msg);
 
124
    bus->send(reply);
120
125
}
121
126
 
122
 
void culss::Skeleton::Private::handle_start_velocity_updates(DBusMessage* msg)
 
127
void culss::Skeleton::Private::handle_start_velocity_updates(const core::dbus::Message::Ptr& msg)
123
128
{
124
129
    try
125
130
    {
126
131
        parent->start_velocity_updates();
127
 
        auto reply = org::freedesktop::dbus::Message::make_method_return(msg);
128
 
        bus->send(reply->get());
 
132
        auto reply = core::dbus::Message::make_method_return(msg);
 
133
        bus->send(reply);
129
134
    } catch(const std::runtime_error& e)
130
135
    {
131
 
        auto error = org::freedesktop::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what());
132
 
        bus->send(error->get());
 
136
        auto error = core::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what());
 
137
        bus->send(error);
133
138
    }
134
139
}
135
140
 
136
 
void culss::Skeleton::Private::handle_stop_velocity_updates(DBusMessage* msg)
 
141
void culss::Skeleton::Private::handle_stop_velocity_updates(const core::dbus::Message::Ptr& msg)
137
142
{
138
143
    parent->stop_velocity_updates();
139
 
    auto reply = org::freedesktop::dbus::Message::make_method_return(msg);
140
 
    bus->send(reply->get());
 
144
    auto reply = core::dbus::Message::make_method_return(msg);
 
145
    bus->send(reply);
141
146
}
142
147
 
143
 
void culss::Skeleton::Private::handle_start_heading_updates(DBusMessage* msg)
 
148
void culss::Skeleton::Private::handle_start_heading_updates(const core::dbus::Message::Ptr& msg)
144
149
{
145
150
    try
146
151
    {
147
152
        parent->start_heading_updates();
148
 
        auto reply = org::freedesktop::dbus::Message::make_method_return(msg);
149
 
        bus->send(reply->get());
 
153
        auto reply = core::dbus::Message::make_method_return(msg);
 
154
        bus->send(reply);
150
155
    } catch(const std::runtime_error& e)
151
156
    {
152
 
        auto error = org::freedesktop::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what());
153
 
        bus->send(error->get());
 
157
        auto error = core::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what());
 
158
        bus->send(error);
154
159
    }
155
160
}
156
161
 
157
 
void culss::Skeleton::Private::handle_stop_heading_updates(DBusMessage* msg)
 
162
void culss::Skeleton::Private::handle_stop_heading_updates(const core::dbus::Message::Ptr& msg)
158
163
{
159
164
    parent->stop_heading_updates();
160
 
    auto reply = org::freedesktop::dbus::Message::make_method_return(msg);
161
 
    bus->send(reply->get());
 
165
    auto reply = core::dbus::Message::make_method_return(msg);
 
166
    bus->send(reply);
162
167
}