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

libpurple: sync account preferences #264

Closed
himselfv opened this issue Jan 19, 2018 · 7 comments
Closed

libpurple: sync account preferences #264

himselfv opened this issue Jan 19, 2018 · 7 comments
Labels

Comments

@himselfv
Copy link
Contributor

himselfv commented Jan 19, 2018

Hi! I'm trying to solve the problem of not getting offline messages from purple-skypeweb (it receives them fine in Pidgin).

I've learned it properly requests conversations history "since last received message". It stores this timestamp in purple account settings:

void
skype_web_get_offline_history(SkypeWebAccount *sa)
{
	skypeweb_get_all_conversations_since(sa, purple_account_get_int(sa->account, "last_message_timestamp", ((gint) time(NULL))));
}

If it's missing, purple-skypeweb uses the current time => gets no history. So far so good.

It updates this timestamp when parsing messages. After I receive a few messages and then shut down spectrum2, I can verify that in the /var/lib/spectrum2/skype.transport directory there's accounts.xml which contains among other things a proper last_message_timestamp.

So if I send something while the transport is offline, and the just start the transport again, the accounts.xml should be read, and purple-skypeweb should use the correct last_message_timestamp now.

But this doesn't happen. When I start the transport, accounts.xml vanishes and after a while is recreated with what I assume is blank content.

I've found this in libpurple backend's main.cpp :: initPurple():

remove("./accounts.xml");

So my question is, why is it being removed? Should it be? And if it should, what's the correct way to deal with this case? (And similar cases where plugins store stuff in purple's account settings).

@vitalyster
Copy link
Collaborator

IIRC, it was made for "server mode" without database, when user doesn't want to save any settings. Yes, it should not be deleted otherwise.

@vitalyster
Copy link
Collaborator

I have spent some time to understand the issue, and it requires too much work: currently spectrum recreated accounts.xml from database everytime it started. I have hardcoded last_message_timestamp sync with database, but skypeweb save it also for every conversation, we need to enumerate all settings before restore and it require core changes in spectrum storage backend

@vitalyster vitalyster changed the title Why is accounts.xml being deleted? libpurple: sync account preferences Jan 22, 2018
@himselfv
Copy link
Contributor Author

himselfv commented Jan 22, 2018

Okay... What if I just keep the accounts.xml? (It doesn't seem to be recreated if it's present, e.g. if I remove the deletion) Would anything break? Wouldn't DB and the file stay in sync automatically? (If the DB is updated in some kind of purple callbacks and the xml is by libpurple itself)

@vitalyster
Copy link
Collaborator

I don't think there will be problems in single user scenario, but can't say what can be break with multiple users

@himselfv
Copy link
Contributor Author

Okay, thanks!

@Programie
Copy link
Contributor

Programie commented May 18, 2018

Removing and recreating the accounts.xml on every transport restart also results in the steam-mobile plugin losing it's access token and asking for the Steam Guard code every time.

Wouldn't simply syncing all account settings with the configured database fix all those issues?

@vitalyster
Copy link
Collaborator

The latest master does not delete accounts.xml. Need more testing in a multi-account environment

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

No branches or pull requests

3 participants