Commit a9bbcc8e authored by Travis Reitter's avatar Travis Reitter

Ensure private and internal data members begin with a _

Helps bgo#629083
parent 74ad4b36
......@@ -73,3 +73,8 @@ Vala-specific rules
blocks. It's arguable that these should be aligned in column 0, as in regular
C functions, but it's too late to change this (as it would make 'git blame'
useless).
5. Private and internal class data members should beging with a _ (public data
members and local variables should not begin with a _). This is to make
non-public data members instantly recognizable as such (which helps
readability).
......@@ -26,14 +26,14 @@
using Folks;
using Folks.Backends.Kf;
private BackendFactory backend_factory = null;
private BackendFactory _backend_factory = null;
/**
* The backend module entry point.
*/
public void module_init (BackendStore backend_store)
{
backend_factory = new BackendFactory (backend_store);
_backend_factory = new BackendFactory (backend_store);
}
/**
......@@ -41,7 +41,7 @@ public void module_init (BackendStore backend_store)
*/
public void module_finalize (BackendStore backend_store)
{
backend_factory = null;
_backend_factory = null;
}
/**
......
......@@ -32,10 +32,10 @@ using Folks.Backends.Kf;
public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
{
private HashTable<string, Persona> _personas;
private File file;
private GLib.KeyFile key_file;
private uint first_unused_id = 0;
private unowned Cancellable save_key_file_cancellable = null;
private File _file;
private GLib.KeyFile _key_file;
private uint _first_unused_id = 0;
private unowned Cancellable _save_key_file_cancellable = null;
private bool _is_prepared = false;
/**
......@@ -125,7 +125,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
display_name: id);
this.trust_level = PersonaStoreTrust.FULL;
this.file = key_file;
this._file = key_file;
this._personas = new HashTable<string, Persona> (str_hash, str_equal);
}
......@@ -138,8 +138,8 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
{
if (!this._is_prepared)
{
string filename = this.file.get_path ();
this.key_file = new GLib.KeyFile ();
string filename = this._file.get_path ();
this._key_file = new GLib.KeyFile ();
/* Load or create the file */
while (true)
......@@ -152,11 +152,11 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
string contents = null;
size_t length = 0;
yield this.file.load_contents_async (null, out contents,
yield this._file.load_contents_async (null, out contents,
out length);
if (length > 0)
{
this.key_file.load_from_data (contents, length,
this._key_file.load_from_data (contents, length,
KeyFileFlags.KEEP_COMMENTS);
}
break;
......@@ -176,7 +176,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
}
/* Ensure the parent directory tree exists for the new file */
File parent_dir = this.file.get_parent ();
File parent_dir = this._file.get_parent ();
try
{
......@@ -203,7 +203,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
try
{
/* Create the file */
FileOutputStream stream = yield this.file.create_async (
FileOutputStream stream = yield this._file.create_async (
FileCreateFlags.PRIVATE, Priority.DEFAULT);
yield stream.close_async (Priority.DEFAULT);
}
......@@ -225,13 +225,13 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
/* We've loaded or created a key file by now, so cycle through the
* groups: each group is a persona which we have to create and
* emit */
string[] groups = this.key_file.get_groups ();
string[] groups = this._key_file.get_groups ();
foreach (string persona_id in groups)
{
if (persona_id.to_int () == this.first_unused_id)
this.first_unused_id++;
if (persona_id.to_int () == this._first_unused_id)
this._first_unused_id++;
Persona persona = new Kf.Persona (this.key_file, persona_id,
Persona persona = new Kf.Persona (this._key_file, persona_id,
this);
this._personas.insert (persona.iid, persona);
}
......@@ -261,7 +261,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
* the main thread). We would cause a deadlock if we used anything as
* fancy/useful as a GCond. */
MainContext context = MainContext.default ();
while (this.save_key_file_cancellable != null)
while (this._save_key_file_cancellable != null)
context.iteration (true);
}
......@@ -275,7 +275,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
try
{
this.key_file.remove_group (persona.display_id);
this._key_file.remove_group (persona.display_id);
yield this.save_key_file ();
/* Signal the removal of the Persona */
......@@ -316,14 +316,14 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
string persona_id = null;
do
{
persona_id = this.first_unused_id.to_string ();
this.first_unused_id++;
persona_id = this._first_unused_id.to_string ();
this._first_unused_id++;
}
while (this.key_file.has_group (persona_id) == true);
while (this._key_file.has_group (persona_id) == true);
/* Create a new persona and set its im-addresses property to update the
* key file */
Persona persona = new Kf.Persona (this.key_file, persona_id, this);
Persona persona = new Kf.Persona (this._key_file, persona_id, this);
this._personas.insert (persona.iid, persona);
persona.im_addresses = im_addresses;
......@@ -338,20 +338,20 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
internal async void save_key_file ()
{
string key_file_data = this.key_file.to_data ();
string key_file_data = this._key_file.to_data ();
Cancellable cancellable = new Cancellable ();
debug ("Saving key file '%s'.", this.file.get_path ());
debug ("Saving key file '%s'.", this._file.get_path ());
/* There's no point in having two competing file write operations.
* We can ensure that only one is running by just checking if a
* cancellable is set. This is thread safe because the code in this file
* is all run in the main thread (inside the main loop), so only we touch
* this.save_key_file_cancellable (albeit in many weird and wonderful
* this._save_key_file_cancellable (albeit in many weird and wonderful
* orders due to idle handler queuing). */
if (this.save_key_file_cancellable != null)
this.save_key_file_cancellable.cancel ();
this.save_key_file_cancellable = cancellable;
if (this._save_key_file_cancellable != null)
this._save_key_file_cancellable.cancel ();
this._save_key_file_cancellable = cancellable;
try
{
......@@ -363,11 +363,11 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
* take this into account until we depend explicitly on
* Vala >= 0.11. */
#if VALA_0_12
yield this.file.replace_contents_async (key_file_data,
yield this._file.replace_contents_async (key_file_data,
key_file_data.length, null, false, FileCreateFlags.PRIVATE,
cancellable);
#else
yield this.file.replace_contents_async (key_file_data,
yield this._file.replace_contents_async (key_file_data,
key_file_data.size (), null, false, FileCreateFlags.PRIVATE,
cancellable);
#endif
......@@ -379,11 +379,11 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
/* Translators: the first parameter is a filename, the second is
* an error message. */
warning (_("Could not write updated key file '%s': %s"),
this.file.get_path (), e.message);
this._file.get_path (), e.message);
}
}
if (this.save_key_file_cancellable == cancellable)
this.save_key_file_cancellable = null;
if (this._save_key_file_cancellable == cancellable)
this._save_key_file_cancellable = null;
}
}
......@@ -32,7 +32,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
Aliasable,
IMable
{
private unowned GLib.KeyFile key_file;
private unowned GLib.KeyFile _key_file;
/* FIXME: As described in the IMable interface, we have to use
* GenericArray<string> here rather than just string[], as null-terminated
* arrays aren't supported as generic types. */
......@@ -65,7 +65,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
debug ("Setting alias of Kf.Persona '%s' to '%s'.", this.uid, value);
this._alias = value;
this.key_file.set_string (this.display_id, "__alias", value);
this._key_file.set_string (this.display_id, "__alias", value);
((Kf.PersonaStore) this.store).save_key_file.begin ();
}
......@@ -87,7 +87,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
try
{
unowned string protocol = (string) k;
this.key_file.remove_key (this.display_id, protocol);
this._key_file.remove_key (this.display_id, protocol);
}
catch (KeyFileError e)
{
......@@ -135,12 +135,10 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
for (; offset > 0; offset--)
addresses[addresses.length - offset] = null;
unowned string[] _addresses =
(string[]) ((PtrArray) addresses).pdata;
_addresses.length = (int) addresses.length;
unowned string[] addrs = (string[]) ((PtrArray) addresses).pdata;
addrs.length = (int) addresses.length;
this.key_file.set_string_list (this.display_id, protocol,
_addresses);
this._key_file.set_string_list (this.display_id, protocol, addrs);
im_addresses.insert (protocol, addresses);
});
......@@ -171,27 +169,28 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
debug ("Adding key-file Persona '%s' (IID '%s', group '%s')", uid, iid,
id);
this.key_file = key_file;
this._key_file = key_file;
this._im_addresses = new HashTable<string, GenericArray<string>> (
str_hash, str_equal);
/* Load the IM addresses from the key file */
try
{
string[] keys = this.key_file.get_keys (this.display_id);
string[] keys = this._key_file.get_keys (this.display_id);
foreach (string key in keys)
{
/* Alias */
if (key == "__alias")
{
this._alias = this.key_file.get_string (this.display_id, key);
this._alias = this._key_file.get_string (this.display_id,
key);
debug (" Loaded alias '%s'.", this._alias);
continue;
}
/* IM addresses */
string protocol = key;
string[] im_addresses = this.key_file.get_string_list (
string[] im_addresses = this._key_file.get_string_list (
this.display_id, protocol);
/* FIXME: We have to convert our nice efficient string[] to a
......@@ -202,12 +201,12 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
GenericArray<string> im_address_array =
new GenericArray<string> ();
foreach (string _address in im_addresses)
foreach (string im_address in im_addresses)
{
try
{
string address =
IMable.normalise_im_address (_address, protocol);
string address = IMable.normalise_im_address (im_address,
protocol);
if (!address_set.contains (address))
{
......
......@@ -45,8 +45,8 @@ private interface LoggerIface : DBus.Object
internal class Logger : GLib.Object
{
private static LoggerIface logger;
private string account_path;
private static LoggerIface _logger;
private string _account_path;
public signal void invalidated ();
public signal void favourite_contacts_changed (string[] added,
......@@ -54,7 +54,7 @@ internal class Logger : GLib.Object
public Logger (string account_path) throws DBus.Error
{
if (this.logger == null)
if (this._logger == null)
{
/* Create a logger proxy for favourites support */
/* FIXME: This should be ported to the Vala GDBus stuff and made
......@@ -69,24 +69,24 @@ internal class Logger : GLib.Object
* the logger service disappears. This is, however, blocked by:
* https://bugzilla.gnome.org/show_bug.cgi?id=623198 */
var dbus_conn = DBus.Bus.get (DBus.BusType.SESSION);
this.logger = dbus_conn.get_object (
this._logger = dbus_conn.get_object (
"org.freedesktop.Telepathy.Logger",
"/org/freedesktop/Telepathy/Logger",
"org.freedesktop.Telepathy.Logger.DRAFT") as LoggerIface;
this.logger.destroy.connect (() =>
this._logger.destroy.connect (() =>
{
/* We've lost the connection to the logger service, so invalidate
* this logger proxy (and all the others too). */
this.logger = null;
this._logger = null;
this.invalidated ();
});
}
this.account_path = account_path;
this.logger.favourite_contacts_changed.connect ((ap, a, r) =>
this._account_path = account_path;
this._logger.favourite_contacts_changed.connect ((ap, a, r) =>
{
if (ap != this.account_path)
if (ap != this._account_path)
return;
this.favourite_contacts_changed (a, r);
......@@ -96,15 +96,15 @@ internal class Logger : GLib.Object
public async string[] get_favourite_contacts () throws DBus.Error
{
/* Invalidated */
if (this.logger == null)
if (this._logger == null)
return {};
AccountFavourites[] favs = yield this.logger.get_favourite_contacts ();
AccountFavourites[] favs = yield this._logger.get_favourite_contacts ();
foreach (AccountFavourites account in favs)
{
/* We only want the favourites from this account */
if (account.account_path == this.account_path)
if (account.account_path == this._account_path)
return account.ids;
}
......@@ -114,20 +114,20 @@ internal class Logger : GLib.Object
public async void add_favourite_contact (string id) throws DBus.Error
{
/* Invalidated */
if (this.logger == null)
if (this._logger == null)
return;
yield this.logger.add_favourite_contact (
new DBus.ObjectPath (this.account_path), id);
yield this._logger.add_favourite_contact (
new DBus.ObjectPath (this._account_path), id);
}
public async void remove_favourite_contact (string id) throws DBus.Error
{
/* Invalidated */
if (this.logger == null)
if (this._logger == null)
return;
yield this.logger.remove_favourite_contact (
new DBus.ObjectPath (this.account_path), id);
yield this._logger.remove_favourite_contact (
new DBus.ObjectPath (this._account_path), id);
}
}
......@@ -45,7 +45,7 @@ public class Tpf.Persona : Folks.Persona,
* unnecessary trips to the Telepathy service to tell it about properties
* being set which are actually just being set from data it's just given us.
*/
private bool is_constructed = false;
private bool _is_constructed = false;
/**
* An avatar for the Persona.
......@@ -92,7 +92,7 @@ public class Tpf.Persona : Folks.Persona,
if (this._alias == value)
return;
if (this.is_constructed)
if (this._is_constructed)
((Tpf.PersonaStore) this.store).change_alias (this, value);
this._alias = value;
}
......@@ -112,7 +112,7 @@ public class Tpf.Persona : Folks.Persona,
if (this._is_favourite == value)
return;
if (this.is_constructed)
if (this._is_constructed)
((Tpf.PersonaStore) this.store).change_is_favourite (this, value);
this._is_favourite = value;
}
......@@ -240,7 +240,7 @@ public class Tpf.Persona : Folks.Persona,
debug ("Creating new Tpf.Persona '%s' for service-specific UID '%s': %p",
uid, id, this);
this.is_constructed = true;
this._is_constructed = true;
/* Set our single IM address */
GenericArray<string> im_address_array = new GenericArray<string> ();
......
......@@ -25,14 +25,14 @@
using Folks;
using Folks.Backends.Tp;
private BackendFactory backend_factory = null;
private BackendFactory _backend_factory = null;
/**
* The Telepathy backend module entry point.
*/
public void module_init (BackendStore backend_store)
{
backend_factory = new BackendFactory (backend_store);
_backend_factory = new BackendFactory (backend_store);
}
/**
......@@ -40,7 +40,7 @@ public void module_init (BackendStore backend_store)
*/
public void module_finalize (BackendStore backend_store)
{
backend_factory = null;
_backend_factory = null;
}
/**
......
......@@ -29,7 +29,7 @@ using Folks.Backends.Tp;
*/
public class Folks.Backends.Tp.Backend : Folks.Backend
{
private AccountManager account_manager;
private AccountManager _account_manager;
private bool _is_prepared = false;
private HashTable<string, PersonaStore> _persona_stores;
......@@ -76,11 +76,11 @@ public class Folks.Backends.Tp.Backend : Folks.Backend
{
if (!this._is_prepared)
{
this.account_manager = AccountManager.dup ();
yield this.account_manager.prepare_async (null);
this.account_manager.account_enabled.connect (
this._account_manager = AccountManager.dup ();
yield this._account_manager.prepare_async (null);
this._account_manager.account_enabled.connect (
this.account_enabled_cb);
this.account_manager.account_validity_changed.connect (
this._account_manager.account_validity_changed.connect (
(a, valid) =>
{
if (valid)
......@@ -88,7 +88,7 @@ public class Folks.Backends.Tp.Backend : Folks.Backend
});
GLib.List<unowned Account> accounts =
this.account_manager.get_valid_accounts ();
this._account_manager.get_valid_accounts ();
foreach (Account account in accounts)
{
this.account_enabled_cb (account);
......@@ -105,10 +105,11 @@ public class Folks.Backends.Tp.Backend : Folks.Backend
*/
public override async void unprepare () throws GLib.Error
{
this.account_manager.account_enabled.disconnect (this.account_enabled_cb);
this.account_manager.account_validity_changed.disconnect (
this._account_manager.account_enabled.disconnect (
this.account_enabled_cb);
this._account_manager.account_validity_changed.disconnect (
this.account_validity_changed_cb);
this.account_manager = null;
this._account_manager = null;
this._persona_stores.foreach ((k, v) =>
{
......
......@@ -40,7 +40,7 @@ public class Folks.BackendStore : Object {
private delegate void ModuleFinalizeFunc (BackendStore store);
/* this contains all backends, regardless of enabled or prepared state */
private HashMap<string,Backend> backend_hash;
private HashMap<string,Backend> _backend_hash;
private HashMap<string,Backend> _prepared_backends;
private File config_file;
private GLib.KeyFile backends_key_file;
......@@ -122,7 +122,7 @@ public class Folks.BackendStore : Object {
Debug.set_flags (Environment.get_variable ("FOLKS_DEBUG"));
this.modules = new HashMap<string,unowned Module> (str_hash, str_equal);
this.backend_hash = new HashMap<string,Backend> (str_hash, str_equal);
this._backend_hash = new HashMap<string,Backend> (str_hash, str_equal);
this._prepared_backends = new HashMap<string,Backend> (str_hash,
str_equal);
}
......@@ -179,7 +179,7 @@ public class Folks.BackendStore : Object {
yield this.prepare ();
/* unload backends that have been disabled since they were loaded */
foreach (var backend_existing in this.backend_hash.values)
foreach (var backend_existing in this._backend_hash.values)
{
yield this.backend_unload_if_needed (backend_existing);
}
......@@ -234,7 +234,7 @@ public class Folks.BackendStore : Object {
this.load_module_from_file (module);
/* this is populated indirectly from load_module_from_file(), above */
foreach (var backend in this.backend_hash.values)
foreach (var backend in this._backend_hash.values)
yield this.backend_load_if_needed (backend);
}
......@@ -269,7 +269,7 @@ public class Folks.BackendStore : Object {
if (!this.backend_is_enabled (backend.name))
{
var backend_existing = this.backend_hash.get (backend.name);
var backend_existing = this._backend_hash.get (backend.name);
if (backend_existing != null)
{
try
......@@ -299,14 +299,14 @@ public class Folks.BackendStore : Object {
public void add_backend (Backend backend)
{
/* Purge any other backend with the same name; re-add if enabled */
var backend_existing = this.backend_hash.get (backend.name);
var backend_existing = this._backend_hash.get (backend.name);
if (backend_existing != null && backend_existing != backend)
{
backend_existing.unprepare ();
this._prepared_backends.unset (backend_existing.name);
}
this.backend_hash.set (backend.name, backend);
this._backend_hash.set (backend.name, backend);
}
private bool backend_is_enabled (string name)
......@@ -339,7 +339,7 @@ public class Folks.BackendStore : Object {
*/
public Backend? get_backend_by_name (string name)
{
return this.backend_hash.get (name);
return this._backend_hash.get (name);
}
/**
......@@ -349,7 +349,7 @@ public class Folks.BackendStore : Object {
*/
public Collection<Backend> list_backends ()
{
return this.backend_hash.values;
return this._backend_hash.values;
}
/**
......
......@@ -61,12 +61,12 @@ public errordomain Folks.IndividualAggregatorError
*/
public class Folks.IndividualAggregator : Object
{
private BackendStore backend_store;
private HashMap<string, PersonaStore> stores;
private unowned PersonaStore writeable_store;
private HashSet<Backend> backends;
private HashTable<string, Individual> link_map;
private bool linking_enabled = true;
private BackendStore _backend_store;
private HashMap<string, PersonaStore> _stores;
private unowned PersonaStore _writeable_store;
private HashSet<Backend> _backends;
private HashTable<string, Individual> _link_map;
private bool _linking_enabled = true;
private bool _is_prepared = false;
/**
......@@ -140,22 +140,22 @@ public class Folks.IndividualAggregator : Object
*/
public IndividualAggregator ()
{
this.stores = new HashMap<string, PersonaStore> ();
this._stores = new HashMap<string, PersonaStore> ();
this.individuals = new HashTable<string, Individual> (str_hash,
str_equal);
this.link_map = new HashTable<string, Individual> (str_hash, str_equal);
this._link_map = new HashTable<string, Individual> (str_hash, str_equal);
this.backends = new HashSet<Backend> ();
this._backends = new HashSet<Backend> ();
string disable_linking =
Environment.get_variable ("FOLKS_DISABLE_LINKING");
if (disable_linking != null)
disable_linking = disable_linking.strip ().down ();
this.linking_enabled = (disable_linking == null ||
this._linking_enabled = (disable_linking == null ||
disable_linking == "no" || disable_linking == "0");
this.backend_store = BackendStore.dup ();
this.backend_store.backend_available.connect (this.backend_available_cb);
this._backend_store = BackendStore.dup ();
this._backend_store.backend_available.connect (this.backend_available_cb);
}
/**
......@@ -181,7 +181,7 @@ public class Folks.IndividualAggregator : Object
{
if (!this._is_prepared)
{
yield this.backend_store.load_backends ();
yield this._backend_store.load_backends ();
this._is_prepared = true;
this.notify_property ("is-prepared");
}
......@@ -190,9 +190,9 @@ public class Folks.IndividualAggregator : Object