Merge lp:~rodrigo-moya/ubuntuone-client/fix-617656 into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: John Lenton
Approved revision: 712
Merged at revision: 708
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/fix-617656
Merge into: lp:ubuntuone-client
Diff against target: 207 lines (+57/-17)
5 files modified
libsyncdaemon/syncdaemon-filesystem-interface.c (+3/-1)
libsyncdaemon/syncdaemon-metadata.c (+20/-13)
libsyncdaemon/syncdaemon-metadata.h (+1/-1)
nautilus/contacts-view.c (+32/-2)
nautilus/contacts-view.h (+1/-0)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/fix-617656
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+35694@code.launchpad.net

Commit message

- Plug a memory leak that might be causing #617656
- Added contacts for users with no addressbooks are kept in memory correctly now
- Fixed syncdaemon_metadata_get_is_synced to work for post-generations folders

Description of the change

This branch fixes several bugs:

- Plug a memory leak that might be causing #617656
- Added contacts for users with no addressbooks are kept in memory correctly now
- Fixed syncdaemon_metadata_get_is_synced to work for post-generations folders

To post a comment you must log in.
Revision history for this message
Roman Yepishev (rye) wrote :

Tested syncdaemon_metadata_get_is_synced to work for post-generations folders.
LP:61756 may also be caused by non-started syncdaemon but since nautilus plugin now waits for syncdaemon to be ready it does not hang that way.
Was not able to reproduce the issue with missing addressbooks, so mark this as Approved.

