Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmSearch: Added window icon
[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 (__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:
98                 //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
99                 //ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
101                 // Virtual functions to be setup by the inheriting classes.
102         
103                 virtual void SetupConnectionObject() {};
104                 
105                 virtual bool IsTaskCompleted() { return false; };
106                 
107                 virtual COConnectResult Connect(bool DoAuthentication) { COConnectResult x; return x; };
108                 virtual void BypassSSLVerification(bool EnableBypass) {};
109                 
110                 virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) { COServerResponse x; return x; };
111                 virtual COServerResponse AddContact(std::string Location, std::string Data) { COServerResponse x; return x; };
112                 virtual COServerResponse EditContact(std::string Location, std::string Data) { COServerResponse x; return x; };
113                 virtual COServerResponse DeleteContact(std::string Location) { COServerResponse x; return x; };
114                 virtual COServerResponse GetServerEntityTagValue(std::string Location) { COServerResponse x; return x; };
115                 virtual COServerResponse GetContact(std::string Location, std::string *PageData) { COServerResponse x; return x; };
116                 virtual COContactList GetContactList(std::string SyncToken) { COContactList x; return x; };
117                 
118                 virtual bool CanDoProcessing() { return false;  };
119                 virtual bool CanDoSSL() { return false; };
120                 virtual COSSLVerified SSLVerify() { COSSLVerified x; return x; };
121                 virtual bool AbleToLogin() { return false; };
122                 virtual bool HasValidResponse() { return false; };
123                 virtual bool IsSelfSigned() { return false; };
124                 virtual std::string GetErrorMessage() { return ""; };
125         
126                 // OS specific functions.
127                 
128 #if defined(__APPLE__)
129     
130                 virtual SecTrustRef BuildSSLCollection() { return nullptr; };
131     
132 #elif defined(__WIN32__)
134                 virtual PCCERT_CONTEXT BuildSSLCollection() { return nullptr; };
136 #else
137                 virtual SSLCertCollectionString BuildSSLCollection() {};
139 #endif
140                 
141         protected:
142                 // Test Mode.
143         
144                 bool TestMode = false;
145         
146                 // Server variables.
147         
148                 std::string ServerAddress = "";
149                 unsigned int ServerPort = 8080;
150                 std::string ServerUser = "";
151                 std::string ServerPass = "";
152                 std::string ServerPrefix = "";
153                 std::string ServerAccount = "";
154                 bool ServerSSL = true;
155                 std::string ErrorMessage = "";
156         
157                 // Connect results.
158         
159                 bool SSLStatus = false;
160                 COSSLVerified SSLVerified = COSSL_NORESULT;
161                 bool ValidResponse = false;
162                 bool AuthPassed = false;
163                 bool CanProcess = false;
164                 bool SSLSelfSigned = false;
165                 bool TaskCompleted = false;
166                 
167         private:
169 };
171 #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