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
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*-
*
* Copyright (C) 2005 Novell Inc.
*
* Authors: Michael Zucchi <notzed@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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include "camel-record.h"
#include "camel-imapx-view-summary.h"
#include "camel-imapx-utils.h"
/* NB, this is only for the messy iterator_get interface, which could be better hidden */
#include "libdb/dist/db.h"
#define d(x) camel_imapx_debug(debug, x)
#define io(x) camel_imapx_debug(io, x)
#define CVSD_CLASS(x) ((CamelViewSummaryDiskClass *)((CamelObject *)x)->klass)
#define CVS_CLASS(x) ((CamelViewSummaryClass *)((CamelObject *)x)->klass)
static CamelViewSummaryDiskClass *cmvs_parent;
/*
* camel_imapx_view_summary_new:
*
* Create a new CamelIMAPXViewSummary object.
*
* Returns: A new CamelIMAPXViewSummary widget.
**/
CamelIMAPXViewSummary *
camel_imapx_view_summary_new(const gchar *base, CamelException *ex)
{
return (CamelIMAPXViewSummary *)camel_view_summary_disk_construct(camel_object_new(camel_imapx_view_summary_get_type()), base, ex);
}
/* NB: must have write lock on folder */
guint32 camel_imapx_view_next_uid(CamelIMAPXView *view)
{
#if 0
guint32 uid;
uid = view->nextuid++;
camel_view_changed((CamelView *)view);
return uid;
#endif
}
/* NB: must have write lock on folder */
void camel_imapx_view_last_uid(CamelIMAPXView *view, guint32 uid)
{
#if 0
uid++;
if (uid > view->nextuid) {
view->nextuid = uid;
camel_view_changed((CamelView *)view);
}
#endif
}
static gint
imapx_view_decode(CamelViewSummaryDisk *s, CamelView *view, CamelRecordDecoder *crd)
{
gint tag, ver;
((CamelViewSummaryDiskClass *)cmvs_parent)->decode(s, view, crd);
if (strchr(view->vid, 1) == NULL) {
camel_record_decoder_reset(crd);
while ((tag = camel_record_decoder_next_section(crd, &ver)) != CR_SECTION_INVALID) {
switch (tag) {
case CVS_IMAPX_SECTION_VIEWINFO:
((CamelIMAPXView *)view)->uidvalidity = camel_record_decoder_int32(crd);
((CamelIMAPXView *)view)->permanentflags = camel_record_decoder_int32(crd);
((CamelIMAPXView *)view)->exists = camel_record_decoder_int32(crd);
((CamelIMAPXView *)view)->separator = camel_record_decoder_int8(crd);
((CamelIMAPXView *)view)->raw_name = g_strdup(camel_record_decoder_string(crd));
break;
}
}
}
return 0;
}
static void
imapx_view_encode(CamelViewSummaryDisk *s, CamelView *view, CamelRecordEncoder *cre)
{
((CamelViewSummaryDiskClass *)cmvs_parent)->encode(s, view, cre);
/* We only store extra data on the root view */
if (strchr(view->vid, 1) == NULL) {
camel_record_encoder_start_section(cre, CVS_IMAPX_SECTION_VIEWINFO, 0);
camel_record_encoder_int32(cre, ((CamelIMAPXView *)view)->uidvalidity);
camel_record_encoder_int32(cre, ((CamelIMAPXView *)view)->permanentflags);
camel_record_encoder_int32(cre, ((CamelIMAPXView *)view)->exists);
camel_record_encoder_int8(cre, ((CamelIMAPXView *)view)->separator);
camel_record_encoder_string(cre, ((CamelIMAPXView *)view)->raw_name);
camel_record_encoder_end_section(cre);
}
}
static void
camel_imapx_view_summary_init(CamelIMAPXViewSummary *obj)
{
struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
s = s;
}
static void
camel_imapx_view_summary_finalise(CamelObject *obj)
{
/*CamelIMAPXViewSummary *mbs = CAMEL_IMAPX_VIEW_SUMMARY(obj);*/
}
static void
camel_imapx_view_summary_class_init(CamelIMAPXViewSummaryClass *klass)
{
((CamelViewSummaryClass *)klass)->view_sizeof = sizeof(CamelIMAPXView);
((CamelViewSummaryDiskClass *)klass)->encode = imapx_view_encode;
((CamelViewSummaryDiskClass *)klass)->decode = imapx_view_decode;
}
CamelType
camel_imapx_view_summary_get_type(void)
{
static CamelType type = CAMEL_INVALID_TYPE;
if (type == CAMEL_INVALID_TYPE) {
cmvs_parent = (CamelViewSummaryDiskClass *)camel_view_summary_disk_get_type();
type = camel_type_register((CamelType)cmvs_parent, "CamelIMAPXViewSummary",
sizeof (CamelIMAPXViewSummary),
sizeof (CamelIMAPXViewSummaryClass),
(CamelObjectClassInitFunc) camel_imapx_view_summary_class_init,
NULL,
(CamelObjectInitFunc) camel_imapx_view_summary_init,
(CamelObjectFinalizeFunc) camel_imapx_view_summary_finalise);
}
return type;
}
|