Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added COContactStatus enum and marked BuildSSLCollection as virtual
[xestiaab/.git] / source / connobject / ConnectionObject.h
1 // ConnectionObject.h - ConnectionObject interface header file.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
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.
10 //
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.
15 //
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__
22 #include <string>
23 #include <vector>
24 #include <iostream>
25 #include "../common/sslcertstructs.h"
27 enum COConnectResult {
28         COCONNECT_UNITTESTFAIL = -1,
29         COCONNECT_OK,
30         COCONNECT_SSLFAIL,
31         COCONNECT_INVALID,
32         COCONNECT_TIMEOUT,
33         COCONNECT_AUTHFAIL
34 };
36 enum CORequestResult {
37         COREQUEST_UNITTESTFAIL = -1,
38         COREQUEST_OK,
39         COREQUEST_ERROR_NOTCONNECTED,
40         COREQUEST_ERROR_SERVER,
41 };
43 enum COSSLVerified {
44         COSSL_UNITTESTFAIL = -1,
45         COSSL_VERIFIED,
46         COSSL_VERIFIED_USER,
47         COSSL_UNABLETOVERIFY,
48         COSSL_NOTAPPLICABLE,
49         COSSL_NORESULT
50 };
52 enum COContactStatus {
53         COCS_UNKNOWN,
54         COCS_UPDATED,
55         COCS_DELETED
56 };
58 struct COServerResponse {
59         CORequestResult RequestResult;
60         std::string EntityTag;
61         int SessionCode;
62         int ResultCode;
63         std::string ResultMessage;
64 };
66 struct COContactData {
67         std::string Location;
68         std::string Data;
69         COContactStatus Status = COCS_UNKNOWN;
70 };
72 struct COContactList {
73         COServerResponse ServerResponse;
74         std::vector<COContactData> ListData;
75         std::string SyncToken;
76 };
78 class ConnectionObject{
79         
80         public:
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);
83         
84                 // Virtual functions to be setup by the inheriting classes.
85         
86                 virtual void SetupConnectionObject() { };
87                 //virtual ~ConnectionObject() {};
88                 
89                 virtual bool IsTaskCompleted() {};
90                 
91                 virtual COConnectResult Connect(bool DoAuthentication) {};
92                 virtual void BypassSSLVerification(bool EnableBypass) {};
93                 
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) {};
101                 
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() {};
109         
110                 // OS specific functions.
111                 
112 #if defined(__APPLE__)
113 #elif defined(__WIN32__)
114 #else
115                 virtual SSLCertCollectionString BuildSSLCollection() {};
117 #endif
118                 
119         protected:
120                 // Test Mode.
121         
122                 bool TestMode = false;
123         
124                 // Server variables.
125         
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 = "";
134         
135                 // Connect results.
136         
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;
144                 
145         private:
147 };
149 #endif
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy