77
72
public $configTabs;
80
* Commands associated with this profile.
83
public $commands = [];
85
/** @var string the client type */
89
* @var ConfigServiceInterface
91
private $configService;
93
/** @var EventDispatcherInterface */
99
private $commandFactory;
102
* Entity constructor.
103
* @param StorageServiceInterface $store
104
* @param LogServiceInterface $log
105
* @param ConfigServiceInterface $config
106
* @param EventDispatcherInterface $dispatcher
107
* @param CommandFactory $commandFactory
109
public function __construct($store, $log, $config, $dispatcher, $commandFactory)
111
$this->setCommonDependencies($store, $log);
113
$this->configService = $config;
114
$this->dispatcher = $dispatcher;
115
$this->commandFactory = $commandFactory;
122
74
public function getId()
124
76
return $this->displayProfileId;
130
79
public function getOwnerId()
132
81
return $this->userId;
138
public function setClientType($clientType)
140
$this->clientType = $clientType;
144
* Get the client type
147
public function getClientType()
149
return (empty($this->clientType)) ? $this->type : $this->clientType;
154
* @param Command $command
156
public function assignCommand($command)
162
foreach ($this->commands as $alreadyAssigned) {
163
/* @var Command $alreadyAssigned */
164
if ($alreadyAssigned->getId() == $command->getId()) {
165
$alreadyAssigned->commandString = $command->commandString;
166
$alreadyAssigned->validationString = $command->validationString;
173
$this->commands[] = $command;
178
* @param Command $command
180
public function unassignCommand($command)
184
$this->commands = array_udiff($this->commands, [$command], function ($a, $b) {
189
return $a->getId() - $b->getId();
196
84
public function load()
201
86
$this->config = json_decode($this->config, true);
202
$this->getLog()->debug('Config loaded [%d]: %s', count($this->config), json_encode($this->config, JSON_PRETTY_PRINT));
87
Log::debug('Config loaded [%d]: %s', count($this->config), json_encode($this->config, JSON_PRETTY_PRINT));
204
89
$this->configDefault = $this->loadFromFile();
206
if (array_key_exists($this->type, $this->configDefault)) {
207
$this->configTabs = $this->configDefault[$this->type]['tabs'];
208
$this->configDefault = $this->configDefault[$this->type]['settings'];
210
$this->getLog()->debug('Unknown type for Display Profile: ' . $this->type);
211
$this->configTabs = $this->configDefault['unknown']['tabs'];
212
$this->configDefault = $this->configDefault['unknown']['settings'];
215
// We've loaded a profile
216
// dispatch an event with a reference to this object, allowing subscribers to modify the config before we
218
$this->dispatcher->dispatch(DisplayProfileLoadedEvent::NAME, new DisplayProfileLoadedEvent($this));
90
$this->configTabs = $this->configDefault[$this->type]['tabs'];
91
$this->configDefault = $this->configDefault[$this->type]['settings'];
220
93
// Just populate the values with the defaults if the values aren't set already
221
94
for ($i = 0; $i < count($this->configDefault); $i++) {
291
$this->manageAssignments();
297
147
public function delete()
299
$this->commands = [];
300
$this->manageAssignments();
302
$this->getStore()->update('DELETE FROM `displayprofile` WHERE displayprofileid = :displayProfileId', ['displayProfileId' => $this->displayProfileId]);
308
private function manageAssignments()
310
$this->getLog()->debug('Managing Assignment for Display Profile: %d. %d commands.', $this->displayProfileId, count($this->commands));
313
foreach ($this->commands as $command) {
314
/* @var Command $command */
315
$this->getStore()->update('
316
INSERT INTO `lkcommanddisplayprofile` (`commandId`, `displayProfileId`, `commandString`, `validationString`) VALUES
317
(:commandId, :displayProfileId, :commandString, :validationString) ON DUPLICATE KEY UPDATE commandString = :commandString2, validationString = :validationString2
319
'commandId' => $command->commandId,
320
'displayProfileId' => $this->displayProfileId,
321
'commandString' => $command->commandString,
322
'validationString' => $command->validationString,
323
'commandString2' => $command->commandString,
324
'validationString2' => $command->validationString
329
$params = ['displayProfileId' => $this->displayProfileId];
331
$sql = 'DELETE FROM `lkcommanddisplayprofile` WHERE `displayProfileId` = :displayProfileId AND `commandId` NOT IN (0';
334
foreach ($this->commands as $command) {
335
/* @var Command $command */
337
$sql .= ',:commandId' . $i;
338
$params['commandId' . $i] = $command->commandId;
343
$this->getStore()->update($sql, $params);
149
PDOConnect::update('DELETE FROM `displayprofile` WHERE displayprofileid = :displayProfileId', ['displayProfileId' => $this->displayProfileId]);
346
152
private function add()
348
$this->displayProfileId = $this->getStore()->insert('
154
$this->displayProfileId = PDOConnect::insert('
349
155
INSERT INTO `displayprofile` (`name`, type, config, isdefault, userid)
350
156
VALUES (:name, :type, :config, :isDefault, :userId)
352
158
'name' => $this->name,
353
159
'type' => $this->type,
354
160
'config' => ($this->config == '') ? '[]' : json_encode($this->config),
355
'isDefault' => $this->isDefault,
356
'userId' => $this->userId
161
'isdefault' => $this->isDefault,
162
'userid' => $this->userId
360
166
private function edit()
362
$this->getStore()->update('
363
169
UPDATE `displayprofile`
364
170
SET `name` = :name, type = :type, config = :config, isdefault = :isDefault
365
171
WHERE displayprofileid = :displayProfileId', [
1064
748
'title' => __('Update Window End Time'),
1065
749
'type' => 'string',
1066
750
'fieldType' => 'timePicker',
1067
'default' => '00:00',
1068
752
'helpText' => __('The end of the time window to install application updates.'),
1069
753
'enabled' => true,
1070
754
'groupClass' => NULL
1073
'name' => 'webViewPluginState',
1074
'tabId' => 'advanced',
1075
'title' => __('WebView Plugin State'),
1077
'fieldType' => 'dropdown',
1079
array('id' => 'OFF', 'value' => __('Off')),
1080
array('id' => 'DEMAND', 'value' => __('On Demand')),
1081
array('id' => 'ON', 'value' => __('On'))
1083
'default' => 'DEMAND',
1084
'helpText' => __('What plugin state should be used when starting a web view.'),
1086
'groupClass' => NULL
1089
'name' => 'hardwareAccelerateWebViewMode',
1090
'tabId' => 'advanced',
1091
'title' => __('Hardware Accelerate Web Content'),
1093
'fieldType' => 'dropdown',
1095
array('id' => '0', 'value' => __('Off')),
1096
array('id' => '2', 'value' => __('Off when transparent')),
1097
array('id' => '1', 'value' => __('On'))
1100
'helpText' => __('Mode for hardware acceleration of web based content.'),
1102
'groupClass' => NULL
1105
'name' => 'timeSyncFromCms',
1106
'tabId' => 'advanced',
1107
'title' => __('Use CMS time?'),
1108
'type' => 'checkbox',
1109
'fieldType' => 'checkbox',
1111
'helpText' => __('Set the device time using the CMS. Only available on rooted devices or system signed players.'),
1113
'groupClass' => NULL
1116
'name' => 'webCacheEnabled',
1117
'tabId' => 'advanced',
1118
'title' => __('Enable caching of Web Resources?'),
1119
'type' => 'checkbox',
1120
'fieldType' => 'checkbox',
1122
'helpText' => __('The standard browser cache will be used - we recommend this is switched off unless specifically required. Effects Web Page and Embedded.'),
1124
'groupClass' => NULL
1127
'name' => 'serverPort',
1128
'tabId' => 'advanced',
1129
'title' => __('Embedded Web Server Port'),
1131
'fieldType' => 'number',
1133
'helpText' => __('The port number to use for the embedded web server on the Player. Only change this if there is a port conflict reported on the status screen.'),
1135
'groupClass' => NULL
1138
'name' => 'installWithLoadedLinkLibraries',
1139
'tabId' => 'advanced',
1140
'title' => __('Load Link Libraries for APK Update'),
1141
'type' => 'checkbox',
1142
'fieldType' => 'checkbox',
1144
'helpText' => __('Should the update command include dynamic link libraries? Only change this if your updates are failing.'),
1146
'groupClass' => NULL
1151
'synonym' => 'xiboforwebos',
1153
['id' => 'general', 'name' => __('General')],
1154
['id' => 'timers', 'name' => __('On/Off Time')],
1155
['id' => 'pictureOptions', 'name' => __('Picture')],
1156
['id' => 'lockOptions', 'name' => __('Lock')],
1157
['id' => 'advanced', 'name' => __('Advanced')],
1161
'name' => 'emailAddress',
1162
'tabId' => 'general',
1163
'title' => __('Email Address'),
1165
'fieldType' => 'text',
1167
'helpText' => __('The email address will be used to license this client. This is the email address you provided when you purchased the licence.'),
1169
'groupClass' => NULL
1172
'name' => 'collectInterval',
1173
'tabId' => 'general',
1174
'title' => __('Collect interval'),
1176
'fieldType' => 'dropdown',
1178
array('id' => 60, 'value' => __('1 minute')),
1179
array('id' => 300, 'value' => __('5 minutes')),
1180
array('id' => 600, 'value' => __('10 minutes')),
1181
array('id' => 1800, 'value' => __('30 minutes')),
1182
array('id' => 3600, 'value' => __('1 hour')),
1183
array('id' => 14400, 'value' => __('4 hours')),
1184
array('id' => 43200, 'value' => __('12 hours')),
1185
array('id' => 86400, 'value' => __('24 hours'))
1188
'helpText' => __('How often should the Player check for new content.'),
1189
'validation' => 'numeric',
1191
'groupClass' => NULL
1194
'name' => 'xmrNetworkAddress',
1195
'tabId' => 'general',
1196
'title' => __('XMR Public Address'),
1198
'fieldType' => 'text',
1200
'helpText' => __('Please enter the public address for XMR.'),
1202
'groupClass' => NULL
1205
'name' => 'statsEnabled',
1206
'tabId' => 'general',
1207
'title' => __('Enable stats reporting?'),
1208
'type' => 'checkbox',
1209
'fieldType' => 'checkbox',
1210
'default' => $this->configService->GetSetting('DISPLAY_PROFILE_STATS_DEFAULT', 0),
1211
'helpText' => __('Should the application send proof of play stats to the CMS.'),
1213
'groupClass' => NULL
1216
'name' => 'orientation',
1217
'tabId' => 'general',
1218
'title' => __('Orientation'),
1220
'fieldType' => 'dropdown',
1222
array('id' => 0, 'value' => __('Landscape')),
1223
array('id' => 1, 'value' => __('Portrait')),
1224
array('id' => 8, 'value' => __('Reverse Landscape')),
1225
array('id' => 9, 'value' => __('Reverse Portrait'))
1228
'helpText' => __('Set the orientation of the device.'),
1230
'groupClass' => NULL
1233
'name' => 'downloadStartWindow',
1234
'tabId' => 'general',
1235
'title' => __('Download Window Start Time'),
1237
'fieldType' => 'timePicker',
1238
'default' => '00:00',
1239
'helpText' => __('The start of the time window to connect to the CMS and download updates.'),
1241
'groupClass' => NULL
1244
'name' => 'downloadEndWindow',
1245
'tabId' => 'general',
1246
'title' => __('Download Window End Time'),
1248
'fieldType' => 'timePicker',
1249
'default' => '00:00',
1250
'helpText' => __('The end of the time window to connect to the CMS and download updates.'),
1252
'groupClass' => NULL
1255
'name' => 'actionBarMode',
1256
'tabId' => 'advanced',
1257
'title' => __('Action Bar Mode'),
1259
'fieldType' => 'dropdown',
1261
array('id' => 0, 'value' => 'Hide'),
1262
array('id' => 1, 'value' => 'Timed')
1265
'helpText' => __('How should the action bar behave?'),
1267
'groupClass' => NULL
1270
'name' => 'actionBarDisplayDuration',
1271
'tabId' => 'advanced',
1272
'title' => __('Action Bar Display Duration'),
1274
'fieldType' => 'text',
1276
'helpText' => __('How long should the Action Bar be shown for, in seconds?'),
1277
'validation' => 'numeric',
1279
'groupClass' => NULL
1282
'name' => 'screenShotSize',
1283
'tabId' => 'advanced',
1284
'title' => __('Screen Shot Size'),
1286
'fieldType' => 'dropdown',
1288
['id' => 1, 'value' => 'Thumbnail'],
1289
['id' => 2, 'value' => 'HD'],
1290
['id' => 3, 'value' => 'FHD'],
1293
'helpText' => __('The size of the screenshot to return when requested.'),
1295
'groupClass' => NULL
1298
'name' => 'mediaInventoryTimer',
1299
'tabId' => 'advanced',
1300
'title' => __('Send progress while downloading'),
1302
'fieldType' => 'text',
1304
'helpText' => __('How often, in minutes, should the Display send its download progress while it is downloading new content?'),
1305
'validation' => 'numeric',
1307
'groupClass' => NULL
1310
'name' => 'logLevel',
1311
'tabId' => 'advanced',
1312
'title' => __('Log Level'),
1314
'fieldType' => 'dropdown',
1316
['id' => 'audit', 'value' => 'Audit'],
1317
['id' => 'error', 'value' => 'Error'],
1318
['id' => 'off', 'value' => 'Off']
1320
'default' => 'error',
1321
'helpText' => __('The logging level that should be recorded by the Player.'),
1323
'groupClass' => NULL
1327
'tabId' => 'timers',
1328
'title' => __('On/Off Timers'),
1330
'fieldType' => 'text',
1332
'helpText' => __('A JSON object indicating the on/off timers to set'),
1334
'groupClass' => NULL
1337
'name' => 'pictureOptions',
1338
'tabId' => 'pictureOptions',
1339
'title' => __('Picture Options'),
1341
'fieldType' => 'text',
1343
'helpText' => __('A JSON object indicating the picture options to set'),
1345
'groupClass' => NULL
1348
'name' => 'lockOptions',
1349
'tabId' => 'lockOptions',
1350
'title' => __('Lock Options'),
1352
'fieldType' => 'text',
1354
'helpText' => __('A JSON object indicating the lock options to set'),
1356
'groupClass' => NULL
b'\\ No newline at end of file'