~morphis/aethercast/audio-streaming

« back to all changes in this revision

Viewing changes to src/w11tng/peerstub.cpp

  • Committer: Simon Fels
  • Date: 2016-05-26 10:05:07 UTC
  • mfrom: (140.2.8 trunk)
  • Revision ID: simon.fels@canonical.com-20160526100507-u3lr0hbmwv6a9ppc
Merge branch 'cleanup-things'

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include <sstream>
19
19
 
20
 
#include <mcs/keep_alive.h>
21
 
#include <mcs/logger.h>
22
 
#include <mcs/utils.h>
 
20
#include <ac/keep_alive.h>
 
21
#include <ac/logger.h>
 
22
#include <ac/utils.h>
23
23
 
24
24
#include "peerstub.h"
25
25
 
35
35
    GError *error = nullptr;
36
36
    connection_.reset(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error));
37
37
    if (!connection_) {
38
 
        MCS_ERROR("Failed to connect to system bus: %s", error->message);
 
38
        AC_ERROR("Failed to connect to system bus: %s", error->message);
39
39
        g_error_free(error);
40
40
        return sp;
41
41
    }
46
46
                                  nullptr,
47
47
                                  [](GObject *source, GAsyncResult *res, gpointer user_data) {
48
48
 
49
 
        auto inst = static_cast<mcs::SharedKeepAlive<PeerStub>*>(user_data)->ShouldDie();
 
49
        auto inst = static_cast<ac::SharedKeepAlive<PeerStub>*>(user_data)->ShouldDie();
50
50
 
51
51
        GError *error = nullptr;
52
52
        inst->proxy_.reset(wpa_supplicant_peer_proxy_new_finish(res, &error));
53
53
        if (!inst->proxy_) {
54
 
            MCS_ERROR("Failed to connect with Peer proxy: %s", error->message);
 
54
            AC_ERROR("Failed to connect with Peer proxy: %s", error->message);
55
55
            g_error_free(error);
56
56
            return;
57
57
        }
62
62
        if (auto sp = inst->delegate_.lock())
63
63
            sp->OnPeerReady();
64
64
 
65
 
    }, new mcs::SharedKeepAlive<PeerStub>{shared_from_this()});
 
65
    }, new ac::SharedKeepAlive<PeerStub>{shared_from_this()});
66
66
 
67
67
    return sp;
68
68
}
69
69
 
70
70
void PeerStub::OnPropertyChanged(GObject *source, GParamSpec *spec, gpointer user_data) {
71
 
    auto inst = static_cast<mcs::WeakKeepAlive<PeerStub>*>(user_data)->GetInstance().lock();
 
71
    auto inst = static_cast<ac::WeakKeepAlive<PeerStub>*>(user_data)->GetInstance().lock();
72
72
 
73
73
    if (not inst)
74
74
        return;
78
78
 
79
79
void PeerStub::ConnectSignals() {
80
80
    g_signal_connect_data(proxy_.get(), "notify::device-name",
81
 
                          G_CALLBACK(&PeerStub::OnPropertyChanged), new mcs::WeakKeepAlive<PeerStub>(shared_from_this()),
82
 
                          [](gpointer data, GClosure *) { delete static_cast<mcs::WeakKeepAlive<PeerStub>*>(data); },
 
81
                          G_CALLBACK(&PeerStub::OnPropertyChanged), new ac::WeakKeepAlive<PeerStub>(shared_from_this()),
 
82
                          [](gpointer data, GClosure *) { delete static_cast<ac::WeakKeepAlive<PeerStub>*>(data); },
83
83
                          GConnectFlags(0));
84
84
 
85
85
    g_signal_connect_data(proxy_.get(), "notify::device-address",
86
 
                          G_CALLBACK(&PeerStub::OnPropertyChanged), new mcs::WeakKeepAlive<PeerStub>(shared_from_this()),
87
 
                          [](gpointer data, GClosure *) { delete static_cast<mcs::WeakKeepAlive<PeerStub>*>(data); },
 
86
                          G_CALLBACK(&PeerStub::OnPropertyChanged), new ac::WeakKeepAlive<PeerStub>(shared_from_this()),
 
87
                          [](gpointer data, GClosure *) { delete static_cast<ac::WeakKeepAlive<PeerStub>*>(data); },
88
88
                          GConnectFlags(0));
89
89
 
90
90
}
95
95
 
96
96
    std::stringstream ss;
97
97
    for (int n = 0; n < 6; n++) {
98
 
        ss << mcs::Utils::Sprintf("%02x", (uint16_t) (data[n] & 0xff));
 
98
        ss << ac::Utils::Sprintf("%02x", (uint16_t) (data[n] & 0xff));
99
99
        //ss << buf;
100
100
        if (n < 5)
101
101
            ss << ":";
154
154
    delegate_.reset();
155
155
}
156
156
 
157
 
mcs::MacAddress PeerStub::Address() const {
 
157
ac::MacAddress PeerStub::Address() const {
158
158
    return address_;
159
159
}
160
160