os4x: removed redundant vformat code, and use libbarrysync
[barry.git] / opensync-plugin-0.4x / src / vcard.h
blobaf12504c0e28892ccf9aef498dcffa4e673ff136
1 ///
2 /// \file vcard.h
3 /// Conversion routines for vcards
4 ///
6 /*
7 Copyright (C) 2006-2010, 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_VCARD_H__
23 #define __BARRYSYNC_VCARD_H__
25 #include <barry/barry.h>
26 #include <barry/barrysync.h>
27 #include <stdint.h>
28 #include <string>
30 // forward declarations
31 class BarryEnvironment;
33 class VCardConverter
35 char *m_Data;
36 Barry::Contact m_Contact;
37 uint32_t m_RecordId;
39 public:
40 VCardConverter();
41 explicit VCardConverter(uint32_t newRecordId);
42 ~VCardConverter();
44 // Transfers ownership of m_Data to the caller
45 char* ExtractData();
47 // Parses vevent data
48 bool ParseData(const char *data);
50 // Barry storage operator
51 void operator()(const Barry::Contact &rec);
53 // Barry builder operator
54 bool operator()(Barry::Contact &rec, unsigned int dbId);
56 // Handles calling of the Barry::Controller to fetch a specific
57 // record, indicated by index (into the RecordStateTable).
58 // Returns a g_malloc'd string of data containing the vevent20
59 // data. It is the responsibility of the caller to free it.
60 // This is intended to be passed into the GetChanges() function.
61 static char* GetRecordData(BarryEnvironment *env, unsigned int dbId,
62 Barry::RecordStateTable::IndexType index);
64 // Handles either adding or overwriting a calendar record,
65 // given vevent20 data in data, and the proper environmebnt,
66 // dbId, StateIndex. Set add to true if adding.
67 static bool CommitRecordData(BarryEnvironment *env, unsigned int dbId,
68 Barry::RecordStateTable::IndexType StateIndex, uint32_t recordId,
69 const char *data, bool add, std::string &errmsg);
72 #endif