~phablet-team/aethercast/fix-for-microsoft-dongle

« back to all changes in this revision

Viewing changes to src/mcs/miracastcontrollerskeleton.cpp

  • Committer: Tarmac
  • Author(s): Simon Fels
  • Date: 2016-03-04 14:14:09 UTC
  • mfrom: (119.4.12 ac-networking-fixes)
  • Revision ID: tarmac-20160304141409-xe8khdgb43nha1fn
Multiple changes for Networking support:

* Add a DisconnectAll dbus method to allow the UI to easily disconnect
  any connected device. Just for the purpose of a demo.
* Return proper errors when scanning fails.
* Enable miracast mode for the WiFi driver if available.
* Set GO intent by default to 7. Should be higher if we're a sink.
* Print frequencies consider for GO negotiation
* Several minor fixes
* Enable unit tests again.

Approved by PS Jenkins bot, Thomas Voß.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
                     G_CALLBACK(&MiracastControllerSkeleton::OnHandleScan), new WeakKeepAlive<MiracastControllerSkeleton>(inst),
120
120
                     [](gpointer data, GClosure *) { delete static_cast<WeakKeepAlive<MiracastControllerSkeleton>*>(data); }, GConnectFlags(0));
121
121
 
 
122
    g_signal_connect_data(inst->manager_obj_.get(), "handle-disconnect-all",
 
123
                     G_CALLBACK(&MiracastControllerSkeleton::OnHandleDisconnectAll), new WeakKeepAlive<MiracastControllerSkeleton>(inst),
 
124
                     [](gpointer data, GClosure *) { delete static_cast<WeakKeepAlive<MiracastControllerSkeleton>*>(data); }, GConnectFlags(0));
 
125
 
122
126
    inst->SyncProperties();
123
127
 
124
128
    g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(inst->manager_obj_.get()),
142
146
 
143
147
    INFO("Scanning for remote devices");
144
148
 
145
 
    inst->Scan();
 
149
    const auto error = inst->Scan();
 
150
    if (error != mcs::Error::kNone) {
 
151
        g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "%s", mcs::ErrorToString(error).c_str());
 
152
        return TRUE;
 
153
    }
146
154
 
147
155
    g_dbus_method_invocation_return_value(invocation, nullptr);
148
156
 
149
157
    return TRUE;
150
158
}
151
159
 
 
160
gboolean MiracastControllerSkeleton::OnHandleDisconnectAll(AethercastInterfaceManager *skeleton,
 
161
                                                           GDBusMethodInvocation *invocation, gpointer user_data) {
 
162
    boost::ignore_unused_variable_warning(skeleton);
 
163
    const auto inst = static_cast<WeakKeepAlive<MiracastControllerSkeleton>*>(user_data)->GetInstance().lock();
 
164
 
 
165
    if (not inst) {
 
166
        g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Invalid state");
 
167
        return TRUE;
 
168
    }
 
169
 
 
170
    g_object_ref(invocation);
 
171
    auto inv = make_shared_gobject(invocation);
 
172
 
 
173
    inst->DisconnectAll([inv](mcs::Error error) {
 
174
        if (error != Error::kNone) {
 
175
            g_dbus_method_invocation_return_error(inv.get(), G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
 
176
                                                  "%s", mcs::ErrorToString(error).c_str());
 
177
            return;
 
178
        }
 
179
 
 
180
        g_dbus_method_invocation_return_value(inv.get(), nullptr);
 
181
    });
 
182
 
 
183
    return TRUE;
 
184
}
 
185
 
152
186
std::shared_ptr<MiracastControllerSkeleton> MiracastControllerSkeleton::FinalizeConstruction() {
153
187
    auto sp = shared_from_this();
154
188