1 // ConnectionObject.h - ConnectionObject interface header file.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __CONNOBJECT_CONNECTIONOBJECT_H__
20 #define __CONNOBJECT_CONNECTIONOBJECT_H__
25 #include "../common/sslcertstructs.h"
27 enum COConnectResult {
28 COCONNECT_UNITTESTFAIL = -1,
36 enum CORequestResult {
37 COREQUEST_UNITTESTFAIL = -1,
39 COREQUEST_ERROR_NOTCONNECTED,
40 COREQUEST_ERROR_SERVER,
44 COSSL_UNITTESTFAIL = -1,
52 enum COContactStatus {
58 struct COServerResponse {
59 CORequestResult RequestResult;
60 std::string EntityTag;
63 std::string ResultMessage;
66 struct COContactData {
69 COContactStatus Status = COCS_UNKNOWN;
72 struct COContactList {
73 COServerResponse ServerResponse;
74 std::vector<COContactData> ListData;
75 std::string SyncToken;
78 class ConnectionObject{
81 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
82 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
84 // Virtual functions to be setup by the inheriting classes.
86 virtual void SetupConnectionObject() { };
87 //virtual ~ConnectionObject() {};
89 virtual bool IsTaskCompleted() {};
91 virtual COConnectResult Connect(bool DoAuthentication) {};
92 virtual void BypassSSLVerification(bool EnableBypass) {};
94 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) {};
95 virtual COServerResponse AddContact(std::string Location, std::string Data) {};
96 virtual COServerResponse EditContact(std::string Location, std::string Data) {};
97 virtual COServerResponse DeleteContact(std::string Location) {};
98 virtual COServerResponse GetServerEntityTagValue(std::string Location) {};
99 virtual COServerResponse GetContact(std::string Location, std::string *PageData) {};
100 virtual COContactList GetContactList(std::string SyncToken) {};
102 virtual bool CanDoProcessing() {};
103 virtual bool CanDoSSL() {};
104 virtual COSSLVerified SSLVerify() {};
105 virtual bool AbleToLogin() {};
106 virtual bool HasValidResponse() {};
107 virtual bool IsSelfSigned() {};
108 virtual std::string GetErrorMessage() {};
110 // OS specific functions.
112 #if defined(__APPLE__)
113 #elif defined(__WIN32__)
115 virtual SSLCertCollectionString BuildSSLCollection() {};
122 bool TestMode = false;
126 std::string ServerAddress = "";
127 unsigned int ServerPort = 8080;
128 std::string ServerUser = "";
129 std::string ServerPass = "";
130 std::string ServerPrefix = "";
131 std::string ServerAccount = "";
132 bool ServerSSL = true;
133 std::string ErrorMessage = "";
137 bool SSLStatus = false;
138 COSSLVerified SSLVerified = COSSL_NORESULT;
139 bool ValidResponse = false;
140 bool AuthPassed = false;
141 bool CanProcess = false;
142 bool SSLSelfSigned = false;
143 bool TaskCompleted = false;