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 struct COServerResponse {
53 CORequestResult RequestResult;
54 std::string EntityTag;
57 std::string ResultMessage;
60 struct COContactData {
65 struct COContactList {
66 COServerResponse ServerResponse;
67 std::vector<COContactData> ListData;
68 std::string SyncToken;
71 class ConnectionObject{
74 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
75 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
77 // Virtual functions to be setup by the inheriting classes.
79 virtual void SetupConnectionObject() { };
80 //virtual ~ConnectionObject() {};
82 virtual bool IsTaskCompleted() {};
84 virtual COConnectResult Connect(bool DoAuthentication) {};
85 virtual void BypassSSLVerification(bool EnableBypass) {};
87 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) {};
88 virtual COServerResponse AddContact(std::string Location, std::string Data) {};
89 virtual COServerResponse EditContact(std::string Location, std::string Data) {};
90 virtual COServerResponse DeleteContact(std::string Location) {};
91 virtual COServerResponse GetServerEntityTagValue(std::string Location) {};
92 virtual COServerResponse GetContact(std::string Location, std::string *PageData) {};
93 virtual COContactList GetContactList(std::string SyncToken) {};
95 virtual bool CanDoProcessing() {};
96 virtual bool CanDoSSL() {};
97 virtual COSSLVerified SSLVerify() {};
98 virtual bool AbleToLogin() {};
99 virtual bool HasValidResponse() {};
100 virtual bool IsSelfSigned() {};
101 virtual std::string GetErrorMessage() {};
103 // OS specific functions.
105 #if defined(__APPLE__)
106 #elif defined(__WIN32__)
108 SSLCertCollectionString BuildSSLCollection() {};
115 bool TestMode = false;
119 std::string ServerAddress = "";
120 unsigned int ServerPort = 8080;
121 std::string ServerUser = "";
122 std::string ServerPass = "";
123 std::string ServerPrefix = "";
124 std::string ServerAccount = "";
125 bool ServerSSL = true;
126 std::string ErrorMessage = "";
130 bool SSLStatus = false;
131 COSSLVerified SSLVerified = COSSL_NORESULT;
132 bool ValidResponse = false;
133 bool AuthPassed = false;
134 bool CanProcess = false;
135 bool SSLSelfSigned = false;
136 bool TaskCompleted = false;