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