OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PIMContactItem.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef PIMCONTACTITEM_HPP_
11 #define PIMCONTACTITEM_HPP_
12 
13 #include <string>
14 #include <map>
15 #include <vector>
16 #include <set>
17 #include <PIMItem/PIMItem.hpp>
18 #include <PIMItem/PIMItemIndex.hpp>
19 
23 namespace OpenAB {
24 
25 class VCardField;
26 
30 class PIMContactItem : public PIMItem
31 {
32  public:
37 
41  virtual ~PIMContactItem();
42 
51  bool parse(const std::string& vCard);
52 
54 
59  std::string getRawData() const;
60 
66  void setId(const PIMItem::ID& id,
67  bool replace = false);
68 
69 #ifdef TESTING
70  std::map<std::string, std::vector<VCardField> > getFields()
71  {
72  return fields;
73  }
74 #endif
75 
76  private:
77  void substituteVCardUID(const std::string newUID);
78 
84  std::map<std::string, std::vector<VCardField> > fields;
85 
86  std::string vCard;
87 };
88 
98 class VCardField {
99  public:
103  VCardField();
104 
109  VCardField(const std::string& v);
110 
114  ~VCardField();
115 
121  bool parse(std::string vCardFieldString);
122 
127  void setValue (const std::string& value);
128 
136  bool operator<(const VCardField& other) const;
137 
143  std::string toString() const;
144 
150  std::string getValue() const;
151 
156  std::map<std::string, std::set<std::string> > getParams() const;
157 
158  private:
159  void processParam(std::string paramLine);
160 
161  void addParam(std::string paramName, std::set<std::string> values);
162 
163  std::string value;
164 
165  std::map<std::string, std::set<std::string> > params;
166 };
167 
172 {
173  public:
180  static unsigned long GetCheckSum(const VCardField& photoField);
181 };
182 
183 } // namespace OpenAB
184 
185 #endif // PIMCONTACTITEM_HPP_
void setValue(const std::string &value)
Sets given value.
Definition: PIMContactItem.cpp:65
Helper class for handling vCard fields of PHOTO or LOGO type.
Definition: PIMContactItem.hpp:171
std::string getRawData() const
Returns vCard string of item.
Definition: PIMContactItem.cpp:439
Smart pointer implementation for safely passing around dynamically created data. Smart pointers are r...
Definition: SmartPtr.hpp:32
static unsigned long GetCheckSum(const VCardField &photoField)
calculates checksum of photo field. Field can have photo data embedded as value or contain URI pointi...
Definition: PIMContactItem.cpp:466
bool parse(const std::string &vCard)
Parses PIMContacItem from vCard string.
Definition: PIMContactItem.cpp:207
PIMContactItem()
Constructor.
Definition: PIMContactItem.cpp:171
void setId(const PIMItem::ID &id, bool replace=false)
Sets id of item.
Definition: PIMContactItem.cpp:444
std::string getValue() const
Returns value of VCardField. VCardField value is the string that occurred after last ":" character in...
Definition: PIMContactItem.cpp:155
SmartPtr< PIMItemIndex > getIndex()
Returns index for given item.
Definition: PIMContactItem.cpp:415
bool parse(std::string vCardFieldString)
Parses field from string.
Definition: PIMContactItem.cpp:32
bool operator<(const VCardField &other) const
Comparison operator. Compares two VCardField objects in alphabetical order (using toString to create ...
Definition: PIMContactItem.cpp:165
Class representing PIM contact item.
Definition: PIMContactItem.hpp:30
std::map< std::string, std::set< std::string > > getParams() const
Return map of all parameters assigned to given field.
Definition: PIMContactItem.cpp:160
~VCardField()
Destructor, virtual by default.
Definition: PIMContactItem.cpp:30
VCardField()
Default constructor.
Definition: PIMContactItem.cpp:26
virtual ~PIMContactItem()
Destructor, virtual by default.
Definition: PIMContactItem.cpp:176
std::string ID
Definition: PIMItem.hpp:64
std::string toString() const
Converts content of VCardField into string format. Used for comparing two VCardField instances and fo...
Definition: PIMContactItem.cpp:113
Represents single parsed vCard field. Filed has its value and additionally it can have set of paramet...
Definition: PIMContactItem.hpp:98
Class representing PIM item.
Definition: PIMItem.hpp:22