TMut's account store
About
E-mail clients developed with Tinymail need to implement an account store. TMutAccountStore is TMut's own account store implementation. It supports getting, creating, deleting and editing accounts. It stores the account info in GKeyFiles, which are similar to inifiles. The GKeyFiles are located in $HOME/.tmut/accounts.
Design
TMutAccountStore is not a subclass of an existing TnyAccountStore, instead it's a whole new implementation. On top of the methods TnyAccountStore requires, it also implements methods to delete, create and edit accounts. TMutAccountStore also has three signals: account-created, account-deleted and account-edited. These signals pass the TnyAccount instance in their callback.
Account instance cache
TMutAccountStore has a cache of TnyAccount instances in priv->accounts as a doubly-linked list. The private load_accounts method fills this cache in with existing accounts while the public tmut_account_store_create_account method adds newly created TnyAccount instances to the same cache before emitting the account-created signal. Before emitting the account-deleted signal tmut_account_store_delete_account removes the TnyAccount from the cache.
Storage cache
TMutAccountStore makes the storage cache point to the $HOME/.tmut directory.
Alerts
The tmut_account_store_alert is implemented using a standard gtk_message_dialog_new.
Finding accounts based on url-string
When finding an account using tmut_account_store_find_account, TMutAccountStore reuses Tinymail's standard tny_account_matches_url_string functionality.
Password getters
Password getters are not strictly to be implemented by the TnyAccountStore, while creating the account instances will the account store need to issue a tny_account_set_forget_pass_func and a tny_account_set_pass_func. The TnyPasswordGetter is an interface that can be implemented by the application developer to provide a user interface component or secured password storage functionality to the E-mail client. per_account_get_pass and per_account_forget_pass simply forward the call to a TnyPasswordGetter.
Shared functions
The create_account_instance function is shared by the load_accounts method which loads the cache of accounts, and the tmut_account_store_create_account whenever TMutAccountStore creates a new account.
Deleting accounts
The public tmut_account_store_delete_account function in a quite simple way finds the account that the developer wants to delete in the account cache, and removes it. Once removed it also emits the account-deleted signal and passes the account. Once emitted it finalizes the instance by unreferencing it.
