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,
44 COCONNECT_NOCONNECTION,
47 enum CORequestResult {
48 COREQUEST_UNITTESTFAIL = -1,
50 COREQUEST_ERROR_NOTCONNECTED,
51 COREQUEST_ERROR_SERVER,
52 COREQUEST_NOCONNECTION,
56 COSSL_UNITTESTFAIL = -1,
64 enum COContactStatus {
70 struct COServerResponse {
71 CORequestResult RequestResult = COREQUEST_NOCONNECTION;
72 std::string EntityTag = "";
75 std::string ResultMessage = "";
78 struct COContactData {
79 std::string Location = "";
80 std::string Data = "";
81 COContactStatus Status = COCS_UNKNOWN;
84 struct COContactList {
85 COServerResponse ServerResponse;
86 std::vector<COContactData> ListData;
87 std::string SyncToken;
90 class ConnectionObject{
93 //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
94 //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
96 // Virtual functions to be setup by the inheriting classes.
98 virtual void SetupConnectionObject() {};
100 virtual bool IsTaskCompleted() { return false; };
102 virtual COConnectResult Connect(bool DoAuthentication) { COConnectResult x; return x; };
103 virtual void BypassSSLVerification(bool EnableBypass) {};
105 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) { COServerResponse x; return x; };
106 virtual COServerResponse AddContact(std::string Location, std::string Data) { COServerResponse x; return x; };
107 virtual COServerResponse EditContact(std::string Location, std::string Data) { COServerResponse x; return x; };
108 virtual COServerResponse DeleteContact(std::string Location) { COServerResponse x; return x; };
109 virtual COServerResponse GetServerEntityTagValue(std::string Location) { COServerResponse x; return x; };
110 virtual COServerResponse GetContact(std::string Location, std::string *PageData) { COServerResponse x; return x; };
111 virtual COContactList GetContactList(std::string SyncToken) { COContactList x; return x; };
113 virtual bool CanDoProcessing() { return false; };
114 virtual bool CanDoSSL() { return false; };
115 virtual COSSLVerified SSLVerify() { COSSLVerified x; return x; };
116 virtual bool AbleToLogin() { return false; };
117 virtual bool HasValidResponse() { return false; };
118 virtual bool IsSelfSigned() { return false; };
119 virtual std::string GetErrorMessage() { return ""; };
121 // OS specific functions.
123 #if defined(__APPLE__)
124 #elif defined(__WIN32__)
126 virtual PCCERT_CONTEXT BuildSSLCollection() { return nullptr; };
129 virtual SSLCertCollectionString BuildSSLCollection() {};
136 bool TestMode = false;
140 std::string ServerAddress = "";
141 unsigned int ServerPort = 8080;
142 std::string ServerUser = "";
143 std::string ServerPass = "";
144 std::string ServerPrefix = "";
145 std::string ServerAccount = "";
146 bool ServerSSL = true;
147 std::string ErrorMessage = "";
151 bool SSLStatus = false;
152 COSSLVerified SSLVerified = COSSL_NORESULT;
153 bool ValidResponse = false;
154 bool AuthPassed = false;
155 bool CanProcess = false;
156 bool SSLSelfSigned = false;
157 bool TaskCompleted = false;