Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
8e5221f246de60bf2ffb49a534d4e6805803939c
[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 #if defined (__WIN32__)
28 #include <Windows.h>
29 #include <basetsd.h>
30 #include <winapifamily.h>
31 #include <security.h>
32 #include <schannel.h>
33 #include <cryptuiapi.h>
34 #include <sspi.h>
35 #endif
37 enum COConnectResult {
38         COCONNECT_UNITTESTFAIL = -1,
39         COCONNECT_OK,
40         COCONNECT_SSLFAIL,
41         COCONNECT_INVALID,
42         COCONNECT_TIMEOUT,
43         COCONNECT_AUTHFAIL
44 };
46 enum CORequestResult {
47         COREQUEST_UNITTESTFAIL = -1,
48         COREQUEST_OK,
49         COREQUEST_ERROR_NOTCONNECTED,
50         COREQUEST_ERROR_SERVER,
51 };
53 enum COSSLVerified {
54         COSSL_UNITTESTFAIL = -1,
55         COSSL_VERIFIED,
56         COSSL_VERIFIED_USER,
57         COSSL_UNABLETOVERIFY,
58         COSSL_NOTAPPLICABLE,
59         COSSL_NORESULT
60 };
62 enum COContactStatus {
63         COCS_UNKNOWN,
64         COCS_UPDATED,
65         COCS_DELETED
66 };
68 struct COServerResponse {
69         CORequestResult RequestResult;
70         std::string EntityTag;
71         int SessionCode;
72         int ResultCode;
73         std::string ResultMessage;
74 };
76 struct COContactData {
77         std::string Location;
78         std::string Data;
79         COContactStatus Status = COCS_UNKNOWN;
80 };
82 struct COContactList {
83         COServerResponse ServerResponse;
84         std::vector<COContactData> ListData;
85         std::string SyncToken;
86 };
88 class ConnectionObject{
89         
90         public:
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.
95         
96                 virtual void SetupConnectionObject() = 0;
97                 //virtual ~ConnectionObject() {};
98                 
99                 virtual bool IsTaskCompleted() = 0;
100                 
101                 virtual COConnectResult Connect(bool DoAuthentication) = 0;
102                 virtual void BypassSSLVerification(bool EnableBypass) = 0;
103                 
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;
111                 
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;
119         
120                 // OS specific functions.
121                 
122 #if defined(__APPLE__)
123 #elif defined(__WIN32__)
125                 virtual PCCERT_CONTEXT BuildSSLCollection() = 0;
127 #else
128                 virtual SSLCertCollectionString BuildSSLCollection() = 0;
130 #endif
131                 
132         protected:
133                 // Test Mode.
134         
135                 bool TestMode = false;
136         
137                 // Server variables.
138         
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 = "";
147         
148                 // Connect results.
149         
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;
157                 
158         private:
160 };
162 #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