Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented support using ConnectionObject/CardDAV2 on Win32 systems.
[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         COCONNECT_NOCONNECTION,
45 };
47 enum CORequestResult {
48         COREQUEST_UNITTESTFAIL = -1,
49         COREQUEST_OK,
50         COREQUEST_ERROR_NOTCONNECTED,
51         COREQUEST_ERROR_SERVER,
52         COREQUEST_NOCONNECTION,
53 };
55 enum COSSLVerified {
56         COSSL_UNITTESTFAIL = -1,
57         COSSL_VERIFIED,
58         COSSL_VERIFIED_USER,
59         COSSL_UNABLETOVERIFY,
60         COSSL_NOTAPPLICABLE,
61         COSSL_NORESULT
62 };
64 enum COContactStatus {
65         COCS_UNKNOWN,
66         COCS_UPDATED,
67         COCS_DELETED
68 };
70 struct COServerResponse {
71         CORequestResult RequestResult = COREQUEST_NOCONNECTION;
72         std::string EntityTag = "";
73         int SessionCode = 0;
74         int ResultCode = 0;
75         std::string ResultMessage = "";
76 };
78 struct COContactData {
79         std::string Location = "";
80         std::string Data = "";
81         COContactStatus Status = COCS_UNKNOWN;
82 };
84 struct COContactList {
85         COServerResponse ServerResponse;
86         std::vector<COContactData> ListData;
87         std::string SyncToken;
88 };
90 class ConnectionObject{
91         
92         public:
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.
97         
98                 virtual void SetupConnectionObject() {};
99                 
100                 virtual bool IsTaskCompleted() { return false; };
101                 
102                 virtual COConnectResult Connect(bool DoAuthentication) { COConnectResult x; return x; };
103                 virtual void BypassSSLVerification(bool EnableBypass) {};
104                 
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; };
112                 
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 ""; };
120         
121                 // OS specific functions.
122                 
123 #if defined(__APPLE__)
124 #elif defined(__WIN32__)
126                 virtual PCCERT_CONTEXT BuildSSLCollection() { return nullptr; };
128 #else
129                 virtual SSLCertCollectionString BuildSSLCollection() {};
131 #endif
132                 
133         protected:
134                 // Test Mode.
135         
136                 bool TestMode = false;
137         
138                 // Server variables.
139         
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 = "";
148         
149                 // Connect results.
150         
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;
158                 
159         private:
161 };
163 #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