Remove the purpose argument from all GetKey() variants.

The type is relevant and required as it determines the type of the
handed in key. The purpose however isn't actually needed and rather
inconvenient to get by depending on the situation.
This commit is contained in:
Michael Lotz
2013-03-05 11:04:08 -05:00
committed by Ryan Leavengood
parent 90013c82e8
commit 51ab46a83c
3 changed files with 25 additions and 33 deletions
+8 -12
View File
@@ -16,27 +16,23 @@ public:
// TODO: -> GetNextPassword() - there can always be more than one key // TODO: -> GetNextPassword() - there can always be more than one key
// with the same identifier/secondaryIdentifier (ie. different username) // with the same identifier/secondaryIdentifier (ie. different username)
status_t GetKey(BKeyType type, BKeyPurpose purpose, status_t GetKey(BKeyType type, const char* identifier,
const char* identifier, BKey& key); BKey& key);
status_t GetKey(BKeyType type, BKeyPurpose purpose, status_t GetKey(BKeyType type, const char* identifier,
const char* identifier,
const char* secondaryIdentifier, BKey& key); const char* secondaryIdentifier, BKey& key);
status_t GetKey(BKeyType type, BKeyPurpose purpose, status_t GetKey(BKeyType type, const char* identifier,
const char* identifier,
const char* secondaryIdentifier, const char* secondaryIdentifier,
bool secondaryIdentifierOptional, bool secondaryIdentifierOptional,
BKey& key); BKey& key);
status_t GetKey(const char* keyring, status_t GetKey(const char* keyring,
BKeyType type, BKeyPurpose purpose, BKeyType type, const char* identifier,
const char* identifier, BKey& key); BKey& key);
status_t GetKey(const char* keyring, status_t GetKey(const char* keyring,
BKeyType type, BKeyPurpose purpose, BKeyType type, const char* identifier,
const char* identifier,
const char* secondaryIdentifier, BKey& key); const char* secondaryIdentifier, BKey& key);
status_t GetKey(const char* keyring, status_t GetKey(const char* keyring,
BKeyType type, BKeyPurpose purpose, BKeyType type, const char* identifier,
const char* identifier,
const char* secondaryIdentifier, const char* secondaryIdentifier,
bool secondaryIdentifierOptional, bool secondaryIdentifierOptional,
BKey& key); BKey& key);
+2 -2
View File
@@ -37,8 +37,8 @@ remove_password(const char* keyring, const char* identifier,
BKeyStore keyStore; BKeyStore keyStore;
BPasswordKey password; BPasswordKey password;
status_t result = keyStore.GetKey(keyring, B_KEY_TYPE_PASSWORD, status_t result = keyStore.GetKey(keyring, B_KEY_TYPE_PASSWORD, identifier,
B_KEY_PURPOSE_ANY, identifier, secondaryIdentifier, false, password); secondaryIdentifier, false, password);
if (result != B_OK) { if (result != B_OK) {
printf("failed to get password \"%s\": %s\n", identifier, printf("failed to get password \"%s\": %s\n", identifier,
strerror(result)); strerror(result));
+15 -19
View File
@@ -28,58 +28,54 @@ BKeyStore::~BKeyStore()
status_t status_t
BKeyStore::GetKey(BKeyType type, BKeyPurpose purpose, const char* identifier, BKeyStore::GetKey(BKeyType type, const char* identifier, BKey& key)
BKey& key)
{ {
return GetKey(NULL, type, purpose, identifier, NULL, true, key); return GetKey(NULL, type, identifier, NULL, true, key);
} }
status_t status_t
BKeyStore::GetKey(BKeyType type, BKeyPurpose purpose, const char* identifier, BKeyStore::GetKey(BKeyType type, const char* identifier,
const char* secondaryIdentifier, BKey& key) const char* secondaryIdentifier, BKey& key)
{ {
return GetKey(NULL, type, purpose, identifier, secondaryIdentifier, true, return GetKey(NULL, type, identifier, secondaryIdentifier, true, key);
key);
} }
status_t status_t
BKeyStore::GetKey(BKeyType type, BKeyPurpose purpose, const char* identifier, BKeyStore::GetKey(BKeyType type, const char* identifier,
const char* secondaryIdentifier, bool secondaryIdentifierOptional, const char* secondaryIdentifier, bool secondaryIdentifierOptional,
BKey& key) BKey& key)
{ {
return GetKey(NULL, type, purpose, identifier, secondaryIdentifier, return GetKey(NULL, type, identifier, secondaryIdentifier,
secondaryIdentifierOptional, key); secondaryIdentifierOptional, key);
} }
status_t status_t
BKeyStore::GetKey(const char* keyring, BKeyType type, BKeyPurpose purpose, BKeyStore::GetKey(const char* keyring, BKeyType type, const char* identifier,
const char* identifier, BKey& key) BKey& key)
{ {
return GetKey(keyring, type, purpose, identifier, NULL, true, key); return GetKey(keyring, type, identifier, NULL, true, key);
} }
status_t status_t
BKeyStore::GetKey(const char* keyring, BKeyType type, BKeyPurpose purpose, BKeyStore::GetKey(const char* keyring, BKeyType type, const char* identifier,
const char* identifier, const char* secondaryIdentifier, BKey& key) const char* secondaryIdentifier, BKey& key)
{ {
return GetKey(keyring, type, purpose, identifier, secondaryIdentifier, true, return GetKey(keyring, type, identifier, secondaryIdentifier, true, key);
key);
} }
status_t status_t
BKeyStore::GetKey(const char* keyring, BKeyType type, BKeyPurpose purpose, BKeyStore::GetKey(const char* keyring, BKeyType type, const char* identifier,
const char* identifier, const char* secondaryIdentifier, const char* secondaryIdentifier, bool secondaryIdentifierOptional,
bool secondaryIdentifierOptional, BKey& key) BKey& key)
{ {
BMessage message(KEY_STORE_GET_KEY); BMessage message(KEY_STORE_GET_KEY);
message.AddString("keyring", keyring); message.AddString("keyring", keyring);
message.AddUInt32("type", type); message.AddUInt32("type", type);
message.AddUInt32("purpose", purpose);
message.AddString("identifier", identifier); message.AddString("identifier", identifier);
message.AddString("secondaryIdentifier", secondaryIdentifier); message.AddString("secondaryIdentifier", secondaryIdentifier);
message.AddBool("secondaryIdentifierOptional", secondaryIdentifierOptional); message.AddBool("secondaryIdentifierOptional", secondaryIdentifierOptional);