Changeset 2553
- Timestamp:
- 08/06/07 10:14:38
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/camel-lite/camel/camel-folder-summary.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (18 diffs)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (43 diffs)
- trunk/libtinymail-camel/tny-camel-send-queue.c (modified) (14 diffs)
- trunk/libtinymail-camel/tny-camel-store-account-priv.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (11 diffs)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (2 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-device.c (modified) (7 diffs)
- trunk/libtinymail-gpe/tny-gpe-device.c (modified) (12 diffs)
- trunk/libtinymail-maemo/tny-maemo-conic-device.c (modified) (13 diffs)
- trunk/libtinymail-maemo/tny-maemo-device-priv.h (added)
- trunk/libtinymail-maemo/tny-maemo-device.c (modified) (12 diffs)
- trunk/libtinymail-olpc/tny-olpc-device.c (modified) (10 diffs)
- trunk/libtinymail/tny-combined-account.c (modified) (1 diff)
- trunk/libtinymail/tny-common-priv.h (modified) (2 diffs)
- trunk/libtinymail/tny-merge-folder.c (modified) (7 diffs)
- trunk/libtinymail/tny-progress-info.c (modified) (5 diffs)
- trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c (modified) (5 diffs)
- trunk/libtinymailui-mozembed/tny-moz-embed-stream.c (modified) (1 diff)
- trunk/tests/shared/device.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r2548 r2553 1 2007-08-06 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * GDK lock awareness 4 1 5 2007-08-02 Philip Van Hoof <pvanhoof@gnome.org> 2 6 trunk/libtinymail-camel/camel-lite/camel/camel-folder-summary.c
r2547 r2553 3207 3207 g_return_if_fail(mi != NULL); 3208 3208 3209 if (mi->summary) { 3209 if (mi->summary) 3210 { 3210 3211 CAMEL_SUMMARY_LOCK(mi->summary, ref_lock); 3211 3212 trunk/libtinymail-camel/tny-camel-account.c
r2548 r2553 70 70 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 71 71 72 tny_lockable_lock (apriv->session->priv->ui_lock); 72 73 g_signal_emit (G_OBJECT (self), 73 74 tny_account_signals [TNY_ACCOUNT_CHANGED], 0); 75 tny_lockable_unlock (apriv->session->priv->ui_lock); 74 76 75 77 return FALSE; … … 625 627 RefreshStatusInfo *oinfo = user_data; 626 628 TnyProgressInfo *info = NULL; 629 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (oinfo->self); 627 630 628 631 info = tny_progress_info_new (G_OBJECT (oinfo->self), oinfo->status_callback, 629 632 oinfo->domain, oinfo->code, what, sofar, 630 oftotal, oinfo->stopper, oinfo->user_data);633 oftotal, oinfo->stopper, apriv->session->priv->ui_lock, oinfo->user_data); 631 634 632 635 if (oinfo->depth > 0) … … 1221 1224 * queue of @self (else it's a bug). */ 1222 1225 1226 typedef struct { 1227 TnySessionCamel *session; 1228 TnyAccount *account; 1229 gboolean online; 1230 } SetOnlInfo; 1231 1232 1233 static gboolean 1234 set_online_happened_idle (gpointer user_data) 1235 { 1236 SetOnlInfo *info = (SetOnlInfo *) user_data; 1237 tny_lockable_lock (info->session->priv->ui_lock); 1238 g_signal_emit (info->account, 1239 tny_camel_account_signals [TNY_CAMEL_ACCOUNT_SET_ONLINE_HAPPENED], 1240 0, info->online); 1241 tny_lockable_unlock (info->session->priv->ui_lock); 1242 return FALSE; 1243 } 1244 1245 static void 1246 set_online_happened_destroy (gpointer user_data) 1247 { 1248 SetOnlInfo *info = (SetOnlInfo *) user_data; 1249 camel_object_unref (info->session); 1250 g_object_unref (info->account); 1251 g_slice_free (SetOnlInfo, info); 1252 return; 1253 } 1254 1255 static void 1256 set_online_happened (TnySessionCamel *session, TnyCamelAccount *account, gboolean online) 1257 { 1258 SetOnlInfo *info = g_slice_new (SetOnlInfo); 1259 1260 info->session = session; 1261 camel_object_ref (info->session); 1262 info->account = TNY_ACCOUNT (g_object_ref (account)); 1263 info->online = online; 1264 1265 g_idle_add_full (G_PRIORITY_DEFAULT, set_online_happened_idle, 1266 info, set_online_happened_destroy); 1267 1268 return; 1269 } 1270 1271 1223 1272 void 1224 1273 _tny_camel_account_set_online (TnyCamelAccount *self, gboolean online, GError **err) … … 1269 1318 1270 1319 if (!camel_exception_is_set (&ex)) 1271 g_signal_emit (self, 1272 tny_camel_account_signals [TNY_CAMEL_ACCOUNT_SET_ONLINE_HAPPENED], 0, TRUE); 1320 set_online_happened (priv->session, self, TRUE); 1273 1321 1274 1322 goto done; … … 1309 1357 1310 1358 if (!camel_exception_is_set (&ex)) 1311 g_signal_emit (self, 1312 tny_camel_account_signals [TNY_CAMEL_ACCOUNT_SET_ONLINE_HAPPENED], 0, TRUE); 1359 set_online_happened (priv->session, self, TRUE); 1313 1360 1314 1361 goto done; … … 1346 1393 1347 1394 if (!camel_exception_is_set (&ex)) 1348 g_signal_emit (self, 1349 tny_camel_account_signals [TNY_CAMEL_ACCOUNT_SET_ONLINE_HAPPENED], 0, FALSE); 1395 set_online_happened (priv->session, self, FALSE); 1350 1396 1351 1397 } … … 1404 1450 { 1405 1451 OnSetOnlineInfo *info = (OnSetOnlineInfo *) data; 1406 if (info->callback) 1452 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (info->account); 1453 TnySessionCamel *session = apriv->session; 1454 1455 if (info->callback) { 1456 tny_lockable_lock (session->priv->ui_lock); 1407 1457 info->callback (info->account, info->err); 1458 tny_lockable_unlock (session->priv->ui_lock); 1459 } 1408 1460 return FALSE; 1409 1461 } … … 1493 1545 tny_camel_account_set_online_default (TnyCamelAccount *self, gboolean online, TnyCamelSetOnlineCallback callback) 1494 1546 { 1547 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 1548 TnySessionCamel *session = priv->session; 1495 1549 1496 1550 /* In case we are a store account, this means that we need to throw the … … 1498 1552 1499 1553 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 1500 {1501 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self);1502 TnySessionCamel *session = priv->session;1503 1504 1554 _tny_camel_store_account_queue_going_online ( 1505 1555 TNY_CAMEL_STORE_ACCOUNT (self), session, online, 1506 1556 on_set_online_done, (gpointer) callback); 1507 }1508 1557 1509 1558 … … 1514 1563 1515 1564 if (TNY_IS_CAMEL_TRANSPORT_ACCOUNT (self)) 1516 { 1517 g_signal_emit (self, 1518 tny_camel_account_signals [TNY_CAMEL_ACCOUNT_SET_ONLINE_HAPPENED], 0, online); 1519 return; 1520 } 1565 set_online_happened (session, self, online); 1521 1566 } 1522 1567 … … 1775 1820 gboolean cancelled; 1776 1821 TnyList *result; 1777 /* This stops us from calling a status callback after the operation has1778 * finished. */1779 1822 TnyIdleStopper* stopper; 1780 1823 GError *err; 1781 1824 TnySessionCamel *session; 1825 1826 GCond* condition; 1827 gboolean had_callback; 1828 GMutex *mutex; 1829 1782 1830 } GetSupportedAuthInfo; 1831 1832 1833 static gboolean 1834 on_supauth_idle_func (gpointer user_data) 1835 { 1836 GetSupportedAuthInfo *info = (GetSupportedAuthInfo *) user_data; 1837 1838 if (info->callback) { 1839 tny_lockable_lock (info->session->priv->ui_lock); 1840 info->callback (info->self, info->cancelled, info->result, &info->err, info->user_data); 1841 tny_lockable_unlock (info->session->priv->ui_lock); 1842 } 1843 1844 tny_idle_stopper_stop (info->stopper); 1845 } 1846 1847 static void 1848 on_supauth_destroy_func (gpointer user_data) 1849 { 1850 GetSupportedAuthInfo *info = (GetSupportedAuthInfo *) user_data; 1851 1852 /* Thread reference */ 1853 g_object_unref (info->self); 1854 camel_object_ref (info->session); 1855 1856 /* Result reference */ 1857 if (info->result) 1858 g_object_unref (info->result); 1859 1860 tny_idle_stopper_destroy (info->stopper); 1861 info->stopper = NULL; 1862 1863 if (info->condition) { 1864 g_mutex_lock (info->mutex); 1865 g_cond_broadcast (info->condition); 1866 info->had_callback = TRUE; 1867 g_mutex_unlock (info->mutex); 1868 } 1869 } 1783 1870 1784 1871 /* Starts the operation in the thread: */ … … 1793 1880 GError *err = NULL; 1794 1881 TnyStatus* status; 1882 GList *authtypes = NULL; 1883 TnyList *result = NULL; 1884 GList *iter = NULL; 1795 1885 1796 1886 g_static_rec_mutex_lock (priv->service_lock); … … 1800 1890 "Get secure authentication methods"); 1801 1891 1802 info->status_callback(G_OBJECT(self), 1803 status, info->user_data); 1804 1805 /* Do the actual work: 1806 * This is happening in a thread, 1807 * and the status callback is being called regularly while this is 1808 * happening. */ 1809 GList *authtypes = camel_service_query_auth_types (priv->service, &ex); 1810 1811 tny_status_set_fraction(status, 1); 1812 info->status_callback(G_OBJECT(self), 1813 status, info->user_data); 1814 1815 /* The result will be a TnyList of TnyPairs: */ 1816 TnyList *result = tny_simple_list_new (); 1817 GList *iter = authtypes; 1818 while (iter) { 1892 authtypes = camel_service_query_auth_types (priv->service, &ex); 1893 /* Result reference */ 1894 result = tny_simple_list_new (); 1895 iter = authtypes; 1896 1897 while (iter) 1898 { 1819 1899 CamelServiceAuthType *item = (CamelServiceAuthType *)iter->data; 1820 1900 if (item) { 1821 /* Get the name of the auth method:1822 * Note that, at least for IMAP, authproto=NULL when1823 * name=Password. */1824 1825 /* We don't use the value part of the TnyPair. */1826 1901 TnyPair *pair = tny_pair_new (item->name, NULL); 1827 1902 tny_list_append (result, G_OBJECT (pair)); 1828 1903 g_object_unref (pair); 1829 1904 } 1830 1831 1905 iter = g_list_next (iter); 1832 1906 } 1907 1833 1908 g_list_free (authtypes); 1834 1909 authtypes = NULL; 1835 1836 1837 /* The work has finished, so clean up and provide the result via the1838 * main callback: */1839 1910 info->result = result; 1840 1911 1841 /* Create the GError if necessary,1842 * from the CamelException: */1843 1912 info->err = NULL; 1844 1913 if (camel_exception_is_set (&ex)) … … 1853 1922 g_static_rec_mutex_unlock (priv->service_lock); 1854 1923 1855 /* Call the callback, with the result, in an idle thread, 1856 * and stop this thread: */ 1857 if (info->callback) { 1858 info->callback (info->self, info->cancelled, info->result, &info->err, info->user_data); 1859 } else { 1860 /* Thread reference */ 1861 g_object_unref (G_OBJECT (self)); 1862 } 1924 info->mutex = g_mutex_new (); 1925 info->condition = g_cond_new (); 1926 info->had_callback = FALSE; 1927 1928 execute_callback (10, G_PRIORITY_HIGH, 1929 on_supauth_idle_func, 1930 info, on_supauth_destroy_func); 1931 1932 /* Wait on the queue for the mainloop callback to be finished */ 1933 g_mutex_lock (info->mutex); 1934 if (!info->had_callback) 1935 g_cond_wait (info->condition, info->mutex); 1936 g_mutex_unlock (info->mutex); 1937 1938 g_mutex_free (info->mutex); 1939 g_cond_free (info->condition); 1940 1941 g_slice_free (GetSupportedAuthInfo, info); 1942 1863 1943 tny_status_free(status); 1864 g_thread_exit (NULL);1865 1944 1866 1945 return NULL; … … 1868 1947 1869 1948 1870 /*TODO: This should be a vfunc so that it is generally available1871 * (and implementable) for other imlpementations. But this should not need a1872 * TnyAccount instance, so we need to find some other object to put the vfunc.1873 */1874 1875 1949 /** 1876 1950 * TnyCamelGetSupportedSecureAuthCallback: … … 1902 1976 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 1903 1977 GetSupportedAuthInfo *info = NULL; 1904 1905 g_return_if_fail (callback);1906 g_return_if_fail (priv->session);1907 1908 /* Store all the interesting info in a struct1909 * launch a thread and keep that struct-instance around.1910 * - While the thread is running, we regularly call the status callback in1911 * an idle handler.1912 * - When the thread is finished, the main callback will1913 * then be called in an idle handler.1914 */1915 1916 /* Check that the session is ready, and stop with a GError if it is not: */1917 1978 GError *err = NULL; 1979 1918 1980 if (!_tny_session_check_operation (priv->session, TNY_ACCOUNT (self), &err, 1919 1981 TNY_ACCOUNT_ERROR, TNY_ACCOUNT_ERROR_GET_SUPPORTED_AUTH)) … … 1925 1987 } 1926 1988 1927 1928 /* Idle info for the status callback: */1929 1989 info = g_slice_new (GetSupportedAuthInfo); 1930 1990 info->session = priv->session; … … 1936 1996 info->user_data = user_data; 1937 1997 1938 /* Use a ref count because we do not know which of the 2 idle callbacks1939 * will be the last, and we can only unref self in the last callback:1940 * This is destroyed in the idle GDestroyNotify callback.1941 * A shared copy is taken and released by the _tny_progress* callback,1942 * so that it can prevent the stats callback from being called after1943 * the main callback. */1944 1998 info->stopper = tny_idle_stopper_new(); 1945 1999 1946 2000 /* thread reference */ 1947 g_object_ref (G_OBJECT (self)); 1948 1949 /* This will cause the idle status callback to be called, 1950 * via _tny_camel_account_start_camel_operation, 1951 * and also calls the idle main callback: */ 1952 1953 g_thread_create (tny_camel_account_get_supported_secure_authentication_async_thread, 1954 info, FALSE, NULL); 1955 } 1956 2001 g_object_ref (self); 2002 camel_object_ref (info->session); 2003 2004 2005 if (TNY_IS_CAMEL_STORE_ACCOUNT (self)) 2006 { 2007 TnyCamelStoreAccountPriv *aspriv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 2008 _tny_camel_queue_launch (aspriv->queue, 2009 tny_camel_account_get_supported_secure_authentication_async_thread, info, 2010 __FUNCTION__); 2011 } else { 2012 g_thread_create (tny_camel_account_get_supported_secure_authentication_async_thread, 2013 info, FALSE, NULL); 2014 } 2015 } 2016 trunk/libtinymail-camel/tny-camel-folder.c
r2551 r2553 78 78 static GObjectClass *parent_class = NULL; 79 79 80 81 typedef struct { 82 GObject *self; 83 GObject *change; 84 } NotFolObInIdleInfo; 85 86 static void 87 do_notify_in_idle_destroy (gpointer user_data) 88 { 89 NotFolObInIdleInfo *info = (NotFolObInIdleInfo *) user_data; 90 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (info->self); 91 92 g_object_unref (info->change); 93 _tny_camel_folder_unreason (priv); 94 g_object_unref (info->self); 95 g_slice_free (NotFolObInIdleInfo, info); 96 } 97 80 98 static void 81 99 notify_folder_store_observers_about (TnyFolderStore *self, TnyFolderStoreChange *change) 82 100 { 83 101 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 102 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (priv->account); 84 103 TnyIterator *iter; 85 104 TnyList *list; 86 105 87 106 g_static_rec_mutex_lock (priv->obs_lock); 88 89 107 if (!priv->sobservers) { 90 108 g_static_rec_mutex_unlock (priv->obs_lock); 91 109 return; 92 110 } 93 94 111 list = tny_list_copy (priv->sobservers); 95 112 g_static_rec_mutex_unlock (priv->obs_lock); 96 113 97 114 iter = tny_list_create_iterator (list); 98 99 115 while (!tny_iterator_is_done (iter)) 100 116 { 101 117 TnyFolderStoreObserver *observer = TNY_FOLDER_STORE_OBSERVER (tny_iterator_get_current (iter)); 102 118 tny_lockable_lock (apriv->session->priv->ui_lock); 103 119 tny_folder_store_observer_update (observer, change); 104 g_object_unref (G_OBJECT (observer)); 120 tny_lockable_unlock (apriv->session->priv->ui_lock); 121 g_object_unref (observer); 105 122 tny_iterator_next (iter); 106 123 } 107 g_object_unref (G_OBJECT (iter)); 108 124 g_object_unref (iter); 109 125 g_object_unref (list); 110 126 111 } 127 return; 128 } 129 130 static gboolean 131 notify_folder_store_observers_about_idle (gpointer user_data) 132 { 133 NotFolObInIdleInfo *info = (NotFolObInIdleInfo *) user_data; 134 notify_folder_store_observers_about (TNY_FOLDER_STORE (info->self), 135 TNY_FOLDER_STORE_CHANGE (info->change)); 136 return FALSE; 137 } 138 139 static void 140 notify_folder_store_observers_about_in_idle (TnyFolderStore *self, TnyFolderStoreChange *change) 141 { 142 NotFolObInIdleInfo *info = g_slice_new (NotFolObInIdleInfo); 143 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 144 145 _tny_camel_folder_reason (priv); 146 info->self = g_object_ref (self); 147 info->change = g_object_ref (change); 148 g_idle_add_full (G_PRIORITY_HIGH, notify_folder_store_observers_about_idle, 149 info, do_notify_in_idle_destroy); 150 } 151 112 152 113 153 static void … … 115 155 { 116 156 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 157 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (priv->account); 117 158 TnyIterator *iter; 118 159 TnyList *list; 119 160 120 161 g_static_rec_mutex_lock (priv->obs_lock); 121 122 162 if (!priv->observers) { 123 163 g_static_rec_mutex_unlock (priv->obs_lock); 124 164 return; 125 165 } 126 127 166 list = tny_list_copy (priv->observers); 128 167 g_static_rec_mutex_unlock (priv->obs_lock); 129 168 130 169 iter = tny_list_create_iterator (list); 131 132 170 while (!tny_iterator_is_done (iter)) 133 171 { 134 172 TnyFolderObserver *observer = TNY_FOLDER_OBSERVER (tny_iterator_get_current (iter)); 173 tny_lockable_lock (apriv->session->priv->ui_lock); 135 174 tny_folder_observer_update (observer, change); 136 g_object_unref (G_OBJECT (observer)); 175 tny_lockable_unlock (apriv->session->priv->ui_lock); 176 g_object_unref (observer); 137 177 tny_iterator_next (iter); 138 178 } 139 g_object_unref (G_OBJECT (iter)); 140 179 g_object_unref (iter); 141 180 g_object_unref (list); 142 181 143 } 182 return; 183 } 184 185 186 static gboolean 187 notify_folder_observers_about_idle (gpointer user_data) 188 { 189 NotFolObInIdleInfo *info = (NotFolObInIdleInfo *) user_data; 190 notify_folder_observers_about (TNY_FOLDER (info->self), 191 TNY_FOLDER_CHANGE (info->change)); 192 return FALSE; 193 } 194 195 static void 196 notify_folder_observers_about_in_idle (TnyFolder *self, TnyFolderChange *change) 197 { 198 NotFolObInIdleInfo *info = g_slice_new (NotFolObInIdleInfo); 199 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 200 201 _tny_camel_folder_reason (priv); 202 info->self = g_object_ref (self); 203 info->change = g_object_ref (change); 204 g_idle_add_full (G_PRIORITY_HIGH, notify_folder_observers_about_idle, 205 info, do_notify_in_idle_destroy); 206 } 207 208 209 static void 210 notify_folder_store_observers_about_for_store_acc (TnyFolderStore *self, TnyFolderStoreChange *change) 211 { 212 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 213 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 214 TnyIterator *iter; 215 TnyList *list = NULL; 216 217 g_static_rec_mutex_lock (priv->obs_lock); 218 if (!priv->sobservers) { 219 g_static_rec_mutex_unlock (priv->obs_lock); 220 return; 221 } 222 list = tny_list_copy (priv->sobservers); 223 g_static_rec_mutex_unlock (priv->obs_lock); 224 225 iter = tny_list_create_iterator (list); 226 while (!tny_iterator_is_done (iter)) 227 { 228 TnyFolderStoreObserver *observer = TNY_FOLDER_STORE_OBSERVER (tny_iterator_get_current (iter)); 229 tny_lockable_lock (apriv->session->priv->ui_lock); 230 tny_folder_store_observer_update (observer, change); 231 tny_lockable_unlock (apriv->session->priv->ui_lock); 232 g_object_unref (observer); 233 tny_iterator_next (iter); 234 } 235 g_object_unref (iter); 236 g_object_unref (list); 237 238 return; 239 } 240 241 static gboolean 242 notify_folder_store_observers_about_for_store_acc_idle (gpointer user_data) 243 { 244 NotFolObInIdleInfo *info = (NotFolObInIdleInfo *) user_data; 245 notify_folder_store_observers_about_for_store_acc (TNY_FOLDER_STORE (info->self), 246 TNY_FOLDER_STORE_CHANGE (info->change)); 247 return FALSE; 248 } 249 250 static void 251 notify_folder_store_observers_about_for_store_acc_in_idle (TnyFolderStore *self, TnyFolderStoreChange *change) 252 { 253 NotFolObInIdleInfo *info = g_slice_new (NotFolObInIdleInfo); 254 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 255 256 _tny_camel_folder_reason (priv); 257 info->self = g_object_ref (self); 258 info->change = g_object_ref (change); 259 g_idle_add_full (G_PRIORITY_HIGH, notify_folder_store_observers_about_for_store_acc_idle, 260 info, do_notify_in_idle_destroy); 261 } 262 144 263 145 264 static void … … 164 283 tny_folder_change_set_new_unread_count (change, priv->unread_length); 165 284 tny_folder_change_set_new_all_count (change, priv->cached_length); 166 notify_folder_observers_about (TNY_FOLDER (self), change);285 notify_folder_observers_about_in_idle (TNY_FOLDER (self), change); 167 286 g_object_unref (change); 168 287 } … … 617 736 tny_folder_change_set_new_unread_count (change, priv->unread_length); 618 737 619 notify_folder_observers_about (self, change);620 621 g_object_unref ( G_OBJECT (change));738 notify_folder_observers_about_in_idle (self, change); 739 740 g_object_unref (change); 622 741 623 742 if (dst_orig_uids) { … … 691 810 change = tny_folder_change_new (self); 692 811 tny_folder_change_add_expunged_header (change, header); 693 notify_folder_observers_about (self, change);812 notify_folder_observers_about_in_idle (self, change); 694 813 g_object_unref (change); 695 814 … … 994 1113 g_object_unref (change); 995 1114 996 if (info->callback) 1115 if (info->callback) { 1116 tny_lockable_lock (info->session->priv->ui_lock); 997 1117 info->callback (info->self, info->cancelled, &info->err, info->user_data); 1118 tny_lockable_unlock (info->session->priv->ui_lock); 1119 } 998 1120 999 1121 tny_idle_stopper_stop (info->stopper); … … 1011 1133 info = tny_progress_info_new (G_OBJECT (oinfo->self), oinfo->status_callback, 1012 1134 TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_SYNC, what, sofar, 1013 oftotal, oinfo->stopper, oinfo-> user_data);1135 oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data); 1014 1136 1015 1137 execute_callback (oinfo->depth, G_PRIORITY_HIGH, … … 1110 1232 { 1111 1233 SyncFolderInfo *info = thr_user_data; 1112 if (info->callback) 1234 if (info->callback) { 1235 tny_lockable_lock (info->session->priv->ui_lock); 1113 1236 info->callback (info->self, TRUE, &info->err, info->user_data); 1237 tny_lockable_unlock (info->session->priv->ui_lock); 1238 } 1114 1239 return FALSE; 1115 1240 } … … 1230 1355 g_object_unref (change); 1231 1356 1232 if (info->callback) 1357 if (info->callback) { 1358 tny_lockable_lock (info->session->priv->ui_lock); 1233 1359 info->callback (info->self, info->cancelled, &info->err, info->user_data); 1360 tny_lockable_unlock (info->session->priv->ui_lock); 1361 } 1234 1362 1235 1363 /* Prevent status callbacks from being called after this … … 1251 1379 info = tny_progress_info_new (G_OBJECT (oinfo->self), oinfo->status_callback, 1252 1380 TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_REFRESH, what, sofar, 1253 oftotal, oinfo->stopper, oinfo->user_data); 1381 oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, 1382 oinfo->user_data); 1254 1383 1255 1384 execute_callback (oinfo->depth, G_PRIORITY_HIGH, … … 1354 1483 { 1355 1484 RefreshFolderInfo *info = thr_user_data; 1356 if (info->callback) 1485 if (info->callback) { 1486 tny_lockable_lock (info->session->priv->ui_lock); 1357 1487 info->callback (info->self, TRUE, &info->err, info->user_data); 1488 tny_lockable_unlock (info->session->priv->ui_lock); 1489 } 1358 1490 return FALSE; 1359 1491 } … … 1483 1615 tny_folder_change_set_new_all_count (change, priv->cached_length); 1484 1616 tny_folder_change_set_new_unread_count (change, priv->unread_length); 1485 notify_folder_observers_about (self, change);1617 notify_folder_observers_about_in_idle (self, change); 1486 1618 g_object_unref (change); 1487 1619 … … 1569 1701 { 1570 1702 GetHeadersInfo *info = thr_user_data; 1571 if (info->callback) 1703 if (info->callback) { 1704 tny_lockable_lock (info->session->priv->ui_lock); 1572 1705 info->callback (info->self, FALSE, info->headers, &info->err, info->user_data); 1706 tny_lockable_unlock (info->session->priv->ui_lock); 1707 } 1573 1708 return FALSE; 1574 1709 } … … 1626 1761 { 1627 1762 GetHeadersInfo *info = thr_user_data; 1628 if (info->callback) 1763 if (info->callback) { 1764 tny_lockable_lock (info->session->priv->ui_lock); 1629 1765 info->callback (info->self, TRUE, info->headers, &info->err, info->user_data); 1766 tny_lockable_unlock (info->session->priv->ui_lock); 1767 } 1630 1768 return FALSE; 1631 1769 } … … 1824 1962 } 1825 1963 1826 if (info->callback) 1964 if (info->callback) { 1965 tny_lockable_lock (info->session->priv->ui_lock); 1827 1966 info->callback (info->self, info->cancelled, info->msg, &info->err, info->user_data); 1967 tny_lockable_unlock (info->session->priv->ui_lock); 1968 } 1828 1969 1829 1970 if (info->msg) … … 1848 1989 info = tny_progress_info_new (G_OBJECT (oinfo->self), oinfo->status_callback, 1849 1990 TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_GET_MSG, what, sofar, 1850 oftotal, oinfo->stopper, oinfo-> user_data);1991 oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data); 1851 1992 1852 1993 execute_callback (oinfo->depth, G_PRIORITY_HIGH, … … 1947 2088 1948 2089 GetMsgInfo *info = (GetMsgInfo *) thr_user_data; 1949 if (info->callback) 2090 if (info->callback) { 2091 tny_lockable_lock (info->session->priv->ui_lock); 1950 2092 info->callback (info->self, TRUE, NULL, &info->err, info->user_data); 2093 tny_lockable_unlock (info->session->priv->ui_lock); 2094 } 1951 2095 return FALSE; 1952 2096 } … … 2089 2233 change = tny_folder_change_new (self); 2090 2234 tny_folder_change_set_received_msg (change, retval); 2091 notify_folder_observers_about (self, change);2092 g_object_unref ( G_OBJECT (change));2235 notify_folder_observers_about_in_idle (self, change); 2236 g_object_unref (change); 2093 2237 } 2094 2238 … … 2442 2586 2443 2587 2444 static void 2445 notify_folder_store_observers_about_for_store_acc (TnyFolderStore *self, TnyFolderStoreChange *change) 2446 { 2447 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 2448 TnyIterator *iter; 2449 2450 if (!priv->sobservers) 2451 return; 2452 2453 iter = tny_list_create_iterator (priv->sobservers); 2454 while (!tny_iterator_is_done (iter)) 2455 { 2456 TnyFolderStoreObserver *observer = TNY_FOLDER_STORE_OBSERVER (tny_iterator_get_current (iter)); 2457 tny_folder_store_observer_update (observer, change); 2458 g_object_unref (observer); 2459 tny_iterator_next (iter); 2460 } 2461 g_object_unref (iter); 2462 } 2463 2464 static void 2465 notify_folder_observers_about_copy (GList *adds, GList *rems, gboolean del) 2466 { 2588 2589 typedef struct { 2590 TnyFolder *folder; 2591 gboolean rem; 2592 } NotFolObsItem; 2593 2594 static void 2595 not_fol_obs_foreach (gpointer key, gpointer value, gpointer user_data) 2596 { 2597 GList *items = (GList *) value; 2598 TnyFolderStore *str = (TnyFolderStore *) key; 2599 TnyFolderStoreChange *change = tny_folder_store_change_new (str); 2600 gboolean in_idle = (gboolean) user_data; 2601 2602 while (items) 2603 { 2604 NotFolObsItem *item = (NotFolObsItem *) items->data; 2605 2606 tny_debug ("tny_folder_copy: observers notify folder-%s %s\n", 2607 item->rem ? "del" : "add", 2608 tny_folder_get_name (item->folder)); 2609 2610 if (item->rem) 2611 tny_folder_store_change_add_removed_folder (change, item->folder); 2612 else 2613 tny_folder_store_change_add_created_folder (change, item->folder); 2614 2615 g_slice_free (NotFolObsItem, item); 2616 items = g_list_next (items); 2617 } 2618 2619 g_list_free (items); 2620 2621 if (TNY_IS_CAMEL_STORE_ACCOUNT (str)) { 2622 if (in_idle) 2623 notify_folder_store_observers_about_for_store_acc_in_idle (str, change); 2624 else 2625 notify_folder_store_observers_about_for_store_acc (str, change); 2626 } else { 2627 if (in_idle) 2628 notify_folder_store_observers_about_in_idle (str, change); 2629 else 2630 notify_folder_store_observers_about (str, change); 2631 } 2632 g_object_unref (change); 2633 2634 return; 2635 } 2636 2637 static void 2638 notify_folder_observers_about_copy (GList *adds, GList *rems, gboolean del, gboolean in_idle) 2639 { 2640 2641 GHashTable *table = g_hash_table_new_full (g_direct_hash, g_direct_equal, 2642 NULL, NULL); 2643 2467 2644 rems = g_list_first (rems); 2468 2469 2645 while (rems) 2470 2646 { 2471 2647 CpyEvent *evt = rems->data; 2472 2473 2474 2648 if (del) { 2475 TnyFolderStoreChange *change = tny_folder_store_change_new (evt->str); 2476 tny_folder_store_change_add_removed_folder (change, evt->fol); 2477 2478 if (TNY_IS_CAMEL_STORE_ACCOUNT (evt->str)) 2479 notify_folder_store_observers_about_for_store_acc (evt->str, change); 2480 else 2481 notify_folder_store_observers_about (evt->str, change); 2482 2483 tny_debug ("tny_folder_copy: observers notify folder-del %s\n", 2484 tny_folder_get_name (evt->fol)); 2485 2486 g_object_unref (change); 2649 gboolean add = FALSE; 2650 NotFolObsItem *item = g_slice_new (NotFolObsItem); 2651 GList *items = g_hash_table_lookup (table, evt->str); 2652 if (!items) 2653 add = TRUE; 2654 item->folder = TNY_FOLDER (g_object_ref (evt->fol)); 2655 item->rem = TRUE; 2656 items = g_list_append (items, item); 2657 if (add) 2658 g_hash_table_insert (table, evt->str, items); 2659 2487 2660 } 2488 2489 2661 cpy_event_free (evt); 2490 2662 rems = g_list_next (rems); 2491 2663 } 2492 2493 2664 g_list_free (rems); 2494 2665 2495 2666 while (adds) 2496 2667 { 2497 TnyFolderStoreChange *change;2498 2668 CpyEvent *evt = adds->data; 2499 2500 change = tny_folder_store_change_new (evt->str); 2501 tny_folder_store_change_add_created_folder (change, evt->fol); 2502 2503 if (TNY_IS_CAMEL_STORE_ACCOUNT (evt->str)) 2504 notify_folder_store_observers_about_for_store_acc (evt->str, change); 2505 else 2506 notify_folder_store_observers_about (evt->str, change); 2507 2508 g_object_unref (change); 2509 2510 tny_debug ("tny_folder_copy: observers notify folder-add %s\n", 2511 tny_folder_get_name (evt->fol)); 2512 2669 gboolean add = FALSE; 2670 NotFolObsItem *item = g_slice_new (NotFolObsItem); 2671 GList *items = g_hash_table_lookup (table, evt->str); 2672 if (!items) 2673 add = TRUE; 2674 item->folder = TNY_FOLDER (g_object_ref (evt->fol)); 2675 item->rem = FALSE; 2676 items = g_list_append (items, item); 2677 if (add) 2678 g_hash_table_insert (table, evt->str, items); 2513 2679 cpy_event_free (evt); 2514 2680 adds = g_list_next (
