Changeset 1737
- Timestamp:
- 03/16/07 15:11:45
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-folder.c (modified) (4 diffs)
- trunk/libtinymail-camel/tny-camel-folder.h (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-store-account.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-camel-store-account.h (modified) (1 diff)
- trunk/libtinymail/tny-account-store.c (modified) (7 diffs)
- trunk/libtinymail/tny-folder.c (modified) (2 diffs)
- trunk/libtinymail/tny-folder.h (modified) (2 diffs)
- trunk/libtinymail/tny-list.c (modified) (1 diff)
- trunk/libtinymail/tny-store-account.c (modified) (2 diffs)
- trunk/libtinymail/tny-store-account.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1736 r1737 4 4 GPL 5 5 6 2007-03.16 Sergio Villar Senin <svillar@igalia.com> 6 2007-03-16 Philip Van Hoof <pvanhoof@gnome.org> 7 8 * Design by contract assertions 9 * tny_account_store_find_account API added 10 * tny_folder_find_msg API added 11 12 * This was a major API change 13 14 2007-03-16 Sergio Villar Senin <svillar@igalia.com> 7 15 8 16 * libtinymailui/tny-msg-view.c: fixed a typo in a function name trunk/libtinymail-camel/tny-camel-folder.c
r1730 r1737 1356 1356 } 1357 1357 1358 1359 1360 1361 static TnyMsg* 1362 tny_camel_folder_find_msg (TnyFolder *self, const gchar *url_string, GError **err) 1363 { 1364 return TNY_CAMEL_FOLDER_GET_CLASS (self)->find_msg_func (self, url_string, err); 1365 } 1366 1367 static TnyMsg* 1368 tny_camel_folder_find_msg_default (TnyFolder *self, const gchar *url_string, GError **err) 1369 { 1370 TnyCamelFolderPriv *priv = TNY_CAMEL_FOLDER_GET_PRIVATE (self); 1371 TnyMsg *retval = NULL; 1372 TnyHeader *hdr; 1373 CamelMessageInfo *info; 1374 const gchar *uid; 1375 1376 if (!_tny_session_check_operation (TNY_FOLDER_PRIV_GET_SESSION(priv), err, 1377 TNY_FOLDER_ERROR, TNY_FOLDER_ERROR_GET_MSG)) 1378 return; 1379 1380 if (!priv->receive_strat) { 1381 _tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv)); 1382 return NULL; 1383 } 1384 1385 g_static_rec_mutex_lock (priv->folder_lock); 1386 1387 if (!priv->folder || !priv->loaded || !CAMEL_IS_FOLDER (priv->folder)) 1388 if (!load_folder_no_lock (priv)) 1389 { 1390 g_static_rec_mutex_unlock (priv->folder_lock); 1391 _tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv)); 1392 return NULL; 1393 } 1394 1395 uid = strrchr (url_string, '/'); 1396 if (uid && uid[0] != '/' && strlen (uid) > 1) 1397 { 1398 uid++; 1399 info = camel_message_info_new_uid (NULL, uid); 1400 hdr = _tny_camel_header_new (); 1401 _tny_camel_header_set_as_memory (TNY_CAMEL_HEADER (hdr), info); 1402 retval = tny_msg_receive_strategy_perform_get_msg (priv->receive_strat, self, hdr, err); 1403 g_object_unref (G_OBJECT (hdr)); 1404 } else { 1405 g_set_error (err, TNY_FOLDER_ERROR, 1406 TNY_FOLDER_ERROR_GET_MSG, 1407 "This url string is malformated"); 1408 retval = NULL; 1409 } 1410 1411 g_static_rec_mutex_unlock (priv->folder_lock); 1412 1413 _tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv)); 1414 1415 return retval; 1416 } 1358 1417 1359 1418 static const gchar* … … 3086 3145 klass->get_headers_func = tny_camel_folder_get_headers; 3087 3146 klass->get_msg_func = tny_camel_folder_get_msg; 3147 klass->find_msg_func = tny_camel_folder_find_msg; 3088 3148 klass->get_msg_async_func = tny_camel_folder_get_msg_async; 3089 3149 klass->get_id_func = tny_camel_folder_get_id; … … 3126 3186 klass->remove_observer_func = tny_camel_folder_store_remove_observer; 3127 3187 3128 3129 3188 return; 3130 3189 } … … 3145 3204 class->get_headers_func = tny_camel_folder_get_headers_default; 3146 3205 class->get_msg_func = tny_camel_folder_get_msg_default; 3206 class->find_msg_func = tny_camel_folder_find_msg_default; 3147 3207 class->get_msg_async_func = tny_camel_folder_get_msg_async_default; 3148 3208 class->get_id_func = tny_camel_folder_get_id_default; trunk/libtinymail-camel/tny-camel-folder.h
r1719 r1737 62 62 void (*set_msg_receive_strategy_func) (TnyFolder *self, TnyMsgReceiveStrategy *st); 63 63 TnyMsg* (*get_msg_func) (TnyFolder *self, TnyHeader *header, GError **err); 64 TnyMsg* (*find_msg_func) (TnyFolder *self, const gchar *url_string, GError **err); 64 65 void (*get_msg_async_func) (TnyFolder *self, TnyHeader *header, TnyGetMsgCallback callback, gpointer user_data); 65 66 void (*get_headers_func) (TnyFolder *self, TnyList *headers, gboolean refresh, GError **err); trunk/libtinymail-camel/tny-camel-store-account.c
r1723 r1737 889 889 } 890 890 891 static TnyFolder* 892 tny_camel_store_account_find_folder (TnyStoreAccount *self, const gchar *url_string, GError **err) 893 { 894 return TNY_CAMEL_STORE_ACCOUNT_GET_CLASS (self)->find_folder_func (self, url_string, err); 895 } 896 897 static TnyFolder* 898 tny_camel_store_account_find_folder_default (TnyStoreAccount *self, const gchar *url_string, GError **err) 899 { 900 TnyFolder *retval = NULL; 901 TnyCamelAccountPriv *apriv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 902 TnyCamelStoreAccountPriv *priv = TNY_CAMEL_STORE_ACCOUNT_GET_PRIVATE (self); 903 CamelException ex = CAMEL_EXCEPTION_INITIALISER; 904 CamelFolderInfo *iter; guint32 flags; CamelStore *store; 905 906 g_assert (CAMEL_IS_SESSION (apriv->session)); 907 908 if (!_tny_session_check_operation (apriv->session, err, 909 TNY_FOLDER_STORE_ERROR, TNY_FOLDER_STORE_ERROR_GET_FOLDERS)) 910 return; 911 912 if (apriv->service == NULL || !CAMEL_IS_SERVICE (apriv->service)) 913 { 914 g_set_error (err, TNY_FOLDER_STORE_ERROR, 915 TNY_FOLDER_STORE_ERROR_GET_FOLDERS, 916 "Account not ready for this operation (%s)", 917 camel_exception_get_description (apriv->ex)); 918 _tny_session_stop_operation (apriv->session); 919 return; 920 } 921 922 store = CAMEL_STORE (apriv->service); 923 924 if (camel_exception_is_set (&ex)) 925 { 926 g_set_error (err, TNY_FOLDER_STORE_ERROR, 927 TNY_FOLDER_STORE_ERROR_GET_FOLDERS, 928 camel_exception_get_description (&ex)); 929 camel_exception_clear (&ex); 930 931 if (store && CAMEL_IS_OBJECT (store)) 932 camel_object_unref (CAMEL_OBJECT (store)); 933 _tny_session_stop_operation (apriv->session); 934 return; 935 } 936 937 g_assert (CAMEL_IS_STORE (store)); 938 939 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL; 940 941 if (!camel_session_is_online ((CamelSession*) apriv->session)) 942 flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; 943 944 iter = camel_store_get_folder_info (store, url_string, flags, &ex); 945 946 if (camel_exception_is_set (&ex)) 947 { 948 g_set_error (err, TNY_FOLDER_STORE_ERROR, 949 TNY_FOLDER_STORE_ERROR_GET_FOLDERS, 950 camel_exception_get_description (&ex)); 951 camel_exception_clear (&ex); 952 953 if (CAMEL_IS_OBJECT (store)) 954 { 955 if (iter && CAMEL_IS_STORE (store)) 956 camel_store_free_folder_info (store, iter); 957 camel_object_unref (CAMEL_OBJECT (store)); 958 } 959 _tny_session_stop_operation (apriv->session); 960 return; 961 } 962 963 if (iter) 964 { 965 gboolean was_new = FALSE; 966 967 TnyCamelFolder *folder = (TnyCamelFolder *) tny_camel_store_account_factor_folder ( 968 TNY_CAMEL_STORE_ACCOUNT (self), 969 iter->full_name, &was_new); 970 971 if (was_new && folder != NULL) 972 _tny_camel_folder_set_folder_info (TNY_FOLDER_STORE (self), folder, iter); 973 974 retval = (TnyFolder *) folder; 975 } 976 977 _tny_session_stop_operation (apriv->session); 978 979 return retval; 980 } 891 981 892 982 static void … … 912 1002 klass->subscribe_func = tny_camel_store_account_subscribe; 913 1003 klass->unsubscribe_func = tny_camel_store_account_unsubscribe; 1004 klass->find_folder_func = tny_camel_store_account_find_folder; 914 1005 915 1006 return; … … 936 1027 class->add_observer_func = tny_camel_store_account_add_observer_default; 937 1028 class->remove_observer_func = tny_camel_store_account_remove_observer_default; 1029 class->find_folder_func = tny_camel_store_account_find_folder_default; 938 1030 939 1031 /* Protected default implementation */ trunk/libtinymail-camel/tny-camel-store-account.h
r1694 r1737 57 57 void (*remove_observer_func) (TnyFolderStore *self, TnyFolderStoreObserver *observer); 58 58 59 TnyFolder * (*find_folder_func) (TnyStoreAccount *self, const gchar *url_string, GError **err); 60 59 61 /* protected virtual methods*/ 60 62 TnyFolder * (*factor_folder_func) (TnyCamelStoreAccount *self, const gchar *full_name, gboolean *was_new); trunk/libtinymail/tny-account-store.c
r1726 r1737 39 39 /** 40 40 * tny_account_store_find_account: 41 * @self: a #TnyAccount Transportobject41 * @self: a #TnyAccountStore object 42 42 * @url_string: the url-string of the account to find 43 43 * … … 48 48 * Implementors: when implementing a platform-specific library, you must 49 49 * implement this method. Let it return the account that corresponds to 50 * @url_string or NULL. Also see tny_account_matches_url_string at #TnyAccount. 50 * @url_string or let it return NULL. Also see 51 * tny_account_matches_url_string at #TnyAccount. 51 52 * 52 53 * This method can be used to resolve url-strings to #TnyAccount instances. … … 81 82 /** 82 83 * tny_account_store_alert: 83 * @self: a #TnyAccount Transportobject84 * @self: a #TnyAccountStore object 84 85 * @type: the message type (severity) 85 86 * @prompt: the prompt … … 150 151 /** 151 152 * tny_account_store_get_device: 152 * @self: a #TnyAccount Transportobject153 * @self: a #TnyAccountStore object 153 154 * 154 155 * This method returns a #TnyDevice instance. You must unreference the return … … 184 185 /** 185 186 * tny_account_store_get_cache_dir: 186 * @self: a #TnyAccount Transportobject187 * @self: a #TnyAccountStore object 187 188 * 188 189 * Get the local path that will be used for storing the disk cache … … 222 223 /** 223 224 * tny_account_store_get_accounts: 224 * @self: a #TnyAccount Transportobject225 * @self: a #TnyAccountStore object 225 226 * @list: a #TnyList instance that will be filled with #TnyAccount instances 226 227 * @types: a #TnyGetAccountsRequestType that describes which account types are needed … … 339 340 /** 340 341 * tny_account_store_add_transport_account: 341 * @self: a #TnyAccount Transportobject342 * @self: a #TnyAccountStore object 342 343 * @account: the account to add 343 344 * trunk/libtinymail/tny-folder.c
r1735 r1737 795 795 * @err: a #GError object or NULL 796 796 * 797 * Get a message in @self identified by @header. You must unreference the798 * return value after use.797 * Get a message in @self identified by @header. If not NULL, you must 798 * unreference the return value after use. 799 799 * 800 800 * Example: … … 834 834 835 835 836 837 /** 838 * tny_folder_find_msg: 839 * @self: a #TnyFolder object 840 * @url_string: the url string 841 * @err: a #GError object or NULL 842 * 843 * Get a message in @self identified by @url_string. If not NULL, you must 844 * unreference the return value after use. 845 * 846 * Example: 847 * <informalexample><programlisting> 848 * TnyMsgView *message_view = tny_platform_factory_new_msg_view (platfact); 849 * TnyFolder *folder = ... 850 * TnyMsg *message = tny_folder_get_msg (folder, "imap://account/INBOX/100", NULL); 851 * tny_msg_view_set_msg (message_view, message); 852 * g_object_unref (G_OBJECT (message)); 853 * </programlisting></informalexample> 854 * 855 * Return value: The message instance or NULL on failure 856 * 857 **/ 858 TnyMsg* 859 tny_folder_find_msg (TnyFolder *self, const gchar *url_string, GError **err) 860 { 861 TnyMsg *retval; 862 863 #ifdef DBC /* require */ 864 g_assert (TNY_IS_FOLDER (self)); 865 g_assert (url_string); 866 g_assert (strlen (url_string) > 0); 867 g_assert (strstr (url_string, "://") != NULL); 868 g_assert (TNY_FOLDER_GET_IFACE (self)->find_msg_func != NULL); 869 #endif 870 871 retval = TNY_FOLDER_GET_IFACE (self)->find_msg_func (self, url_string, err); 872 873 #ifdef DBC /* ensure */ 874 if (retval) 875 g_assert (TNY_IS_MSG (retval)); 876 #endif 877 878 return retval; 879 } 836 880 837 881 trunk/libtinymail/tny-folder.h
r1719 r1737 93 93 void (*set_msg_receive_strategy_func) (TnyFolder *self, TnyMsgReceiveStrategy *st); 94 94 TnyMsg* (*get_msg_func) (TnyFolder *self, TnyHeader *header, GError **err); 95 TnyMsg* (*find_msg_func) (TnyFolder *self, const gchar *url_string, GError **err); 95 96 void (*get_msg_async_func) (TnyFolder *self, TnyHeader *header, TnyGetMsgCallback callback, gpointer user_data); 96 97 void (*get_headers_func) (TnyFolder *self, TnyList *headers, gboolean refresh, GError **err); … … 128 129 void tny_folder_sync (TnyFolder *self, gboolean expunge, GError **err); 129 130 TnyMsg* tny_folder_get_msg (TnyFolder *self, TnyHeader *header, GError **err); 131 TnyMsg* tny_folder_find_msg (TnyFolder *self, const gchar *url_string, GError **err); 130 132 void tny_folder_get_msg_async (TnyFolder *self, TnyHeader *header, TnyGetMsgCallback callback, gpointer user_data); 131 133 void tny_folder_get_headers (TnyFolder *self, TnyList *headers, gboolean refresh, GError **err); trunk/libtinymail/tny-list.c
r1732 r1737 134 134 #endif 135 135 136 TNY_LIST_GET_IFACE (self)->append_func (self, item); 136 TNY_LIST_GET_IFACE (self)->append_func (self, item); 137 137 138 138 #ifdef DBC /* ensure */ trunk/libtinymail/tny-store-account.c
r1732 r1737 20 20 #include <config.h> 21 21 22 #ifdef DBC 23 #include <string.h> 24 #endif 25 22 26 #include <tny-store-account.h> 23 27 #include <tny-folder-store.h> … … 25 29 26 30 guint tny_store_account_signals [TNY_STORE_ACCOUNT_LAST_SIGNAL]; 31 32 /** 33 * tny_store_account_find_folder: 34 * @self: a #TnyStoreAccount object 35 * @url_string: the url-string of the folder to find 36 * 37 * Try to find the folder in @self that corresponds to @url_string. If this 38 * method does not return NULL, the returned value is the found folder and 39 * must be unreferenced after use. 40 * 41 * Implementors: when implementing a #TnyStoreAccount, you must implement 42 * this method. Let it return the folder that corresponds to @url_string or 43 * let it return NULL. 44 * 45 * This method can be used to resolve url-strings to #TnyAccount instances. 46 * 47 * Return value: the found account or NULL. 48 **/ 49 TnyFolder* 50 tny_store_account_find_folder (TnyStoreAccount *self, const gchar *url_string, GError **err) 51 { 52 TnyFolder *retval; 53 54 #ifdef DBC /* require */ 55 g_assert (TNY_IS_STORE_ACCOUNT (self)); 56 g_assert (url_string); 57 g_assert (strlen (url_string) > 0); 58 g_assert (strstr (url_string, "://")); 59 g_assert (TNY_STORE_ACCOUNT_GET_IFACE (self)->find_folder_func != NULL); 60 #endif 61 62 retval = TNY_STORE_ACCOUNT_GET_IFACE (self)->find_folder_func (self, url_string, err); 63 64 #ifdef DBC /* ensure */ 65 if (retval) 66 g_assert (TNY_IS_FOLDER (retval)); 67 #endif 68 69 return retval; 70 } 27 71 28 72 /** trunk/libtinymail/tny-store-account.h
r1202 r1737 59 59 void (*subscribe_func) (TnyStoreAccount *self, TnyFolder *folder); 60 60 void (*unsubscribe_func) (TnyStoreAccount *self, TnyFolder *folder); 61 TnyFolder * (*find_folder_func) (TnyStoreAccount *self, const gchar *url_string, GError **err); 61 62 }; 62 63 … … 65 66 void tny_store_account_subscribe (TnyStoreAccount *self, TnyFolder *folder); 66 67 void tny_store_account_unsubscribe (TnyStoreAccount *self, TnyFolder *folder); 68 TnyFolder* tny_store_account_find_folder (TnyStoreAccount *self, const gchar *url_string, GError **err); 67 69 68 70
