QString Api::tryGetCountryCode(CancellationToken cancellationToken) const { qInfo() << "Getting the country code"; try { ApiConnectionSettings connectionSettings(Config::geolocationApiUrl, QStringList()); ApiConnectionStrategy strategy(connectionSettings, Config::geolocationTimeout, Config::geolocationTimeout); QString path = "v1/country"; QBuffer buffer; if (!strategy.execute(m_dataSource, path, buffer, cancellationToken)) { throw ApiConnectionError("Failed to connect to the api."); } auto document = QJsonDocument::fromBinaryData(buffer.data()); return document.object()["country"].toString(); } catch (ApiConnectionError&) { return QString(); } }
// Updatee connects to established member and stores credentials // in the qpid.cluster-credentials exchange to prove it // is safe for updater to connect and give an update. void Cluster::authenticate() { if (!broker.getOptions().auth) return; std::vector<Url> urls = initMap.getUrls(); for (std::vector<Url>::iterator i = urls.begin(); i != urls.end(); ++i) { if (!i->empty()) { client::Connection c; c.open(*i, connectionSettings(settings)); AutoClose<client::Connection> closeConnection(c); client::Session s = c.newSession(CredentialsExchange::NAME); AutoClose<client::Session> closeSession(s); client::Message credentials; credentials.getHeaders().setUInt64(CredentialsExchange::NAME, getId()); s.messageTransfer(arg::content=credentials, arg::destination=CredentialsExchange::NAME); s.sync(); } } }
void ExplorerWidget::ui_itemDoubleClicked(QTreeWidgetItem *item, int column) { auto collectionItem = dynamic_cast<ExplorerCollectionTreeItem *>(item); if (collectionItem) { AppRegistry::instance().app()->openShell(collectionItem->collection()); return; } auto replicaMemberItem = dynamic_cast<ExplorerReplicaSetTreeItem*>(item); if (replicaMemberItem && replicaMemberItem->isUp()) { AppRegistry::instance().app()->openShell(replicaMemberItem->server(), replicaMemberItem->connectionSettings(), ScriptInfo("", true)); return; } // Toggle expanded state item->setExpanded(!item->isExpanded()); }
void Cluster::retractOffer(const MemberId& updater, uint64_t updateeInt, Lock& l) { // An offer was received while handling an error, and converted to a retract. // Behavior is very similar to updateOffer. if (state == LEFT) return; MemberId updatee(updateeInt); boost::optional<Url> url = map.updateOffer(updater, updatee); if (updater == self) { assert(state == OFFER); if (url) { // My offer was first. if (updateThread) updateThread.join(); // Join the previous updateThread to avoid leaks. updateThread = Thread(new RetractClient(*url, connectionSettings(settings))); } setReady(l); makeOffer(map.firstJoiner(), l); // Maybe make another offer. // Don't unstall the event queue, that was already done in deliveredFrame } QPID_LOG(debug,*this << " retracted offer " << updater << " to " << updatee); }
void Cluster::updateStart(const MemberId& updatee, const Url& url, Lock& l) { // Check for credentials if authentication is enabled. if (broker.getOptions().auth && !credentialsExchange->check(updatee)) { QPID_LOG(error, "Un-authenticated attempt to join the cluster"); return; } // NOTE: deliverEventQueue is already stopped at the stall point by deliveredEvent. if (state == LEFT) return; assert(state == OFFER); state = UPDATER; QPID_LOG(notice, *this << " sending update to " << updatee << " at " << url); if (updateThread) updateThread.join(); // Join the previous updateThread to avoid leaks. updateThread = Thread( new UpdateClient(self, updatee, url, broker, map, *expiryPolicy, getConnections(l), decoder, boost::bind(&Cluster::updateOutDone, this), boost::bind(&Cluster::updateOutError, this, _1), connectionSettings(settings))); }
/*! * \overload */ void Sodaq_WifiBee::connectionSettings(const String& APN, const String& username, const String& password) { connectionSettings(APN.c_str(), username.c_str(), password.c_str()); }
void QtLoginWindow::handleOpenConnectionOptions() { QtConnectionSettingsWindow connectionSettings(currentOptions_); if (connectionSettings.exec() == QDialog::Accepted) { currentOptions_ = connectionSettings.getOptions(); } }