void GaduPubdirSocketNotifiers::socketEvent() { kdebugf(); if (gg_pubdir_watch_fd(H) == -1) { finished(false); return; } struct gg_pubdir *p = (struct gg_pubdir *)H->data; switch (H->state) { case GG_STATE_CONNECTING: kdebugmf(KDEBUG_NETWORK | KDEBUG_INFO, "changing QSocketNotifiers\n"); watchFor(H); break; case GG_STATE_ERROR: kdebugmf(KDEBUG_NETWORK | KDEBUG_INFO, "error!\n"); finished(false); break; case GG_STATE_DONE: if (p->success) kdebugmf(KDEBUG_NETWORK | KDEBUG_INFO, "success!\n"); else kdebugmf(KDEBUG_NETWORK | KDEBUG_INFO, "error!\n"); finished(p->success); break; } kdebugf2(); }
void GaduTokenSocketNotifiers::socketEvent() { kdebugf(); if (gg_token_watch_fd(H) == -1) { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "getting token error\n"); finished(QString(), QPixmap()); return; } struct gg_pubdir *p = (struct gg_pubdir *)H->data; switch (H->state) { case GG_STATE_CONNECTING: kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "changing QSocketNotifiers.\n"); watchFor(H); break; case GG_STATE_ERROR: kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "getting token error\n"); finished(QString(), QPixmap()); break; case GG_STATE_DONE: if (p->success) { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "success\n"); struct gg_token *t = (struct gg_token *)H->data; QString tokenId = QString::fromUtf8(t->tokenid); //nie optymalizowac!!! QByteArray buf(H->body_size, '0'); for (unsigned int i = 0; i < H->body_size; ++i) buf[i] = H->body[i]; QPixmap tokenImage; tokenImage.loadFromData(buf); finished(tokenId, tokenImage); } else { kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "getting token error\n"); finished(QString(), QPixmap()); } break; } kdebugf2(); }
void GaduProtocolSocketNotifiers::handleEventDisconnect(struct gg_event *e) { Q_UNUSED(e) // close connection gg_logoff(m_session); // we don't have connection anymore watchFor(nullptr); m_protocol->disconnectedFromServer(); m_protocol->setStatus(Status{}, SourceUser); }
void GaduProtocolSocketNotifiers::handleEventConnFailed(struct gg_event *e) { GaduProtocol::GaduError err; switch (e->event.failure) { case GG_FAILURE_RESOLVING: err = GaduProtocol::ConnectionServerNotFound; break; case GG_FAILURE_CONNECTING: err = GaduProtocol::ConnectionCannotConnect; break; case GG_FAILURE_NEED_EMAIL: err = GaduProtocol::ConnectionNeedEmail; break; case GG_FAILURE_INVALID: err = GaduProtocol::ConnectionInvalidData; break; case GG_FAILURE_READING: err = GaduProtocol::ConnectionCannotRead; break; case GG_FAILURE_WRITING: err = GaduProtocol::ConnectionCannotWrite; break; case GG_FAILURE_PASSWORD: err = GaduProtocol::ConnectionIncorrectPassword; break; case GG_FAILURE_TLS: err = GaduProtocol::ConnectionTlsError; break; case GG_FAILURE_INTRUDER: err = GaduProtocol::ConnectionIntruderError; break; case GG_FAILURE_UNAVAILABLE: err = GaduProtocol::ConnectionUnavailableError; break; default: err = GaduProtocol::ConnectionUnknow; break; } m_protocol->socketConnFailed(err); // we don't have connection anymore watchFor(nullptr); }
void DccSocketNotifiers::start() { watchFor(); }
void GaduPubdirSocketNotifiers::finished(bool ok) { emit done(ok, H); watchFor(0); deleteLater(); }
void GaduTokenSocketNotifiers::finished(const QString& tokenId, const QPixmap& tokenPixmap) { emit done(tokenId, tokenPixmap); watchFor(0); deleteLater(); }
void GaduProtocolSocketNotifiers::socketEvent() { auto e = gg_watch_fd(m_session); if (!e || GG_STATE_IDLE == m_session->state) { if (e && e->type == GG_EVENT_CONN_FAILED) handleEventConnFailed(e); else m_protocol->socketConnFailed(GaduProtocol::ConnectionUnknow); return; } watchFor(m_session); // maybe fd has changed, we need to check always switch (e->type) { case GG_EVENT_MSG: emit msgEventReceived(e); break; case GG_EVENT_MULTILOGON_MSG: emit multilogonMsgEventReceived(e); break; case GG_EVENT_MULTILOGON_INFO: handleEventMultilogonInfo(e); break; case GG_EVENT_TYPING_NOTIFICATION: emit typingNotificationEventReceived(e); break; case GG_EVENT_NOTIFY: case GG_EVENT_NOTIFY_DESCR: handleEventNotify(e); break; case GG_EVENT_NOTIFY60: handleEventNotify60(e); break; case GG_EVENT_STATUS: case GG_EVENT_STATUS60: handleEventStatus(e); break; case GG_EVENT_ACK: emit ackEventReceived(e); break; case GG_EVENT_CONN_FAILED: handleEventConnFailed(e); break; case GG_EVENT_CONN_SUCCESS: handleEventConnSuccess(e); break; case GG_EVENT_DISCONNECT: handleEventDisconnect(e); break; case GG_EVENT_PUBDIR50_SEARCH_REPLY: m_protocol->CurrentSearchService->handleEventPubdir50SearchReply(e); // break; case GG_EVENT_PUBDIR50_READ: m_protocol->CurrentPersonalInfoService->handleEventPubdir50Read(e); m_protocol->CurrentContactPersonalInfoService->handleEventPubdir50Read(e); // break; case GG_EVENT_PUBDIR50_WRITE: m_protocol->CurrentPersonalInfoService->handleEventPubdir50Write(e); break; case GG_EVENT_IMAGE_REQUEST: m_protocol->CurrentChatImageService->handleEventImageRequest(e); break; case GG_EVENT_IMAGE_REPLY: m_protocol->CurrentChatImageService->handleEventImageReply(e); break; case GG_EVENT_USERLIST100_VERSION: static_cast<GaduRosterService *>(m_protocol->rosterService())->handleEventUserlist100Version(e); break; case GG_EVENT_USERLIST100_REPLY: static_cast<GaduRosterService *>(m_protocol->rosterService())->handleEventUserlist100Reply(e); break; case GG_EVENT_USER_DATA: m_userDataService->handleUserDataEvent(e->event.user_data); break; case GG_EVENT_IMTOKEN: m_imTokenService->setIMToken(e->event.imtoken.imtoken); break; } gg_free_event(e); }