folder.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <cinthash.h>
#include "intl.h"
#include "x_alloc.h"
#include "logging.h"
#include "folder.h"
#include "lxml.h"
#include "processing.h"
#include "manager.h"
#include "mailbox.h"
#include "message.h"
Include dependency graph for folder.c:
 
|  | 
| 
 Compounds | 
| struct | XePFolderListCopyCbData_s | 
| 
 Defines | 
| #define | XEP_FOLDER_RECONNECT_MAX_TRIES   5 | 
| #define | XEP_FOLDER_HASH_SIZE   128 | 
| 
 Typedefs | 
| typedef XePFolderListCopyCbData_s | XePFolderListCopyCbData | 
| 
 Functions | 
| XePFolder * | a_Folder_new (XePFolderType type) | 
| XePFolder * | a_Folder_new_copy (XePFolder *folder) | 
| void | a_Folder_free (XePFolder *folder) | 
| void | a_Folder_free_copy (XePFolder *folder) | 
| void | a_Folder_copy (XePFolder *source, XePFolder *target) | 
| XePFolder * | a_Folder_get_from_uid (long uid) | 
| const char * | a_Folder_get_id (XePFolder *folder) | 
| void | a_Folder_set_path (XePFolder *folder, const char *path) | 
| void | a_Folder_set_path_p (XePFolder *folder, char *path) | 
| const char * | a_Folder_get_path (XePFolder *folder) | 
| void | a_Folder_set_mailbox (XePFolder *folder, XePMailbox *mailbox) | 
| XePMailbox * | a_Folder_get_mailbox (XePFolder *folder) | 
| void | a_Folder_update_id (XePFolder *folder) | 
| const char * | a_Folder_get_short_name (XePFolder *folder) | 
| clist * | a_Folder_list_new (void) | 
| clist * | a_Folder_list_new_copy (clist *folders) | 
| void | a_Folder_list_free (clist *folders) | 
| void | a_Folder_list_free_copy (clist *folders) | 
| void | a_Folder_list_copy (clist *source, clist *target, XePMailbox *mailbox, XePFolderListCopyCb user_cb, void *user_data) | 
| XePFolderRef * | a_Folder_ref_new (void) | 
| XePFolderRef * | a_Folder_ref_new_copy (XePFolderRef *folder_ref) | 
| void | a_Folder_ref_free (XePFolderRef *folder_ref) | 
| void | a_Folder_ref_free_content (XePFolderRef *folder_ref) | 
| void | a_Folder_ref_relink_all (void) | 
| int | a_Folder_ref_link_to_folder (XePFolderRef *folder_ref) | 
| clist * | a_Folder_ref_list_new (void) | 
| void | a_Folder_ref_list_free (clist *folder_refs) | 
| chash * | a_Folder_ref_hash_new (void) | 
| void | a_Folder_ref_hash_free (void) | 
| chash * | a_Folder_ref_hash_get (void) | 
| int | a_Folder_register (XePFolder *folder) | 
| int | a_Folder_unregister (XePFolder *folder) | 
| int | a_Folder_register_list (clist *folders) | 
| int | a_Folder_unregister_list (clist *folders) | 
| XePFolder * | a_Folder_get_from_ref (const char *ref) | 
| XePManagerThreadState | a_Folder_get_thread_state (XePFolder *folder) | 
| int | a_Folder_is_locked (XePFolder *folder) | 
| int | a_Folder_init (XePFolder *folder) | 
| int | a_Folder_connect (XePFolder *folder) | 
| int | a_Folder_disconnect (XePFolder *folder) | 
| int | a_Folder_noop (XePFolder *folder) | 
| int | a_Folder_expunge (XePFolder *folder) | 
| int | a_Folder_sync (XePFolder *folder) | 
| int | a_Folder_check (XePFolder *folder) | 
| int | a_Folder_append (XePFolder *folder, const char *data, size_t size) | 
| int | a_Folder_mailbox_connect (XePFolder *folder) | 
| int | a_Folder_mailbox_disconnect (XePFolder *folder) | 
| int | a_Folder_mailbox_list (XePFolder *folder, struct mail_list **mb_list) | 
| int | a_Folder_mailbox_lsub (XePFolder *folder, struct mail_list **mb_list) | 
| void | a_Folder_append_file_async (XePFolder *folder, const char *filename, XePManagerMsgCb user_cb, void *user_data) | 
| void | a_Folder_disconnect_async (XePFolder *folder, XePManagerMsgCb user_cb, void *user_data) | 
| uint32_t | a_Folder_tree_get_total_count (XePFolder *folder) | 
| void | a_Folder_messages_change_flags_async (XePFolder *folder, carray *messages, XePManagerMsgCb user_cb, void *user_data) | 
Define Documentation
  
    | 
        
          | #define XEP_FOLDER_HASH_SIZE   128 |  | 
  
    | 
        
          | #define XEP_FOLDER_RECONNECT_MAX_TRIES   5 |  | 
