~albaguirre/unity-system-compositor/mock-implement-new-display-method

« back to all changes in this revision

Viewing changes to src/powerd_mediator.cpp

Split out the single DBusConnectionHandle from DBusConnectionThread

This allows having multiple connection names that actually work. As opposed to assigning multiple connection names to a single DBusConnection, in which case the first one wins. Fixes: https://bugs.launchpad.net/bugs/1536383.

Approved by PS Jenkins bot, Alexandros Frantzis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
}
46
46
 
47
47
usc::PowerdMediator::PowerdMediator(std::string const& bus_addr)
48
 
    : connection{bus_addr.c_str()},
49
 
      dbus_event_loop{connection},
 
48
    : connection{std::make_shared<DBusConnectionHandle>(bus_addr.c_str())},
50
49
      pending_suspend_block_request{false},
51
50
      dim_brightness_{10},
52
51
      min_brightness_{0},
59
58
      proximity_enabled{false},
60
59
      sys_state{SysState::unknown}
61
60
{
62
 
    connection.add_match(
 
61
    dbus_event_loop.add_connection(connection);
 
62
    connection->add_match(
63
63
        "type='signal',"
64
64
        "sender='com.canonical.powerd',"
65
65
        "interface='com.canonical.powerd',"
66
66
        "member='SysPowerStateChange'");
67
 
    connection.add_match(
 
67
    connection->add_match(
68
68
        "type='signal',"
69
69
        "sender='org.freedesktop.DBus',"
70
70
        "interface='org.freedesktop.DBus',"
71
71
        "member='NameOwnerChanged'");
72
 
    connection.add_filter(handle_dbus_message_thunk, this);
 
72
    connection->add_filter(handle_dbus_message_thunk, this);
73
73
 
74
74
    std::promise<void> event_loop_started;
75
75
    auto event_loop_started_future = event_loop_started.get_future();
477
477
        [this, &msg, &reply_promise]
478
478
        {
479
479
            auto const reply = dbus_connection_send_with_reply_and_block(
480
 
                connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr);
 
480
                *connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr);
481
481
 
482
482
            reply_promise.set_value(reply);
483
483
        };