| 118 { |
118 { |
| 119 return (gevo_prpl_get_field(account, buddy) != 0); |
119 return (gevo_prpl_get_field(account, buddy) != 0); |
| 120 } |
120 } |
| 121 |
121 |
| 122 gboolean |
122 gboolean |
| 123 gevo_load_addressbook(const gchar* uri, EBook **book, GError **error) |
123 gevo_load_addressbook(const gchar* uid, EBook **book, GError **error) { |
| |
124 gboolean result = FALSE; |
| |
125 ESourceRegistry *registry; |
| |
126 ESource *source; |
| |
127 |
| |
128 g_return_val_if_fail(book != NULL, FALSE); |
| |
129 |
| |
130 registry = e_source_registry_new_sync(NULL, error); |
| |
131 |
| |
132 if(!registry) { |
| |
133 return FALSE; |
| |
134 } |
| |
135 |
| |
136 if(uid == NULL) { |
| |
137 source = e_source_registry_ref_default_address_book(registry); |
| |
138 } else { |
| |
139 source = e_source_registry_ref_source(registry, uid); |
| |
140 } |
| |
141 |
| |
142 g_object_unref(registry); |
| |
143 |
| |
144 result = gevo_load_addressbook_from_source(source, book, error); |
| |
145 |
| |
146 g_object_unref(source); |
| |
147 |
| |
148 return result; |
| |
149 } |
| |
150 |
| |
151 gboolean |
| |
152 gevo_load_addressbook_from_source(ESource *source, EBook **book, |
| |
153 GError **error) |
| 124 { |
154 { |
| 125 gboolean result = FALSE; |
155 gboolean result = FALSE; |
| 126 |
156 |
| 127 g_return_val_if_fail(book != NULL, FALSE); |
157 *book = e_book_new(source, error); |
| 128 |
158 |
| 129 if (uri == NULL) |
159 if(*book == NULL) { |
| 130 *book = e_book_new_system_addressbook(error); |
|
| 131 else |
|
| 132 *book = e_book_new_from_uri(uri, error); |
|
| 133 |
|
| 134 if (*book == NULL) |
|
| 135 return FALSE; |
160 return FALSE; |
| |
161 } |
| 136 |
162 |
| 137 *error = NULL; |
163 *error = NULL; |
| 138 |
164 |
| 139 result = e_book_open(*book, FALSE, error); |
165 result = e_book_open(*book, FALSE, error); |
| 140 |
166 |
| 141 if (!result && *book != NULL) |
167 if(!result && *book != NULL) { |
| 142 { |
|
| 143 g_object_unref(*book); |
168 g_object_unref(*book); |
| 144 *book = NULL; |
169 *book = NULL; |
| 145 } |
170 } |
| 146 |
171 |
| 147 return result; |
172 return result; |