Add B*Key::PrintToStream() method for debugging convenience.
This commit is contained in:
committed by
Ryan Leavengood
parent
8d9bc9e0ee
commit
c494c06109
@@ -73,6 +73,8 @@ public:
|
||||
bool operator==(const BKey& other) const;
|
||||
bool operator!=(const BKey& other) const;
|
||||
|
||||
virtual void PrintToStream();
|
||||
|
||||
protected:
|
||||
virtual status_t _Flatten(BMessage& message) const;
|
||||
virtual status_t _Unflatten(const BMessage& message);
|
||||
@@ -108,6 +110,8 @@ public:
|
||||
|
||||
status_t SetPassword(const char* password);
|
||||
const char* Password() const;
|
||||
|
||||
virtual void PrintToStream();
|
||||
};
|
||||
|
||||
#endif // _KEY_H
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <Key.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#if 0
|
||||
// TODO: move this to the KeyStore or the registrar backend if needed
|
||||
@@ -198,6 +200,40 @@ BKey::operator!=(const BKey& other) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BKey::PrintToStream()
|
||||
{
|
||||
if (Type() == B_KEY_TYPE_GENERIC)
|
||||
printf("generic key:\n");
|
||||
|
||||
const char* purposeString = "unknown";
|
||||
switch (fPurpose) {
|
||||
case B_KEY_PURPOSE_ANY:
|
||||
purposeString = "any";
|
||||
break;
|
||||
case B_KEY_PURPOSE_GENERIC:
|
||||
purposeString = "generic";
|
||||
break;
|
||||
case B_KEY_PURPOSE_WEB:
|
||||
purposeString = "web";
|
||||
break;
|
||||
case B_KEY_PURPOSE_NETWORK:
|
||||
purposeString = "network";
|
||||
break;
|
||||
case B_KEY_PURPOSE_VOLUME:
|
||||
purposeString = "volume";
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\tpurpose: %s\n", purposeString);
|
||||
printf("\tidentifier: \"%s\"\n", fIdentifier.String());
|
||||
printf("\tsecondary identifier: \"%s\"\n", fSecondaryIdentifier.String());
|
||||
printf("\towner: \"%s\"\n", fOwner.String());
|
||||
printf("\tcreation time: %" B_PRIu64 "\n", fCreationTime);
|
||||
printf("\traw data length: %" B_PRIuSIZE "\n", fData.BufferLength());
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BKey::_Flatten(BMessage& message) const
|
||||
{
|
||||
@@ -290,3 +326,12 @@ BPasswordKey::Password() const
|
||||
{
|
||||
return (const char*)Data();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPasswordKey::PrintToStream()
|
||||
{
|
||||
printf("password key:\n");
|
||||
BKey::PrintToStream();
|
||||
printf("\tpassword: \"%s\"\n", Password());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user