MCPcopy Create free account
hub / github.com/WiVRn/WiVRn / create_dbus_connection

Function create_dbus_connection

server/main.cpp:909–937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907}
908
909auto create_dbus_connection()
910{
911 // When process has cap_sys_nice, DBUS_SESSION_BUS_ADDRESS is ignored by gdbus
912 GError * error = nullptr;
913 if (const char * bus_address = getenv("DBUS_SESSION_BUS_ADDRESS"))
914 {
915 auto connection = g_dbus_connection_new_for_address_sync(
916 bus_address,
917 GDBusConnectionFlags(G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION | G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT),
918 nullptr,
919 nullptr,
920 &error);
921 if (error)
922 {
923 auto msg = std::string("Failed to connect to dbus at ") + bus_address + ": " + error->message;
924 g_error_free(error);
925 throw std::runtime_error(msg);
926 }
927 return connection;
928 }
929 auto connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error);
930 if (error)
931 {
932 auto msg = std::string("Failed to connect to session bus: ") + error->message;
933 g_error_free(error);
934 throw std::runtime_error(msg);
935 }
936 return connection;
937}
938
939} // namespace
940

Callers 1

inner_mainFunction · 0.85

Calls 1

stringClass · 0.50

Tested by

no test coverage detected