void MTPageCreateContract::on_pushButtonSelect_clicked() { QString qstr_default_id = Moneychanger::It()->get_default_nym_id(); // ------------------------------------------- QString qstr_current_id = field("NymID").toString(); // ------------------------------------------- if (qstr_current_id.isEmpty()) qstr_current_id = qstr_default_id; // ------------------------------------------- if (qstr_current_id.isEmpty() && (opentxs::OTAPI_Wrap::It()->GetNymCount() > 0)) qstr_current_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetNym_ID(0)); // ------------------------------------------- // Select from Nyms in local wallet. // DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t the_count = opentxs::OTAPI_Wrap::It()->GetNymCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < the_count; ++ii) { QString OT_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetNym_ID(ii)); QString OT_name(""); // ----------------------------------------------- if (!OT_id.isEmpty()) { if (!qstr_current_id.isEmpty() && (OT_id == qstr_current_id)) bFoundDefault = true; // ----------------------------------------------- OT_name = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetNym_Name(OT_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_id, OT_name); } } // ----------------------------------------------- if (bFoundDefault) theChooser.SetPreSelected(qstr_current_id); // ----------------------------------------------- theChooser.setWindowTitle(tr("Choose a Signer for the New Contract")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { if (!theChooser.m_qstrCurrentID .isEmpty() && !theChooser.m_qstrCurrentName.isEmpty()) { setField("NymID", theChooser.m_qstrCurrentID); setField("NymName", theChooser.m_qstrCurrentName); // ----------------------------------------- ui->lineEditID->home(false); // ----------------------------------------- if (qstr_default_id.isEmpty()) emit SetDefaultNym(theChooser.m_qstrCurrentID, theChooser.m_qstrCurrentName); // ---------------------------------------- return; } } }
void MTCompose::on_fromButton_clicked() { // Select from Nyms in local wallet. // DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t nym_count = OTAPI_Wrap::It()->GetNymCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < nym_count; ++ii) { //Get OT Nym ID QString OT_nym_id = QString::fromStdString(OTAPI_Wrap::It()->GetNym_ID(ii)); QString OT_nym_name(""); // ----------------------------------------------- if (!OT_nym_id.isEmpty()) { if (!m_senderNymId.isEmpty() && (OT_nym_id == m_senderNymId)) bFoundDefault = true; // ----------------------------------------------- MTNameLookupQT theLookup; OT_nym_name = QString::fromStdString(theLookup.GetNymName(OT_nym_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_nym_id, OT_nym_name); } } // ----------------------------------------------- if (bFoundDefault && !m_senderNymId.isEmpty()) theChooser.SetPreSelected(m_senderNymId); // ----------------------------------------------- theChooser.setWindowTitle(tr("Choose your Sender identity")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { qDebug() << QString("SELECT was clicked for NymID: %1").arg(theChooser.m_qstrCurrentID); if (!theChooser.m_qstrCurrentID.isEmpty()) { m_senderNymId = theChooser.m_qstrCurrentID; // ----------------------------------------- if (theChooser.m_qstrCurrentName.isEmpty()) ui->fromButton->setText(QString("")); else ui->fromButton->setText(theChooser.m_qstrCurrentName); // ----------------------------------------- return; } } else { qDebug() << "CANCEL was clicked"; } // ----------------------------------------------- m_senderNymId = QString(""); ui->fromButton->setText(tr("<Click to choose Sender>")); }
void PageOffer_Assets::on_pushButtonSelectAsset_clicked() { // ------------------------------------------- QString qstr_current_id = field("InstrumentDefinitionID").toString(); // ------------------------------------------- if (qstr_current_id.isEmpty() && (opentxs::OTAPI_Wrap::It()->GetAssetTypeCount() > 0)) qstr_current_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetAssetType_ID(0)); // ------------------------------------------- // Select from Asset Types in local wallet. // DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t the_count = opentxs::OTAPI_Wrap::It()->GetAssetTypeCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < the_count; ++ii) { QString OT_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetAssetType_ID(ii)); QString OT_name(""); // ----------------------------------------------- if (!OT_id.isEmpty()) { if (!qstr_current_id.isEmpty() && (0 == qstr_current_id.compare(OT_id))) bFoundDefault = true; // ----------------------------------------------- OT_name = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetAssetType_Name(OT_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_id, OT_name); } } // ----------------------------------------------- if (bFoundDefault) theChooser.SetPreSelected(qstr_current_id); // ----------------------------------------------- theChooser.setWindowTitle(tr("Select the Asset Type")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { if (!theChooser.m_qstrCurrentID .isEmpty() && !theChooser.m_qstrCurrentName.isEmpty()) { setField("AssetName", theChooser.m_qstrCurrentName); setField("InstrumentDefinitionID", theChooser.m_qstrCurrentID); // ----------------------------------------- ui->lineEditInstrumentDefinitionID->home(false); // ----------------------------------------- } } }
// Issue a currency onto a notary based on the currently-selected contract. // void MTAssetDetails::on_pushButton_clicked() { // if (m_pPlainTextEdit) // qstrContents = m_pPlainTextEdit->toPlainText(); // -------------------------- if (opentxs::OTAPI_Wrap::It()->GetServerCount() <= 0) { QMessageBox::information(this, tr("Moneychanger"), tr("There are no server contracts in this wallet. " "(The notary is the server.) Please add a server contract (aka notary " "contract) to your wallet, and then come back here and try to issue an asset onto that server.")); return; } // -------------------------- QString qstrAssetID = ui->lineEditID->text(); QString qstrNymID; if (!qstrAssetID.isEmpty()) { QString qstrContents = QString::fromStdString(opentxs::OTAPI_Wrap::It()->LoadAssetContract(qstrAssetID.toStdString())); if (!qstrContents.isEmpty()) { // First we get the "signer nym" ID from the asset contract. std::string str_signer_nym = opentxs::OTAPI_Wrap::It()->GetSignerNymID(qstrContents.toStdString()); if (!str_signer_nym.empty()) { qstrNymID = QString::fromStdString(str_signer_nym); // -------------------------- // Then we see if the local wallet actually contains the private key // for that Nym. if (opentxs::OTAPI_Wrap::It()->VerifyUserPrivateKey(str_signer_nym)) { // Ideally at this point, we will already have some way of differentiating // between the notaries where the assets have, and have not, already been // issued. // This is really OT client's responsibility to track this by keeping a copy // of it's issuing receipt. (The notary should keep this receipt as well.) // The notary needs this receipt so it can prove later that the currency // really was issued onto his notary (and how many units the issuer authorized.) // Whereas the client should keep these receipts so he can know which ones are // issued on which servers. // // In the meantime, the best we can do is ask the servers to tell us what they // know about certain currencies. It's a bit slower but it will work. // // But I'm not coding that tonight. Instead, I'll just ask the server and // try it -- whether it succeeds or not I'll just pop up a message box. // // TODO: Need a dialog to pop up here // We already have the asset ID, and the Nym ID. // We'll let the user choose the server. // Then check to see if that Nym is registered on that server. // Then actually call the issue message. // QString qstr_default_id = Moneychanger::It()->get_default_notary_id(); // ------------------------------------------- QString qstr_current_id = qstr_default_id; // ------------------------------------------- if (qstr_current_id.isEmpty()) //&& (opentxs::OTAPI_Wrap::It()->GetServerCount() > 0)) // Already checked at the top of this function. qstr_current_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetServer_ID(0)); // ------------------------------------------- // Select from Servers in local wallet. // DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t the_count = opentxs::OTAPI_Wrap::It()->GetServerCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < the_count; ++ii) { QString OT_id = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetServer_ID(ii)); QString OT_name(""); // ----------------------------------------------- if (!OT_id.isEmpty()) { if (!qstr_current_id.isEmpty() && (OT_id == qstr_current_id)) bFoundDefault = true; // ----------------------------------------------- OT_name = QString::fromStdString(opentxs::OTAPI_Wrap::It()->GetServer_Name(OT_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_id, OT_name); } } // ----------------------------------------------- if (bFoundDefault) theChooser.SetPreSelected(qstr_current_id); // ----------------------------------------------- theChooser.setWindowTitle(tr("Select the Notary")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { if (!theChooser.m_qstrCurrentID.isEmpty()) { // setField("NotaryID", theChooser.m_qstrCurrentID); // setField("ServerName", theChooser.m_qstrCurrentName); // ----------------------------------------- QString qstrNotaryID = theChooser.m_qstrCurrentID; // Then check to see if that Nym is registered on that server. // bool bIsRegiseredAtServer = opentxs::OTAPI_Wrap::It()->IsNym_RegisteredAtServer(qstrNymID .toStdString(), qstrNotaryID.toStdString()); if (!bIsRegiseredAtServer) { opentxs::OT_ME madeEasy; // If the Nym's not registered at the server, then register him first. // int32_t nSuccess = 0; { MTSpinner theSpinner; std::string strResponse = madeEasy.register_nym(qstrNotaryID.toStdString(), qstrNymID .toStdString()); // This also does getRequest internally, if success. nSuccess = madeEasy.VerifyMessageSuccess(strResponse); } // -1 is error, // 0 is reply received: failure // 1 is reply received: success // switch (nSuccess) { case (1): { bIsRegiseredAtServer = true; break; // SUCCESS } case (0): { QMessageBox::warning(this, tr("Failed Registration"), tr("Failed while trying to register Nym at Server.")); break; } default: { QMessageBox::warning(this, tr("Error in Registration"), tr("Error while trying to register Nym at Server.")); break; } } // switch // -------------------------- if (1 != nSuccess) { Moneychanger::It()->HasUsageCredits(qstrNotaryID, qstrNymID); return; } } // is registered at server. // ---------------------------------------- // Then actually call the issue message. // if (bIsRegiseredAtServer) { // ----------------------------------- { opentxs::OT_ME madeEasy; bool bSuccess = false; { MTSpinner theSpinner; const std::string str_reply = madeEasy.retrieve_contract(qstrNotaryID.toStdString(), qstrNymID .toStdString(), qstrContents.toStdString()); const int32_t nResult = madeEasy.VerifyMessageSuccess(str_reply); bSuccess = (1 == nResult); } // ----------------------------------- if (bSuccess) { QMessageBox::information(this, tr("Moneychanger"), tr("Apparently this asset is already registered on the selected notary. " "(I just asked the notary.)")); return; } } // ----------------------------------- { opentxs::OT_ME madeEasy; std::string str_issuer_acct; bool bSuccess = false; { MTSpinner theSpinner; const std::string str_reply = madeEasy.issue_asset_type(qstrNotaryID.toStdString(), qstrNymID .toStdString(), qstrContents.toStdString()); const int32_t nResult = madeEasy.VerifyMessageSuccess(str_reply); bSuccess = (1 == nResult); if (bSuccess) str_issuer_acct = opentxs::OTAPI_Wrap::It()->Message_GetNewIssuerAcctID(str_reply); } // ----------------------------------- if (!bSuccess) { QMessageBox::information(this, tr("Moneychanger"), QString(tr("%1 '%2' %3 '%4'. %5")). arg(tr("Failed to register")). arg(ui->lineEditName->text()). arg(tr("on notary")). arg(theChooser.m_qstrCurrentName). arg(tr("<br>Perhaps it is already registered there? Alternately, the notary " " admin may have the permissions turned off."))); Moneychanger::It()->HasUsageCredits(qstrNotaryID, qstrNymID); return; } QString qstrNewIssuerAcct(QString::fromStdString(str_issuer_acct)); QMessageBox::information(this, tr("Moneychanger"), QString(tr("%1 '%2' %3 '%4'. %5: %6")). arg(tr("Successfully registered")). arg(ui->lineEditName->text()). arg(tr("on notary")). arg(theChooser.m_qstrCurrentName). arg(tr("Your new issuer account was created with the ID")). arg(qstrNewIssuerAcct)); QString qstrAcctNewName(tr("New Issuer Account")); opentxs::OTAPI_Wrap::It()->SetAccountWallet_Name(str_issuer_acct, str_signer_nym, qstrAcctNewName.toStdString()); emit newAccountAdded(qstrNewIssuerAcct); return; } // ----------------------------------- } } } } else // There's no private key in this wallet, for this asset contract. { QMessageBox::information(this, tr("Moneychanger"), tr("Sorry, but only the Nym who signed that asset contract can register it onto a notary.")); return; } } } } }
void PageOffer_Accounts::on_pushButtonSelectCurrencyAcct_clicked() { QString qstrNymID = field("NymID") .toString(); QString qstrAssetID = field("CurrencyID") .toString(); QString qstrServerID = field("ServerID") .toString(); // ------------------------------------------- QString qstr_current_id = field("CurrencyAcctID").toString(); // ------------------------------------------- if (qstr_current_id.isEmpty() && (OTAPI_Wrap::It()->GetAccountCount() > 0)) qstr_current_id = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_ID(0)); // ------------------------------------------- // Select from currency accounts in local wallet. // DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t the_count = OTAPI_Wrap::It()->GetAccountCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < the_count; ++ii) { QString OT_id = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_ID(ii)); QString OT_name(""); // ----------------------------------------------- if (!OT_id.isEmpty()) { // Filter the accounts shown based on asset type, server ID, and Nym ID. // QString qstrAcctNymID = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_NymID (OT_id.toStdString())); QString qstrAcctAssetID = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_AssetTypeID (OT_id.toStdString())); QString qstrAcctServerID = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_ServerID (OT_id.toStdString())); // ----------------------------------------------- if ((qstrAcctNymID != qstrNymID) || (qstrAcctAssetID != qstrAssetID) || (qstrAcctServerID != qstrServerID)) continue; // ----------------------------------------------- if (!qstr_current_id.isEmpty() && (OT_id == qstr_current_id)) bFoundDefault = true; // ----------------------------------------------- OT_name = QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_Name(OT_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_id, OT_name); } } // ----------------------------------------------- if (bFoundDefault) theChooser.SetPreSelected(qstr_current_id); // ----------------------------------------------- theChooser.setWindowTitle(tr("Select the Currency Account")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { if (!theChooser.m_qstrCurrentID .isEmpty() && !theChooser.m_qstrCurrentName.isEmpty()) { setField("CurrencyAcctName", theChooser.m_qstrCurrentName); setField("CurrencyAcctID", theChooser.m_qstrCurrentID); // ----------------------------------------- ui->lineEditCurrencyAcctID->home(false); // ----------------------------------------- int64_t lBalance = OTAPI_Wrap::It()->GetAccountWallet_Balance(theChooser.m_qstrCurrentID.toStdString()); std::string str_formatted = OTAPI_Wrap::It()->FormatAmount(qstrAssetID.toStdString(), lBalance); QString qstrBalance = QString::fromStdString(str_formatted); setField("CurrencyAcctBalance", qstrBalance); } } }
void DlgExportCash::on_buttonBox_accepted() { if (m_bExportToPassphrase) { accept(); return; } // -------------------------------- // If we're exporting to a recipient, then we need to select // the recipient... // // Select recipient from the address book and convert to Nym ID. // ----------------------------------------------- DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; MTContactHandler::getInstance()->GetContacts(the_map); if (!m_hisNymId.isEmpty()) { int nContactID = MTContactHandler::getInstance()->FindContactIDByNymID(m_hisNymId); if (nContactID > 0) { QString strTempID = QString("%1").arg(nContactID); theChooser.SetPreSelected(strTempID); } } // ----------------------------------------------- theChooser.setWindowTitle(tr("Choose the Recipient")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { qDebug() << QString("SELECT was clicked for ID: %1").arg(theChooser.m_qstrCurrentID); // If not the same as before, then we have to choose a NymID based on the selected Contact. // QString qstrContactName; int nSelectedContactID = theChooser.m_qstrCurrentID.toInt(); if (nSelectedContactID <= 0) // Should never happen. { m_hisNymId = QString(""); m_hisName = QString(""); return; } // else... // qstrContactName = MTContactHandler::getInstance()->GetContactName(nSelectedContactID); if (qstrContactName.isEmpty()) m_hisName = tr("(Contact has a blank name)"); else m_hisName = qstrContactName; // --------------------------------------------- // Next we need to find a Nym based on this Contact... // mapIDName theNymMap; if (MTContactHandler::getInstance()->GetNyms(theNymMap, nSelectedContactID)) { // This contact has exactly one Nym, so we'll go with it. // if (theNymMap.size() == 1) { mapIDName::iterator theNymIt = theNymMap.begin(); m_hisNymId = theNymIt.key(); // QString qstrNymName = theNymIt.value(); // --------------------------- accept(); return; } else // There are multiple Nyms to choose from. { DlgChooser theNymChooser(this); theNymChooser.m_map = theNymMap; theNymChooser.setWindowTitle(tr("Recipient has multiple Nyms. (Please choose one.)")); // ----------------------------------------------- if (theNymChooser.exec() == QDialog::Accepted) { m_hisNymId = theNymChooser.m_qstrCurrentID; accept(); return; } else // User must have cancelled. { m_hisNymId = QString(""); m_hisName = QString(""); } } } else // No nyms found for this ContactID. { m_hisNymId = QString(""); m_hisName = QString(""); // ------------------------------------- QMessageBox::warning(this, tr("Contact has no known identities"), tr("Sorry, Contact '%1' has no known NymIDs (to export cash to.)").arg(qstrContactName)); } // -------------------------------- } // Chooser (on click accepted) }
void MTSendDlg::on_toButton_clicked() { // Select recipient from the address book and convert to Nym ID. // ----------------------------------------------- DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; MTContactHandler::getInstance()->GetContacts(the_map); if (!m_hisNymId.isEmpty()) { int nContactID = MTContactHandler::getInstance()->FindContactIDByNymID(m_hisNymId); if (nContactID > 0) { QString strTempID = QString("%1").arg(nContactID); theChooser.SetPreSelected(strTempID); } } // ----------------------------------------------- theChooser.setWindowTitle(tr("Choose the Recipient")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { qDebug() << QString("SELECT was clicked for ID: %1").arg(theChooser.m_qstrCurrentID); // If not the same as before, then we have to choose a NymID based on the selected Contact. // int nSelectedContactID = theChooser.m_qstrCurrentID.toInt(); int nOldNymContactID = MTContactHandler::getInstance()->FindContactIDByNymID(m_hisNymId); // If they had matched, then we could have kept m_hisNymId as it was. // But since they are different, we have to figure out a NymID to use, based // on nSelectedContactID. // if (nSelectedContactID != nOldNymContactID) { QString qstrContactName; if (nSelectedContactID <= 0) // Should never happen. { qstrContactName = QString(""); m_hisNymId = QString(""); ui->toButton->setText(tr("<Click to choose Recipient>")); return; } // else... // qstrContactName = MTContactHandler::getInstance()->GetContactName(nSelectedContactID); if (qstrContactName.isEmpty()) ui->toButton->setText(tr("(Contact has a blank name)")); else ui->toButton->setText(qstrContactName); // --------------------------------------------- // Next we need to find a Nym based on this Contact... // mapIDName theNymMap; if (MTContactHandler::getInstance()->GetNyms(theNymMap, nSelectedContactID)) { if (theNymMap.size() == 1) { mapIDName::iterator theNymIt = theNymMap.begin(); if (theNymIt != theNymMap.end()) { QString qstrNymID = theNymIt.key(); QString qstrNymName = theNymIt.value(); m_hisNymId = qstrNymID; } else { m_hisNymId = QString(""); ui->toButton->setText(tr("<Click to choose Recipient>")); // ------------------------------------- QMessageBox::warning(this, tr("Contact has no known identities"), tr("Sorry, Contact '%1' has no known NymIDs (to send funds to.)").arg(qstrContactName)); return; } } else // There are multiple Nyms to choose from. { DlgChooser theNymChooser(this); theNymChooser.m_map = theNymMap; theNymChooser.setWindowTitle(tr("Recipient has multiple Nyms. (Please choose one.)")); // ----------------------------------------------- if (theNymChooser.exec() == QDialog::Accepted) m_hisNymId = theNymChooser.m_qstrCurrentID; else // User must have cancelled. { m_hisNymId = QString(""); ui->toButton->setText(tr("<Click to choose Recipient>")); } } } else // No nyms found for this ContactID. { m_hisNymId = QString(""); ui->toButton->setText(tr("<Click to choose Recipient>")); // ------------------------------------- QMessageBox::warning(this, tr("Contact has no known identities"), tr("Sorry, Contact '%1' has no known NymIDs (to send funds to.)").arg(qstrContactName)); return; } // -------------------------------- } } else { qDebug() << "CANCEL was clicked"; } // ----------------------------------------------- }
void MTSendDlg::on_fromButton_clicked() { // Select from Accounts in local wallet. // DlgChooser theChooser(this); theChooser.SetIsAccounts(); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- const int32_t acct_count = OTAPI_Wrap::GetAccountCount(); // ----------------------------------------------- for(int32_t ii = 0; ii < acct_count; ++ii) { //Get OT Acct ID QString OT_acct_id = QString::fromStdString(OTAPI_Wrap::GetAccountWallet_ID(ii)); QString OT_acct_name(""); // ----------------------------------------------- if (!OT_acct_id.isEmpty()) { if (!m_myAcctId.isEmpty() && (OT_acct_id == m_myAcctId)) bFoundDefault = true; // ----------------------------------------------- MTNameLookupQT theLookup; OT_acct_name = QString::fromStdString(theLookup.GetAcctName(OT_acct_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_acct_id, OT_acct_name); } } // ----------------------------------------------- if (bFoundDefault && !m_myAcctId.isEmpty()) theChooser.SetPreSelected(m_myAcctId); // ----------------------------------------------- theChooser.setWindowTitle(tr("Select the Source Account")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { qDebug() << QString("SELECT was clicked for AcctID: %1").arg(theChooser.m_qstrCurrentID); if (!theChooser.m_qstrCurrentID.isEmpty()) { QString display_name(""); QString from_button_text(""); // ----------------------------------------- m_myAcctId = theChooser.m_qstrCurrentID; // ----------------------------------------- if (theChooser.m_qstrCurrentName.isEmpty()) display_name = QString(""); else display_name = theChooser.m_qstrCurrentName; // ----------------------------------------- from_button_text = MTHome::FormDisplayLabelForAcctButton(m_myAcctId, display_name); // ----------------------------------------- ui->fromButton->setText(from_button_text); // ----------------------------------------- return; } } else { qDebug() << "CANCEL was clicked"; } // ----------------------------------------------- m_myAcctId = QString(""); ui->fromButton->setText(tr("<Click to choose Account>")); }
void PageSmart_PartyAcct::on_pushButtonSelect_clicked() { QWizard * pWizard = wizard(); if (NULL == pWizard) return; WizardPartyAcct * pWizardPartyAcct = dynamic_cast<WizardPartyAcct*>(pWizard); if (NULL == pWizardPartyAcct) return; mapIDName & mapConfirmed = pWizardPartyAcct->m_mapConfirmed; // ------------------------------------------- QString qstrTemplate = field("SmartTemplate").toString(); std::string str_template = qstrTemplate.toStdString(); // ------------------------------------------- QString qstrParty = field("PartyName").toString(); std::string str_party = qstrParty.toStdString(); // ------------------------------------------- QString qstr_current_id = field("AcctName").toString(); if (0 == qstr_current_id.compare(m_qstrClickText)) qstr_current_id = QString(""); // ------------------------------------------- DlgChooser theChooser(this); // ----------------------------------------------- mapIDName & the_map = theChooser.m_map; bool bFoundDefault = false; // ----------------------------------------------- int32_t acct_count = opentxs::OTAPI_Wrap::It()->Party_GetAcctCount(str_template, str_party); for (int32_t i = 0; i < acct_count; i++) { std::string acctName = opentxs::OTAPI_Wrap::It()->Party_GetAcctNameByIndex(str_template, str_party, i); if ("" == acctName) { QMessageBox::information(this, tr("Moneychanger"), tr("Strange, there is an account on this smart contract without a name. Failure.")); wizard()->reject(); return; } QString qstrAcctName = QString::fromStdString(acctName); mapIDName::iterator it = mapConfirmed.find(qstrAcctName); bool alreadyConfirmed = (mapConfirmed.end() != it); std::string partyAcctID = opentxs::OTAPI_Wrap::It()->Party_GetAcctID(str_template, str_party, acctName); if (alreadyConfirmed || "" != partyAcctID) { continue; } // ------------------------------ // It's not confirmed yet, so we can add it to the list of accounts to choose from. // QString OT_id = qstrAcctName; QString OT_name = OT_id; // ----------------------------------------------- if (!OT_id.isEmpty()) { if (!qstr_current_id.isEmpty() && (0 == qstr_current_id.compare(OT_id))) bFoundDefault = true; // ----------------------------------------------- the_map.insert(OT_id, OT_name); } } // ----------------------------------------------- // This should never happen because as long as the account // count is not the same as the mapConfirmed size, we thus still // have more accounts that need to be confirmed. That's the only // reason we're in this function at all -- Moneychanger popped up // this wizard to collect the next account because it can see // more accounts still need to be confirmed and that's how it decided // to pop up this wizard in the first place. // if (0 == the_map.size()) { QMessageBox::information(this, tr("Moneychanger"), tr("Strange: though I didn't think it was the case at first, It seems now that all accounts ARE already confirmed on this contract. (Failure.)")); wizard()->reject(); return; } // ----------------------------------------------- if (bFoundDefault) theChooser.SetPreSelected(qstr_current_id); // ----------------------------------------------- theChooser.setWindowTitle(tr("Choose the next account")); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { if (!theChooser.m_qstrCurrentID.isEmpty()) { setField("AcctName", theChooser.m_qstrCurrentID); emit completeChanged(); return; } } }
void MTCompose::on_serverButton_clicked() { // Select from servers in local wallet filtered by both Nyms. // DlgChooser theChooser(this); mapIDName & the_map = theChooser.m_map; // ----------------------------------------------- mapIDName map_recipientServers; // If server ID is explicitly set, then we may know about a server that the contact // record DOESN'T know about. Therefore we only do this block if the server ID ISN'T // set (where we filter it based on the known servers for a given Nym.) // if (m_serverId.isEmpty() && !m_recipientNymId.isEmpty()) { if (MTContactHandler::getInstance()->GetServers(map_recipientServers, m_recipientNymId)) { the_map = map_recipientServers; // ------------------------------ if (DBHandler::getInstance()->runQuery("SELECT `server` FROM `default_server` WHERE `default_id`='1' LIMIT 0,1")) { QString default_server_id = DBHandler::getInstance()->queryString("SELECT `server` FROM `default_server` WHERE `default_id`='1' LIMIT 0,1", 0, 0); if (!default_server_id.isEmpty()) { mapIDName::iterator it_server = the_map.find(default_server_id); if (it_server != the_map.end()) theChooser.SetPreSelected(default_server_id); } } } } // ----------------------------------------------- if (the_map.size() < 1) { const int32_t server_count = OTAPI_Wrap::It()->GetServerCount(); // ----------------------------------------------- for (int32_t ii = 0; ii < server_count; ++ii) { //Get OT Server ID // QString OT_server_id = QString::fromStdString(OTAPI_Wrap::It()->GetServer_ID(ii)); QString OT_server_name(""); // ----------------------------------------------- if (!OT_server_id.isEmpty()) { if (!m_serverId.isEmpty() && (OT_server_id == m_serverId)) theChooser.SetPreSelected(m_serverId); // ----------------------------------------------- OT_server_name = QString::fromStdString(OTAPI_Wrap::It()->GetServer_Name(OT_server_id.toStdString())); // ----------------------------------------------- the_map.insert(OT_server_id, OT_server_name); } } } // ----------------------------------------------- theChooser.setWindowTitle("Select an OT Server"); // ----------------------------------------------- if (theChooser.exec() == QDialog::Accepted) { qDebug() << QString("SELECT was clicked for ServerID: %1").arg(theChooser.m_qstrCurrentID); if (!theChooser.m_qstrCurrentID.isEmpty()) { m_serverId = theChooser.m_qstrCurrentID; // ----------------------------------------- if (theChooser.m_qstrCurrentName.isEmpty()) ui->serverButton->setText(tr("(This server has a blank name)")); else ui->serverButton->setText(theChooser.m_qstrCurrentName); // ----------------------------------------- return; } } else { qDebug() << "CANCEL was clicked"; } // ----------------------------------------------- m_serverId = QString(""); ui->serverButton->setText(tr("<Click to choose an OT Server>")); }