Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customicon support #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

netson
Copy link

@netson netson commented Aug 29, 2018

Updated to the latest master and reworked some parts to also support customicons for groups.

@@ -125,14 +129,6 @@ def notes(self):
def notes(self, value):
return self._set_string_field('Notes', value)

@property
def icon(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the icon getter and setters?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the exact same functions exist in the baseelement; didn't seem necessary


assert type(version) is tuple, 'The provided version is not a tuple, but a {}'.format(
type(version)
)
self._version = version

self._meta = meta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: what's this meta stuff?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KDBX XML contains a Meta tag which contains the customicons (the actual image files). Since it doesn't use a generic key index but instead a base64 index to link the image to the entry, I send the meta tag + children to the the entry, so the base64 index can be converted to a numerical one (as the keepass UI does as well)

@@ -314,6 +314,7 @@ def test_set_and_get_fields(self):
entry.expires = False
entry.expiry_time = changed_time
entry.icon = icons.GLOBE
entry.customicon = "9"
Copy link
Member

@pschmitt pschmitt Aug 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this even be valid? I was expecting more something like an actual image file

EDIT: And icon / customicon should have their own dedicated test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way keepass works is that when you set a customicon, it sets the default icon to 0. If you do not want to use the customicon anymore, the CustomIconUUID tag should be removed from the entry. I can only create a separate test for customicons if I modify the test KDBX files; the code will not set customicon to a value which does not actually exist. So setting this to 9 will only result in a customicon with index 9 if at least 10 customicons exist. In all other cases (as it does here) customicon is set to None, which removes the tag from the entry XML.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to elaborate, customicons are only stored in the database once and are referred to by entries by using a UUID which is base64 encoded. This PR does not add the possibility to add actual image files as custom icons, but merely allows you to set customicons which already exist in the DB by providing their numerical index.

@@ -391,12 +393,6 @@ def test_db_info(self):
def tearDown(self):
os.remove(os.path.join(base_dir, 'change_creds.kdbx'))

class CtxManagerTests(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this was intentional, but probably happened because you merged some pull requests after I rebased; I guess it can be ignored.

@@ -39,13 +39,6 @@ Simple Example
# save database
>>> kp.save()

Context Manager Example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you deleting this?

>>> group = find_groups(name='social', first=True)
>>> entry = kp.add_entry(group, 'testing', 'foo_user', 'passw0rd')
>>> entry = kp.add_entry(group, 'testing', 'foo_user', 'passw0rd', customicon="2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use single quotes

@Evidlo
Copy link
Member

Evidlo commented Oct 3, 2018

We should implement this fully for entries and groups before merging.

@Evidlo Evidlo force-pushed the master branch 2 times, most recently from cf4549b to a6dd83d Compare January 19, 2020 04:01
@Elias481
Copy link

I would also really like custom icons.
But for me the icon-management part (add, remove, lookup) similiar to binary attachment would be important, too.
And I dislike the idea to work with indices here as opposed to the attachment the custom icon do not have indices but UUIDs. So why intoduce an index here that does not really exists (and by definition is not stable as XML allows to reorder the elements)?
(I would have no issues with making the SETTER flexible, so allowing for index and the actual binary data optionally but converting this to the UUID then - and have an icons-function that resolves the UUID to binary - and possibly the current index.)

I see it's long time this PR is pending now...

@staehler
Copy link

staehler commented Jul 6, 2023

Is there a chance to get customicons for groups and entries?
Would be really nice, as our keepass database would fit better to individual application entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants