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