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 #if defined (__WIN32__)
30 #include <winapifamily.h>
33 #include <cryptuiapi.h>
37 enum COConnectResult {
38 COCONNECT_UNITTESTFAIL = -1,
46 enum CORequestResult {
47 COREQUEST_UNITTESTFAIL = -1,
49 COREQUEST_ERROR_NOTCONNECTED,
50 COREQUEST_ERROR_SERVER,
54 COSSL_UNITTESTFAIL = -1,
62 enum COContactStatus {
68 struct COServerResponse {
69 CORequestResult RequestResult;
70 std::string EntityTag;
73 std::string ResultMessage;
76 struct COContactData {
79 COContactStatus Status = COCS_UNKNOWN;
82 struct COContactList {
83 COServerResponse ServerResponse;
84 std::vector<COContactData> ListData;
85 std::string SyncToken;
88 class ConnectionObject{
91 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
92 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
94 // Virtual functions to be setup by the inheriting classes.
96 virtual void SetupConnectionObject() = 0;
97 //virtual ~ConnectionObject() {};
99 virtual bool IsTaskCompleted() = 0;
101 virtual COConnectResult Connect(bool DoAuthentication) = 0;
102 virtual void BypassSSLVerification(bool EnableBypass) = 0;
104 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) = 0;
105 virtual COServerResponse AddContact(std::string Location, std::string Data) = 0;
106 virtual COServerResponse EditContact(std::string Location, std::string Data) = 0;
107 virtual COServerResponse DeleteContact(std::string Location) = 0;
108 virtual COServerResponse GetServerEntityTagValue(std::string Location) = 0;
109 virtual COServerResponse GetContact(std::string Location, std::string *PageData) = 0;
110 virtual COContactList GetContactList(std::string SyncToken) = 0;
112 virtual bool CanDoProcessing() = 0;
113 virtual bool CanDoSSL() = 0;
114 virtual COSSLVerified SSLVerify() = 0;
115 virtual bool AbleToLogin() = 0;
116 virtual bool HasValidResponse() = 0;
117 virtual bool IsSelfSigned() = 0;
118 virtual std::string GetErrorMessage() = 0;
120 // OS specific functions.
122 #if defined(__APPLE__)
123 #elif defined(__WIN32__)
125 virtual PCCERT_CONTEXT BuildSSLCollection() = 0;
128 virtual SSLCertCollectionString BuildSSLCollection() = 0;
135 bool TestMode = false;
139 std::string ServerAddress = "";
140 unsigned int ServerPort = 8080;
141 std::string ServerUser = "";
142 std::string ServerPass = "";
143 std::string ServerPrefix = "";
144 std::string ServerAccount = "";
145 bool ServerSSL = true;
146 std::string ErrorMessage = "";
150 bool SSLStatus = false;
151 COSSLVerified SSLVerified = COSSL_NORESULT;
152 bool ValidResponse = false;
153 bool AuthPassed = false;
154 bool CanProcess = false;
155 bool SSLSelfSigned = false;
156 bool TaskCompleted = false;