Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Changed ConnectionObject and updated unit tests accordingly.
[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>
26 enum COConnectResult {
27         COCONNECT_UNITTESTFAIL = -1,
28         COCONNECT_OK,
29         COCONNECT_SSLFAIL,
30         COCONNECT_INVALID,
31         COCONNECT_TIMEOUT,
32         COCONNECT_AUTHFAIL
33 };
35 enum CORequestResult {
36         COREQUEST_UNITTESTFAIL = -1,
37         COREQUEST_OK,
38         COREQUEST_ERROR_NOTCONNECTED,
39         COREQUEST_ERROR_SERVER
40 };
42 enum COSSLVerified {
43         COSSL_UNITTESTFAIL = -1,
44         COSSL_VERIFIED,
45         COSSL_VERIFIED_USER,
46         COSSL_UNABLETOVERIFY,
47         COSSL_NOTAPPLICABLE,
48         COSSL_NORESULT
49 };
51 struct COServerResponse {
52         CORequestResult RequestResult;
53         std::string EntityTag;
54         int SessionCode;
55         int ResultCode;
56         std::string ResultMessage;
57 };
59 struct COContactData {
60         std::string Location;
61         std::string Data;
62 };
64 struct COContactList {
65         COServerResponse ServerResponse;
66         std::vector<COContactData> ListData;
67         std::string SyncToken;
68 };
70 class ConnectionObject{
71         
72         public:
73                 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
74                 ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
75         
76                 // Virtual functions to be setup by the inheriting classes.
77         
78                 virtual void SetupConnectionObject() { };
79                 //virtual ~ConnectionObject() {};
80                 
81                 virtual bool IsTaskCompleted() {};
82                 
83                 virtual COConnectResult Connect(bool DoAuthentication) {};
84                 
85                 virtual std::string GetDefaultPrefix() {};
86                 virtual COServerResponse AddContact(std::string Location, std::string Data) {};
87                 virtual COServerResponse EditContact(std::string Location, std::string Data) {};
88                 virtual COServerResponse DeleteContact(std::string Location, std::string EntityTag) {};
89                 virtual COServerResponse GetServerEntityTagValue(std::string Location) {};
90                 virtual COServerResponse GetContact(std::string Location) {};
91                 virtual COContactList GetContactList(std::string SyncToken) {};
92                 
93                 virtual bool CanDoProcessing() {};
94                 virtual bool CanDoSSL() {};
95                 virtual COSSLVerified SSLVerify() {};
96                 virtual bool AbleToLogin() {};
97                 virtual bool HasValidResponse() {};
98                 virtual bool IsSelfSigned() {};
99                 virtual std::string GetErrorMessage() {};
100                 
101         protected:
102                 // Test Mode.
103         
104                 bool TestMode = false;
105         
106                 // Server variables.
107         
108                 std::string ServerAddress = "";
109                 unsigned int ServerPort = 8080;
110                 std::string ServerUser = "";
111                 std::string ServerPass = "";
112                 std::string ServerPrefix = "";
113                 std::string ServerAccount = "";
114                 bool ServerSSL = true;
115                 std::string ErrorMessage = "";
116         
117                 // Connect results.
118         
119                 bool SSLStatus = false;
120                 COSSLVerified SSLVerified = COSSL_NORESULT;
121                 bool ValidResponse = false;
122                 bool AuthPassed = false;
123                 bool CanProcess = false;
124                 bool SSLSelfSigned = false;
125                 bool TaskCompleted = false;
126                 
127         private:
129 };
131 #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