[folks] Refer to non-local variables and methods with full name.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Refer to non-local variables and methods with full name.
- Date: Thu, 30 Dec 2010 01:24:48 +0000 (UTC)
commit dc3acdfca04a03f00f0fb04d375fa6946145ce4b
Author: Travis Reitter <travis reitter collabora co uk>
Date: Tue Dec 28 17:21:53 2010 -0800
Refer to non-local variables and methods with full name.
The benefit here is to make it easier to tell when variables are local. Methods
are referred to similarly for consistency.
Fixes bgo#629083
HACKING | 6 ++++
backends/telepathy/lib/tpf-persona-store.vala | 32 ++++++++++++++-----------
backends/telepathy/lib/tpf-persona.vala | 6 ++--
folks/backend-store.vala | 2 +-
folks/has-presence.vala | 3 +-
folks/individual-aggregator.vala | 2 +-
6 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/HACKING b/HACKING
index fdaa818..051a49c 100644
--- a/HACKING
+++ b/HACKING
@@ -100,3 +100,9 @@ Vala-specific rules
9. As in most languages, avoid casting. Casting is usually a sign of an error
which should be fixed and reduces readability.
+
+10. Refer to non-local variables and methods with their qualified name. Within a
+ class function, refer to private data members like 'this._foo' and foreign
+ package symbols like 'package_name.symbol'.
+
+ This makes scope immediately clear, helping readability.
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index af4211b..116e5d8 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -530,12 +530,14 @@ public class Tpf.PersonaStore : Folks.PersonaStore
val.get_boxed ();
var channel_type = TelepathyGLib.asv_get_string (props,
- _tp_channel_channel_type);
+ this._tp_channel_channel_type);
bool handle_type_valid;
var handle_type = TelepathyGLib.asv_get_uint32 (props,
- _tp_channel_handle_type, out handle_type_valid);
+ this._tp_channel_handle_type,
+ out handle_type_valid);
- if ((channel_type == _tp_channel_contact_list_type) &&
+ if ((channel_type ==
+ this._tp_channel_contact_list_type) &&
handle_type_valid &&
(handle_type == HandleType.GROUP))
{
@@ -566,8 +568,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
/* Add the local user */
_conn.notify["self-handle"].connect (this._self_handle_changed_cb);
- if (_conn.self_handle != 0)
- this._self_handle_changed_cb (_conn, null);
+ if (this._conn.self_handle != 0)
+ this._self_handle_changed_cb (this._conn, null);
/* We can only initialise the favourite contacts once _conn is prepared */
this._initialise_favourite_contacts.begin ();
@@ -589,7 +591,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
/* We have to do it this way instead of using
* TpLowleve.get_contacts_by_handle_async() as we're in a notification
* callback */
- c.get_contacts_by_handle (contact_handles, (uint[]) _contact_features,
+ c.get_contacts_by_handle (contact_handles,
+ (uint[]) this._contact_features,
(conn, contacts, failed, error, weak_object) =>
{
if (error != null)
@@ -903,12 +906,13 @@ public class Tpf.PersonaStore : Folks.PersonaStore
var tp_reason = TelepathyGLib.asv_get_uint32 (details, "change-reason",
out valid);
if (valid)
- reason = _change_reason_from_tp_reason (tp_reason);
+ reason = Tpf.PersonaStore._change_reason_from_tp_reason (tp_reason);
this._ignore_by_handle (handle, message, actor, reason);
}
- private Groupable.ChangeReason _change_reason_from_tp_reason (uint reason)
+ private static Groupable.ChangeReason _change_reason_from_tp_reason (
+ uint reason)
{
return (Groupable.ChangeReason) reason;
}
@@ -1417,7 +1421,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
try
{
- var personas = yield _create_personas_from_contact_ids (
+ var personas = yield this._create_personas_from_contact_ids (
contact_ids);
if (personas == null)
@@ -1430,17 +1434,17 @@ public class Tpf.PersonaStore : Folks.PersonaStore
var persona = personas.data;
if (this._subscribe != null)
- _change_standard_contact_list_membership (_subscribe, persona,
- true);
+ this._change_standard_contact_list_membership (this._subscribe,
+ persona, true);
if (this._publish != null)
{
- var flags = _publish.group_get_flags ();
+ var flags = this._publish.group_get_flags ();
if ((flags & ChannelGroupFlags.CAN_ADD) ==
ChannelGroupFlags.CAN_ADD)
{
- _change_standard_contact_list_membership (_publish,
- persona, true);
+ this._change_standard_contact_list_membership (
+ this._publish, persona, true);
}
}
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index 9713c87..66de0e9 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -168,7 +168,7 @@ public class Tpf.Persona : Folks.Persona,
*/
public async void change_group (string group, bool is_member)
{
- if (_change_group (group, is_member))
+ if (this._change_group (group, is_member))
{
Tpf.PersonaStore store = (Tpf.PersonaStore) this.store;
yield store._change_group_membership (this, group, is_member);
@@ -214,7 +214,7 @@ public class Tpf.Persona : Folks.Persona,
{
unowned string id = contact.get_identifier ();
unowned Connection connection = contact.connection;
- var account = _account_for_connection (connection);
+ var account = this._account_for_connection (connection);
var uid = this.build_uid ("telepathy", account.get_protocol (), id);
Object (alias: contact.get_alias (),
@@ -337,7 +337,7 @@ public class Tpf.Persona : Folks.Persona,
private void _contact_notify_presence_type ()
{
- this.presence_type = _folks_presence_type_from_tp (
+ this.presence_type = Tpf.Persona._folks_presence_type_from_tp (
this.contact.get_presence_type ());
}
diff --git a/folks/backend-store.vala b/folks/backend-store.vala
index c1d83f3..e96f27b 100644
--- a/folks/backend-store.vala
+++ b/folks/backend-store.vala
@@ -207,7 +207,7 @@ public class Folks.BackendStore : Object {
bool is_file;
bool is_dir;
- yield _get_file_info (file, out is_file, out is_dir);
+ yield this._get_file_info (file, out is_file, out is_dir);
if (is_file)
{
modules.set (subpath, file);
diff --git a/folks/has-presence.vala b/folks/has-presence.vala
index 76415df..5a3028a 100644
--- a/folks/has-presence.vala
+++ b/folks/has-presence.vala
@@ -142,7 +142,8 @@ public interface Folks.HasPresence : Object
*/
public static int typecmp (PresenceType type_a, PresenceType type_b)
{
- return _type_availability (type_a) - _type_availability (type_b);
+ return (HasPresence._type_availability (type_a) -
+ HasPresence._type_availability (type_b));
}
/**
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 5253554..b55a876 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -754,7 +754,7 @@ public class Folks.IndividualAggregator : Object
Persona persona = null;
try
{
- var details_copy = _asv_copy (details);
+ var details_copy = this._asv_copy (details);
persona = yield store.add_persona_from_details (details_copy);
}
catch (PersonaStoreError e)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]