void SendFileAction::actionInstanceCreated(Action *action) { auto account = action->context()->chat().chatAccount(); if (!account || !account.protocolHandler() || !account.protocolHandler()->fileTransferService()) return; connect(account.protocolHandler()->fileTransferService(), SIGNAL(canSendChanged()), action, SLOT(checkState())); }
void FileTransferHandlerManager::protocolHandlerChanged() { auto account = Account{sender()}; if (!account) return; if (account.protocolHandler()) createHandlers(account); else removeHandlers(account); }
void SubscriptionAction::updateActionState(Action *action) { action->setEnabled(false); if (action->context()->buddies().isAnyTemporary()) return; auto const &contact = action->context()->contacts().toContact(); if (!contact) return; if (action->context()->buddies().contains(m_myself->buddy())) return; auto account = contact.contactAccount(); if (!account || !account.protocolHandler() || !account.protocolHandler()->rosterService()) return; if (!account.protocolHandler()->isConnected()) return; action->setEnabled(true); }
void JabberOutgoingFileTransferHandler::send(QIODevice *source) { if (m_inProgress) // already sending/receiving return; m_source = source; auto account = transfer().peer().contactAccount(); if (account.isNull()) { transfer().setTransferStatus(FileTransferStatus::NotConnected); deleteLater(); return; // TODO: notify } JabberProtocol *jabberProtocol = dynamic_cast<JabberProtocol *>(account.protocolHandler()); if (!jabberProtocol) { transfer().setTransferStatus(FileTransferStatus::NotConnected); deleteLater(); return; } auto jid = m_resourceService->bestContactJid(transfer().peer()); auto fileInfo = QXmppTransferFileInfo{}; fileInfo.setName(transfer().remoteFileName()); fileInfo.setSize(transfer().fileSize()); m_transferJob = m_transferManager->sendFile(jid.full(), m_source, fileInfo); if (m_transferJob->error() == QXmppTransferJob::Error::NoError) { connect(m_transferJob, SIGNAL(progress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); connect( m_transferJob, SIGNAL(stateChanged(QXmppTransferJob::State)), this, SLOT(stateChanged(QXmppTransferJob::State))); connect(m_transferJob, SIGNAL(error(QXmppTransferJob::Error)), this, SLOT(error(QXmppTransferJob::Error))); transfer().setTransferStatus(FileTransferStatus::WaitingForAccept); m_inProgress = true; } else error(m_transferJob->error()); }