VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

Last change on this file was 104313, checked in by vboxsync, 5 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in the settings related GUI classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.2 KB
Line 
1/* $Id: UIMachineSettingsUSB.cpp 104313 2024-04-12 13:10:30Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineSettingsUSB class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QCheckBox>
30#include <QComboBox>
31#include <QHeaderView>
32#include <QHelpEvent>
33#include <QLineEdit>
34#include <QMenu>
35#include <QRadioButton>
36#include <QSpacerItem>
37#include <QVBoxLayout>
38
39/* GUI includes: */
40#include "QITreeWidget.h"
41#include "QIWidgetValidator.h"
42#include "UIConverter.h"
43#include "UIIconPool.h"
44#include "UIMachineSettingsUSB.h"
45#include "UIErrorString.h"
46#include "QIToolBar.h"
47#include "UIUSBFiltersEditor.h"
48#include "UIUSBSettingsEditor.h"
49
50/* COM includes: */
51#include "CExtPack.h"
52#include "CExtPackManager.h"
53#include "CUSBController.h"
54#include "CUSBDeviceFilter.h"
55#include "CUSBDeviceFilters.h"
56
57
58/** Machine settings: USB filter data structure. */
59struct UIDataSettingsMachineUSBFilter
60{
61 /** Constructs data. */
62 UIDataSettingsMachineUSBFilter() {}
63
64 /** Returns whether the @a other passed data is equal to this one. */
65 bool equal(const UIDataSettingsMachineUSBFilter &other) const
66 {
67 return true
68 && (m_guiData == other.m_guiData)
69 ;
70 }
71
72 /** Returns whether the @a other passed data is equal to this one. */
73 bool operator==(const UIDataSettingsMachineUSBFilter &other) const { return equal(other); }
74 /** Returns whether the @a other passed data is different from this one. */
75 bool operator!=(const UIDataSettingsMachineUSBFilter &other) const { return !equal(other); }
76
77 /** Holds the USB filter data. */
78 UIDataUSBFilter m_guiData;
79};
80
81
82/** Machine settings: USB page data structure. */
83struct UIDataSettingsMachineUSB
84{
85 /** Constructs data. */
86 UIDataSettingsMachineUSB()
87 : m_fUSBEnabled(false)
88 , m_enmUSBControllerType(KUSBControllerType_Null)
89 {}
90
91 /** Returns whether the @a other passed data is equal to this one. */
92 bool equal(const UIDataSettingsMachineUSB &other) const
93 {
94 return true
95 && (m_fUSBEnabled == other.m_fUSBEnabled)
96 && (m_enmUSBControllerType == other.m_enmUSBControllerType)
97 ;
98 }
99
100 /** Returns whether the @a other passed data is equal to this one. */
101 bool operator==(const UIDataSettingsMachineUSB &other) const { return equal(other); }
102 /** Returns whether the @a other passed data is different from this one. */
103 bool operator!=(const UIDataSettingsMachineUSB &other) const { return !equal(other); }
104
105 /** Holds whether the USB is enabled. */
106 bool m_fUSBEnabled;
107 /** Holds the USB controller type. */
108 KUSBControllerType m_enmUSBControllerType;
109};
110
111
112UIMachineSettingsUSB::UIMachineSettingsUSB()
113 : m_pCache(0)
114 , m_pEditorUsbSettings(0)
115{
116 prepare();
117}
118
119UIMachineSettingsUSB::~UIMachineSettingsUSB()
120{
121 cleanup();
122}
123
124bool UIMachineSettingsUSB::isUSBEnabled() const
125{
126 return m_pEditorUsbSettings->isFeatureEnabled();
127}
128
129bool UIMachineSettingsUSB::changed() const
130{
131 return m_pCache ? m_pCache->wasChanged() : false;
132}
133
134void UIMachineSettingsUSB::loadToCacheFrom(QVariant &data)
135{
136 /* Sanity check: */
137 if (!m_pCache)
138 return;
139
140 /* Fetch data to machine: */
141 UISettingsPageMachine::fetchData(data);
142
143 /* Clear cache initially: */
144 m_pCache->clear();
145
146 /* Prepare old USB data: */
147 UIDataSettingsMachineUSB oldUsbData;
148
149 /* Gather old USB data: */
150 oldUsbData.m_fUSBEnabled = !m_machine.GetUSBControllers().isEmpty();
151 oldUsbData.m_enmUSBControllerType = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI) > 0 ? KUSBControllerType_XHCI
152 : m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI) > 0 ? KUSBControllerType_EHCI
153 : m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI) > 0 ? KUSBControllerType_OHCI
154 : KUSBControllerType_Null;
155
156 /* Check whether controller is valid: */
157 const CUSBDeviceFilters &comFiltersObject = m_machine.GetUSBDeviceFilters();
158 if (!comFiltersObject.isNull())
159 {
160 /* For each filter: */
161 const CUSBDeviceFilterVector &filters = comFiltersObject.GetDeviceFilters();
162 for (int iFilterIndex = 0; iFilterIndex < filters.size(); ++iFilterIndex)
163 {
164 /* Prepare old data: */
165 UIDataSettingsMachineUSBFilter oldFilterData;
166
167 /* Check whether filter is valid: */
168 const CUSBDeviceFilter &filter = filters.at(iFilterIndex);
169 if (!filter.isNull())
170 {
171 /* Gather old data: */
172 oldFilterData.m_guiData.m_fActive = filter.GetActive();
173 oldFilterData.m_guiData.m_strName = filter.GetName();
174 oldFilterData.m_guiData.m_strVendorId = filter.GetVendorId();
175 oldFilterData.m_guiData.m_strProductId = filter.GetProductId();
176 oldFilterData.m_guiData.m_strRevision = filter.GetRevision();
177 oldFilterData.m_guiData.m_strManufacturer = filter.GetManufacturer();
178 oldFilterData.m_guiData.m_strProduct = filter.GetProduct();
179 oldFilterData.m_guiData.m_strSerialNumber = filter.GetSerialNumber();
180 oldFilterData.m_guiData.m_strPort = filter.GetPort();
181 const QString strRemote = filter.GetRemote();
182 UIRemoteMode enmRemoteMode = UIRemoteMode_Any;
183 if (strRemote == "true" || strRemote == "yes" || strRemote == "1")
184 enmRemoteMode = UIRemoteMode_On;
185 else if (strRemote == "false" || strRemote == "no" || strRemote == "0")
186 enmRemoteMode = UIRemoteMode_Off;
187 oldFilterData.m_guiData.m_enmRemoteMode = enmRemoteMode;
188 }
189
190 /* Cache old data: */
191 m_pCache->child(iFilterIndex).cacheInitialData(oldFilterData);
192 }
193 }
194
195 /* Cache old USB data: */
196 m_pCache->cacheInitialData(oldUsbData);
197
198 /* Upload machine to data: */
199 UISettingsPageMachine::uploadData(data);
200}
201
202void UIMachineSettingsUSB::getFromCache()
203{
204 /* Sanity check: */
205 if (!m_pCache)
206 return;
207
208 /* Get old USB data from cache: */
209 const UIDataSettingsMachineUSB &oldUsbData = m_pCache->base();
210
211 /* Load old USB data from cache: */
212 if (m_pEditorUsbSettings)
213 {
214 m_pEditorUsbSettings->setFeatureEnabled(oldUsbData.m_fUSBEnabled);
215 m_pEditorUsbSettings->setUsbControllerType(oldUsbData.m_enmUSBControllerType);
216
217 /* For each filter => load it from cache: */
218 QList<UIDataUSBFilter> filters;
219 for (int iFilterIndex = 0; iFilterIndex < m_pCache->childCount(); ++iFilterIndex)
220 {
221 const UIDataSettingsMachineUSBFilter &oldUsbFilterData = m_pCache->child(iFilterIndex).base();
222 UIDataUSBFilter filter;
223 filter.m_fActive = oldUsbFilterData.m_guiData.m_fActive;
224 filter.m_strName = oldUsbFilterData.m_guiData.m_strName;
225 filter.m_strVendorId = oldUsbFilterData.m_guiData.m_strVendorId;
226 filter.m_strProductId = oldUsbFilterData.m_guiData.m_strProductId;
227 filter.m_strRevision = oldUsbFilterData.m_guiData.m_strRevision;
228 filter.m_strManufacturer = oldUsbFilterData.m_guiData.m_strManufacturer;
229 filter.m_strProduct = oldUsbFilterData.m_guiData.m_strProduct;
230 filter.m_strSerialNumber = oldUsbFilterData.m_guiData.m_strSerialNumber;
231 filter.m_strPort = oldUsbFilterData.m_guiData.m_strPort;
232 filter.m_enmRemoteMode = oldUsbFilterData.m_guiData.m_enmRemoteMode;
233 filters << filter;
234 }
235 m_pEditorUsbSettings->setUsbFilters(filters);
236 }
237
238 /* Polish page finally: */
239 polishPage();
240
241 /* Revalidate: */
242 revalidate();
243}
244
245void UIMachineSettingsUSB::putToCache()
246{
247 /* Sanity check: */
248 if (!m_pCache)
249 return;
250
251 /* Prepare new USB data: */
252 UIDataSettingsMachineUSB newUsbData;
253
254 /* Gather new USB data: */
255 if (m_pEditorUsbSettings)
256 {
257 newUsbData.m_fUSBEnabled = m_pEditorUsbSettings->isFeatureEnabled();
258 newUsbData.m_enmUSBControllerType = newUsbData.m_fUSBEnabled
259 ? m_pEditorUsbSettings->usbControllerType()
260 : KUSBControllerType_Null;
261 /* For each filter => save it to cache: */
262 const QList<UIDataUSBFilter> filters = m_pEditorUsbSettings->usbFilters();
263 for (int iFilterIndex = 0; iFilterIndex < filters.size(); ++iFilterIndex)
264 {
265 /* Gather and cache new data: */
266 UIDataUSBFilter filter = filters.at(iFilterIndex);
267 UIDataSettingsMachineUSBFilter newUsbFilterData;
268 newUsbFilterData.m_guiData.m_fActive = filter.m_fActive;
269 newUsbFilterData.m_guiData.m_strName = filter.m_strName;
270 newUsbFilterData.m_guiData.m_strVendorId = filter.m_strVendorId;
271 newUsbFilterData.m_guiData.m_strProductId = filter.m_strProductId;
272 newUsbFilterData.m_guiData.m_strRevision = filter.m_strRevision;
273 newUsbFilterData.m_guiData.m_strManufacturer = filter.m_strManufacturer;
274 newUsbFilterData.m_guiData.m_strProduct = filter.m_strProduct;
275 newUsbFilterData.m_guiData.m_strSerialNumber = filter.m_strSerialNumber;
276 newUsbFilterData.m_guiData.m_strPort = filter.m_strPort;
277 newUsbFilterData.m_guiData.m_enmRemoteMode = filter.m_enmRemoteMode;
278 m_pCache->child(iFilterIndex).cacheCurrentData(newUsbFilterData);
279 }
280 }
281
282 /* Cache new USB data: */
283 m_pCache->cacheCurrentData(newUsbData);
284}
285
286void UIMachineSettingsUSB::saveFromCacheTo(QVariant &data)
287{
288 /* Fetch data to machine: */
289 UISettingsPageMachine::fetchData(data);
290
291 /* Update data and failing state: */
292 setFailed(!saveData());
293
294 /* Upload machine to data: */
295 UISettingsPageMachine::uploadData(data);
296}
297
298bool UIMachineSettingsUSB::validate(QList<UIValidationMessage> &messages)
299{
300 Q_UNUSED(messages);
301
302 /* Pass by default: */
303 bool fPass = true;
304
305 /* Return result: */
306 return fPass;
307}
308
309void UIMachineSettingsUSB::setOrderAfter(QWidget *pWidget)
310{
311 setTabOrder(pWidget, m_pEditorUsbSettings);
312}
313
314void UIMachineSettingsUSB::sltRetranslateUI()
315{
316}
317
318void UIMachineSettingsUSB::polishPage()
319{
320 /* Polish USB page availability: */
321 m_pEditorUsbSettings->setFeatureAvailable(isMachineOffline());
322 m_pEditorUsbSettings->setUsbControllerOptionAvailable(isMachineOffline());
323 m_pEditorUsbSettings->setUsbFiltersOptionAvailable(isMachineInValidMode());
324}
325
326void UIMachineSettingsUSB::prepare()
327{
328 /* Prepare cache: */
329 m_pCache = new UISettingsCacheMachineUSB;
330 AssertPtrReturnVoid(m_pCache);
331
332 /* Prepare everything: */
333 prepareWidgets();
334 prepareConnections();
335
336 /* Apply language settings: */
337 sltRetranslateUI();
338}
339
340void UIMachineSettingsUSB::prepareWidgets()
341{
342 /* Prepare main layout: */
343 QVBoxLayout *pLayout = new QVBoxLayout(this);
344 if (pLayout)
345 {
346 /* Prepare settings editor: */
347 m_pEditorUsbSettings = new UIUSBSettingsEditor(this);
348 if (m_pEditorUsbSettings)
349 {
350 addEditor(m_pEditorUsbSettings);
351 pLayout->addWidget(m_pEditorUsbSettings);
352 }
353 }
354}
355
356void UIMachineSettingsUSB::prepareConnections()
357{
358 /* Configure validation connections: */
359 connect(m_pEditorUsbSettings, &UIUSBSettingsEditor::sigValueChanged,
360 this, &UIMachineSettingsUSB::revalidate);
361}
362
363void UIMachineSettingsUSB::cleanup()
364{
365 /* Cleanup cache: */
366 delete m_pCache;
367 m_pCache = 0;
368}
369
370bool UIMachineSettingsUSB::saveData()
371{
372 /* Sanity check: */
373 if (!m_pCache)
374 return false;
375
376 /* Prepare result: */
377 bool fSuccess = true;
378 /* Save USB settings from cache: */
379 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
380 {
381 /* Get new USB data from cache: */
382 const UIDataSettingsMachineUSB &newUsbData = m_pCache->data();
383
384 /* Save USB data: */
385 if (fSuccess && isMachineOffline())
386 {
387 /* Remove USB controllers: */
388 if (!newUsbData.m_fUSBEnabled)
389 fSuccess = removeUSBControllers();
390
391 else
392
393 /* Create/update USB controllers: */
394 if (newUsbData.m_fUSBEnabled)
395 fSuccess = createUSBControllers(newUsbData.m_enmUSBControllerType);
396 }
397
398 /* Save USB filters data: */
399 if (fSuccess)
400 {
401 /* Make sure filters object really exists: */
402 CUSBDeviceFilters comFiltersObject = m_machine.GetUSBDeviceFilters();
403 fSuccess = m_machine.isOk() && comFiltersObject.isNotNull();
404
405 /* Show error message if necessary: */
406 if (!fSuccess)
407 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
408 else
409 {
410 /* For each filter data set: */
411 int iOperationPosition = 0;
412 for (int iFilterIndex = 0; fSuccess && iFilterIndex < m_pCache->childCount(); ++iFilterIndex)
413 {
414 /* Check if USB filter data was changed: */
415 const UISettingsCacheMachineUSBFilter &filterCache = m_pCache->child(iFilterIndex);
416
417 /* Remove filter marked for 'remove' or 'update': */
418 if (fSuccess && (filterCache.wasRemoved() || filterCache.wasUpdated()))
419 {
420 fSuccess = removeUSBFilter(comFiltersObject, iOperationPosition);
421 if (fSuccess && filterCache.wasRemoved())
422 --iOperationPosition;
423 }
424
425 /* Create filter marked for 'create' or 'update': */
426 if (fSuccess && (filterCache.wasCreated() || filterCache.wasUpdated()))
427 fSuccess = createUSBFilter(comFiltersObject, iOperationPosition, filterCache.data());
428
429 /* Advance operation position: */
430 ++iOperationPosition;
431 }
432 }
433 }
434 }
435 /* Return result: */
436 return fSuccess;
437}
438
439bool UIMachineSettingsUSB::removeUSBControllers(const QSet<KUSBControllerType> &types /* = QSet<KUSBControllerType>() */)
440{
441 /* Prepare result: */
442 bool fSuccess = true;
443 /* Remove controllers: */
444 if (fSuccess && isMachineOffline())
445 {
446 /* Get controllers for further activities: */
447 const CUSBControllerVector &controllers = m_machine.GetUSBControllers();
448 fSuccess = m_machine.isOk();
449
450 /* Show error message if necessary: */
451 if (!fSuccess)
452 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
453
454 /* For each controller: */
455 for (int iControllerIndex = 0; fSuccess && iControllerIndex < controllers.size(); ++iControllerIndex)
456 {
457 /* Get current controller: */
458 const CUSBController &comController = controllers.at(iControllerIndex);
459
460 /* Get controller type for further activities: */
461 KUSBControllerType enmType = KUSBControllerType_Null;
462 if (fSuccess)
463 {
464 enmType = comController.GetType();
465 fSuccess = comController.isOk();
466 }
467 /* Get controller name for further activities: */
468 QString strName;
469 if (fSuccess)
470 {
471 strName = comController.GetName();
472 fSuccess = comController.isOk();
473 }
474
475 /* Show error message if necessary: */
476 if (!fSuccess)
477 notifyOperationProgressError(UIErrorString::formatErrorInfo(comController));
478 else
479 {
480 /* Pass only if requested types were not defined or contains the one we found: */
481 if (!types.isEmpty() && !types.contains(enmType))
482 continue;
483
484 /* Remove controller: */
485 if (fSuccess)
486 {
487 m_machine.RemoveUSBController(comController.GetName());
488 fSuccess = m_machine.isOk();
489 }
490
491 /* Show error message if necessary: */
492 if (!fSuccess)
493 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
494 }
495 }
496 }
497 /* Return result: */
498 return fSuccess;
499}
500
501bool UIMachineSettingsUSB::createUSBControllers(KUSBControllerType enmType)
502{
503 /* Prepare result: */
504 bool fSuccess = true;
505 /* Add controllers: */
506 if (fSuccess && isMachineOffline())
507 {
508 /* Get each controller count for further activities: */
509 ULONG cOhciCtls = 0;
510 if (fSuccess)
511 {
512 cOhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_OHCI);
513 fSuccess = m_machine.isOk();
514 }
515 ULONG cEhciCtls = 0;
516 if (fSuccess)
517 {
518 cEhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_EHCI);
519 fSuccess = m_machine.isOk();
520 }
521 ULONG cXhciCtls = 0;
522 if (fSuccess)
523 {
524 cXhciCtls = m_machine.GetUSBControllerCountByType(KUSBControllerType_XHCI);
525 fSuccess = m_machine.isOk();
526 }
527
528 /* Show error message if necessary: */
529 if (!fSuccess)
530 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
531 else
532 {
533 /* For requested controller type: */
534 switch (enmType)
535 {
536 case KUSBControllerType_OHCI:
537 {
538 /* Remove excessive controllers: */
539 if (cXhciCtls || cEhciCtls)
540 fSuccess = removeUSBControllers(QSet<KUSBControllerType>()
541 << KUSBControllerType_XHCI
542 << KUSBControllerType_EHCI);
543
544 /* Add required controller: */
545 if (fSuccess && !cOhciCtls)
546 {
547 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
548 fSuccess = m_machine.isOk();
549
550 /* Show error message if necessary: */
551 if (!fSuccess)
552 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
553 }
554
555 break;
556 }
557 case KUSBControllerType_EHCI:
558 {
559 /* Remove excessive controllers: */
560 if (cXhciCtls)
561 fSuccess = removeUSBControllers(QSet<KUSBControllerType>()
562 << KUSBControllerType_XHCI);
563
564 /* Add required controllers: */
565 if (fSuccess)
566 {
567 if (fSuccess && !cOhciCtls)
568 {
569 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
570 fSuccess = m_machine.isOk();
571 }
572 if (fSuccess && !cEhciCtls)
573 {
574 m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI);
575 fSuccess = m_machine.isOk();
576 }
577
578 /* Show error message if necessary: */
579 if (!fSuccess)
580 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
581 }
582
583 break;
584 }
585 case KUSBControllerType_XHCI:
586 {
587 /* Remove excessive controllers: */
588 if (cEhciCtls || cOhciCtls)
589 fSuccess = removeUSBControllers(QSet<KUSBControllerType>()
590 << KUSBControllerType_EHCI
591 << KUSBControllerType_OHCI);
592
593 /* Add required controller: */
594 if (fSuccess && !cXhciCtls)
595 {
596 m_machine.AddUSBController("xHCI", KUSBControllerType_XHCI);
597 fSuccess = m_machine.isOk();
598
599 /* Show error message if necessary: */
600 if (!fSuccess)
601 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
602 }
603
604 break;
605 }
606 default:
607 break;
608 }
609 }
610 }
611 /* Return result: */
612 return fSuccess;
613}
614
615bool UIMachineSettingsUSB::removeUSBFilter(CUSBDeviceFilters &comFiltersObject, int iPosition)
616{
617 /* Prepare result: */
618 bool fSuccess = true;
619 /* Remove filter: */
620 if (fSuccess)
621 {
622 /* Remove filter: */
623 comFiltersObject.RemoveDeviceFilter(iPosition);
624 fSuccess = comFiltersObject.isOk();
625
626 /* Show error message if necessary: */
627 if (!fSuccess)
628 notifyOperationProgressError(UIErrorString::formatErrorInfo(comFiltersObject));
629 }
630 /* Return result: */
631 return fSuccess;
632}
633
634bool UIMachineSettingsUSB::createUSBFilter(CUSBDeviceFilters &comFiltersObject, int iPosition, const UIDataSettingsMachineUSBFilter &filterData)
635{
636 /* Prepare result: */
637 bool fSuccess = true;
638 /* Add filter: */
639 if (fSuccess)
640 {
641 /* Create filter: */
642 CUSBDeviceFilter comFilter = comFiltersObject.CreateDeviceFilter(filterData.m_guiData.m_strName);
643 fSuccess = comFiltersObject.isOk() && comFilter.isNotNull();
644
645 /* Show error message if necessary: */
646 if (!fSuccess)
647 notifyOperationProgressError(UIErrorString::formatErrorInfo(comFiltersObject));
648 else
649 {
650 /* Save whether filter is active: */
651 if (fSuccess)
652 {
653 comFilter.SetActive(filterData.m_guiData.m_fActive);
654 fSuccess = comFilter.isOk();
655 }
656 /* Save filter Vendor ID: */
657 if (fSuccess)
658 {
659 comFilter.SetVendorId(filterData.m_guiData.m_strVendorId);
660 fSuccess = comFilter.isOk();
661 }
662 /* Save filter Product ID: */
663 if (fSuccess)
664 {
665 comFilter.SetProductId(filterData.m_guiData.m_strProductId);
666 fSuccess = comFilter.isOk();
667 }
668 /* Save filter revision: */
669 if (fSuccess)
670 {
671 comFilter.SetRevision(filterData.m_guiData.m_strRevision);
672 fSuccess = comFilter.isOk();
673 }
674 /* Save filter manufacturer: */
675 if (fSuccess)
676 {
677 comFilter.SetManufacturer(filterData.m_guiData.m_strManufacturer);
678 fSuccess = comFilter.isOk();
679 }
680 /* Save filter product: */
681 if (fSuccess)
682 {
683 comFilter.SetProduct(filterData.m_guiData.m_strProduct);
684 fSuccess = comFilter.isOk();
685 }
686 /* Save filter serial number: */
687 if (fSuccess)
688 {
689 comFilter.SetSerialNumber(filterData.m_guiData.m_strSerialNumber);
690 fSuccess = comFilter.isOk();
691 }
692 /* Save filter port: */
693 if (fSuccess)
694 {
695 comFilter.SetPort(filterData.m_guiData.m_strPort);
696 fSuccess = comFilter.isOk();
697 }
698 /* Save filter remote mode: */
699 if (fSuccess)
700 {
701 QString strRemote;
702 switch (filterData.m_guiData.m_enmRemoteMode)
703 {
704 case UIRemoteMode_On: strRemote = "1"; break;
705 case UIRemoteMode_Off: strRemote = "0"; break;
706 default: break;
707 }
708 comFilter.SetRemote(strRemote);
709 fSuccess = comFilter.isOk();
710 }
711
712 /* Show error message if necessary: */
713 if (!fSuccess)
714 notifyOperationProgressError(UIErrorString::formatErrorInfo(comFilter));
715 else
716 {
717 /* Insert filter onto corresponding position: */
718 comFiltersObject.InsertDeviceFilter(iPosition, comFilter);
719 fSuccess = comFiltersObject.isOk();
720
721 /* Show error message if necessary: */
722 if (!fSuccess)
723 notifyOperationProgressError(UIErrorString::formatErrorInfo(comFiltersObject));
724 }
725 }
726 }
727 /* Return result: */
728 return fSuccess;
729}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use