Bumped copyright dates for 2013
[barry.git] / opensync-plugin / src / vevent.h
blob2672a0b1ac053cd53d5cea052c8de8bd155704e3
1 //
2 // \file vevent.h
3 // Conversion routines for vevents (VCALENDAR, etc)
4 //
6 /*
7 Copyright (C) 2006-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRYSYNC_VEVENT_H__
23 #define __BARRYSYNC_VEVENT_H__
25 #include <barry/barry.h>
26 #include <stdint.h>
27 #include <string>
29 // forward declarations
30 class BarryEnvironment;
32 class VEventConverter
34 char *m_Data;
35 Barry::Calendar m_Cal;
36 uint32_t m_RecordId;
37 std::string m_last_errmsg;
39 public:
40 VEventConverter();
41 explicit VEventConverter(uint32_t newRecordId);
42 ~VEventConverter();
44 // Transfers ownership of m_Data to the caller
45 char* ExtractData();
47 const Barry::Calendar& GetCalendar() const { return m_Cal; };
48 const std::string& GetLastError() const { return m_last_errmsg; }
50 // Parses vevent data
51 bool ParseData(const char *data);
53 // Merge vevent data
54 bool MergeData(const Barry::Calendar &origin);
56 // Barry storage operator
57 void operator()(const Barry::Calendar &rec);
59 // Barry builder operator
60 bool operator()(Barry::Calendar &rec, Barry::Builder &);
62 // Handles calling of the Barry::Controller to fetch a specific
63 // record, indicated by index (into the RecordStateTable).
64 // Returns a g_malloc'd string of data containing the vevent20
65 // data. It is the responsibility of the caller to free it.
66 // This is intended to be passed into the GetChanges() function.
67 static char* GetRecordData(BarryEnvironment *env, unsigned int dbId,
68 Barry::RecordStateTable::IndexType index);
70 // Handles either adding or overwriting a calendar record,
71 // given vevent20 data in data, and the proper environmebnt,
72 // dbId, StateIndex. Set add to true if adding.
73 static bool CommitRecordData(BarryEnvironment *env, unsigned int dbId,
74 Barry::RecordStateTable::IndexType StateIndex, uint32_t recordId,
75 const char *data, bool add, std::string &errmsg);
78 #endif