예제 #1
0
void ContactView::onSave()
{
  try
  {
    if (FromDialog())
    {
      if (_current_record)
      {
        //_current_contact.bit_id_hash = _current_record->name_hash;
        if (!_current_contact.public_key.valid() )
        {
          _current_contact.public_key = _current_record->active_key;
          FC_ASSERT(_current_contact.public_key.valid() );
        }
        // TODO: lookup block id / timestamp that registered this ID
        // _current_contact.known_since.setMSecsSinceEpoch( );
      }
      else if (!_current_record)  /// note: user is entering manual public key
      {
        elog("!current record??\n");
        /*
           if( _current_contact.known_since == QDateTime() )
         {
            _current_contact.known_since = QDateTime::currentDateTime();
         }
         */
        std::string enteredPKey = ui->khid_pubkey->getPublicKeyText().toStdString();
        if (enteredPKey.empty() == false)
        {
          bool publicKeySemanticallyValid = false;
          assert(public_key_address::is_valid(enteredPKey, &publicKeySemanticallyValid));
          assert(publicKeySemanticallyValid);
          public_key_address key_address(enteredPKey);
          _current_contact.public_key = key_address.key;
        }
      }
      _current_contact.privacy_setting = bts::addressbook::secret_contact;
      int idxNewContact = _address_book->storeContact(_current_contact);

      /// notify identity observers
      if (_current_contact.isOwn())
        IdentityObservable::getInstance().notify(_current_contact);

      contactEditable(false);
      emit savedNewContact(idxNewContact);
    }    
  }
  FC_RETHROW_EXCEPTIONS(warn, "onSave")
}
예제 #2
0
void ContactView::onSave()
{
  try
  {
    if (doDataExchange (true))
    {
      if (_current_record)
      {
        //_current_contact.bit_id_hash = _current_record->name_hash;
        if (!_current_contact.public_key.valid() )
        {
          _current_contact.public_key = _current_record->active_key;
          FC_ASSERT(_current_contact.public_key.valid() );
        }
        // TODO: lookup block id / timestamp that registered this ID
        // _current_contact.known_since.setMSecsSinceEpoch( );
      }
      else if (!_current_record)  /// note: user is entering manual public key
      {
        elog("!current record??\n");
        /*
           if( _current_contact.known_since == QDateTime() )
         {
            _current_contact.known_since = QDateTime::currentDateTime();
         }
         */
        std::string enteredPKey = ui->public_key->text().toStdString();
        if (enteredPKey.empty() == false)
        {
          assert(public_key_address::is_valid(enteredPKey) && "Some bug in control validator");
          public_key_address key_address(enteredPKey);
          _current_contact.public_key = key_address.key;
        }
      }
      _current_contact.privacy_setting = bts::addressbook::secret_contact;
      int idxNewContact = _address_book->storeContact(_current_contact);

      keyEdit(false);
      emit savedNewContact(idxNewContact);
    }    
  }
  FC_RETHROW_EXCEPTIONS(warn, "onSave")
}