OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Google.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 GOOGLE_H_
11 #define GOOGLE_H_
12 
13 #include <plugin/source/Source.hpp>
14 #include <gdata/gdata.h>
16 #include <list>
17 
37 {
38  public:
42  GoogleSource(const std::string& login,
43  const OpenAB::SecureString& password,
44  const std::string& filter);
45 
46  GoogleSource(const std::string& clientId,
47  const OpenAB::SecureString& clientSecret,
48  const OpenAB::SecureString& refreshToken,
49  const std::string& filter);
50 
51 
52  virtual ~GoogleSource();
53 
55 
57 
59 
61 
63 
64  int getTotalCount() const;
65 
66  private:
70  GoogleSource(GoogleSource const &other);
71 
75  GoogleSource& operator=(GoogleSource const &other);
76 
81  void construct(const std::string& ignoreFields);
82 
83  void cleanup();
84 
93  std::string convertContact(GDataContactsContact* contact,
94  guint8* photoData,
95  gsize photoDataLen,
96  gchar* photoContentType);
97 
101  static void* downloadThreadFunc(void* ptr);
102 
106  bool downloadPhoto();
107 
108  //User credentials
109  std::string userLogin;
110  OpenAB::SecureString userPassword;
111 
112  std::string clientId;
113  OpenAB::SecureString clientSecret;
114  OpenAB::SecureString refreshToken;
115 
116  // list of vCard fields to be ignored
117  std::vector<std::string> ignoredFields;
118 
119  // current transfer status, updated by downloadThreadFunc
120  OpenAB_Source::Source::eGetItemRet transferStatus;
121 
122  //GData specific members
123  GDataAuthorizer* authorizer;
124  GDataContactsService *service;
125 
126  GCancellable *cancellable;
127 
128 
129  unsigned int totalNumber;
130  //buffer of already converted vCards
131  std::list<std::string> bufferedVCards;
132 
133  pthread_t downloadThread;
134  bool threadCreated;
135  bool paused;
136  bool cancelled;
137  pthread_mutex_t mutex;
138  pthread_cond_t bufferReadyCond;
139 };
140 
141 #endif // GOOGLE_H_
eCancelRet
Definition: Source.hpp:138
eResumeRet
Definition: Source.hpp:123
virtual ~GoogleSource()
Definition: Google.cpp:97
enum OpenAB_Source::Source::eInit init()
Initializes Source.
Definition: Google.cpp:136
SecureString class, used to store strings like passwords etc. Current implementation encodes string i...
Definition: SecureString.hpp:26
GoogleSource(const std::string &login, const OpenAB::SecureString &password, const std::string &filter)
Constructor.
Definition: Google.cpp:26
enum OpenAB_Source::Source::eCancelRet cancel()
Cancels Source, if such operation is supported. After canceling Source next call to getVCard() should...
Definition: Google.cpp:308
eSuspendRet
Definition: Source.hpp:108
Documentation for Source plugin interface.
Definition: Source.hpp:76
int getTotalCount() const
Returns total count of items available from Source, if such information is available.
Definition: Google.cpp:321
eGetItemRet
Definition: Source.hpp:155
Definition: Google.hpp:36
enum OpenAB_Source::Source::eGetItemRet getItem(OpenAB::SmartPtr< OpenAB::PIMItem > &item)
Gets PIM Item from Source. If Source is suspended getItem() should block until Source will be resumed...
Definition: Google.cpp:240
eInit
Definition: Source.hpp:94
enum OpenAB_Source::Source::eSuspendRet suspend()
Suspends Source, if such operation is supported.
Definition: Google.cpp:292
enum OpenAB_Source::Source::eResumeRet resume()
Resumes Source, if such operation is supported.
Definition: Google.cpp:300