aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local/camel-local-folder.h
blob: 73059f03b34b89f6ea84f33cc337bbc5f57634f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 * Author: Michael Zucchi <notzed@ximian.com>
 *
 * Copyright (C) 1999 Ximian (www.ximian.com/).
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of version 2 of the GNU General Public 
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#ifndef CAMEL_LOCAL_FOLDER_H
#define CAMEL_LOCAL_FOLDER_H 1

#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus }*/

#include <camel/camel-folder.h>
#include <camel/camel-folder-search.h>
#include <camel/camel-index.h>
#include "camel-local-summary.h"
#include "camel-lock.h"

/*  #include "camel-store.h" */

#define CAMEL_LOCAL_FOLDER_TYPE     (camel_local_folder_get_type ())
#define CAMEL_LOCAL_FOLDER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_LOCAL_FOLDER_TYPE, CamelLocalFolder))
#define CAMEL_LOCAL_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_LOCAL_FOLDER_TYPE, CamelLocalFolderClass))
#define CAMEL_IS_LOCAL_FOLDER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_LOCAL_FOLDER_TYPE))

enum {
    CAMEL_LOCAL_FOLDER_ARG_INDEX_BODY = CAMEL_FOLDER_ARG_LAST,

    CAMEL_LOCAL_FOLDER_ARG_LAST = CAMEL_FOLDER_ARG_LAST + 0x100
};

enum {
    CAMEL_LOCAL_FOLDER_INDEX_BODY = CAMEL_LOCAL_FOLDER_ARG_INDEX_BODY | CAMEL_ARG_BOO,
};

typedef struct {
    CamelFolder parent_object;
    struct _CamelLocalFolderPrivate *priv;

    guint32 flags;      /* open mode flags */

    int locked;     /* lock counter */
    CamelLockType locktype; /* what type of lock we have */

    char *base_path;    /* base path of the local folder */
    char *folder_path;  /* the path to the folder itself */
    char *summary_path; /* where the summary lives */
    char *index_path;   /* where the index file lives */

    CamelIndex *index;     /* index for this folder */
    CamelFolderSearch *search; /* used to run searches, we just use the real thing (tm) */
    CamelFolderChangeInfo *changes; /* used to store changes to the folder during processing */
} CamelLocalFolder;

typedef struct {
    CamelFolderClass parent_class;

    /* Virtual methods */   
    
    /* path construction, only used at init */
    char * (* get_full_path) (const char *toplevel_dir, const char *full_name);
    char * (* get_meta_path) (const char *toplevel_dir, const char *full_name, const char *ext);
    
    /* summary factory, only used at init */
    CamelLocalSummary *(*create_summary)(const char *path, const char *folder, CamelIndex *index);

    /* Lock the folder for my operations */
    int (*lock)(CamelLocalFolder *, CamelLockType type, CamelException *ex);

    /* Unlock the folder for my operations */
    void (*unlock)(CamelLocalFolder *);
} CamelLocalFolderClass;


/* public methods */
/* flags are taken from CAMEL_STORE_FOLDER_* flags */
CamelLocalFolder *camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store,
                           const char *full_name, guint32 flags, CamelException *ex);

/* Standard Camel function */
CamelType camel_local_folder_get_type(void);

/* Lock the folder for internal use.  May be called repeatedly */
/* UNIMPLEMENTED */
int camel_local_folder_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
int camel_local_folder_unlock(CamelLocalFolder *lf);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* CAMEL_LOCAL_FOLDER_H */