Typedef Documentation
Function Documentation
  
    | 
        
          | int a_Folder_append | ( | XePFolder * | folder, |  
          |  |  | const char * | data, |  
          |  |  | size_t | size |  
          |  | ) |  |  | 
  
    |  | 
Append a message to a folder  Parameters:
  
    | folder |  |  | data | pointer to the rfc2822/822 message |  | size | the size of the message | 
 Returns:MAIL_NO_ERROR on success and MAIL_ERROR_XXX on error 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_append_file_async | ( | XePFolder * | folder, |  
          |  |  | const char * | filename, |  
          |  |  | XePManagerMsgCb | user_cb, |  
          |  |  | void * | user_data |  
          |  | ) |  |  | 
  
    |  | 
Append a file to a folder in an asynchronous way then call the user provided function when finished.  Parameters:
  
    | folder | the target XePFolder |  | filename | the file containing the RFC2822/822 message to append |  | user_cb | the user callback function called when the operation finishes |  | user_data | the user data to pass to the user callback function | 
 | 
Here is the call graph for this function:
 
Here is the call graph for this function:
 
Here is the call graph for this function:
 
  
    |  | 
Copy the settings of one source folder to the target folder The target has: 
an identical IDan identitcal pathfor REAL and MAILBOX types: a copy of source's rule_refs (target's original rule_refs are freeed)for VIRTUAL type: a copy of source's folder_refs and condition_refs (target's original ones are freeed)  | 
Here is the call graph for this function:
 
  
    | 
        
          | int a_Folder_disconnect | ( | XePFolder * | folder | ) |  |  | 
Here is the call graph for this function:
 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_free_copy | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Free a folder (without unregistering) To be used for folders created with a_Folder_new_copy      | 
  
    | 
        
          | XePFolder* a_Folder_get_from_ref | ( | const char * | ref | ) |  |  | 
  
    |  | 
Return the XePFolder registered with the given ID (ref)  Returns:pointer to the XePFolder if found, NULL otherwise. 
 | 
  
    | 
        
          | XePFolder* a_Folder_get_from_uid | ( | long | uid | ) |  |  | 
  
    |  | 
Find the folder associated to the given Unique Identifier (uid)  Parameters:
  
 Returns:the XePFolder associated to it, or NULL if there is no folder with this uid 
 | 
  
    | 
        
          | const char* a_Folder_get_id | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Return the folder's ID  Parameters:
  
    | folder | the folder which ID is sought | 
 | 
  
    | 
        
          | const char* a_Folder_get_path | ( | XePFolder * | folder | ) |  |  | 
  
    | 
        
          | const char* a_Folder_get_short_name | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Get a short name for the folder For VIRTUAL folders, this is its path (i.e. name) For MAILBOX folders, this is Mailbox ID For REAL folders: 
IMAP: last part of the pathMH: idemeverything else, the complete path  | 
  
    |  | 
