# 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-2011, 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 "dll.h"
    00026 #include "vbase.h"
    00027 #include "r_contact.h"
    00028 #include <stdint.h>
    00029 #include <string>
    00030
    00031 namespace Barry { namespace Sync {
    00032
    00033 //
    00034 // vCard
    00035 //
    00036 /// Class for converting between RFC 2425/2426 vCard data format,
    00037 /// and the Barry::Contact class.
    00038 ///
    00039 class BXEXPORT vCard : public vBase
    00040 {
    00041         // data to pass to external requests
    00042         char *m_gCardData;      // dynamic memory returned by vformat()... can
    00043                                 // be used directly by the plugin, without
    00044                                 // overmuch allocation and freeing (see Extract())
    00045         std::string m_vCardData;// copy of m_gCardData, for C++ use
    00046         Barry::Contact m_BarryContact;
    00047
    00048 protected:
    00049         void AddAddress(const char *rfc_type, const Barry::PostalAddress &addr);
    00050         void AddCategories(const Barry::CategoryList &categories);
    00051         void AddPhoneCond(const std::string &phone);
    00052         void AddPhoneCond(const char *rfc_type, const std::string &phone);
    00053
    00054         void ParseAddress(vAttr &adr, Barry::PostalAddress &address);
    00055         void ParseCategories(vAttr &cat, Barry::CategoryList &cats);
    00056
    00057 public:
    00058         vCard();
    00059         ~vCard();
    00060
    00061         const std::string&      ToVCard(const Barry::Contact &con);
    00062         const Barry::Contact&   ToBarry(const char *vcal, uint32_t RecordId);
    00063
    00064         const std::string&      GetVCard() const { return m_vCardData; }
    00065         const Barry::Contact&   GetBarryContact() const { return m_BarryContact; }
    00066
    00067         char* ExtractVCard();
    00068
    00069         void Clear();
    00070
    00071         // This is the v-name of the innermost BEGIN/END block
    00072         static const char* GetVName() { return "VCARD"; }
    00073 };
    00074
    00075 }} // namespace Barry::Sync
    00076
    00077 #endif
    00078