// APIRequestDelegate void Acl::handleReplyNonBlocking(RequestOperation *request, QNetworkReply *networkReply) { // Schedule network reply for deletion networkReply->deleteLater(); if(request == _delete) { bool success; if(deleteReply(networkReply)) { emit deleteFinished(); } else { emit deleteFailed(errorString()); } } else if(request == _get) { AclRule rule; if(getReply(networkReply, rule)) { emit getFinished(rule); } else { emit getFailed(errorString()); } } else if(request == _insert) { AclRule rule; if(insertReply(networkReply, rule)) { emit insertFinished(rule); } else { emit insertFailed(errorString()); } } else if(request == _list) { // TODO: Implement. } else if(request == _patch) { AclRule rule; if(patchReply(networkReply, rule)) { emit patchFinished(rule); } else { emit patchFailed(errorString()); } } else if(request == _update) { AclRule rule; if(updateReply(networkReply, rule)) { emit updateFinished(rule); } else { emit updateFailed(errorString()); } } else if(request == _watch) { // TODO: Implement. } else { qDebug() << "Warning: Received response for unknown request."; } }
void GaduRosterService::importContactList() { if (!m_connection || !m_connection.data()->hasSession()) { emit getFinished(false); return; } m_synchronizingContacts = contacts(); for (auto &&contact : m_synchronizingContacts) contact.rosterEntry()->setSynchronizingFromRemote(); auto writableSessionToken = m_connection.data()->writableSessionToken(); int ret = gg_userlist100_request(writableSessionToken.rawSession(), GG_USERLIST100_GET, 0, GG_USERLIST100_FORMAT_TYPE_GG70, 0); if (-1 == ret) { markSynchronizingAsSynchronized(); emit getFinished(false); } }
void PEPManager::get(const XMPP::Jid &jid, const QString &node, const QString &id) { PEPGetTask* g = new PEPGetTask(client_->rootTask(), jid.bare(), node, id); connect(g, SIGNAL(finished()), SLOT(getFinished())); g->go(true); }
void ServerSocket::service() { if (socket->bind(service_port) != sf::Socket::Status::Done) { std::cout << "!ServerSocket: Error opening socket at port " << service_port << std::endl; reportFinished(); return; } std::cout << "#ServerSocket: socket up at port " << service_port << std::endl; // Verify client knows we are here char buffer[1024]; std::size_t received_count = 0; int wait_duration = 100000; long wait_start = game.getGameRunningTime(); bool got_response = false; while ((game.getGameRunningTime() < wait_start + wait_duration) && !got_response) { if (socket->receive(buffer, sizeof(buffer), received_count, sender, senderPort) != sf::Socket::Done) { //std::cout << "no news" << std::endl; } else { std::cout << "#ServerSocket: Got handshake from client. Continuing to loop" << std::endl; got_response = true; } } if (!got_response) { std::cout << "!SocketThread: Didn't get response from client in time during initial handshake" << std::endl; reportFinished(); return; } while (!getFinished()) { // First check if the server has anything to send to the client if (game.getServer()->stateHasChanged()) { sendDeltas(); } // Then receive the client's information if (socket->receive(buffer, sizeof(buffer), received_count, sender, senderPort) != sf::Socket::Done) { } else { std::cout << "#ServerThread: Client told us: " << buffer <<" first char: " << buffer[0] << std::endl; if (buffer[0] == 'u') game.getNetworkedInput()->up(service_port); else if (buffer[0] == 'd') game.getNetworkedInput()->down(service_port); else if (buffer[0] == 'l') game.getNetworkedInput()->left(service_port); else if (buffer[0] == 'r') game.getNetworkedInput()->right(service_port); else if (buffer[0] == 'x') reportFinished(); } } std::cout << "#Server_thread: Exiting safely" << std::endl; }
void GaduRosterService::handleEventUserlist100GetReply(struct gg_event *e) { if (!m_stateMachine->isPerformingGet()) { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got unexpected userlist 100 get reply, ignoring\n"); return; } auto accountData = GaduAccountData{account()}; if (e->event.userlist100_reply.format_type != GG_USERLIST100_FORMAT_TYPE_GG70) { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got userlist 100 reply with unwanted format type (%d)\n", (int)e->event.userlist100_reply.format_type); getFinished(false); return; } auto content = e->event.userlist100_reply.reply; if (!content) { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "got userlist 100 reply without any content\n"); getFinished(false); return; } kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "userlist 100 reply:\n%s\n", content); if (accountData.userlistVersion() != (int)e->event.userlist100_reply.version) { auto content2 = QByteArray{content}; auto buddies = m_gaduListHelper->byteArrayToBuddyList(account(), content2); getFinished(true); auto result = m_rosterReplacer->replaceRoster(account(), buddies, haveToAskForAddingContacts()); accountData.setUserlistVersion(e->event.userlist100_reply.version); accountData.setInitialRosterImport(false); for (auto &&contact : result.first) contact.rosterEntry()->setSynchronized(); for (auto &&contact : result.second) { auto ownerBuddy = contact.ownerBuddy(); contact.setOwnerBuddy(Buddy::null); m_buddyManager->removeBuddyIfEmpty(ownerBuddy, true); removeContact(contact); contact.rosterEntry()->setSynchronized(); } // cleanup references, so buddy and contact instances can be removed // this is really a hack, we need to call aboutToBeRemoved someway for non-manager contacts and buddies too // or just only store managed only, i dont know yet for (auto &&buddy : buddies) { for (auto &&contact : buddy.contacts()) contact.data()->aboutToBeRemoved(); buddy.data()->aboutToBeRemoved(); } } else { markSynchronizingAsSynchronized(); getFinished(true); } }