OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
DAVHelper.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 DAVHELPER_HPP_
11 #define DAVHELPER_HPP_
12 
13 #include <string>
14 #include <vector>
15 #include <map>
16 #include <libxml/parser.h>
17 #include <libxml/xmlmemory.h>
18 
22 class DAVHelper
23 {
24  public:
28  DAVHelper();
29 
33  virtual ~DAVHelper();
34 
38  typedef unsigned int DAVStatusCode;
39 
43  struct DAVPropStat
44  {
45  std::map<std::string, std::string> properties;
47  };
48 
52  struct DAVResponse
53  {
54  std::string href;
55  std::vector<DAVPropStat> properties;
57  std::map<std::string, std::string> error;
66  bool hasProperty(const std::string& prop);
67 
77  std::string getProperty(const std::string& prop);
78 
79  std::vector<std::string> getPropertiesNames();
80 
81  bool hasError(const std::string& error);
82  };
83 
90  bool parseDAVMultistatus(const std::string &xml, std::vector<DAVResponse>& responses);
91 
92  bool parseDAVMultistatus(const std::string &xml,
93  std::vector<DAVResponse>& responses,
94  std::string& syncToken);
95 
96  static const std::string PROPERTY_ETAG;
97  static const std::string PROPERTY_CTAG;
98  static const std::string PROPERTY_SYNC_TOKEN;
99  static const std::string PROPERTY_RESOURCE_TYPE;
100  static const std::string PROPERTY_RESOURCE_TYPE_ADDRESSBOOK;
101  static const std::string PROPERTY_RESOURCE_TYPE_CALENDAR;
102  static const std::string PROPERTY_ADDRESSBOOK_HOME_SET_HREF;
103  static const std::string PROPERTY_CALENDAR_HOME_SET_HREF;
104  static const std::string PROPERTY_CURRENT_USER_PRINCIPAL_HREF;
105  static const std::string PROPERTY_ADDRESS_DATA;
106  static const std::string PROPERTY_CALENDAR_DATA;
107  static const std::string PROPERTY_DISPLAY_NAME;
111  static const std::string ERROR_UID_CONFLICT;
112  private:
116  DAVHelper(DAVHelper const &other);
117 
121  DAVHelper& operator=(DAVHelper const &other);
122 
123  void parseDAVSubProperty(xmlDocPtr doc, xmlNodePtr node,
124  const std::string& prefix, std::map<std::string, std::string>& result);
125  std::map<std::string, std::string> parseDAVProperty(xmlDocPtr doc, xmlNodePtr node);
126  DAVStatusCode parseDAVStatus(xmlDocPtr doc, xmlNodePtr node);
127  std::string parseDAVHref(xmlDocPtr doc, xmlNodePtr node);
128  DAVPropStat parseDAVPropStat(xmlDocPtr doc, xmlNodePtr node);
129  DAVResponse parseDAVResponse(xmlDocPtr doc, xmlNodePtr node);
130 
131  xmlNsPtr davNamespace;
132 };
133 
134 #endif // DAVHELPER_HPP_
DAVHelper()
Constructor.
Definition: DAVHelper.cpp:35
static const std::string PROPERTY_ADDRESSBOOK_HOME_SET_HREF
Definition: DAVHelper.hpp:102
std::vector< DAVPropStat > properties
Definition: DAVHelper.hpp:55
bool hasError(const std::string &error)
Definition: DAVHelper.cpp:345
static const std::string ERROR_UID_CONFLICT
Definition: DAVHelper.hpp:111
static const std::string PROPERTY_ADDRESS_DATA
Definition: DAVHelper.hpp:105
std::string getProperty(const std::string &prop)
Gets value of given property. For properties naming see documentation of hasProperty().
Definition: DAVHelper.cpp:327
bool parseDAVMultistatus(const std::string &xml, std::vector< DAVResponse > &responses)
Parses multistatus DAV response.
Definition: DAVHelper.cpp:219
static const std::string PROPERTY_CTAG
Definition: DAVHelper.hpp:97
bool hasProperty(const std::string &prop)
Checks if response contains given property. In case of properties which contains nested properties...
Definition: DAVHelper.cpp:290
static const std::string PROPERTY_CURRENT_USER_PRINCIPAL_HREF
Definition: DAVHelper.hpp:104
std::map< std::string, std::string > error
Definition: DAVHelper.hpp:57
static const std::string PROPERTY_SUPPORTED_CALENDAR_COMPONENT_SET_TODO
Definition: DAVHelper.hpp:109
virtual ~DAVHelper()
Destructor, virtual by default.
Definition: DAVHelper.cpp:39
static const std::string PROPERTY_SUPPORTED_CALENDAR_COMPONENT_SET_EVENT
Definition: DAVHelper.hpp:108
unsigned int DAVStatusCode
DAV response status code - uses the same values as HTTP response codes.
Definition: DAVHelper.hpp:38
DAV PropStat.
Definition: DAVHelper.hpp:43
static const std::string PROPERTY_CALENDAR_HOME_SET_HREF
Definition: DAVHelper.hpp:103
DAV Response.
Definition: DAVHelper.hpp:52
static const std::string PROPERTY_RESOURCE_TYPE
Definition: DAVHelper.hpp:99
std::string href
Definition: DAVHelper.hpp:54
std::map< std::string, std::string > properties
Definition: DAVHelper.hpp:45
static const std::string PROPERTY_SYNC_TOKEN
Definition: DAVHelper.hpp:98
std::vector< std::string > getPropertiesNames()
Definition: DAVHelper.cpp:308
static const std::string PROPERTY_RESOURCE_TYPE_ADDRESSBOOK
Definition: DAVHelper.hpp:100
static const std::string PROPERTY_SUPPORTED_CALENDAR_COMPONENT_SET_JOURNAL
Definition: DAVHelper.hpp:110
static const std::string PROPERTY_CALENDAR_DATA
Definition: DAVHelper.hpp:106
Helper class handling DAV responses parsing.
Definition: DAVHelper.hpp:22
static const std::string PROPERTY_ETAG
Definition: DAVHelper.hpp:96
static const std::string PROPERTY_RESOURCE_TYPE_CALENDAR
Definition: DAVHelper.hpp:101
static const std::string PROPERTY_DISPLAY_NAME
Definition: DAVHelper.hpp:107
DAVStatusCode status
Definition: DAVHelper.hpp:56
DAVStatusCode status
Definition: DAVHelper.hpp:46