Example #1
0
void ProfileWizard::createProfile(int result)
{
  if (_profile_edit->isComplete() )
  {
    bts::profile_config conf;
    conf.firstname  = _profile_edit->ui.first_name->text().toUtf8().constData();
    conf.firstname  = fc::trim( conf.firstname );
    conf.middlename = _profile_edit->ui.middle_name->text().toUtf8().constData();
    conf.middlename = fc::trim( conf.middlename );
    conf.lastname   = _profile_edit->ui.last_name->text().toUtf8().constData();
    conf.lastname   = fc::trim( conf.lastname );
    conf.brainkey   = _profile_edit->ui.brainkey->text().toUtf8().constData();
    conf.brainkey   = fc::trim( conf.brainkey );

    std::string                      password = _profile_edit->ui.local_password1->text().toUtf8().constData();

    std::string profile_name         = conf.firstname + " " + conf.lastname;
    auto                             app = bts::application::instance();
    fc::thread* main_thread = &fc::thread::current();
    QProgressBar* progress = new QProgressBar();
    progress->setWindowTitle( "Creating Profile" );
    progress->setMaximum(1000);
    progress->resize( 640, 20 );
    progress->show();
    int x=(qApp->desktop()->width() - progress->width())/2;
    int y=(qApp->desktop()->height() - progress->height())/2;
    progress->move(x,y);
    auto                             profile = app->create_profile(profile_name, conf, password, 
                                               [=]( double p )
                                               {
                                                  main_thread->async( [=](){ 
                                                                      progress->setValue( 1000*p );
                                                                      qApp->sendPostedEvents();
                                                                      qApp->processEvents();
                                                                      if( p >= 1.0 ) progress->deleteLater();
                                                                      } ).wait();
                                               }
                                               );
    assert(profile != nullptr);

    //store myself as contact
  /*
    std::string dac_id_string = _nym_page->_profile_nym_ui.keyhotee_id->text().toStdString();
    bts::addressbook::wallet_contact myself;
    myself.wallet_index = 0;
    myself.first_name = conf.firstname;
    myself.last_name = conf.lastname;
    myself.set_dac_id(dac_id_string);
    auto priv_key = profile->get_keychain().get_identity_key(myself.dac_id_string);
    myself.public_key = priv_key.get_public_key();
    profile->get_addressbook()->store_contact(myself);

    //store myself as identity
    bts::addressbook::wallet_identity new_identity;
    static_cast<bts::addressbook::contact&>(new_identity) = myself;
    profile->store_identity(new_identity);

    bts::application::instance()->add_receive_key(priv_key);
    */

    _mainApp.displayMainWindow();
  }
}