[telepathy-mission-control/master] McdAccountManager: add and test SupportedAccountProperties property

Simon McVittie simon.mcvittie at collabora.co.uk
Mon May 4 11:55:07 PDT 2009


---
 src/mcd-account-manager.c                          |   25 ++++++++
 .../account-manager/create-with-properties.py      |   16 +++++-
 xml/Account_Manager.xml                            |   64 ++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletions(-)

diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 88a846c..70d9faa 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -662,10 +662,35 @@ get_invalid_accounts (TpSvcDBusProperties *self, const gchar *name,
     accounts_to_gvalue (priv->accounts, FALSE, value);
 }
 
+static void
+get_supported_account_properties (TpSvcDBusProperties *svc,
+                                  const gchar *name,
+                                  GValue *value)
+{
+    static const gchar * const supported[] = {
+        MC_IFACE_ACCOUNT ".AutomaticPresence",
+        MC_IFACE_ACCOUNT ".Enabled",
+        MC_IFACE_ACCOUNT ".Icon",
+        MC_IFACE_ACCOUNT ".Nickname",
+        MC_IFACE_ACCOUNT ".ConnectAutomatically",
+        MC_IFACE_ACCOUNT_INTERFACE_AVATAR ".Avatar",
+        MC_IFACE_ACCOUNT_INTERFACE_COMPAT ".Profile",
+        MC_IFACE_ACCOUNT_INTERFACE_COMPAT ".SecondaryVCardFields",
+        MC_IFACE_ACCOUNT_INTERFACE_CONDITIONS ".Condition",
+        /* FIXME: setting RequestedPresence at create time doesn't work yet */
+        /* MC_IFACE_ACCOUNT ".RequestedPresence", */
+        NULL
+    };
+
+    g_value_init (value, G_TYPE_STRV);
+    g_value_set_static_boxed (value, supported);
+}
+
 static const McdDBusProp account_manager_properties[] = {
     { "ValidAccounts", NULL, get_valid_accounts },
     { "InvalidAccounts", NULL, get_invalid_accounts },
     { "Interfaces", NULL, mcd_dbus_get_interfaces },
+    { "SupportedAccountProperties", NULL, get_supported_account_properties },
     { 0 },
 };
 
diff --git a/test/twisted/account-manager/create-with-properties.py b/test/twisted/account-manager/create-with-properties.py
index c1004a1..19763a0 100644
--- a/test/twisted/account-manager/create-with-properties.py
+++ b/test/twisted/account-manager/create-with-properties.py
@@ -25,12 +25,26 @@ def test(q, bus, mc):
     assert properties.get('InvalidAccounts') == [], \
         properties.get('InvalidAccounts')
     interfaces = properties.get('Interfaces')
+    supported = properties.get('SupportedAccountProperties')
 
     # assert that current functionality exists
     assert cs.AM_IFACE_CREATION_DRAFT in interfaces, interfaces
     assert cs.AM_IFACE_NOKIA_QUERY in interfaces, interfaces
 
-    params = dbus.Dictionary({"account": "someguy at example.com",
+    assert (cs.ACCOUNT + '.AutomaticPresence') in supported
+    assert (cs.ACCOUNT + '.Enabled') in supported
+    assert (cs.ACCOUNT + '.Icon') in supported
+    assert (cs.ACCOUNT + '.Nickname') in supported
+    assert (cs.ACCOUNT + '.ConnectAutomatically') in supported
+    assert (cs.ACCOUNT_IFACE_AVATAR + '.Avatar') in supported
+    assert (cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.Profile') in supported
+    assert (cs.ACCOUNT_IFACE_NOKIA_COMPAT + '.SecondaryVCardFields') in supported
+    assert (cs.ACCOUNT_IFACE_NOKIA_CONDITIONS + '.Condition') in supported
+
+    # FIXME: setting RequestedPresence at create time doesn't work yet
+    #assert (cs.ACCOUNT + '.RequestedPresence') in supported
+
+    params = dbus.Dictionary({"account": "anarki at example.com",
         "password": "secrecy"}, signature='sv')
 
     cm_name_ref = dbus.service.BusName(cs.tp_name_prefix +
diff --git a/xml/Account_Manager.xml b/xml/Account_Manager.xml
index 6fb9b08..df53a45 100644
--- a/xml/Account_Manager.xml
+++ b/xml/Account_Manager.xml
@@ -127,6 +127,70 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
       </arg>
     </signal>
 
+    <property name="SupportedAccountProperties"
+      tp:name-for-bindings="Supported_Account_Properties"
+      type="as" tp:type="DBus_Qualified_Member[]" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>A list of the fully qualified names of properties that can be set
+          via the Properties argument to
+          <tp:member-ref>CreateAccount</tp:member-ref> when an account is
+          created.</p>
+
+        <tp:rationale>
+          <p>Examples of good properties to support here include
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">Icon</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">Enabled</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">Nickname</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">AutomaticPresence</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">ConnectAutomatically</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">RequestedPresence</tp:dbus-ref>
+            and
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account.Interface.Avatar">Avatar</tp:dbus-ref>.
+            </p>
+
+          <p>Examples of properties that would make no sense here include
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">Valid</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">Connection</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">ConnectionStatus</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">ConnectionStatusReason</tp:dbus-ref>,
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">CurrentPresence</tp:dbus-ref>
+            and
+            <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">NormalizedName</tp:dbus-ref>.
+          </p>
+        </tp:rationale>
+
+        <p>This property MUST NOT include include the <tp:dbus-ref
+            namespace="org.freedesktop.Telepathy.Account">DisplayName</tp:dbus-ref>
+          and <tp:dbus-ref
+            namespace="org.freedesktop.Telepathy.Account">Parameters</tp:dbus-ref>
+          properties, which are set using separate arguments.</p>
+
+        <p>This property MAY include the names of properties that, after
+          account creation, will be read-only: this indicates that the property
+          can be set at account creation but not changed later.</p>
+
+        <tp:rationale>
+          <p>For example, an account manager might support migration tools that
+            use this to preserve the <tp:dbus-ref
+              namespace="org.freedesktop.Telepathy.Account">HasBeenOnline</tp:dbus-ref>
+            property, even though that property is usually read-only.</p>
+        </tp:rationale>
+      </tp:docstring>
+    </property>
+
     <method name="CreateAccount" tp:name-for-bindings="Create_Account">
       <tp:docstring>
         Request the creation of a new <tp:dbus-ref
-- 
1.5.6.5




More information about the telepathy-commits mailing list