DEV Community

Gary Kramlich
Gary Kramlich

Posted on

Tags, Tags, Tags

This article was originally posted on Patreon and has been brought over here to get all of the Pidgin Development/History posts into one single place.

In Pidgin 3 and likewise Purple 2, we have allowed plugins to attach arbitrary data to BuddyListNodes. A BuddyListNode is a node in the tree data structure that represented the buddy list.

This data structure has been causing us some problems for awhile, namely related to traversal, but it also made it difficult to have a buddy be in multiple groups. For these reasons, as well as others, I've been slowly working on a new way to represent buddies. But before we can do the transition, we need to handle those dang arbitrary settings.

The old API allowed you to get and set string, integer, and boolean values on these data types by giving them a name. This makes a lot of sense, but it creates a lot of code, especially when boolean values can usually be determined intuitively by their existence or lack there of. But even then, a boolean value was essentially just an integer value with just 0 or 1.

Effectively that means we need to handle integers and strings, but if we're trying to simplify the API as much as possible we can go much further. So of course, we did just that.

Instead of having a name, type, and value, we now just have a tag which is a string. The idea is a format that's very easy to write and parse. The format can be found below in ABNF:

<tag> ::= <name> [: <value>]
<name> ::= <sequence of any characters except :>
<value> ::= <sequence of any characters>
Enter fullscreen mode Exit fullscreen mode

Purple 3 even includes helpers parsing the name and value from a tag as well as creating one from a name and value. But more importantly, we can now add these tags to whatever we want via the PurpleTags object!

Currently tags are only used by the new PurpleContact and PurplePerson, with plans to add them to PurpleConversation as well. But we'll discuss all of those in another post in the near future, so stay tuned!!

Is there something else we should be adding tags to? If so, please comment below and let us know!!

Top comments (0)