void TConnectionProcessor::TOutboxQueue::moveMsgToSentDB(const TStoredMailMessage& pendingMsg,
  const TPhysicalMailMessage& sentMsg)
  {
  try
    {
    TIdentity id;
    bool result = findIdentity(pendingMsg.from_key, &id);
    assert(result);

    TStorableMessage storableMsg;
    Processor.PrepareStorableMessage(id, sentMsg, &storableMsg);

    TStoredMailMessage savedMsg = Sent->store_message(storableMsg, nullptr);
    savedMsg.setRead();
    Sent->store_message_header(savedMsg);

    Processor.Sink->OnMessageSent(pendingMsg, savedMsg, sentMsg.src_msg_id);

    std::lock_guard<std::mutex> guard(OutboxDbLock);

    Outbox->remove_message(pendingMsg);
    }
  catch(const fc::exception& e)
    {
    elog("${e}", ("e", e.to_detail_string()));
    }
  }
inline
bool TConnectionProcessor::TOutboxQueue::findIdentityPrivateKey(const TRecipientPublicKey& senderId,
  bts::extended_private_key* key) const
  {
  *key = bts::extended_private_key();

  TIdentity id;
  if(findIdentity(senderId, &id))
    {
    *key = Profile->get_keychain().get_identity_key(id.dac_id_string);
    return true;
    }

  return false;
  }
Example #3
0
Identity RecognitionDatabase::addIdentity(const QMap<QString, QString>& attributes)
{
    if (!d || !d->dbAvailable)
    {
        return Identity();
    }

    QMutexLocker lock(&d->mutex);

    if (attributes.contains(QString::fromLatin1("uuid")))
    {
        Identity matchByUuid = findIdentity(QString::fromLatin1("uuid"), attributes.value(QString::fromLatin1("uuid")));

        if (!matchByUuid.isNull())
        {
            // This situation is not well defined.

            qCDebug(LIBKFACE_LOG) << "Called addIdentity with a given UUID, and there is such a UUID already in the database."
                                  << "The existing identity is returned without adjusting properties!";

            return matchByUuid;
        }
    }

    Identity identity;
    {
        DatabaseFaceOperationGroup group(d->db);
        int id = DatabaseFaceAccess(d->db).db()->addIdentity();
        identity.setId(id);
        identity.setAttributesMap(attributes);
        identity.setAttribute(QString::fromLatin1("uuid"), QUuid::createUuid().toString());
        DatabaseFaceAccess(d->db).db()->updateIdentity(identity);
    }

    d->identityCache[identity.id()] = identity;

    return identity;
}