GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tech/cxx_sessionhub.cpp
Date: 2026-12-03 19:36:00
Exec Total Coverage
Lines: 0 60 0.0%
Functions: 0 21 0.0%
Branches: 0 34 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/tech/sessionhub.hpp"
30 #include "gate/structs.hpp"
31 #include "gate/arrays.hpp"
32 #include "gate/files.hpp"
33
34 namespace gate
35 {
36
37 // specialization must be done in gate namespace!
38 template<>
39 struct StructDescriptor<tech::SessionEntry> : public DynStructDescriptorBase<tech::SessionEntry>
40 {
41 StructDescriptor()
42 : DynStructDescriptorBase<tech::SessionEntry>("SessionEntry")
43 {
44 this->addMember(&struct_type_t::session_id, "session_id");
45 this->addMember(&struct_type_t::join_token, "join_token");
46 this->addMember(&struct_type_t::timeout_seconds, "timeout_seconds");
47 this->addMember(&struct_type_t::time_started_utc, "time_started_utc");
48 this->addMember(&struct_type_t::time_started, "time_started");
49 this->addMember(&struct_type_t::time_last_access, "time_last_access");
50 this->addMember(&struct_type_t::time_expiration, "time_expiration");
51 this->updateDescriptor();
52 }
53 };
54
55 namespace tech
56 {
57
58 class LockFileMutex
59 {
60 public:
61 explicit LockFileMutex(String const& lockfilepath);
62 ~LockFileMutex() noexcept;
63
64 private:
65 LockFileMutex(LockFileMutex const&);
66 LockFileMutex& operator=(LockFileMutex const&);
67
68 gate_file_t fileHandle;
69 };
70
71 ✗ LockFileMutex::LockFileMutex(String const& lockfilepath)
72 {
73 ✗ result_t result = gate_file_open(
74 lockfilepath.c_impl(),
75 GATE_STREAM_OPEN_READWRITE | GATE_FILE_OPEN_SHARED,
76 &this->fileHandle);
77 ✗ GATEXX_CHECK_EXCEPTION(result);
78
79 ✗ result = gate_file_lock(this->fileHandle, true);
80 ✗ if (GATE_FAILED(result))
81 {
82 ✗ gate_file_close(this->fileHandle);
83 ✗ GATEXX_RAISE_EXCEPTION(results::Failed, "Could not lock file", 1);
84 }
85 ✗ }
86
87 ✗ LockFileMutex::~LockFileMutex() noexcept
88 {
89 ✗ gate_file_close(this->fileHandle);
90 ✗ }
91
92 static StaticString const accessLockFile = "access.loc";
93
94
95 ✗ SessionHub::SessionHub(String const& storage)
96 ✗ : storagePath(storage)
97 {
98 // ensure storage path exists:
99 ✗ if (!File::isDirectory(this->storagePath))
100 {
101 ✗ File::createDirectory(this->storagePath);
102 }
103
104 // create sessions root path:
105 ✗ static StaticString const sessionsSubDir = "sessions";
106 ✗ this->sessionsRootPath = File::buildPath(this->storagePath, sessionsSubDir);
107 ✗ if (!File::isDirectory(this->sessionsRootPath))
108 {
109 ✗ File::createDirectory(this->sessionsRootPath);
110 }
111
112 ✗ this->sessionsLockPath = File::buildPath(this->sessionsRootPath, accessLockFile);
113 ✗ if (!File::exists(this->sessionsLockPath))
114 {
115 ✗ File::setContent(this->sessionsLockPath, String());
116 }
117
118 ✗ static StaticString const publicSubDir = "public";
119 ✗ }
120
121 ✗ SessionHub::~SessionHub() noexcept
122 {
123 ✗ }
124
125 ✗ SessionEntry SessionHub::createSession()
126 {
127 ✗ return SessionEntry();
128 }
129
130 ✗ SessionEntry SessionHub::getSession(String const& sessionId)
131 {
132 ✗ return SessionEntry();
133 }
134
135 ✗ void SessionHub::deleteSession(String const& sessionId)
136 {
137 ✗ }
138
139 ✗ SessionLoginEntry SessionHub::createSessionLogin(String const& sessionId)
140 {
141 ✗ return SessionLoginEntry();
142 }
143
144 ✗ SessionLoginEntry SessionHub::getSessionLogin(String const& sessionLoginToken)
145 {
146 ✗ return SessionLoginEntry();
147 }
148
149 ✗ void SessionHub::deleteSessionLogin(String const& sessionLoginToken)
150 {
151 ✗ }
152
153 ✗ SessionServiceEntry SessionHub::createSessionService(String const& sessionId, String const& serviceId)
154 {
155 ✗ return SessionServiceEntry();
156 }
157
158 ✗ SessionServiceEntry SessionHub::getSessionService(String const& sessionId, String const& serviceId)
159 {
160 ✗ return SessionServiceEntry();
161 }
162
163 ✗ void SessionHub::deleteSessionService(String const& sessionId, String const& serviceId)
164 {
165
166 ✗ }
167
168 ✗ SessionChannelEntry SessionHub::createSessionChannel(String const& sessionId, String const& serviceId, String const& channelId)
169 {
170 ✗ return SessionChannelEntry();
171 }
172
173 ✗ SessionChannelEntry SessionHub::getSessionChannel(String const& sessionId, String const& serviceId, String const& channelId)
174 {
175 ✗ return SessionChannelEntry();
176 }
177
178 ✗ void SessionHub::deleteSessionChannel(String const& sessionId, String const& serviceId, String const& channelId)
179 {
180
181 ✗ }
182
183 ✗ void SessionHub::updateSessionChannel(String const& sessionId, String const& serviceId, String const& channelId, Blob const& data)
184 {
185
186 ✗ }
187
188 ✗ Array<Blob> SessionHub::readSessionChannel(String const& sessionId, String const& serviceId, String const& channelId,
189 uint64_t requestUpdateId, uint64_t& finalUpdateId)
190 {
191 ✗ return Array<Blob>();
192 }
193
194
195 ✗ String SessionHub::getStorageRoot()
196 {
197 // TODO
198 ✗ return String();
199 }
200
201 ✗ String SessionHub::createNewSessionId()
202 {
203 // TODO
204 ✗ return String();
205 }
206
207 ✗ String SessionHub::createNewJoinToken()
208 {
209 // TODO
210 ✗ return String();
211 }
212
213
214
215 } // end of namespace tech
216 } // end of namespace gate
217