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 enum COConnectResult {
26 COCONNECT_UNITTESTFAIL = -1,
33 enum CORequestResult {
34 COREQUEST_UNITTESTFAIL = -1,
36 COREQUEST_ERROR_NOTCONNECTED,
37 COREQUEST_ERROR_SERVER
41 COSSL_UNITTESTFAIL = -1,
49 struct COServerResponse {
50 CORequestResult RequestResult;
51 std::string EntityTag;
54 std::string ResultMessage;
57 struct COContactData {
62 struct COContactList {
63 COServerResponse ServerResponse;
64 std::vector<COContactData> ListData;
65 std::string SyncToken;
68 class ConnectionObject{
71 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
72 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
74 // Virtual functions to be setup by the inheriting classes.
76 virtual void SetupConnectionObject() {};
77 //virtual ~ConnectionObject() {};
79 virtual bool IsTaskCompleted() {};
81 virtual COConnectResult Connect() {};
83 virtual std::string GetDefaultPrefix() {};
84 virtual COServerResponse AddContact(std::string Location, std::string Data) {};
85 virtual COServerResponse EditContact(std::string Location, std::string Data) {};
86 virtual COServerResponse DeleteContact(std::string Location, std::string EntityTag) {};
87 virtual COServerResponse GetServerEntityTagValue(std::string Location) {};
88 virtual COServerResponse GetContact(std::string Location) {};
89 virtual COContactList GetContactList(std::string SyncToken) {};
91 virtual bool CanDoProcessing() {};
92 virtual bool CanDoSSL() {};
93 virtual COSSLVerified SSLVerify() {};
94 virtual bool AbleToLogin() {};
95 virtual bool HasValidResponse() {};
100 bool TestMode = false;
104 std::string ServerAddress = "";
105 unsigned int ServerPort = 8080;
106 std::string ServerUser = "";
107 std::string ServerPass = "";
108 std::string ServerPrefix = "";
109 std::string ServerAccount = "";
110 bool ServerSSL = true;
111 std::string ErrorMessage = "";
112 std::string ErrorBufferMessage = "";
116 bool SSLStatus = false;
117 COSSLVerified SSLVerified = COSSL_NORESULT;
118 bool ValidResponse = false;
119 bool AuthPassed = false;
120 bool CanProcess = false;
121 bool SSLSelfSigned = false;
122 bool TaskCompleted = false;