Ensure async thread join
[platform/core/security/key-manager.git] / misc / ckm_db_tool / ckm-logic-ext.cpp
index 3b035fc..2cb55d1 100644 (file)
@@ -27,6 +27,8 @@ namespace {
 
 const char *DB_CMD_OBJECT_SELECT = "SELECT * FROM [join_name_object_tables];";
 
+const char *DB_CMD_NAME_SELECT_BY_IDX = "SELECT name, label FROM NAMES WHERE idx = ?001;";
+
 } // anonymous namespace
 
 namespace CKM {
@@ -55,6 +57,32 @@ void CKMLogicExt::saveRow(uid_t user, const DB::Row &row)
        m_userDataMap[user].database.saveRow(row);
 }
 
+NameEntry CKMLogicExt::getNameByIdx(uid_t user, int idx)
+{
+       DB::SqlConnection::DataCommandUniquePtr selectCommand =
+               m_userDataMap[user].database.m_connection->PrepareDataCommand(DB_CMD_NAME_SELECT_BY_IDX);
+       selectCommand->BindInteger(1, idx);
+
+       if (!selectCommand->Step())
+               ThrowErr(Exc::DatabaseFailed, "getting name from database failed");
+
+       NameEntry name;
+       name.name = selectCommand->GetColumnString(0);
+       name.owner = selectCommand->GetColumnString(1);
+       return name;
+}
+
+int CKMLogicExt::readDataHelperProtected(
+       const Credentials &cred,
+       DataType dataType,
+       const Name &name,
+       const ClientId &explicitOwner,
+       const Password &password,
+       Crypto::GObjUPtr &obj)
+{
+       return readDataHelper(false, cred, dataType, name, explicitOwner, password, obj);
+}
+
 } // namespace CKM