grim/poc/sqlite-instances

SQLite-instances

This is a proof of concept to see if we can keep a gobject accessible when a ref is persisted elsewhere by storing the pointer in a SQLite database.

The idea here, is that for pidgin3, libpurple's SQLite history adapter, would use a temporary cache table in SQLite that holds a hydrated instance of a message. The UI itself holds a reference to this message and the SQLite history adapter has a weak reference on it to remove it from the cache.

By doing this, a protocol plugin can tell the history API that a message was updated, either modified, receipts changed, new reaction, etc, and the core won't need to tell the UI because the UI will already have the instance and should be monitoring the properties of the message for changes.

So say for example, the UI is displaying a chat, and a remote author changed the content of a message. The protocol plugin will do the following:

PurpleHistoryManager *manager = purple_history_manager_get_default();
PurpleMessage *msg = NULL;

msg = purple_history_manager_query_one(manager, "account:{account-id} id:{message-id}");

purple_message_set_content(msg, new_content);
purple_message_set_edited(msg, TRUE);

purple_history_manager_write(manager, msg);

g_clear_object(&msg);

So what happens here is that manager will look at a temporary table, to check if it has a pointer to a message with the given account and message ids. If it does, it can just return a reference to the object because the UI has it in memory.

Recent Changes
Tags
Branches
Bookmarks