D-Bus server: fixed HTTP presence for recent libdbus

Testing with libdbus 1.6.0 on Debian Testing failed because the
lib changed some behavior: instead of looking up the owner of
a certain bus name immediately, it now does that when invoking
a method. Therefore the check for "have connection" in NetworkManager
and ConnMan client code was too simplistic and missed the fact that
both were not usable, causing the server to assume that HTTP was down
while in reality it should have assumed it to be up.
This commit is contained in:
Patrick Ohly 2012-07-12 15:53:48 +00:00
parent 7b48710114
commit 93f2020ef0
4 changed files with 10 additions and 2 deletions

View File

@ -30,6 +30,7 @@ ConnmanClient::ConnmanClient(Server &server):
"SYSTEM" /* use real ConnMan */,
NULL, true, NULL),
"/", "net.connman.Manager", "net.connman", true),
m_available(false),
m_server(server),
m_propertyChanged(*this, "PropertyChanged")
{
@ -46,6 +47,7 @@ ConnmanClient::ConnmanClient(Server &server):
void ConnmanClient::getPropCb (const std::map <std::string,
boost::variant<std::string> >& props, const string &error){
if (!error.empty()) {
m_available = false;
if (error == "org.freedesktop.DBus.Error.ServiceUnknown") {
// ensure there is still first set of singal set in case of no
// connman available
@ -57,6 +59,7 @@ void ConnmanClient::getPropCb (const std::map <std::string,
return;
}
m_available = true;
typedef std::pair <std::string, boost::variant<std::string> > element;
bool httpPresence = false;
BOOST_FOREACH (element entry, props) {

View File

@ -45,9 +45,10 @@ public:
void getPropCb(const std::map <std::string, boost::variant<std::string> >& props, const std::string &error);
/** TRUE if watching ConnMan status */
bool isAvailable() { return getConnection() != NULL; }
bool isAvailable() { return m_available; }
private:
bool m_available;
Server &m_server;
GDBusCXX::SignalWatch2 <std::string, boost::variant<std::string> > m_propertyChanged;

View File

@ -34,6 +34,7 @@ NetworkManagerClient::NetworkManagerClient(Server &server) :
"org.freedesktop.NetworkManager",
"org.freedesktop.NetworkManager",
true),
m_available(false),
m_server(server),
m_stateChanged(*this, "StateChanged"),
m_properties(*this)
@ -98,6 +99,8 @@ void NetworkManagerClient::NetworkManagerProperties::getCallback(
"Error in calling Get of Interface "
"org.freedesktop.DBus.Properties : %s", error.c_str());
} else {
// Now, and only now, do we know that NetworkManager is running.
m_manager.m_available = true;
m_manager.stateChanged(boost::get<uint32_t>(prop));
}
}

View File

@ -63,9 +63,10 @@ public:
void stateChanged(uint32_t uiState);
/** TRUE if watching Network Manager status */
bool isAvailable() { return getConnection() != NULL; }
bool isAvailable() { return m_available; }
private:
bool m_available;
class NetworkManagerProperties : public DBusRemoteObject
{