Get the state of the thread associated with the folder  Parameters:
  
    | folder | an existing folder | 
 Returns:the thread state 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | int a_Folder_is_locked | ( | XePFolder * | folder | ) |  |  | 
Here is the call graph for this function:
 
  
    |  | 
Copy the list of folders from source to target Disconnect and free source folders marked for delete (uid < 0) Register new folders Call user_cb when all changes are done  Parameters:
  
    | source | the list of folders to copy |  | target | the list that will receive the copies |  | mailbox | the target mailbox |  | user_cb | a user function called when operation finishes |  | user_data | the user data to pass to user_cb() as second arg | 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_list_free | ( | clist * | folders | ) |  |  | 
  
    |  | 
Releases resources from a folder list.  Parameters:
  
    | folders | the list of folders to be deleted. | 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_list_free_copy | ( | clist * | folders | ) |  |  | 
Here is the call graph for this function:
 
  
    | 
        
          | clist* a_Folder_list_new | ( | void |  | ) |  |  | 
  
    | 
        
          | clist* a_Folder_list_new_copy | ( | clist * | folders | ) |  |  | 
Here is the call graph for this function:
 
  
    | 
        
          | int a_Folder_mailbox_connect | ( | XePFolder * | folder | ) |  |  | 
  
    | 
        
          | int a_Folder_mailbox_disconnect | ( | XePFolder * | folder | ) |  |  | 
  
    | 
        
          | int a_Folder_mailbox_list | ( | XePFolder * | folder, |  
          |  |  | struct mail_list ** | mb_list |  
          |  | ) |  |  | 
Here is the call graph for this function:
 
  
    | 
        
          | int a_Folder_mailbox_lsub | ( | XePFolder * | folder, |  
          |  |  | struct mail_list ** | mb_list |  
          |  | ) |  |  | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_messages_change_flags_async | ( | XePFolder * | folder, |  
          |  |  | carray * | messages, |  
          |  |  | XePManagerMsgCb | user_cb, |  
          |  |  | void * | user_data |  
          |  | ) |  |  | 
Here is the call graph for this function:
 
  
    |  | 
Create a new folder and register it The newly created folder has: 
a unique strictly positive uida thread state set to XEP_MANAGER_THREAD_STATE_NONEfor REAL and MAILBOX types: an emtpy list of rule_refsfor VIRTUAL type: emtpy lists in folder_refs and confition_refs The rest is O on NULL  | 
  
    |  | 
Create a copy of a folder The copy has: 
the same UID,an identical IDan identical PATHa thread state set to XEP_MANAGER_THREAD_STATE_NONEfor REAL and MAILBOXES types: a copy of rule_refsfor VIRTUAL type: a copy of folder_refs and condition_refs  | 
Here is the call graph for this function:
 
Here is the call graph for this function:
 
  
    |  | 
Unregister and release resources used by XePFolderId      | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_ref_free_content | ( | XePFolderRef * | folder_ref | ) |  |  | 
  
    |  | 
Release resources used by XePFolderRef content without unregistering it      | 
  
    | 
        
          | void a_Folder_ref_hash_free | ( | void |  | ) |  |  | 
  
    |  | 
Free the global hash table for XePFolder references      | 
  
    | 
        
          | chash* a_Folder_ref_hash_get | ( | void |  | ) |  |  | 
  
    |  | 
Return the pointer to the global hash table for XePFolderRefs      | 
  
    | 
        
          | chash* a_Folder_ref_hash_new | ( | void |  | ) |  |  | 
  
    |  | 
Create the global hash table that will store registered folder IDs      | 
  
    | 
        
          | int a_Folder_ref_link_to_folder | ( | XePFolderRef * | folder_ref | ) |  |  | 
  
    |  | 
