Bumped copyright dates for 2013
[barry.git] / opensync-plugin-0.4x / src / vjournal.h
bloba0752c1272dfe7dee267fb3cb29495293d4153a3
1 //
2 // \file vjournal.h
3 // Conversion routines for vjournals (VCALENDAR, etc)
4 //
6 /*
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2006-2013, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRYSYNC_VJOURNAL_H__
24 #define __BARRYSYNC_VJOURNAL_H__
26 #include <barry/barry.h>
27 #include <barry/barrysync.h>
28 #include <stdint.h>
29 #include <string>
32 // forward declarations
33 class BarryEnvironment;
35 class VJournalConverter
37 char *m_Data;
38 Barry::Memo m_Memo;
39 uint32_t m_RecordId;
40 std::string m_last_errmsg;
42 public:
43 VJournalConverter();
44 explicit VJournalConverter(uint32_t newRecordId);
45 ~VJournalConverter();
47 const std::string& GetLastError() const { return m_last_errmsg; }
49 // Transfers ownership of m_Data to the caller
50 char* ExtractData();
52 // Parses vjournal data
53 bool ParseData(const char *data);
55 // Barry storage operator
56 void operator()(const Barry::Memo &rec);
58 // Barry builder operator
59 bool operator()(Barry::Memo &rec, Barry::Builder &);
61 // Handles calling of the Barry::Controller to fetch a specific
62 // record, indicated by index (into the RecordStateTable).
63 // Returns a g_malloc'd string of data containing the vevent20
64 // data. It is the responsibility of the caller to free it.
65 // This is intended to be passed into the GetChanges() function.
66 static char* GetRecordData(BarryEnvironment *env, unsigned int dbId,
67 Barry::RecordStateTable::IndexType index);
69 // Handles either adding or overwriting a calendar record,
70 // given vevent20 data in data, and the proper environmebnt,
71 // dbId, StateIndex. Set add to true if adding.
72 static bool CommitRecordData(BarryEnvironment *env, unsigned int dbId,
73 Barry::RecordStateTable::IndexType StateIndex, uint32_t recordId,
74 const char *data, bool add, std::string &errmsg);
77 #endif