Changeset 1212
- Timestamp:
- 11/23/06 14:46:55
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-account-store.sgml (modified) (4 diffs)
- trunk/docs/devel/reference/tmpl/tny-device.sgml (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-shared.sgml (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (5 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1211 r1212 1 2006-11-23 Sergio Villar Senin <svillar@igalia.com> 2 * libtinymail-camel/tny-camel-folder.c: added support to rename 3 folders 4 * libtinymail-camel/tny-camel-store-account.c: refactored the 5 subscriptions code 6 * libtinymail-gnome-desktop/tny-gnome-account-store.c: removed a small 7 leak 8 1 9 2006-11-21 Sergio Villar Senin <svillar@igalia.com> 2 10 * Fixed a bug when subscribing new folders trunk/docs/devel/reference/tmpl/tny-account-store.sgml
r1202 r1212 43 43 </para> 44 44 45 @: 46 @: 47 45 48 @tnyaccountstore: the object which received the signal. 46 49 @arg1: … … 50 53 51 54 </para> 55 56 @: 57 @: 52 58 53 59 @tnyaccountstore: the object which received the signal. … … 59 65 </para> 60 66 67 @: 68 @: 69 61 70 @tnyaccountstore: the object which received the signal. 62 71 @arg1: … … 66 75 67 76 </para> 77 78 @: 68 79 69 80 @tnyaccountstore: the object which received the signal. trunk/docs/devel/reference/tmpl/tny-device.sgml
r1202 r1212 29 29 30 30 </para> 31 32 @: 33 @: 31 34 32 35 @tnydevice: the object which received the signal. trunk/docs/devel/reference/tmpl/tny-shared.sgml
r1202 r1212 292 292 </para> 293 293 294 @ tnystoreaccount: the object which received the signal.295 @ arg1:294 @: 295 @: 296 296 297 297 <!-- ##### STRUCT TnyStoreAccountIface ##### --> trunk/libtinymail-camel/tny-camel-folder.c
r1202 r1212 196 196 } 197 197 198 priv->cached_length = camel_folder_get_message_count (priv->folder); 198 priv->subscribed = 199 camel_store_folder_subscribed (store, 200 camel_folder_get_full_name (priv->folder)); 201 priv->cached_length = camel_folder_get_message_count (priv->folder); 199 202 200 203 /* priv->folder_changed_id = camel_object_hook_event (priv->folder, … … 381 384 382 385 g_mutex_lock (priv->folder_lock); 386 387 if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 388 { 389 CamelStore *store; 390 CamelFolder *cfolder; 391 392 if (!load_folder_no_lock (priv)) 393 { 394 g_mutex_unlock (priv->folder_lock); 395 return; 396 } 397 store = (CamelStore*) _tny_camel_account_get_service 398 (TNY_CAMEL_ACCOUNT (priv->account)); 399 cfolder = tny_camel_folder_get_folder (TNY_CAMEL_FOLDER (self)); 400 priv->subscribed = camel_store_folder_subscribed (store, 401 camel_folder_get_full_name (cfolder)); 402 } 403 383 404 retval = priv->subscribed; 384 405 g_mutex_unlock (priv->folder_lock); … … 1068 1089 { 1069 1090 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 1070 1071 if (!load_folder (priv)) 1091 gchar *full_name; 1092 CamelFolder *cfolder; 1093 CamelFolderInfo *parent_info; 1094 const gchar *old_path; 1095 gchar *new_path; 1096 CamelException ex; 1097 1098 g_mutex_lock (priv->folder_lock); 1099 1100 if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 1101 if (!load_folder_no_lock (priv)) 1102 { 1103 g_mutex_unlock (priv->folder_lock); 1104 return; 1105 } 1106 1107 if (!priv->iter || !priv->iter_parented) 1072 1108 return; 1073 1109 1074 camel_folder_rename (priv->folder, name); 1110 /* Create new full name */ 1111 cfolder = tny_camel_folder_get_folder (TNY_CAMEL_FOLDER (self)); 1112 old_path = camel_folder_get_full_name (cfolder); 1113 parent_info = priv->iter->parent; 1114 new_path = g_strdup_printf ("%s/%s", parent_info->name, name); 1115 1116 /* Check that the name really changes */ 1117 if (!strcmp (old_path, new_path)) 1118 { 1119 g_free (new_path); 1120 return; 1121 } 1122 1123 /* Rename folder */ 1124 camel_exception_init (&ex); 1125 camel_store_rename_folder (cfolder->parent_store, old_path, (const gchar *) new_path, &ex); 1126 g_free (new_path); 1127 1128 if (camel_exception_is_set (&ex)) 1129 { 1130 g_warning (N_("Renaming folder %s to %s failed: %s\n"), 1131 camel_folder_get_name (cfolder), 1132 name, 1133 camel_exception_get_description (&ex)); 1134 camel_exception_clear (&ex); 1135 return; 1136 } 1075 1137 1076 1138 if (G_UNLIKELY (priv->cached_name)) … … 1079 1141 priv->cached_name = g_strdup (name); 1080 1142 1081 return;1143 g_mutex_unlock (priv->folder_lock); 1082 1144 } 1083 1145 … … 1356 1418 info = camel_store_create_folder (store, priv->folder_name, name, &ex); 1357 1419 1358 if (camel_exception_is_set (&ex)) { 1359 g_warning ("Creating folder failed: %s\n", 1420 if (camel_exception_is_set (&ex)) 1421 { 1422 g_warning (N_("Creating folder failed: %s\n"), 1360 1423 camel_exception_get_description (&ex)); 1361 1424 g_object_unref (G_OBJECT (folder)); trunk/libtinymail-camel/tny-camel-store-account.c
r1202 r1212 89 89 90 90 camel_url_set_protocol (url, priv->proto); 91 92 91 camel_url_set_user (url, priv->user); 93 92 camel_url_set_host (url, priv->host); … … 165 164 } 166 165 167 168 static void 169 tny_camel_store_account_subscribe (TnyStoreAccount *self, TnyFolder *folder) 170 { 171 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 166 /** 167 * This utility function performs folder subscriptions/unsubscriptions 168 * since the code for both operations is almost the same. If the 169 * subscribe parameter is TRUE, then we're asking for a folder 170 * subscription, else for a folder unsubscription */ 171 static void 172 set_subscription (TnyStoreAccount *self, TnyFolder *folder, gboolean subscribe) 173 { 174 TnyCamelAccountPriv *apriv; 172 175 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 173 176 CamelStore *store; … … 175 178 const gchar *folder_full_name; 176 179 177 g_assert (TNY_IS_CAMEL_FOLDER (folder)); 178 180 apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 181 182 /* Get store */ 179 183 g_static_rec_mutex_lock (apriv->service_lock); 180 184 store = camel_session_get_store ((CamelSession*) apriv->session, … … 182 186 g_static_rec_mutex_unlock (apriv->service_lock); 183 187 188 if (!camel_store_supports_subscriptions (store)) 189 goto cleanup; 190 184 191 /* Retrieve the folder full name */ 185 192 cfolder = tny_camel_folder_get_folder (TNY_CAMEL_FOLDER (folder)); 186 193 folder_full_name = camel_folder_get_full_name (cfolder); 187 194 188 if (camel_store_supports_subscriptions (store) 189 && !camel_store_folder_subscribed (store, folder_full_name)) { 190 195 if (camel_store_folder_subscribed (store, folder_full_name) == subscribe) 196 goto cleanup; 197 198 /* Subscribe or unsubscribe */ 199 if (subscribe) 191 200 camel_store_subscribe_folder (store, folder_full_name, &ex); 192 193 if (camel_exception_is_set (&ex)) { 194 g_warning (N_("Could not subscribe to folder %s: %s\n"), 195 tny_folder_get_name (folder), 196 camel_exception_get_description (&ex)); 197 camel_exception_clear (&ex); 198 } else { 199 /* Sync */ 200 _tny_camel_folder_set_subscribed (TNY_CAMEL_FOLDER (folder), TRUE); 201 202 g_signal_emit (self, 203 tny_store_account_signals [TNY_STORE_ACCOUNT_SUBSCRIPTION_CHANGED], 204 0, folder); 205 } 206 } 207 208 camel_object_unref (CAMEL_OBJECT (cfolder)); 209 camel_object_unref (CAMEL_OBJECT (store)); 210 211 return; 212 } 213 214 static void 215 tny_camel_store_account_unsubscribe (TnyStoreAccount *self, TnyFolder *folder) 216 { 217 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 218 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 219 CamelStore *store; 220 221 g_assert (TNY_IS_CAMEL_FOLDER (folder)); 222 223 g_static_rec_mutex_lock (apriv->service_lock); 224 store = camel_session_get_store ((CamelSession*) apriv->session, 225 apriv->url_string, &ex); 226 g_static_rec_mutex_unlock (apriv->service_lock); 227 228 camel_store_unsubscribe_folder (store, tny_folder_get_name (folder), &ex); 201 else 202 camel_store_unsubscribe_folder (store, folder_full_name, &ex); 229 203 230 204 if (camel_exception_is_set (&ex)) { 231 g_warning (N_("Could not unsubscribe to folder %s: %s\n"), 205 g_warning (N_("Could not %s folder %s: %s\n"), 206 subscribe ? _("subscribe to") : _("unsubscribe"), 232 207 tny_folder_get_name (folder), 233 208 camel_exception_get_description (&ex)); … … 235 210 } else { 236 211 /* Sync */ 237 _tny_camel_folder_set_subscribed (TNY_CAMEL_FOLDER (folder), FALSE);238 212 _tny_camel_folder_set_subscribed (TNY_CAMEL_FOLDER (folder), subscribe); 213 239 214 g_signal_emit (self, 240 215 tny_store_account_signals [TNY_STORE_ACCOUNT_SUBSCRIPTION_CHANGED], 241 216 0, folder); 242 217 } 243 244 camel_object_unref (CAMEL_OBJECT (store)); 245 246 return; 218 camel_object_unref (CAMEL_OBJECT (cfolder)); 219 220 cleanup: 221 camel_object_unref (CAMEL_OBJECT (store)); 222 } 223 224 static void 225 tny_camel_store_account_subscribe (TnyStoreAccount *self, TnyFolder *folder) 226 { 227 g_assert (TNY_IS_CAMEL_FOLDER (folder)); 228 229 set_subscription (self, folder, TRUE); 230 } 231 232 static void 233 tny_camel_store_account_unsubscribe (TnyStoreAccount *self, TnyFolder *folder) 234 { 235 g_assert (TNY_IS_CAMEL_FOLDER (folder)); 236 237 set_subscription (self, folder, FALSE); 247 238 } 248 239 trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c
r1107 r1212 415 415 if (options) 416 416 { 417 GSList *tmp = options; 417 418 while (options) 418 419 { … … 421 422 options = g_slist_next (options); 422 423 } 423 g_slist_free ( options);424 g_slist_free (tmp); 424 425 } 425 426
