summaryrefslogtreecommitdiff
path: root/camel/camel-store-summary.h
blob: 68e1557f4cf794648c14e37a9a95c04e491f7a64 (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 * This library is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation.
 *
 * This library 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 Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Michael Zucchi <notzed@ximian.com>
 */

#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
#error "Only <camel/camel.h> can be included directly."
#endif

#ifndef CAMEL_STORE_SUMMARY_H
#define CAMEL_STORE_SUMMARY_H

#include <stdio.h>

#include <camel/camel-enums.h>
#include <camel/camel-mime-parser.h>

/* Standard GObject macros */
#define CAMEL_TYPE_STORE_SUMMARY \
	(camel_store_summary_get_type ())
#define CAMEL_STORE_SUMMARY(obj) \
	(G_TYPE_CHECK_INSTANCE_CAST \
	((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummary))
#define CAMEL_STORE_SUMMARY_CLASS(cls) \
	(G_TYPE_CHECK_CLASS_CAST \
	((cls), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))
#define CAMEL_IS_STORE_SUMMARY(obj) \
	(G_TYPE_CHECK_INSTANCE_TYPE \
	((obj), CAMEL_TYPE_STORE_SUMMARY))
#define CAMEL_IS_STORE_SUMMARY_CLASS(cls) \
	(G_TYPE_CHECK_CLASS_TYPE \
	((cls), CAMEL_TYPE_STORE_SUMMARY))
#define CAMEL_STORE_SUMMARY_GET_CLASS(obj) \
	(G_TYPE_INSTANCE_GET_CLASS \
	((obj), CAMEL_TYPE_STORE_SUMMARY, CamelStoreSummaryClass))

G_BEGIN_DECLS

struct _CamelFolderSummary;

typedef struct _CamelStoreSummary CamelStoreSummary;
typedef struct _CamelStoreSummaryClass CamelStoreSummaryClass;
typedef struct _CamelStoreSummaryPrivate CamelStoreSummaryPrivate;

typedef struct _CamelStoreInfo CamelStoreInfo;

#define CAMEL_STORE_INFO_FOLDER_UNKNOWN (~0)

enum {
	CAMEL_STORE_INFO_PATH = 0,
	CAMEL_STORE_INFO_LAST
};

struct _CamelStoreInfo {
	volatile gint refcount;
	gchar *path;
	guint32 flags;
	guint32 unread;
	guint32 total;
};

struct _CamelStoreSummary {
	GObject parent;
	CamelStoreSummaryPrivate *priv;

	GPtrArray *folders;	/* CamelStoreInfo's */
	GHashTable *folders_path; /* CamelStoreInfo's by path name */
};

struct _CamelStoreSummaryClass {
	GObjectClass parent_class;

	/* size of memory objects */
	gsize store_info_size;

	/* load/save the global info */
	gint		(*summary_header_load)	(CamelStoreSummary *summary,
						 FILE *file);
	gint		(*summary_header_save)	(CamelStoreSummary *summary,
						 FILE *file);

	/* create/save/load an individual message info */
	CamelStoreInfo *
			(*store_info_new)	(CamelStoreSummary *summary,
						 const gchar *path);
	CamelStoreInfo *
			(*store_info_load)	(CamelStoreSummary *summary,
						 FILE *file);
	gint		(*store_info_save)	(CamelStoreSummary *summary,
						 FILE *file,
						 CamelStoreInfo *info);
	void		(*store_info_free)	(CamelStoreSummary *summary,
						 CamelStoreInfo *info);

	/* virtualise access methods */
	void		(*store_info_set_string)
						(CamelStoreSummary *summary,
						 CamelStoreInfo *info,
						 gint type,
						 const gchar *value);
};

GType		camel_store_summary_get_type	(void) G_GNUC_CONST;
CamelStoreSummary *
		camel_store_summary_new		(void);
void		camel_store_summary_set_filename
						(CamelStoreSummary *summary,
						 const gchar *filename);

/* load/save the summary in its entirety */
gint		camel_store_summary_load	(CamelStoreSummary *summary);
gint		camel_store_summary_save	(CamelStoreSummary *summary);

/* set the dirty bit on the summary */
void		camel_store_summary_touch	(CamelStoreSummary *summary);

/* add a new raw summary item */
void		camel_store_summary_add		(CamelStoreSummary *summary,
						 CamelStoreInfo *info);

/* build/add raw summary items */
CamelStoreInfo *
		camel_store_summary_add_from_path
						(CamelStoreSummary *summary,
						 const gchar *path);

/* Just build raw summary items */
CamelStoreInfo *
		camel_store_summary_info_new	(CamelStoreSummary *summary);
CamelStoreInfo *
		camel_store_summary_info_ref	(CamelStoreSummary *summary,
						 CamelStoreInfo *info);
void		camel_store_summary_info_unref	(CamelStoreSummary *summary,
						 CamelStoreInfo *info);

/* removes a summary item */
void		camel_store_summary_remove	(CamelStoreSummary *summary,
						 CamelStoreInfo *info);
void		camel_store_summary_remove_path	(CamelStoreSummary *summary,
						 const gchar *path);

/* lookup functions */
gint		camel_store_summary_count	(CamelStoreSummary *summary);
CamelStoreInfo *
		camel_store_summary_path	(CamelStoreSummary *summary,
						 const gchar *path);
GPtrArray *	camel_store_summary_array	(CamelStoreSummary *summary);
void		camel_store_summary_array_free	(CamelStoreSummary *summary,
						 GPtrArray *array);

void		camel_store_info_set_string	(CamelStoreSummary *summary,
						 CamelStoreInfo *info,
						 gint type,
						 const gchar *value);

const gchar *	camel_store_info_path		(CamelStoreSummary *summary,
						 CamelStoreInfo *info);
const gchar *	camel_store_info_name		(CamelStoreSummary *summary,
						 CamelStoreInfo *info);

gboolean	camel_store_summary_connect_folder_summary
						(CamelStoreSummary *summary,
						 const gchar *path,
						 struct _CamelFolderSummary *folder_summary);
gboolean	camel_store_summary_disconnect_folder_summary
						(CamelStoreSummary *summary,
						 struct _CamelFolderSummary *folder_summary);

G_END_DECLS

#endif /* CAMEL_STORE_SUMMARY_H */