void AccountsListWidget::on_PGP__released () { #ifdef ENABLE_CRYPT QModelIndex index = Ui_.Accounts_-> selectionModel ()->currentIndex (); if (!index.isValid ()) return; IAccount *acc = index .data (RAccObj).value<IAccount*> (); ISupportPGP *pgpAcc = qobject_cast<ISupportPGP*> (acc->GetObject ()); if (!pgpAcc) { QMessageBox::warning (this, "LeechCraft", tr ("The account %1 doesn't support encryption.") .arg (acc->GetAccountName ())); return; } const QString& str = tr ("Please select new PGP key for the account %1.") .arg (acc->GetAccountName ()); PGPKeySelectionDialog dia (str, PGPKeySelectionDialog::TPrivate, pgpAcc->GetPrivateKey (), this); if (dia.exec () != QDialog::Accepted) return; pgpAcc->SetPrivateKey (dia.GetSelectedKey ()); Core::Instance ().AssociatePrivateKey (acc, dia.GetSelectedKey ()); #endif }
void AccountsListWidget::on_Delete__released () { auto index = Ui_.Accounts_->selectionModel ()->currentIndex (); index = index.sibling (index.row (), Columns::Name); if (!index.isValid ()) return; QStandardItem *item = AccountsModel_->itemFromIndex (index); IAccount *acc = 0; if (item && Item2Account_.contains (item)) acc = Item2Account_ [item]; else return; if (QMessageBox::question (this, "LeechCraft", tr ("Are you sure you want to remove the account %1?") .arg ("<em>" + acc->GetAccountName () + "</em>"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; QObject *bpObj = acc->GetParentBloggingPlatform (); IBloggingPlatform *ibp = qobject_cast<IBloggingPlatform*> (bpObj); if (!ibp) { qWarning () << Q_FUNC_INFO << "parent blogging platform for" << acc->GetAccountID () << "doesn't implement IBloggingPlatform"; return; } ibp->RemoveAccount (acc->GetObject ()); }
void AccountsListWidget::handleAccountValidated (QObject *accObj, bool validated) { IAccount *acc = qobject_cast<IAccount*> (accObj); if (!acc) { qWarning () << Q_FUNC_INFO << accObj << "is not an IAccount"; return; } if (!Account2Item_.contains (acc)) { qWarning () << Q_FUNC_INFO << "account" << acc->GetAccountName () << acc->GetObject () << "from" << sender () << "not found here"; return; } QStandardItem *item = Account2Item_ [acc]; AccountsModel_->item (item->row (), Columns::IsValidated)->setText (validated ? tr ("Validated") : tr ("Not validated")); Ui_.Accounts_->header ()->setResizeMode (QHeaderView::ResizeToContents); }
void CTradeLockDlg::OnShow(BOOL bShow) { if (bShow) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); m_edPsw.SetWindowText(""); m_cbFundAccount.ResetContent(); IAccount* pCurrAccount = m_pAccountMng->GetCurrentAccount(atTrade); int nCurrIndex = 0; for (int i = 0; i < m_pAccountMng->GetCount(atTrade); i++) { IAccount* pAccount = m_pAccountMng->GetAccount(i, atTrade); CString sTmp = ""; sTmp.Format(_T("股票%s(%s)"), pAccount->GetAccountName(), pAccount->GetUserName()); int nIndex = m_cbFundAccount.AddString(sTmp); m_cbFundAccount.SetItemDataPtr(nIndex, pAccount); if (pAccount == pCurrAccount) { nCurrIndex = nIndex; } } if (m_cbFundAccount.GetCount() > 0) { m_cbFundAccount.SetCurSel(nCurrIndex); } if (pCurrAccount->GetConnectHandle() == 0) { m_stErrorHint.SetWindowText("由于未知的原因连接被断开,请检查网络后重新连接!"); } else { m_stErrorHint.SetWindowText(""); } } }
IAccount* ImportManager::GetAccountID (Entity e) { const QString& accName = e.Additional_ ["AccountName"].toString (); auto accs = Core::Instance ().GetAccounts ([] (IProtocol *proto) { return qobject_cast<ISupportImport*> (proto->GetQObject ()); }); IAccount *acc = 0; Q_FOREACH (acc, accs) if (acc->GetAccountName () == accName) return acc; const QString& impId = e.Additional_ ["AccountID"].toString (); EntityQueues_ [impId] << e; if (EntityQueues_ [impId].size () > 1) return 0; if (AccID2OurID_.contains (impId)) return AccID2OurID_ [impId]; AccountHandlerChooserDialog dia (accs, tr ("Select account to import history from %1 into:").arg (accName)); if (dia.exec () != QDialog::Accepted) return 0; acc = dia.GetSelectedAccount (); AccID2OurID_ [impId] = acc; return acc; }
void AccountActionsManager::joinAccountConfFromBM () { IAccount *account = GetAccountFromSender (sender (), Q_FUNC_INFO); if (!account) return; const QVariant& bmData = sender ()->property ("Azoth/BMData"); if (bmData.isNull ()) return; const auto proto = qobject_cast<IMUCProtocol*> (account->GetParentProtocol ()); if (!proto) { qWarning () << Q_FUNC_INFO << account->GetAccountName () << "parent protocol does not implement IMUCProtocol"; return; } auto jWidget = proto->GetMUCJoinWidget (); IMUCJoinWidget *imjw = qobject_cast<IMUCJoinWidget*> (jWidget); imjw->SetIdentifyingData (bmData.toMap ()); imjw->Join (account->GetQObject ()); jWidget->deleteLater (); }
void AccountsListWidget::on_Delete__released() { QModelIndex index = Ui_.Accounts_-> selectionModel ()->currentIndex (); if (!index.isValid ()) return; IAccount *acc = index .data (RAccObj).value<IAccount*> (); if (QMessageBox::question (this, "LeechCraft", tr ("Are you sure you want to remove the account %1?") .arg (acc->GetAccountName ()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; QObject *protoObj = acc->GetParentProtocol (); IProtocol *proto = qobject_cast<IProtocol*> (protoObj); if (!proto) { qWarning () << Q_FUNC_INFO << "parent protocol for" << acc->GetAccountID () << "doesn't implement IProtocol"; return; } proto->RemoveAccount (acc->GetObject ()); }
QString ProxyObject::GetAccountPassword (QObject *accObj, bool useStored) { if (useStored) { const QString& result = GetPassword (accObj); if (!result.isNull ()) return result; } IAccount *acc = qobject_cast<IAccount*> (accObj); QString result = QInputDialog::getText (0, "LeechCraft", tr ("Enter password for %1:").arg (acc->GetAccountName ()), QLineEdit::Password); if (!result.isNull ()) SetPassword (result, accObj); return result; }