void FileSendDialog::SendProto () { auto acc = qobject_cast<IAccount*> (Entry_->GetParentAccount ()); auto xferMgr = qobject_cast<ITransferManager*> (acc->GetTransferManager ()); if (!xferMgr) { qWarning () << Q_FUNC_INFO << "null Xfer manager for" << Entry_->GetQObject (); return; } const auto& filename = Ui_.FileEdit_->text (); if (filename.isEmpty ()) return; QObject *job = xferMgr->SendFile (Entry_->GetEntryID (), EntryVariant_, filename, Ui_.CommentEdit_->toPlainText ()); if (!job) { Core::Instance ().SendEntity (Util::MakeNotification ("Azoth", tr ("Unable to send file to %1.") .arg (Entry_->GetEntryName ()), PCritical_)); return; } Core::Instance ().GetTransferJobManager ()->HandleJob (job); }
FileSendDialog::FileSendDialog (ICLEntry *entry, const QString& suggested, QWidget *parent) : QDialog (parent) , Entry_ (entry) , EntryVariant_ (Core::Instance ().GetChatTabsManager ()->GetActiveVariant (entry)) , AccSupportsFT_ (false) { Ui_.setupUi (this); setAttribute (Qt::WA_DeleteOnClose); connect (this, SIGNAL (accepted ()), this, SLOT (send ())); show (); auto name = entry->GetEntryName (); if (name != entry->GetHumanReadableID ()) name += " (" + entry->GetHumanReadableID () + ")"; Ui_.TargetLabel_->setText (name); auto acc = Entry_->GetParentAccount (); auto itm = qobject_cast<ITransferManager*> (acc->GetTransferManager ()); if (itm && itm->IsAvailable ()) { AccSupportsFT_ = true; Ui_.TransferMethod_->addItem (tr ("Protocol file transfer")); } FillSharers (); if (!Ui_.TransferMethod_->count ()) { QMessageBox::warning (this, "LeechCraft", tr ("There aren't any file transfer methods available. " "Please either make sure protocol file transfers are enabled and " "active, or install a module like NetStoreManager.")); deleteLater (); return; } if (suggested.isEmpty ()) { if (XmlSettingsManager::Instance ().property ("AutoOpenFileDialogOnSend").toBool ()) on_FileBrowse__released (); } else Ui_.FileEdit_->setText (suggested); }