Bug 32153

Summary: Account Storage commit() virtual method not optional (as claimed in docs)
Product: Telepathy Reporter: Travis Reitter <travis.reitter>
Component: mission-controlAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/wjt/telepathy-mission-control-wjt.git;a=shortlog;h=refs/heads/misc
Whiteboard: review+
i915 platform: i915 features:

Description Travis Reitter 2010-12-06 15:58:21 UTC
The documentation for mcp_account_storage_commit() claims that the commit() virtual function doesn't need to be implemented if commit_one() is.

However, the code for mcp_account_storage_commit() doesn't use commit_one() at all and returns an "error" response if commit() is not implemented.
Comment 1 Jonny Lamb 2010-12-07 00:18:01 UTC
m5-account-plugins != mission-control
Comment 3 Will Thompson 2011-01-05 09:48:15 UTC
here's a branch that fixes this, as well as fixing a number of other storage buglets and improving the test suite a bit.
Comment 4 Jonny Lamb 2011-01-06 01:21:05 UTC
-    old_string = mcd_storage_dup_string (storage, name, key);
     new_string = g_value_get_string (value);
 
-    if (!tp_strdiff (old_string, new_string))
-    {
-        g_free (old_string);
-        return SET_RESULT_UNCHANGED;
+    if (*new_string == '\0') {
+        new_string = NULL;
     }

What if the value GValue hasn't had a string set to it yet? g_value_get_string will return NULL and *NULL isn't so cool.
Comment 5 Will Thompson 2011-01-06 03:33:26 UTC
(In reply to comment #4)
> -    old_string = mcd_storage_dup_string (storage, name, key);
>      new_string = g_value_get_string (value);
> 
> -    if (!tp_strdiff (old_string, new_string))
> -    {
> -        g_free (old_string);
> -        return SET_RESULT_UNCHANGED;
> +    if (*new_string == '\0') {
> +        new_string = NULL;
>      }
> 
> What if the value GValue hasn't had a string set to it yet? g_value_get_string
> will return NULL and *NULL isn't so cool.

As discussed IRL this is actually safe because dbus-glib never gives you GValues containing NULL strings. But I've amended the patch to use tp_str_empty; and merged it. Cheers! This fix will be in 5.7.2
Comment 6 Vivek Dasmohapatra 2011-01-19 10:00:35 UTC
Released in 5.7.2

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.