Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
ConnectionObject: Removed commented out code.
[xestiaab/.git] / source / connobject / ConnectionObject.h
1 // ConnectionObject.h - ConnectionObject interface header file.
2 //
3 // (c) 2012-2016 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 (__APPLE__)
28 #import <Foundation/Foundation.h>
29 #import <SecurityInterface/SFCertificateTrustPanel.h>
30 #endif
32 #if defined (__WIN32__)
33 #include <Windows.h>
34 #include <basetsd.h>
35 #include <winapifamily.h>
36 #include <security.h>
37 #include <schannel.h>
38 #include <cryptuiapi.h>
39 #include <sspi.h>
40 #endif
42 enum COConnectResult {
43         COCONNECT_UNITTESTFAIL = -1,
44         COCONNECT_OK,
45         COCONNECT_SSLFAIL,
46         COCONNECT_INVALID,
47         COCONNECT_TIMEOUT,
48         COCONNECT_AUTHFAIL,
49         COCONNECT_NOCONNECTION,
50 };
52 enum CORequestResult {
53         COREQUEST_UNITTESTFAIL = -1,
54         COREQUEST_OK,
55         COREQUEST_ERROR_NOTCONNECTED,
56         COREQUEST_ERROR_SERVER,
57         COREQUEST_NOCONNECTION,
58 };
60 enum COSSLVerified {
61         COSSL_UNITTESTFAIL = -1,
62         COSSL_VERIFIED,
63         COSSL_VERIFIED_USER,
64         COSSL_UNABLETOVERIFY,
65         COSSL_NOTAPPLICABLE,
66         COSSL_NORESULT
67 };
69 enum COContactStatus {
70         COCS_UNKNOWN,
71         COCS_UPDATED,
72         COCS_DELETED
73 };
75 struct COServerResponse {
76         CORequestResult RequestResult = COREQUEST_NOCONNECTION;
77         std::string EntityTag = "";
78         int SessionCode = 0;
79         int ResultCode = 0;
80         std::string ResultMessage = "";
81 };
83 struct COContactData {
84         std::string Location = "";
85         std::string Data = "";
86         COContactStatus Status = COCS_UNKNOWN;
87 };
89 struct COContactList {
90         COServerResponse ServerResponse;
91         std::vector<COContactData> ListData;
92         std::string SyncToken;
93 };
95 class ConnectionObject{
96         
97         public:
99                 // Virtual functions to be setup by the inheriting classes.
100         
101                 virtual void SetupConnectionObject() {};
102                 
103                 virtual bool IsTaskCompleted() { return false; };
104                 
105                 virtual COConnectResult Connect(bool DoAuthentication) { COConnectResult x; return x; };
106                 virtual void BypassSSLVerification(bool EnableBypass) {};
107                 
108                 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) { COServerResponse x; return x; };
109                 virtual COServerResponse AddContact(std::string Location, std::string Data) { COServerResponse x; return x; };
110                 virtual COServerResponse EditContact(std::string Location, std::string Data) { COServerResponse x; return x; };
111                 virtual COServerResponse DeleteContact(std::string Location) { COServerResponse x; return x; };
112                 virtual COServerResponse GetServerEntityTagValue(std::string Location) { COServerResponse x; return x; };
113                 virtual COServerResponse GetContact(std::string Location, std::string *PageData) { COServerResponse x; return x; };
114                 virtual COContactList GetContactList(std::string SyncToken) { COContactList x; return x; };
115                 
116                 virtual bool CanDoProcessing() { return false;  };
117                 virtual bool CanDoSSL() { return false; };
118                 virtual COSSLVerified SSLVerify() { COSSLVerified x; return x; };
119                 virtual bool AbleToLogin() { return false; };
120                 virtual bool HasValidResponse() { return false; };
121                 virtual bool IsSelfSigned() { return false; };
122                 virtual std::string GetErrorMessage() { return ""; };
123         
124                 // OS specific functions.
125                 
126 #if defined(__APPLE__)
127     
128                 virtual SecTrustRef BuildSSLCollection() { return nullptr; };
129     
130 #elif defined(__WIN32__)
132                 virtual PCCERT_CONTEXT BuildSSLCollection() { return nullptr; };
134 #else
135                 virtual SSLCertCollectionString BuildSSLCollection() {};
137 #endif
138                 
139         protected:
140                 // Test Mode.
141         
142                 bool TestMode = false;
143         
144                 // Server variables.
145         
146                 std::string ServerAddress = "";
147                 unsigned int ServerPort = 8080;
148                 std::string ServerUser = "";
149                 std::string ServerPass = "";
150                 std::string ServerPrefix = "";
151                 std::string ServerAccount = "";
152                 bool ServerSSL = true;
153                 std::string ErrorMessage = "";
154         
155                 // Connect results.
156         
157                 bool SSLStatus = false;
158                 COSSLVerified SSLVerified = COSSL_NORESULT;
159                 bool ValidResponse = false;
160                 bool AuthPassed = false;
161                 bool CanProcess = false;
162                 bool SSLSelfSigned = false;
163                 bool TaskCompleted = false;
164                 
165         private:
167 };
169 #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