review: Approve (fieldtest)
Revision history for this message
John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libsyncdaemon/syncdaemon-filesystem-interface.c'
2--- libsyncdaemon/syncdaemon-filesystem-interface.c 2010-08-06 21:24:22 +0000
3+++ libsyncdaemon/syncdaemon-filesystem-interface.c 2010-09-16 17:12:21 +0000
4@@ -140,6 +140,8 @@
5 g_error_free (error);
6 gmd->callback (gmd->interface, FALSE, NULL, gmd->user_data);
7 }
8+
9+ g_free (gmd);
10 }
11
12 /**
13@@ -153,7 +155,7 @@
14 gpointer user_data)
15 {
16 GotMetadataData *gmd;
17- const char *method;
18+ const gchar *method;
19
20 g_return_if_fail (SYNCDAEMON_IS_FILESYSTEM_INTERFACE (interface));
21
22
23=== modified file 'libsyncdaemon/syncdaemon-metadata.c'
24--- libsyncdaemon/syncdaemon-metadata.c 2010-08-06 23:09:21 +0000
25+++ libsyncdaemon/syncdaemon-metadata.c 2010-09-16 17:12:21 +0000
26@@ -30,6 +30,7 @@
27 gchar *share_id;
28 gchar *node_id;
29 gboolean is_synced;
30+ gboolean is_dir;
31 };
32
33 static void
34@@ -97,7 +98,10 @@
35 syncdaemon_metadata_set_server_hash (metadata, g_hash_table_lookup (hash, "server_hash"));
36 syncdaemon_metadata_set_share_id (metadata, g_hash_table_lookup (hash, "share_id"));
37 syncdaemon_metadata_set_node_id (metadata, g_hash_table_lookup (hash, "node_id"));
38- syncdaemon_metadata_set_is_synced (metadata, g_hash_table_lookup (hash, "quick_tree_synced"));
39+ syncdaemon_metadata_set_is_synced (
40+ metadata,
41+ g_strcmp0 (g_hash_table_lookup (hash, "quick_tree_synced"), "synced") == 0);
42+ metadata->priv->is_dir = g_strcmp0 (g_hash_table_lookup (hash, "is_dir"), "True") == 0;
43 /* FIXME: we ignore the other values in the hash table since none of our
44 clients use them for now */
45 }
46@@ -236,29 +240,32 @@
47 gboolean
48 syncdaemon_metadata_get_is_synced (SyncdaemonMetadata *metadata)
49 {
50- const gchar * local, * server;
51- gboolean is_updated;
52+ gchar *local, *server;
53+ gboolean is_updated;
54
55 g_return_val_if_fail (SYNCDAEMON_IS_METADATA (metadata), FALSE);
56
57- local = syncdaemon_metadata_get_local_hash (metadata);
58- server = syncdaemon_metadata_get_server_hash (metadata);
59-
60- is_updated = local && server && *local && *server &&
61- strcmp (local, server) == 0;
62-
63- /* we are synced if both is_synced and is_updated are true */
64- return metadata->priv->is_synced && is_updated;
65+ /* If it's a dir, we have the 'quick_tree_synced' value */
66+ if (metadata->priv->is_dir)
67+ return metadata->priv->is_synced;
68+
69+ local = metadata->priv->local_hash;
70+ server = metadata->priv->server_hash;
71+
72+ is_updated = local && server && *local && *server &&
73+ g_strcmp0 (local, server) == 0;
74+
75+ return is_updated;
76 }
77
78 /**
79 * syncdaemon_metadata_set_is_synced:
80 */
81 void
82-syncdaemon_metadata_set_is_synced (SyncdaemonMetadata *metadata, const gchar *is_synced)
83+syncdaemon_metadata_set_is_synced (SyncdaemonMetadata *metadata, gboolean is_synced)
84 {
85 g_return_if_fail (SYNCDAEMON_IS_METADATA (metadata));
86
87- metadata->priv->is_synced = !is_synced || (is_synced && *is_synced);
88+ metadata->priv->is_synced = is_synced;
89 }
90
91
92=== modified file 'libsyncdaemon/syncdaemon-metadata.h'
93--- libsyncdaemon/syncdaemon-metadata.h 2010-08-06 21:24:22 +0000
94+++ libsyncdaemon/syncdaemon-metadata.h 2010-09-16 17:12:21 +0000
95@@ -59,7 +59,7 @@
96 const gchar *syncdaemon_metadata_get_node_id (SyncdaemonMetadata *metadata);
97 void syncdaemon_metadata_set_node_id (SyncdaemonMetadata *metadata, const gchar *node_id);
98 gboolean syncdaemon_metadata_get_is_synced (SyncdaemonMetadata *metadata);
99-void syncdaemon_metadata_set_is_synced (SyncdaemonMetadata *metadata, const gchar *is_synced);
100+void syncdaemon_metadata_set_is_synced (SyncdaemonMetadata *metadata, gboolean is_synced);
101
102
103 #endif
104
105=== modified file 'nautilus/contacts-view.c'
106--- nautilus/contacts-view.c 2010-09-07 15:21:00 +0000
107+++ nautilus/contacts-view.c 2010-09-16 17:12:21 +0000
108@@ -79,6 +79,11 @@
109 cv->source_list = NULL;
110 }
111
112+ if (cv->added_contacts != NULL) {
113+ g_hash_table_destroy (cv->added_contacts);
114+ cv->added_contacts = NULL;
115+ }
116+
117 while (cv->books != NULL) {
118 EBook *book = (EBook *) cv->books->data;
119 cv->books = g_slist_remove (cv->books, book);
120@@ -153,6 +158,7 @@
121 GTK_TREE_SELECTION (view),
122 &model);
123 #endif
124+
125 for (l = selected_items; l != NULL; l = l->next) {
126 GtkTreeIter iter;
127
128@@ -387,7 +393,7 @@
129 #endif
130
131 gtk_list_store_prepend (model, &new_row);
132- gtk_list_store_set (GTK_LIST_STORE (model), &new_row,
133+ gtk_list_store_set (model, &new_row,
134 CONTACTS_VIEW_COLUMN_NAME, contact_name,
135 CONTACTS_VIEW_COLUMN_MARKUP, contact_markedup_name,
136 CONTACTS_VIEW_COLUMN_EMAIL, contact_email,
137@@ -544,6 +550,7 @@
138 cv->selection = g_hash_table_new_full (g_str_hash, g_str_equal,
139 (GDestroyNotify) g_free,
140 (GDestroyNotify) free_selected_contact_info);
141+ cv->added_contacts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
142
143 /* Get recently used contacts */
144 cv->config_client = gconf_client_get_default ();
145@@ -692,6 +699,22 @@
146 retrieve_contacts (cv, book, search_string, tmp_selection);
147 }
148
149+ /* If we added contacts in-memory, add them to the model now */
150+ g_hash_table_iter_init (&hash_iter, cv->added_contacts);
151+ while (g_hash_table_iter_next (&hash_iter, &key, &value)) {
152+ gchar *markup;
153+
154+ /* We only add it if it's not on the other lists */
155+ if (!g_hash_table_lookup (tmp_selection, key)) {
156+ markup = g_markup_escape_text ((const gchar *) key, -1);
157+ add_one_contact (cv, (const gchar *) key,
158+ (const gchar *) markup,
159+ (const gchar *) value,
160+ NULL, tmp_selection);
161+ g_free (markup);
162+ }
163+ }
164+
165 g_hash_table_unref (tmp_selection);
166 }
167
168@@ -741,6 +764,7 @@
169 GSList *l;
170 gchar *s;
171 GdkPixbuf *pixbuf;
172+ gboolean added = FALSE;
173
174 icon_theme = gtk_icon_theme_get_default ();
175
176@@ -776,7 +800,9 @@
177 e_contact_set (contact, E_CONTACT_FULL_NAME, (gconstpointer) contact_name);
178 e_contact_set (contact, E_CONTACT_EMAIL_1, (gconstpointer) contact_email);
179
180- if (!e_book_add_contact (E_BOOK (l->data), contact, &error)) {
181+ if (e_book_add_contact (E_BOOK (l->data), contact, &error))
182+ added = TRUE;
183+ else {
184 g_warning ("Could not add contact to %s: %s", uri, error->message);
185 g_error_free (error);
186 }
187@@ -786,4 +812,8 @@
188 break;
189 }
190 }
191+
192+ /* If the contact was not added, keep a copy of it so that it shows */
193+ if (!added)
194+ g_hash_table_insert (cv->added_contacts, g_strdup (contact_name), g_strdup (contact_email));
195 }
196
197=== modified file 'nautilus/contacts-view.h'
198--- nautilus/contacts-view.h 2010-07-07 17:25:37 +0000
199+++ nautilus/contacts-view.h 2010-09-16 17:12:21 +0000
200@@ -44,6 +44,7 @@
201 GSList *books;
202 GHashTable *selection;
203 GHashTable *recently_used;
204+ GHashTable *added_contacts;
205
206 /* Widgets */
207 GtkWidget *contacts_list;

Subscribers

People subscribed via source and target branches