vcard.h

Go to the documentation of this file.
00001 ///
00002 /// \file       vcard.h
00003 ///             Conversion routines for vcards
00004 ///
00005 
00006 /*
00007     Copyright (C) 2006-2010, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRY_SYNC_VCARD_H__
00023 #define __BARRY_SYNC_VCARD_H__
00024 
00025 #include "vbase.h"
00026 #include "r_contact.h"
00027 #include <stdint.h>
00028 #include <string>
00029 
00030 namespace Barry { namespace Sync {
00031 
00032 //
00033 // vCard
00034 //
00035 /// Class for converting between RFC 2425/2426 vCard data format,
00036 /// and the Barry::Contact class.
00037 ///
00038 class vCard : public vBase
00039 {
00040         // data to pass to external requests
00041         char *m_gCardData;      // dynamic memory returned by vformat()... can
00042                                 // be used directly by the plugin, without
00043                                 // overmuch allocation and freeing (see Extract())
00044         std::string m_vCardData;// copy of m_gCardData, for C++ use
00045         Barry::Contact m_BarryContact;
00046 
00047 protected:
00048         void AddAddress(const char *rfc_type, const Barry::PostalAddress &addr);
00049         void AddCategories(const Barry::CategoryList &categories);
00050         void AddPhoneCond(const std::string &phone);
00051         void AddPhoneCond(const char *rfc_type, const std::string &phone);
00052 
00053         void ParseAddress(vAttr &adr, Barry::PostalAddress &address);
00054         void ParseCategories(vAttr &cat, Barry::CategoryList &cats);
00055 
00056 public:
00057         vCard();
00058         ~vCard();
00059 
00060         const std::string&      ToVCard(const Barry::Contact &con);
00061         const Barry::Contact&   ToBarry(const char *vcal, uint32_t RecordId);
00062 
00063         const std::string&      GetVCard() const { return m_vCardData; }
00064         const Barry::Contact&   GetBarryContact() const { return m_BarryContact; }
00065 
00066         char* ExtractVCard();
00067 
00068         void Clear();
00069 };
00070 
00071 }} // namespace Barry::Sync
00072 
00073 #endif
00074 
Generated by  doxygen 1.6.2-20100208