本文整理汇总了C++中OT_ME::create_pseudonym方法的典型用法代码示例。如果您正苦于以下问题:C++ OT_ME::create_pseudonym方法的具体用法?C++ OT_ME::create_pseudonym怎么用?C++ OT_ME::create_pseudonym使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OT_ME
的用法示例。
在下文中一共展示了OT_ME::create_pseudonym方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddButtonClicked
//virtual
void MTNymDetails::AddButtonClicked()
{
MTWizardAddNym theWizard(this);
theWizard.setWindowTitle(tr("Create Nym (a.k.a. Create Identity)"));
if (QDialog::Accepted == theWizard.exec())
{
QString qstrName = theWizard.field("Name") .toString();
int nKeysizeIndex = theWizard.field("Keysize") .toInt();
int nAuthorityIndex = theWizard.field("Authority").toInt();
QString qstrSource = theWizard.field("Source") .toString();
QString qstrLocation = theWizard.field("Location") .toString();
// ---------------------------------------------------
// NOTE: theWizard won't allow each page to finish unless the data is provided.
// (Therefore we don't have to check here to see if any of the data is empty.)
int32_t nKeybits = 1024;
switch (nKeysizeIndex)
{
case 0: // 1024
nKeybits = 1024;
break;
case 1: // 2048
nKeybits = 2048;
break;
case 2: // 4096
nKeybits = 4096;
break;
default:
qDebug() << QString("%1: %2").arg(tr("Error in keysize selection. Using default")).arg(nKeybits);
break;
}
// -------------------------------------------
std::string NYM_ID_SOURCE("");
if (0 != nAuthorityIndex) // Zero would be Self-Signed, which needs no source.
NYM_ID_SOURCE = qstrSource.toStdString();
// -------------------------------------------
std::string ALT_LOCATION("");
if (!qstrLocation.isEmpty())
ALT_LOCATION = qstrLocation.toStdString();
// -------------------------------------------
// Create Nym here...
//
OT_ME madeEasy;
std::string str_id = madeEasy.create_pseudonym(nKeybits, NYM_ID_SOURCE, ALT_LOCATION);
if (str_id.empty())
{
QMessageBox::warning(this, tr("Failed Creating Nym"),
tr("Failed trying to create Nym."));
return;
}
// ------------------------------------------------------
// Get the ID of the new nym.
//
QString qstrID = QString::fromStdString(str_id);
// ------------------------------------------------------
// Register the Namecoin name.
if (nAuthorityIndex == 1)
{
const unsigned cnt = OTAPI_Wrap::GetNym_CredentialCount (str_id);
if (cnt != 1)
{
qDebug () << "Expected one master credential, got " << cnt
<< ". Skipping Namecoin registration.";
}
else
{
const std::string cred = OTAPI_Wrap::GetNym_CredentialID (str_id, 0);
const QString qCred = QString::fromStdString (cred);
NMC_NameManager& nmc = NMC_NameManager::getInstance ();
nmc.startRegistration (qstrID, qCred);
}
}
// ------------------------------------------------------
// Set the Name of the new Nym.
//
//bool bNameSet =
OTAPI_Wrap::SetNym_Name(qstrID.toStdString(), qstrID.toStdString(), qstrName.toStdString());
// -----------------------------------------------
// Commenting this out for now.
//
// QMessageBox::information(this, tr("Success!"), QString("%1: '%2' %3: %4").arg(tr("Success Creating Nym! Name")).
// arg(qstrName).arg(tr("ID")).arg(qstrID));
// ----------
m_pOwner->m_map.insert(qstrID, qstrName);
m_pOwner->SetPreSelected(qstrID);
//.........这里部分代码省略.........