menu: added new Keywords tag to .desktop files
[barry.git] / src / vcard.h
blob7d9a190b0192f07230596cc3daa53d4793f61274
1 ///
2 /// \file vcard.h
3 /// Conversion routines for vcards
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 __BARRY_SYNC_VCARD_H__
23 #define __BARRY_SYNC_VCARD_H__
25 #include "dll.h"
26 #include "vbase.h"
27 #include "r_contact.h"
28 #include <stdint.h>
29 #include <string>
31 namespace Barry { namespace Sync {
34 // vCard
36 /// Class for converting between RFC 2425/2426 vCard data format,
37 /// and the Barry::Contact class.
38 ///
39 class BXEXPORT vCard : public vBase
41 // data to pass to external requests
42 char *m_gCardData; // dynamic memory returned by vformat()... can
43 // be used directly by the plugin, without
44 // overmuch allocation and freeing (see Extract())
45 std::string m_vCardData;// copy of m_gCardData, for C++ use
46 Barry::Contact m_BarryContact;
48 protected:
49 void AddAddress(const char *rfc_type, const Barry::PostalAddress &addr);
50 void AddPhoneCond(const std::string &phone);
51 void AddPhoneCond(const char *rfc_type, const std::string &phone);
53 void ParseAddress(vAttr &adr, Barry::PostalAddress &address);
54 void ParseCategories(vAttr &cat, Barry::CategoryList &cats);
56 public:
57 vCard();
58 ~vCard();
60 const std::string& ToVCard(const Barry::Contact &con);
61 const Barry::Contact& ToBarry(const char *vcal, uint32_t RecordId);
63 const std::string& GetVCard() const { return m_vCardData; }
64 const Barry::Contact& GetBarryContact() const { return m_BarryContact; }
66 char* ExtractVCard();
68 void Clear();
70 // This is the v-name of the innermost BEGIN/END block
71 static const char* GetVName() { return "VCARD"; }
74 }} // namespace Barry::Sync
76 #endif