Changeset 1010
- Timestamp:
- 10/16/06 20:45:13
- Files:
-
- trunk/libtinymail/tny-account-store.c (modified) (6 diffs)
- trunk/libtinymail/tny-folder-store-query.c (modified) (10 diffs)
- trunk/libtinymail/tny-folder-store.c (modified) (1 diff)
- trunk/libtinymail/tny-folder.c (modified) (2 diffs)
- trunk/libtinymail/tny-fs-stream.c (modified) (13 diffs)
- trunk/libtinymail/tny-header.c (modified) (1 diff)
- trunk/libtinymail/tny-list.c (modified) (1 diff)
- trunk/libtinymail/tny-mime-part.c (modified) (2 diffs)
- trunk/libtinymail/tny-simple-list.c (modified) (4 diffs)
- trunk/libtinymail/tny-store-account.c (modified) (3 diffs)
- trunk/libtinymail/tny-stream.c (modified) (1 diff)
- trunk/libtinymailui/tny-mime-part-saver.c (modified) (1 diff)
- trunk/libtinymailui/tny-mime-part-view.c (modified) (3 diffs)
- trunk/libtinymailui/tny-msg-view.c (modified) (1 diff)
- trunk/tests/shared/account-store.c (modified) (7 diffs)
- trunk/tests/shared/account-store.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymail/tny-account-store.c
r917 r1010 184 184 * the unit tests and the normal tests. 185 185 * 186 * Example (that uses a cache): 187 * <informalexample><programlisting> 188 * static TnyCamelSession *session = NULL; 189 * static TnyList *accounts = NULL; 190 * static gchar* 191 * account_get_pass_func (TnyAccount *account, const gchar *prompt, gboolean *cancel) 192 * { 193 * return g_strdup ("the password"); 194 * } 195 * static void 196 * account_forget_pass_func (TnyAccount *account) 197 * { 198 * g_print ("Password was incorrect\n"); 199 * } 200 * static void 201 * tny_my_account_store_get_accounts (TnyAccountStore *self, TnyList *list, TnyGetAccountsRequestType types) 202 * { 203 * TnyIterator *iter; 204 * if (session == NULL) 205 * session = tny_session_camel_new (TNY_ACCOUNT_STORE (self)); 206 * if (accounts == NULL) 207 * { 208 * accounts = tny_simple_list_new (); 209 * for (... each account ... ) 210 * { 211 * TnyAccount *account = TNY_ACCOUNT (tny_camel_store_account_new ()); 212 * tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (account), session); 213 * tny_account_set_proto (account, "imap"); 214 * tny_account_set_name (account, "account i"); 215 * tny_account_set_user (account, "user of account i"); 216 * tny_account_set_hostname (account, "server.domain of account i"); 217 * tny_account_set_id (account, "i"); 218 * tny_account_set_forget_pass_func (account, account_forget_pass_func); 219 * tny_account_set_pass_func (account, account_get_pass_func); 220 * tny_list_prepend (accounts, account); 221 * g_object_unref (G_OBJECT (account)); 222 * } 223 * } 224 * iter = tny_list_create_iterator (accounts); 225 * while (tny_iterator_is_done (iter)) 226 * { 227 * GObject *cur = tny_iterator_get_current (iter); 228 * tny_list_prepend (list, cur); 229 * g_object_unref (cur); 230 * tny_iterator_next (iter); 231 * } 232 * g_object_unref (G_OBJECT (iter)); 233 * } 234 * </programlisting></informalexample> 186 235 **/ 187 236 void … … 203 252 * @account: the account to add 204 253 * 254 * API WARNING: This API might change 255 * 205 256 * Add a transport account to the store 206 *207 257 **/ 208 258 void … … 224 274 * @account: the account to add 225 275 * 276 * API WARNING: This API might change 277 * 226 278 * Add a storage account to the store 227 *228 279 **/ 229 280 void … … 316 367 tny_account_store_initialized = TRUE; 317 368 } 318 319 369 return; 320 370 } … … 325 375 { 326 376 static GType type = 0; 327 328 377 if (G_UNLIKELY(type == 0)) 329 378 { … … 345 394 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); 346 395 } 347 348 396 return type; 349 397 } trunk/libtinymail/tny-folder-store-query.c
r1007 r1010 47 47 { 48 48 TnyFolderStoreQueryItem *self = (TnyFolderStoreQueryItem*) object; 49 50 if (self->regex) 49 if (self->regex) 51 50 regfree (self->regex); 52 53 51 item_parent_class->finalize (object); 54 52 } … … 58 56 { 59 57 TnyFolderStoreQuery *self = (TnyFolderStoreQuery*) object; 60 61 58 g_object_unref (G_OBJECT (self->items)); 62 63 59 parent_class->finalize (object); 64 65 60 return; 66 61 } … … 70 65 { 71 66 GObjectClass *object_class; 72 73 67 object_class = (GObjectClass *)klass; 74 68 item_parent_class = g_type_class_peek_parent (klass); 75 76 69 object_class->finalize = tny_folder_store_query_item_finalize; 77 78 70 return; 79 71 } … … 83 75 { 84 76 GObjectClass *object_class; 85 86 77 object_class = (GObjectClass *)klass; 87 78 parent_class = g_type_class_peek_parent (klass); 88 89 79 object_class->finalize = tny_folder_store_query_finalize; 90 91 80 return; 92 81 } … … 96 85 { 97 86 self->options = 0; 98 self->regex = NULL;87 self->regex = NULL; 99 88 return; 100 89 } … … 128 117 NULL 129 118 }; 130 131 132 119 object_type = g_type_register_static (G_TYPE_OBJECT, 133 120 "TnyFolderStoreQuery", &object_info, 0); 134 135 136 121 } 137 122 … … 160 145 NULL 161 146 }; 162 163 164 147 object_type = g_type_register_static (G_TYPE_OBJECT, 165 148 "TnyFolderStoreQueryItem", &object_info, 0); … … 241 224 tny_folder_store_query_add_item (TnyFolderStoreQuery *query, const gchar *pattern, TnyFolderStoreQueryOption options) 242 225 { 243 gint er=0;226 gint er=0; 244 227 gboolean addit=pattern?TRUE:FALSE; 245 regex_t *regex = g_new0 (regex_t, 1);228 regex_t *regex = g_new0 (regex_t, 1); 246 229 gboolean has_regex = FALSE; 247 248 if (addit)230 231 if (addit) 249 232 er = regcomp (regex, (const char*)pattern, 0); 250 251 233 if (addit && er != 0) 252 234 { … … 255 237 g_free (erstr); 256 238 regfree (regex); 257 addit = FALSE;258 regex = NULL;239 addit = FALSE; 240 regex = NULL; 259 241 } else { 260 has_regex = TRUE;242 has_regex = TRUE; 261 243 addit = TRUE; 262 244 } 263 245 264 246 if (addit) 265 247 { 266 TnyFolderStoreQueryItem *add = g_object_new (TNY_TYPE_FOLDER_STORE_QUERY_ITEM, NULL);248 TnyFolderStoreQueryItem *add = g_object_new (TNY_TYPE_FOLDER_STORE_QUERY_ITEM, NULL); 267 249 add->options = options; 268 if (has_regex)250 if (has_regex) 269 251 add->regex = regex; 270 else add->regex = NULL;252 else add->regex = NULL; 271 253 tny_list_prepend (query->items, G_OBJECT (add)); 272 254 g_object_unref (G_OBJECT (add)); 273 } 255 } 274 256 } 275 257 … … 285 267 tny_folder_store_query_get_items (TnyFolderStoreQuery *query) 286 268 { 287 return g_object_ref (G_OBJECT (query->items));269 return g_object_ref (G_OBJECT (query->items)); 288 270 } 289 271 trunk/libtinymail/tny-folder-store.c
r1006 r1010 231 231 type = g_type_register_static (G_TYPE_INTERFACE, 232 232 "TnyFolderStore", &info, 0); 233 234 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); 233 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); 235 234 } 236 235 trunk/libtinymail/tny-folder.c
r1009 r1010 72 72 * are advised to hide messages that have been marked as being deleted from your 73 73 * summary view. 74 * 74 * g 75 75 * In Gtk+ for the #GtkTreeView component, you can do this using the 76 76 * #GtkTreeModelFilter tree model filtering model. … … 311 311 * return value after use. 312 312 * 313 * Example: 314 * <informalexample><programlisting> 315 * TnyMsgView *message_view = tny_platform_factory_new_msg_view (platfact); 316 * TnyFolder *folder = ... 317 * TnyHeader *header = ... 318 * TnyMsg *message = tny_folder_get_message (folder, header); 319 * tny_msg_view_set_msg (message_view, message); 320 * </programlisting></informalexample> 321 * 313 322 * Return value: The message instance or NULL on failure 314 323 * trunk/libtinymail/tny-fs-stream.c
r966 r1010 25 25 /* 26 26 * Authors: Bertrand Guiheneuf <bertrand@helixcode.com> 27 * Michael Zucchi <notzed@ximian.com>27 * Michael Zucchi <notzed@ximian.com> 28 28 * 29 29 * Copyright 1999-2003 Ximian, Inc. (www.ximian.com) … … 85 85 { 86 86 gssize len = tny_stream_write (output, tmp_buf + nb_written, 87 nb_read - nb_written);87 nb_read - nb_written); 88 88 if (G_UNLIKELY (len < 0)) 89 89 return -1; … … 105 105 if ((nread = read (priv->fd, buffer, n)) > 0) 106 106 priv->offset += nread; 107 108 if (nread != n) 107 if (nread != n) 109 108 priv->eos = TRUE; 110 111 if (read (priv->fd, b, 1) != 1) 109 if (read (priv->fd, b, 1) != 1) 112 110 priv->eos = TRUE; 113 111 114 112 priv->offset = lseek (priv->fd, priv->offset, SEEK_SET); 115 116 113 return nread; 117 114 … … 123 120 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 124 121 gssize nwritten; 125 126 122 if ((nwritten = write (priv->fd, buffer, n)) > 0) 127 123 priv->offset += nwritten; 128 129 priv->eos = FALSE; 130 124 priv->eos = FALSE; 131 125 return nwritten; 132 126 } … … 136 130 { 137 131 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 138 139 132 if (close (priv->fd) == -1) 140 133 return -1; 141 142 134 priv->fd = -1; 143 144 135 return 0; 145 136 } … … 158 149 { 159 150 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 160 161 151 if (fd == -1) 162 152 return; 163 164 153 if (priv->fd != -1) 165 154 close (priv->fd); 166 167 155 priv->fd = fd; 168 169 156 priv->offset = lseek (priv->fd, 0, SEEK_SET); 170 171 157 if (priv->offset == -1) 172 158 priv->offset = 0; 173 174 159 priv->eos = FALSE; 175 176 160 return; 177 161 } … … 198 182 { 199 183 TnyFsStream *self = g_object_new (TNY_TYPE_FS_STREAM, NULL); 200 201 184 tny_fs_stream_set_fd (self, fd); 202 203 185 return TNY_STREAM (self); 204 186 } … … 209 191 TnyFsStream *self = (TnyFsStream *)instance; 210 192 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 211 212 193 priv->eos = TRUE; 213 194 priv->fd = -1; 214 195 priv->offset = 0; 215 216 196 return; 217 197 } … … 222 202 TnyFsStream *self = (TnyFsStream *)object; 223 203 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 224 225 204 if (priv->fd != -1) 226 {205 { 227 206 fsync (priv->fd); 228 207 close (priv->fd); … … 230 209 priv->fd = -1; 231 210 priv->eos = TRUE; 232 233 211 (*parent_class->finalize) (object); 234 235 212 return; 236 213 } … … 254 231 { 255 232 TnyFsStreamPriv *priv = TNY_FS_STREAM_GET_PRIVATE (self); 256 priv->offset = lseek (priv->fd, 0, SEEK_SET);257 priv->eos = FALSE;233 priv->offset = lseek (priv->fd, 0, SEEK_SET); 234 priv->eos = FALSE; 258 235 return 0; 259 236 } … … 267 244 klass->flush_func = tny_fs_flush; 268 245 klass->is_eos_func = tny_fs_is_eos; 269 270 246 klass->read_func = tny_fs_stream_read; 271 247 klass->write_func = tny_fs_stream_write; … … 283 259 parent_class = g_type_class_peek_parent (class); 284 260 object_class = (GObjectClass*) class; 285 286 261 object_class->finalize = tny_fs_stream_finalize; 287 288 262 g_type_class_add_private (object_class, sizeof (TnyFsStreamPriv)); 289 263 trunk/libtinymail/tny-header.c
r900 r1010 30 30 * 31 31 * Set the reply-to header 32 *33 32 **/ 34 33 void trunk/libtinymail/tny-list.c
r965 r1010 349 349 0, 350 350 0, /* n_preallocs */ 351 NULL, /* instance_init */351 NULL, /* instance_init */ 352 352 NULL 353 353 }; trunk/libtinymail/tny-mime-part.c
r940 r1010 41 41 * if (tny_mime_part_is_attachment (part)) 42 42 * { 43 * g_print ("Found an attachment (%s)\n",44 * tny_mime_part_get_filename (part));43 * g_print ("Found an attachment (%s)\n", 44 * tny_mime_part_get_filename (part)); 45 45 * } 46 46 * g_object_unref (G_OBJECT (part)); … … 465 465 NULL 466 466 }; 467 468 467 type = g_type_register_static (G_TYPE_INTERFACE, 469 468 "TnyMimePart", &info, 0); 470 471 /* g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); */472 469 } 473 470 trunk/libtinymail/tny-simple-list.c
r965 r1010 80 80 81 81 g_mutex_lock (priv->iterator_lock); 82 83 82 priv->first = g_list_remove (priv->first, item); 84 83 g_object_unref (G_OBJECT (item)); 85 86 84 g_mutex_unlock (priv->iterator_lock); 87 85 … … 99 97 { 100 98 TnySimpleList *copy = g_object_new (TNY_TYPE_SIMPLE_LIST, NULL); 101 102 99 TnySimpleListPriv *priv = TNY_SIMPLE_LIST_GET_PRIVATE (self); 103 100 TnySimpleListPriv *cpriv = TNY_SIMPLE_LIST_GET_PRIVATE (copy); … … 176 173 object_class = (GObjectClass *)klass; 177 174 parent_class = g_type_class_peek_parent (klass); 178 179 175 object_class->finalize = tny_simple_list_finalize; 180 181 176 g_type_class_add_private (object_class, sizeof (TnySimpleListPriv)); 182 177 … … 237 232 238 233 object_type = g_type_register_static (G_TYPE_OBJECT, 239 "TnySimpleList", &object_info, 0);234 "TnySimpleList", &object_info, 0); 240 235 241 236 g_type_add_interface_static (object_type, TNY_TYPE_LIST, 242 &tny_list_info);237 &tny_list_info); 243 238 244 239 } trunk/libtinymail/tny-store-account.c
r900 r1010 29 29 * @folder: The folder to unsubscribe from 30 30 * 31 * WARNING: This API might soonchange31 * API WARNING: This API might change 32 32 * 33 33 * Unsubscribe from a folder … … 51 51 * @folder: The folder to subscribe to 52 52 * 53 * WARNING: This API might soonchange53 * API WARNING: This API might change 54 54 * 55 55 * Subscribe to a folder … … 104 104 105 105 g_type_interface_add_prerequisite (type, TNY_TYPE_ACCOUNT); 106 g_type_interface_add_prerequisite (type, TNY_TYPE_FOLDER_STORE);106 g_type_interface_add_prerequisite (type, TNY_TYPE_FOLDER_STORE); 107 107 } 108 108 trunk/libtinymail/tny-stream.c
r966 r1010 209 209 type = g_type_register_static (G_TYPE_INTERFACE, 210 210 "TnyStream", &info, 0); 211 212 /* g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); */213 211 } 214 212 trunk/libtinymailui/tny-mime-part-saver.c
r1003 r1010 47 47 * { 48 48 * if (self->save_strategy)) 49 * g_object_unref (G_OBJECT (self->save_strategy));49 * g_object_unref (G_OBJECT (self->save_strategy)); 50 50 * } 51 51 * </programlisting></informalexample> trunk/libtinymailui/tny-mime-part-view.c
r1002 r1010 23 23 24 24 25 26 25 /** 27 26 * tny_mime_part_view_clear: … … 42 41 43 42 TNY_MIME_PART_VIEW_GET_IFACE (self)->clear_func (self); 44 return; 43 return; 45 44 } 46 45 … … 80 79 * @mime_part to the user. 81 80 * 81 * Example: 82 * <informalexample><programlisting> 83 * static void 84 * tny_gtk_text_mime_part_view_set_part (TnyMimePartView *self, TnyMimePart *part) 85 * { 86 * if (part) 87 * { 88 * GtkTextBuffer *buffer; 89 * TnyStream *dest; 90 * buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self)); 91 * if (buffer && GTK_IS_TEXT_BUFFER (buffer)) 92 * gtk_text_buffer_set_text (buffer, "", 0); 93 * dest = tny_gtk_text_buffer_stream_new (buffer); 94 * tny_stream_reset (dest); 95 * tny_mime_part_decode_to_stream (part, dest); 96 * tny_stream_reset (dest); 97 * g_object_unref (G_OBJECT (dest)); 98 * } 99 * } 100 * </programlisting></informalexample> 82 101 **/ 83 102 void trunk/libtinymailui/tny-msg-view.c
r1002 r1010 83 83 * } 84 84 * if (!retval) 85 * retval = TNY_MOZ_EMBED_MSG_VIEW_GET_CLASS (self)->create_mime_part_view_for_orig_func (self, part);85 * retval = TNY_MOZ_EMBED_MSG_VIEW_GET_CLASS (self)->create_mime_part_view_for_orig_func (self, part); 86 86 * return retval; 87 87 * } trunk/tests/shared/account-store.c
r949 r1010 73 73 { 74 74 TnyTestAccountStore *me = (TnyTestAccountStore*) self; 75 75 76 76 if (me->cache_dir == NULL) 77 77 { … … 81 81 gchar *attempt = g_strdup_printf ("tinymail.%d", att); 82 82 gchar *str = g_build_filename (g_get_tmp_dir (), attempt, NULL); 83 g_free (attempt); 84 dir = g_dir_open (str, 0, NULL);83 g_free (attempt); 84 dir = g_dir_open (str, 0, NULL); 85 85 if (dir) 86 {86 { 87 87 g_dir_close (dir); 88 88 g_free (str); … … 100 100 tny_test_account_store_get_accounts (TnyAccountStore *self, TnyList *list, TnyGetAccountsRequestType types) 101 101 { 102 TnyTestAccountStore *me = (TnyTestAccountStore *) self; 103 102 TnyTestAccountStore *me = (TnyTestAccountStore *) self; 104 103 TnyAccount *account = TNY_ACCOUNT (tny_camel_store_account_new ()); 105 104 106 105 /* Dear visitor of the SVN-web. This is indeed a fully functional and 107 106 working IMAP account. This does not mean that you need to fuck it up */ … … 110 109 camel_session_set_online ((CamelSession*)me->session, me->force_online); 111 110 tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (account), !me->force_online); 112 111 113 112 tny_account_set_proto (account, "imap"); 114 113 tny_account_set_name (account, "unit test account"); … … 121 120 tny_list_prepend (list, (GObject*)account); 122 121 g_object_unref (G_OBJECT (account)); 123 124 return; 122 123 return; 125 124 } 126 125 … … 136 135 if (self->cache_dir) 137 136 g_free (self->cache_dir); 138 139 137 self->cache_dir = g_strdup (cachedir); 140 138 } 141 139 142 140 self->session = tny_session_camel_new (TNY_ACCOUNT_STORE (self)); 143 self->force_online = force_online;144 145 if (self->force_online)141 self->force_online = force_online; 142 143 if (self->force_online) 146 144 tny_device_force_online (self->device); 147 else145 else 148 146 tny_device_force_offline (self->device); 149 147 150 148 return TNY_ACCOUNT_STORE (self); 151 149 } … … 159 157 160 158 self->device = tny_platform_factory_new_device (platfact); 161 162 159 163 160 return; 164 161 } trunk/tests/shared/account-store.h
r900 r1010 42 42 { 43 43 GObject parent; 44 44 45 45 gchar *cache_dir; 46 TnySessionCamel *session;47 TnyDevice *device;48 gboolean force_online;46 TnySessionCamel *session; 47 TnyDevice *device; 48 gboolean force_online; 49 49 }; 50 50
