1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */ 2 /* Balsa E-Mail Client 3 * 4 * Copyright (C) 1997-2013 Stuart Parmenter and others, 5 * See the file AUTHORS for a list. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 * 02111-1307, USA. 21 */ 22 23 #ifndef __LIBBALSA_MAILBOX_H__ 24 #define __LIBBALSA_MAILBOX_H__ 25 26 #ifndef BALSA_VERSION 27 # error "Include config.h before this file." 28 #endif 29 30 #include <gdk/gdk.h> 31 #include <gmime/gmime.h> 32 33 #ifdef BALSA_USE_THREADS 34 #include <pthread.h> 35 #endif 36 37 #include "libbalsa.h" 38 39 #define LIBBALSA_TYPE_MAILBOX \ 40 (libbalsa_mailbox_get_type()) 41 #define LIBBALSA_MAILBOX(obj) \ 42 (G_TYPE_CHECK_INSTANCE_CAST ((obj), LIBBALSA_TYPE_MAILBOX, LibBalsaMailbox)) 43 #define LIBBALSA_MAILBOX_CLASS(klass) \ 44 (G_TYPE_CHECK_CLASS_CAST ((klass), LIBBALSA_TYPE_MAILBOX, \ 45 LibBalsaMailboxClass)) 46 #define LIBBALSA_IS_MAILBOX(obj) \ 47 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIBBALSA_TYPE_MAILBOX)) 48 #define LIBBALSA_IS_MAILBOX_CLASS(klass) \ 49 (G_TYPE_CHECK_CLASS_TYPE ((klass), LIBBALSA_TYPE_MAILBOX)) 50 #define LIBBALSA_MAILBOX_GET_CLASS(mailbox) \ 51 (G_TYPE_INSTANCE_GET_CLASS ((mailbox), LIBBALSA_TYPE_MAILBOX, \ 52 LibBalsaMailboxClass)) 53 54 #define MAILBOX_OPEN(mailbox) (mailbox->state != LB_MAILBOX_STATE_CLOSED) 55 56 #define MAILBOX_CLOSED(mailbox) (mailbox->state == LB_MAILBOX_STATE_CLOSED) 57 58 #define RETURN_IF_MAILBOX_CLOSED(mailbox)\ 59 do {\ 60 if (MAILBOX_CLOSED (mailbox))\ 61 {\ 62 g_print (_("*** ERROR: Mailbox Stream Closed: %s ***\n"), __PRETTY_FUNCTION__);\ 63 libbalsa_unlock_mailbox (mailbox);\ 64 return;\ 65 }\ 66 } while (0) 67 #define RETURN_VAL_IF_CONTEXT_CLOSED(mailbox, val)\ 68 do {\ 69 if (MAILBOX_CLOSED (mailbox))\ 70 {\ 71 g_print (_("*** ERROR: Mailbox Stream Closed: %s ***\n"), __PRETTY_FUNCTION__);\ 72 libbalsa_unlock_mailbox (mailbox);\ 73 return (val);\ 74 }\ 75 } while (0) 76 77 #define LIBBALSA_MAILBOX_UNTHREADED "libbalsa-mailbox-unthreaded" 78 79 80 typedef enum { 81 LB_MAILBOX_SORT_NO, /* == NATURAL */ 82 LB_MAILBOX_SORT_SUBJECT, 83 LB_MAILBOX_SORT_DATE, 84 LB_MAILBOX_SORT_SIZE, 85 LB_MAILBOX_SORT_SENDER, 86 LB_MAILBOX_SORT_THREAD /* this is not exactly sorting flag but 87 * a message index ordering flag. */ 88 } LibBalsaMailboxSortFields; 89 90 typedef struct _SortTuple SortTuple; 91 /* Sorting */ 92 struct _SortTuple { 93 guint offset; 94 GNode *node; 95 }; 96 97 typedef enum { 98 LB_MAILBOX_SORT_TYPE_ASC, 99 LB_MAILBOX_SORT_TYPE_DESC 100 } LibBalsaMailboxSortType; 101 102 typedef enum { 103 LIBBALSA_NTFY_SOURCE, 104 LIBBALSA_NTFY_FINISHED, 105 LIBBALSA_NTFY_MSGINFO, 106 LIBBALSA_NTFY_PROGRESS, 107 LIBBALSA_NTFY_UPDATECONFIG, 108 LIBBALSA_NTFY_ERROR 109 } LibBalsaMailboxNotify; 110 111 112 /* MBG: If this enum is changed (even just the order) make sure to 113 * update pref-manager.c so the preferences work correctly */ 114 typedef enum { 115 LB_MAILBOX_THREADING_FLAT, 116 LB_MAILBOX_THREADING_SIMPLE, 117 LB_MAILBOX_THREADING_JWZ 118 } LibBalsaMailboxThreadingType; 119 120 121 typedef enum { 122 LB_MAILBOX_SHOW_UNSET = 0, 123 LB_MAILBOX_SHOW_FROM, 124 LB_MAILBOX_SHOW_TO 125 } LibBalsaMailboxShow; 126 127 typedef enum { 128 LB_MAILBOX_SUBSCRIBE_NO, 129 LB_MAILBOX_SUBSCRIBE_YES, 130 LB_MAILBOX_SUBSCRIBE_UNSET 131 } LibBalsaMailboxSubscribe; 132 133 typedef enum { 134 LB_FETCH_RFC822_HEADERS = 1<<0, /* prepare all rfc822 headers */ 135 LB_FETCH_STRUCTURE = 1<<1 /* prepare message structure */ 136 } LibBalsaFetchFlag; 137 138 typedef enum { 139 LB_MAILBOX_STATE_CLOSED, 140 LB_MAILBOX_STATE_OPENING, 141 LB_MAILBOX_STATE_OPEN, 142 LB_MAILBOX_STATE_CLOSING 143 } LibBalsaMailboxState; 144 145 #ifdef HAVE_GPGME 146 typedef enum { 147 LB_MAILBOX_CHK_CRYPT_NEVER, /* never auto decrypt/signature check */ 148 LB_MAILBOX_CHK_CRYPT_MAYBE, /* auto decrypt/signature check if possible */ 149 LB_MAILBOX_CHK_CRYPT_ALWAYS /* always auto decrypt/signature check */ 150 } LibBalsaChkCryptoMode; 151 #endif 152 153 enum LibBalsaMailboxCapability { 154 LIBBALSA_MAILBOX_CAN_SORT, 155 LIBBALSA_MAILBOX_CAN_THREAD 156 }; 157 158 /* 159 * structures 160 */ 161 typedef struct _LibBalsaMailboxClass LibBalsaMailboxClass; 162 163 typedef struct _LibBalsaMailboxView LibBalsaMailboxView; 164 struct _LibBalsaMailboxView { 165 InternetAddressList *mailing_list_address; 166 gchar *identity_name; 167 LibBalsaMailboxThreadingType threading_type; 168 /** filter is a frontend-specific code determining used view 169 * filter. GUI usually allows to generate only a subset of all 170 * possible LibBalsaCondition's and mapping from arbitary 171 * LibBalsaCondition to a GUI configuration is not always 172 * possible. Therefore, we provide this variable for GUI's 173 * convinence. */ 174 int filter; 175 LibBalsaMailboxSortType sort_type; 176 LibBalsaMailboxSortFields sort_field; 177 LibBalsaMailboxSortFields sort_field_prev; 178 LibBalsaMailboxShow show; 179 LibBalsaMailboxSubscribe subscribe; 180 gboolean exposed; 181 gboolean open; 182 gboolean in_sync; /* view is in sync with config */ 183 gboolean used; /* keep track of usage */ 184 185 #ifdef HAVE_GPGME 186 LibBalsaChkCryptoMode gpg_chk_mode; 187 #endif 188 189 /* Display statistics: 190 * - total >= 0 both counts are valid; 191 * - total < 0 && unread == 0 unread is known to be zero; 192 * - total < 0 && unread > 0 unread is known to be > 0, 193 * but the count is not valid; 194 * - total < 0 && unread < 0 both are unknown. 195 */ 196 int unread; 197 int total; 198 time_t mtime; /* Mailbox mtime when counts were cached. */ 199 }; 200 201 struct _LibBalsaMailbox { 202 GObject object; 203 gint stamp; /* used to determine iterators' validity. Increased on each 204 * modification of mailbox. */ 205 206 gchar *config_prefix; /* unique string identifying mailbox */ 207 /* in the config file */ 208 gchar *name; /* displayed name for a special mailbox; */ 209 /* Isn't it a GUI thing? */ 210 gchar *url; /* Unique resource locator, file://, imap:// etc */ 211 guint open_ref; 212 213 int lock; /* 0 if mailbox is unlocked; */ 214 /* >0 if mailbox is (recursively locked). */ 215 #ifdef BALSA_USE_THREADS 216 pthread_t thread_id; /* id of thread that locked the mailbox */ 217 #endif 218 gboolean is_directory; 219 gboolean readonly; 220 gboolean disconnected; 221 222 GPtrArray *mindex; /* the basic message index used for index 223 * displaying/columns of GtkTreeModel interface 224 * and NOTHING else. */ 225 GNode *msg_tree; /* the possibly filtered tree of messages; 226 * gdk lock MUST BE HELD when accessing. */ 227 LibBalsaCondition *view_filter; /* to choose a subset of messages 228 * to be displayed, e.g., only 229 * undeleted. */ 230 LibBalsaCondition *persistent_view_filter; /* the part of the view 231 * filter that will persist 232 * to the next time the 233 * mailbox is opened */ 234 gboolean view_filter_pending; /* a view filter has been set 235 * but the view has not been updated */ 236 237 /* info fields */ 238 gboolean has_unread_messages; 239 glong unread_messages; /* number of unread messages in the mailbox */ 240 unsigned first_unread; /* set to 0 if there is no unread present. 241 * used for automatical scrolling down on opening. 242 */ 243 /* Associated filters (struct mailbox_filter) */ 244 GSList * filters; 245 gboolean filters_loaded; 246 247 LibBalsaMailboxView *view; 248 LibBalsaMailboxState state; 249 250 /* Whether to reassemble a message from its parts. */ 251 gboolean no_reassemble; 252 253 /* Whether the tree has been changed since some event. */ 254 gboolean msg_tree_changed; 255 256 #ifdef BALSA_USE_THREADS 257 /* Array of msgnos that need to be displayed. */ 258 GArray *msgnos_pending; 259 /* Array of msgnos that have been changed. */ 260 GArray *msgnos_changed; 261 #endif /* BALSA_USE_THREADS */ 262 guint changed_idle_id; 263 guint queue_check_idle_id; 264 }; 265 266 /* Search iter */ 267 struct _LibBalsaMailboxSearchIter { 268 gint ref_count; 269 gint stamp; 270 LibBalsaMailbox *mailbox; 271 LibBalsaCondition *condition; 272 gpointer user_data; /* private backend info */ 273 }; 274 275 /** Iterates over a list of messages, returning each time it is called 276 flags and the stream to a message. It is the responsibility of the 277 called to un-ref the stream after use. */ 278 typedef gboolean (*LibBalsaAddMessageIterator)(LibBalsaMessageFlag *, 279 GMimeStream **stream, 280 void *); 281 282 struct _LibBalsaMailboxClass { 283 GObjectClass parent_class; 284 285 /* Signals */ 286 void (*changed) (LibBalsaMailbox * mailbox); 287 void (*message_expunged) (LibBalsaMailbox * mailbox, guint seqno); 288 void (*progress_notify) (LibBalsaMailbox * mailbox, int type, 289 int prog, int tot, const gchar* msg); 290 291 /* Virtual Functions */ 292 gboolean (*open_mailbox) (LibBalsaMailbox * mailbox, GError **err); 293 void (*close_mailbox) (LibBalsaMailbox * mailbox, gboolean expunge); 294 LibBalsaMessage *(*get_message) (LibBalsaMailbox * mailbox, guint msgno); 295 gboolean (*prepare_threading)(LibBalsaMailbox *mailbox, guint start); 296 gboolean (*fetch_message_structure)(LibBalsaMailbox *mailbox, 297 LibBalsaMessage * message, 298 LibBalsaFetchFlag flags); 299 void (*fetch_headers)(LibBalsaMailbox *mailbox, 300 LibBalsaMessage * message); 301 void (*release_message) (LibBalsaMailbox * mailbox, 302 LibBalsaMessage * message); 303 gboolean (*get_message_part) (LibBalsaMessage *message, 304 LibBalsaMessageBody *part, 305 GError **err); 306 GMimeStream *(*get_message_stream) (LibBalsaMailbox * mailbox, 307 guint msgno, gboolean peek); 308 309 void (*check) (LibBalsaMailbox * mailbox); 310 311 void (*search_iter_free) (LibBalsaMailboxSearchIter * iter); 312 gboolean (*message_match) (LibBalsaMailbox * mailbox, 313 guint msgno, 314 LibBalsaMailboxSearchIter *search_iter); 315 gboolean (*can_match) (LibBalsaMailbox * mailbox, 316 LibBalsaCondition *condition); 317 void (*save_config) (LibBalsaMailbox * mailbox, const gchar * prefix); 318 void (*load_config) (LibBalsaMailbox * mailbox, const gchar * prefix); 319 gboolean (*sync) (LibBalsaMailbox * mailbox, gboolean expunge); 320 guint (*add_messages) (LibBalsaMailbox * mailbox, 321 LibBalsaAddMessageIterator msg_iterator, 322 void *iter_arg, GError ** err); 323 gboolean (*messages_change_flags) (LibBalsaMailbox * mailbox, 324 GArray *msgnos, 325 LibBalsaMessageFlag set, 326 LibBalsaMessageFlag clear); 327 gboolean (*messages_copy) (LibBalsaMailbox * mailbox, GArray *msgnos, 328 LibBalsaMailbox * dest, GError **err); 329 /* Test message flags */ 330 gboolean(*msgno_has_flags) (LibBalsaMailbox * mailbox, guint msgno, 331 LibBalsaMessageFlag set, 332 LibBalsaMessageFlag unset); 333 334 gboolean (*can_do) (LibBalsaMailbox *mailbox, 335 enum LibBalsaMailboxCapability cap); 336 void (*set_threading) (LibBalsaMailbox * mailbox, 337 LibBalsaMailboxThreadingType thread_type); 338 void (*update_view_filter) (LibBalsaMailbox * mailbox, 339 LibBalsaCondition *view_filter); 340 void (*sort) (LibBalsaMailbox * mailbox, GArray *sort_array); 341 gboolean (*close_backend)(LibBalsaMailbox * mailbox); 342 guint (*total_messages)(LibBalsaMailbox * mailbox); 343 GArray *(*duplicate_msgnos) (LibBalsaMailbox * mailbox); 344 #if BALSA_USE_THREADS 345 void (*lock_store) (LibBalsaMailbox * mailbox, gboolean lock); 346 #endif /* BALSA_USE_THREADS */ 347 }; 348 349 GType libbalsa_mailbox_get_type(void); 350 351 LibBalsaMailbox *libbalsa_mailbox_new_from_config(const gchar * prefix); 352 353 /* 354 * open and close a mailbox 355 */ 356 /* XXX these need to return a value if they failed */ 357 gboolean libbalsa_mailbox_open(LibBalsaMailbox * mailbox, GError **err); 358 gboolean libbalsa_mailbox_is_valid(LibBalsaMailbox * mailbox); 359 gboolean libbalsa_mailbox_is_open(LibBalsaMailbox *mailbox); 360 void libbalsa_mailbox_close(LibBalsaMailbox * mailbox, gboolean expunge); 361 362 void libbalsa_mailbox_check(LibBalsaMailbox * mailbox); 363 void libbalsa_mailbox_changed(LibBalsaMailbox * mailbox); 364 void libbalsa_mailbox_set_unread_messages_flag(LibBalsaMailbox * mailbox, 365 gboolean has_unread); 366 void libbalsa_mailbox_progress_notify(LibBalsaMailbox * mailbox, 367 int type, int prog, int tot, 368 const gchar* msg); 369 370 /** Message access functions. 371 */ 372 373 /** libbalsa_mailbox_get_message() returns structure containing 374 changed, UTF-8 converted data of the message. LibBalsaMessage 375 will contain only basic information about the message sufficient to 376 produce message index unless more information was requested to be 377 prefetched. 378 */ 379 LibBalsaMessage *libbalsa_mailbox_get_message(LibBalsaMailbox * mailbox, 380 guint msgno); 381 382 /** libbalsa_mailbox_prepare_threading() requests prefetching of information 383 needed for client-side message threading. 384 msgnos are related to currently set view. 385 Returns TRUE if successful; FALSE may mean that the mailbox was 386 closed during the operation. 387 */ 388 gboolean libbalsa_mailbox_prepare_threading(LibBalsaMailbox * mailbox, 389 guint start); 390 391 /** libbalsa_mailbox_fetch_message_structure() fetches detailed 392 message structure for given message. It can also fetch all RFC822 393 headers of the message. 394 */ 395 gboolean libbalsa_mailbox_fetch_message_structure(LibBalsaMailbox * 396 mailbox, 397 LibBalsaMessage * 398 message, 399 LibBalsaFetchFlag flags); 400 401 /** libbalsa_mailbox_release_message() is called when the message 402 content and structure are no longer needed. It's passed to the 403 maildir and mh backends to unref the mime_message, but is a noop 404 for other backends. 405 */ 406 void libbalsa_mailbox_release_message(LibBalsaMailbox * mailbox, 407 LibBalsaMessage * message); 408 409 void libbalsa_mailbox_set_msg_headers(LibBalsaMailbox * mailbox, 410 LibBalsaMessage * message); 411 412 /** libbalsa_mailbox_get_message_part() ensures that a selected, single 413 part of the message is loaded. 414 */ 415 gboolean libbalsa_mailbox_get_message_part(LibBalsaMessage *message, 416 LibBalsaMessageBody *part, 417 GError **err); 418 419 /** libbalsa_mailbox_get_message_stream() returns a message stream associated 420 with full RFC822 text of the message. 421 */ 422 GMimeStream *libbalsa_mailbox_get_message_stream(LibBalsaMailbox * mailbox, 423 guint msgno, gboolean peek); 424 425 426 /** libbalsa_mailbox_sync_storage() asks the mailbox to synchronise 427 the memory information about messages with disk. Many drivers 428 update storage immediately and for them this operation may be 429 no-op. When expunge is set, driver is supposed to clean up the mailbox, 430 including physical removal of old deleted messages. 431 */ 432 433 gboolean libbalsa_mailbox_sync_storage(LibBalsaMailbox * mailbox, 434 gboolean expunge); 435 436 /* This function returns TRUE if the mailbox can be matched 437 against the given filters (eg : IMAP mailbox can't 438 use the SEARCH IMAP command for regex match, so the 439 match is done via default filtering funcs->can be slow) 440 */ 441 gboolean libbalsa_mailbox_can_match(LibBalsaMailbox *mailbox, 442 LibBalsaCondition *condition); 443 gboolean libbalsa_mailbox_message_match(LibBalsaMailbox *mailbox, 444 guint msgno, 445 LibBalsaMailboxSearchIter *search_iter); 446 447 /* Search iter */ 448 LibBalsaMailboxSearchIter 449 *libbalsa_mailbox_search_iter_new(LibBalsaCondition * condition); 450 LibBalsaMailboxSearchIter 451 *libbalsa_mailbox_search_iter_view(LibBalsaMailbox * mailbox); 452 LibBalsaMailboxSearchIter 453 *libbalsa_mailbox_search_iter_ref(LibBalsaMailboxSearchIter * iter); 454 void libbalsa_mailbox_search_iter_unref(LibBalsaMailboxSearchIter * iter); 455 gboolean libbalsa_mailbox_search_iter_step(LibBalsaMailbox * mailbox, 456 LibBalsaMailboxSearchIter 457 * search_iter, 458 GtkTreeIter * iter, 459 gboolean forward, 460 guint stop_msgno); 461 462 /* Default filtering function (on reception) 463 It is ONLY FOR INTERNAL USE 464 */ 465 void libbalsa_mailbox_run_filters_on_reception(LibBalsaMailbox * mailbox); 466 467 void libbalsa_mailbox_save_config(LibBalsaMailbox * mailbox, 468 const gchar * prefix); 469 470 gboolean libbalsa_mailbox_add_message(LibBalsaMailbox * mailbox, 471 GMimeStream * stream, 472 LibBalsaMessageFlag flags, 473 GError ** err); 474 475 guint libbalsa_mailbox_add_messages(LibBalsaMailbox * mailbox, 476 LibBalsaAddMessageIterator msg_iterator, 477 void *arg, 478 GError ** err); 479 480 gboolean libbalsa_mailbox_close_backend(LibBalsaMailbox * mailbox); 481 482 /* Message number-list methods */ 483 gboolean libbalsa_mailbox_messages_change_flags(LibBalsaMailbox * mailbox, 484 GArray * msgnos, 485 LibBalsaMessageFlag set, 486 LibBalsaMessageFlag clear); 487 gboolean libbalsa_mailbox_messages_copy(LibBalsaMailbox * mailbox, 488 GArray * msgnos, 489 LibBalsaMailbox * dest, GError **err); 490 gboolean libbalsa_mailbox_messages_move(LibBalsaMailbox * mailbox, 491 GArray * msgnos, 492 LibBalsaMailbox * dest, GError **err); 493 494 /* 495 * misc mailbox releated functions 496 */ 497 GType libbalsa_mailbox_type_from_path(const gchar * filename); 498 499 guint libbalsa_mailbox_total_messages(LibBalsaMailbox * mailbox); 500 gboolean libbalsa_mailbox_can_move_duplicates(LibBalsaMailbox * mailbox); 501 gint libbalsa_mailbox_move_duplicates(LibBalsaMailbox * mailbox, 502 LibBalsaMailbox * dest, 503 GError ** err); 504 505 /* 506 * Mailbox views-related functions. 507 */ 508 typedef struct LibBalsaMailboxIndexEntry_ LibBalsaMailboxIndexEntry; 509 void libbalsa_mailbox_index_entry_set_no(LibBalsaMailboxIndexEntry *entry, 510 unsigned no); 511 void libbalsa_mailbox_index_entry_clear(LibBalsaMailbox * mailbox, 512 guint msgno); 513 void libbalsa_mailbox_index_set_flags(LibBalsaMailbox *mailbox, 514 unsigned msgno, LibBalsaMessageFlag f); 515 gboolean libbalsa_mailbox_set_view_filter(LibBalsaMailbox * mailbox, 516 LibBalsaCondition * 517 filter_condition, 518 gboolean update_immediately); 519 void libbalsa_mailbox_make_view_filter_persistent(LibBalsaMailbox * 520 mailbox); 521 522 gboolean libbalsa_mailbox_can_do(LibBalsaMailbox *mailbox, 523 enum LibBalsaMailboxCapability cap); 524 525 /** libbalsa_mailbox_set_threading() uses backend-optimized threading mode 526 to produce a tree of messages. The tree is put in msg_tree and used 527 later by GtkTreeModel interface. 528 libbalsa_mailbox_set_threading() is the public method; 529 libbalsa_mailbox_set_msg_tree and libbalsa_mailbox_unlink_and_prepend 530 are helpers for the subclass methods. 531 */ 532 void libbalsa_mailbox_set_threading(LibBalsaMailbox *mailbox, 533 LibBalsaMailboxThreadingType thread_type); 534 void libbalsa_mailbox_set_msg_tree(LibBalsaMailbox * mailbox, 535 GNode * msg_tree); 536 void libbalsa_mailbox_unlink_and_prepend(LibBalsaMailbox * mailbox, 537 GNode * node, GNode * parent); 538 539 /* Mailbox views. */ 540 LibBalsaMailboxView *libbalsa_mailbox_view_new(void); 541 void libbalsa_mailbox_view_free(LibBalsaMailboxView * view); 542 gboolean libbalsa_mailbox_set_identity_name(LibBalsaMailbox * mailbox, 543 const gchar * identity_name); 544 void libbalsa_mailbox_set_threading_type(LibBalsaMailbox * mailbox, 545 LibBalsaMailboxThreadingType 546 threading_type); 547 void libbalsa_mailbox_set_sort_type(LibBalsaMailbox * mailbox, 548 LibBalsaMailboxSortType sort_type); 549 void libbalsa_mailbox_set_sort_field(LibBalsaMailbox * mailbox, 550 LibBalsaMailboxSortFields sort_field); 551 gboolean libbalsa_mailbox_set_show(LibBalsaMailbox * mailbox, 552 LibBalsaMailboxShow show); 553 gboolean libbalsa_mailbox_set_subscribe(LibBalsaMailbox * mailbox, 554 LibBalsaMailboxSubscribe 555 subscribe); 556 void libbalsa_mailbox_set_exposed(LibBalsaMailbox * mailbox, 557 gboolean exposed); 558 void libbalsa_mailbox_set_open(LibBalsaMailbox * mailbox, gboolean open); 559 void libbalsa_mailbox_set_filter(LibBalsaMailbox * mailbox, gint filter); 560 #ifdef HAVE_GPGME 561 gboolean libbalsa_mailbox_set_crypto_mode(LibBalsaMailbox * mailbox, 562 LibBalsaChkCryptoMode gpg_chk_mode); 563 #endif 564 void libbalsa_mailbox_set_unread(LibBalsaMailbox * mailbox, gint unread); 565 void libbalsa_mailbox_set_total (LibBalsaMailbox * mailbox, gint total); 566 void libbalsa_mailbox_set_mtime (LibBalsaMailbox * mailbox, time_t mtime); 567 568 InternetAddressList 569 *libbalsa_mailbox_get_mailing_list_address(LibBalsaMailbox * mailbox); 570 const gchar *libbalsa_mailbox_get_identity_name(LibBalsaMailbox * mailbox); 571 LibBalsaMailboxThreadingType 572 libbalsa_mailbox_get_threading_type(LibBalsaMailbox * mailbox); 573 LibBalsaMailboxSortType libbalsa_mailbox_get_sort_type(LibBalsaMailbox * 574 mailbox); 575 LibBalsaMailboxSortFields libbalsa_mailbox_get_sort_field(LibBalsaMailbox * 576 mailbox); 577 LibBalsaMailboxShow libbalsa_mailbox_get_show(LibBalsaMailbox * mailbox); 578 LibBalsaMailboxSubscribe libbalsa_mailbox_get_subscribe(LibBalsaMailbox * 579 mailbox); 580 gboolean libbalsa_mailbox_get_exposed(LibBalsaMailbox * mailbox); 581 gboolean libbalsa_mailbox_get_open(LibBalsaMailbox * mailbox); 582 gint libbalsa_mailbox_get_filter(LibBalsaMailbox * mailbox); 583 #ifdef HAVE_GPGME 584 LibBalsaChkCryptoMode libbalsa_mailbox_get_crypto_mode(LibBalsaMailbox * mailbox); 585 #endif 586 gint libbalsa_mailbox_get_unread(LibBalsaMailbox * mailbox); 587 gint libbalsa_mailbox_get_total (LibBalsaMailbox * mailbox); 588 time_t libbalsa_mailbox_get_mtime(LibBalsaMailbox * mailbox); 589 590 /** force update of given msgno */ 591 void libbalsa_mailbox_msgno_changed(LibBalsaMailbox *mailbox, guint seqno); 592 void libbalsa_mailbox_msgno_inserted(LibBalsaMailbox * mailbox, 593 guint seqno, GNode * parent, 594 GNode ** sibling); 595 void libbalsa_mailbox_msgno_removed(LibBalsaMailbox *mailbox, guint seqno); 596 void libbalsa_mailbox_msgno_filt_check(LibBalsaMailbox * mailbox, 597 guint seqno, 598 LibBalsaMailboxSearchIter 599 * search_iter, 600 gboolean hold_selected); 601 602 /* Search */ 603 gboolean libbalsa_mailbox_msgno_find(LibBalsaMailbox * mailbox, 604 guint seqno, 605 GtkTreePath ** path, 606 GtkTreeIter * iter); 607 /* Manage message flags */ 608 gboolean libbalsa_mailbox_msgno_change_flags(LibBalsaMailbox * mailbox, 609 guint msgno, 610 LibBalsaMessageFlag set, 611 LibBalsaMessageFlag clear); 612 /* Test message flags */ 613 gboolean libbalsa_mailbox_msgno_has_flags(LibBalsaMailbox * mailbox, 614 guint seqno, 615 LibBalsaMessageFlag set, 616 LibBalsaMessageFlag unset); 617 618 /* set icons */ 619 void libbalsa_mailbox_set_unread_icon(GdkPixbuf * pixbuf); 620 void libbalsa_mailbox_set_trash_icon(GdkPixbuf * pixbuf); 621 void libbalsa_mailbox_set_flagged_icon(GdkPixbuf * pixbuf); 622 void libbalsa_mailbox_set_replied_icon(GdkPixbuf * pixbuf); 623 void libbalsa_mailbox_set_attach_icon(GdkPixbuf * pixbuf); 624 #ifdef HAVE_GPGME 625 void libbalsa_mailbox_set_good_icon(GdkPixbuf * pixbuf); 626 void libbalsa_mailbox_set_notrust_icon(GdkPixbuf * pixbuf); 627 void libbalsa_mailbox_set_bad_icon(GdkPixbuf * pixbuf); 628 void libbalsa_mailbox_set_sign_icon(GdkPixbuf * pixbuf); 629 void libbalsa_mailbox_set_encr_icon(GdkPixbuf * pixbuf); 630 #endif /* HAVE_GPGME */ 631 632 /* Partial messages */ 633 void libbalsa_mailbox_try_reassemble(LibBalsaMailbox * mailbox, 634 const gchar * id); 635 636 /* Message numbers and arrays */ 637 void libbalsa_mailbox_register_msgnos(LibBalsaMailbox * mailbox, 638 GArray * msgnos); 639 void libbalsa_mailbox_unregister_msgnos(LibBalsaMailbox * mailbox, 640 GArray * msgnos); 641 642 /* Accessors for LibBalsaMailboxIndexEntry */ 643 LibBalsaMessageStatus libbalsa_mailbox_msgno_get_status(LibBalsaMailbox * 644 mailbox, 645 guint msgno); 646 const gchar *libbalsa_mailbox_msgno_get_subject(LibBalsaMailbox * mailbox, 647 guint msgno); 648 void libbalsa_mailbox_msgno_update_attach(LibBalsaMailbox * mailbox, 649 guint msgno, 650 LibBalsaMessage * message); 651 void libbalsa_mailbox_cache_message(LibBalsaMailbox * mailbox, guint msgno, 652 LibBalsaMessage * message); 653 654 /* Set the foreground and background colors of an array of messages */ 655 void libbalsa_mailbox_set_foreground(LibBalsaMailbox * mailbox, 656 GArray * msgnos, const gchar * color); 657 void libbalsa_mailbox_set_background(LibBalsaMailbox * mailbox, 658 GArray * msgnos, const gchar * color); 659 660 #if BALSA_USE_THREADS 661 662 /* Lock and unlock the mail store--currently, a no-op except for mbox. 663 */ 664 void libbalsa_mailbox_lock_store (LibBalsaMailbox * mailbox); 665 void libbalsa_mailbox_unlock_store(LibBalsaMailbox * mailbox); 666 667 #else /* BALSA_USE_THREADS */ 668 669 #define libbalsa_mailbox_lock_store(mailbox) 670 #define libbalsa_mailbox_unlock_store(mailbox) 671 672 #endif /* BALSA_USE_THREADS */ 673 674 /* columns ids */ 675 typedef enum { 676 LB_MBOX_MSGNO_COL, 677 LB_MBOX_MARKED_COL, 678 LB_MBOX_ATTACH_COL, 679 LB_MBOX_FROM_COL, 680 LB_MBOX_SUBJECT_COL, 681 LB_MBOX_DATE_COL, 682 LB_MBOX_SIZE_COL, 683 LB_MBOX_WEIGHT_COL, 684 LB_MBOX_STYLE_COL, 685 LB_MBOX_FOREGROUND_COL, 686 LB_MBOX_FOREGROUND_SET_COL, 687 LB_MBOX_BACKGROUND_COL, 688 LB_MBOX_BACKGROUND_SET_COL, 689 LB_MBOX_N_COLS 690 } LibBalsaMailboxColumn; 691 692 extern gchar *libbalsa_mailbox_date_format; 693 694 #endif /* __LIBBALSA_MAILBOX_H__ */ 695