Set the XePFolder member of XePFolderRef to the folder registered under the reference stored in the ref member of the XePFolderRef. After successful operation, the XePFolderRef has a consitent state where its ref corresponds to its folder  Returns:0 on success 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_ref_list_free | ( | clist * | folder_refs | ) |  |  | 
  
    |  | 
Unregister and free all XePFolderRefs in the list and free the list itself      | 
Here is the call graph for this function:
 
  
    | 
        
          | clist* a_Folder_ref_list_new | ( | void |  | ) |  |  | 
  
    |  | 
Create an empty list that will contain XePFolderRefs      | 
  
    |  | 
Create and register a new XePFolderRef This is a triplet (Ref, XePFolder, enabled) where Ref is the reference (ID) of a folder, XePFolder contains the pointer to this referred to folder and enabled is a flag XePFolderRefs are registered      | 
  
    |  | 
Create and register a new XePFolderRef with the same reference as the given one      | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_ref_relink_all | ( | void |  | ) |  |  | 
  
    |  | 
Relink all folder references to the correspondig folder This functions updates the XePFolderRef::folder member of all known XePFolderRefs.      | 
Here is the call graph for this function:
 
  
    |  | 
Register a folder in the global hash table for folder IDs  Returns:0 on success. Fails if folder's id is already registered 
 | 
  
    | 
        
          | int a_Folder_register_list | ( | clist * | folders | ) |  |  | 
  
    |  | 
Register a list of folders in the global hash table for folder IDs  Returns:0 on success. Fails as soon as a_Folder_register() fails for one of the items in the list 
 | 
Here is the call graph for this function:
 
  
    |  | 
Set the mailbox to which the folder pertains This invalidates folder's ID and thus a_Folder_update_id() should be called afterwards      | 
  
    | 
        
          | void a_Folder_set_path | ( | XePFolder * | folder, |  
          |  |  | const char * | path |  
          |  | ) |  |  | 
  
    |  | 
Set folder's path, or in case of a VFolder, its name  Parameters:
  
    | folder | the folder which path/name is to be set |  | path | the path/name of the folder/VFolder | 
 | 
  
    | 
        
          | void a_Folder_set_path_p | ( | XePFolder * | folder, |  
          |  |  | char * | path |  
          |  | ) |  |  | 
  
    |  | 
Set folder's path, or in case of a VFolder, its name This invalidates folder ID, thus a_Folder_update_id() should be called afterwards.  Parameters:
  
    | folder | the folder which path/name is to be set |  | path | the path/name of the folder/VFolder, folder will get ownership on path. | 
 | 
  
    |  | 
Sync folder content with mailbox Eventually connect to the mailbox and retrieve content. At the end of the operation, folder should have the same information as the mailbox.      | 
Here is the call graph for this function:
 
  
    | 
        
          | uint32_t a_Folder_tree_get_total_count | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Get total count of message tree nodes, including dummy messages this is used for the tree view because it needs to know the total number of rows displayed      | 
  
    | 
        
          | int a_Folder_unregister | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Unregister a folder in the global hash table for folder IDs  Returns:0 on success. Fails if folder ID was not found to be registered 
 | 
  
    | 
        
          | int a_Folder_unregister_list | ( | clist * | folders | ) |  |  | 
  
    |  | 
Unregister a list of folders in the global hash table for folder IDs  Returns:0 on success. Fails as soon as a_Folder_unregister() fails for one of the items in the list 
 | 
Here is the call graph for this function:
 
  
    | 
        
          | void a_Folder_update_id | ( | XePFolder * | folder | ) |  |  | 
  
    |  | 
Update folder's ID. ID is composed from its Mailbox ID and its path. As setting the mailbox or the path of the folder invalidates its id string, this function must be called explicitly to recreate it.  Parameters:
  
    | folder | the folder which ID string has to be updated. The ID string is the concatenation of mailbox's ID and folder's path with a colon between them. | 
 | 
Here is the call graph for this function:
 
Generated on Wed Oct 22 15:51:28 2003 for XetPan by
 1.3.2
 
1.3.2