MCPcopy Create free account
hub / github.com/Atarity/Lightpack / Lock

Method Lock

Software/src/LightpackPluginInterface.cpp:187–230  ·  view source on GitHub ↗

TODO: lock unlock

Source from the content-addressed store, hash-verified

185
186//TODO: lock unlock
187bool LightpackPluginInterface::Lock(QString sessionKey)
188{
189 if (sessionKey == "") return false;
190 if (lockSessionKeys.contains(sessionKey)) return true;
191 if (sessionKey.indexOf("API", 0) != -1)
192 {
193 if (lockSessionKeys.count()>0)
194 return false;
195 lockSessionKeys.insert(0,sessionKey);
196 emit updateDeviceLockStatus(DeviceLocked::Api,lockSessionKeys);
197 }
198 else
199 {
200 Plugin* plugin = findSessionKey(sessionKey);
201 if (plugin == NULL) return false;
202
203 foreach (QString key,lockSessionKeys)
204 {
205 if (key.indexOf("API", 0) != -1) break;
206
207 Plugin* pluginLock = findSessionKey(key);
208 if (pluginLock == NULL) return false;
209 DEBUG_LOW_LEVEL << Q_FUNC_INFO << lockSessionKeys.indexOf(key);
210 if (plugin->getPriority() > pluginLock->getPriority())
211 lockSessionKeys.insert(lockSessionKeys.indexOf(key),sessionKey);
212 DEBUG_LOW_LEVEL << Q_FUNC_INFO << lockSessionKeys.indexOf(sessionKey);
213
214 }
215 if (!lockSessionKeys.contains(sessionKey))
216 {
217 DEBUG_LOW_LEVEL << Q_FUNC_INFO << "add to end";
218 lockSessionKeys.insert(lockSessionKeys.count(),sessionKey);
219 }
220 if (lockSessionKeys[0].indexOf("API", 0) != -1)
221 emit updateDeviceLockStatus(DeviceLocked::Api,lockSessionKeys);
222 else
223 emit updateDeviceLockStatus(DeviceLocked::Plugin, lockSessionKeys);
224}
225 DEBUG_LOW_LEVEL << Q_FUNC_INFO << "lock end";
226 lockAlive = true;
227 emit ChangeLockStatus (true);
228 return true;
229
230}
231
232bool LightpackPluginInterface::UnLock(QString sessionKey)
233{

Callers 1

clientProcessCommandsMethod · 0.45

Calls 2

countMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected