void processCurrentAuthCandidate() { if (currentAuthCandidate!=authCandidates.end() && hueComm.findInProgress) { // try to authorize FOCUSLOG("Auth candidate: uuid=%s, baseURL=%s -> try creating user", currentAuthCandidate->first.c_str(), currentAuthCandidate->second.c_str()); JsonObjectPtr request = JsonObject::newObj(); request->add("username", JsonObject::newString(userName)); request->add("devicetype", JsonObject::newString(deviceType)); hueComm.apiAction(httpMethodPOST, currentAuthCandidate->second.c_str(), request, boost::bind(&BridgeFinder::handleCreateUserAnswer, this, _1, _2), true); } else { // done with all candidates (or find aborted in hueComm) if (authCandidates.size()>0 && MainLoop::now()<startedAuth+authTimeWindow && hueComm.findInProgress) { // we have still candidates and time to do a retry in a second, and find is not aborted retryLoginTicket = MainLoop::currentMainLoop().executeOnce(boost::bind(&BridgeFinder::attemptPairingWithCandidates, this), 1*Second); return; } else { // all candidates tried, nothing found in given time LOG(LOG_NOTICE, "Could not register with a hue bridge"); hueComm.findInProgress = false; callback(ErrorPtr(new HueCommError(HueCommErrorNoRegistration, "No hue bridge found ready to register"))); // done! keepAlive.reset(); // will delete object if nobody else keeps it return; } } }
int CGraphItem::GetProperties(StringStringMap & results) const { results = m_propStringString; return results.size(); }