VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileManager.cpp@ 71439

Last change on this file since 71439 was 71439, checked in by vboxsync, 7 years ago

FE/Qt: bugref:6699 Add a tree widget to file manager which will serve as a 'file operations progress' widget

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.9 KB
Line 
1/* $Id: UIGuestControlFileManager.cpp 71439 2018-03-21 19:39:44Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIGuestControlFileManager class implementation.
4 */
5
6/*
7 * Copyright (C) 2016-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifdef VBOX_WITH_PRECOMPILED_HEADERS
19# include <precomp.h>
20#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
21
22/* Qt includes: */
23# include <QAbstractItemModel>
24# include <QHBoxLayout>
25# include <QHeaderView>
26# include <QPlainTextEdit>
27# include <QPushButton>
28# include <QSplitter>
29# include <QGridLayout>
30
31/* GUI includes: */
32# include "QILabel.h"
33# include "QILineEdit.h"
34# include "QITabWidget.h"
35# include "QITreeWidget.h"
36# include "QIWithRetranslateUI.h"
37# include "UIExtraDataManager.h"
38# include "UIIconPool.h"
39# include "UIGuestControlConsole.h"
40# include "UIGuestControlFileManager.h"
41# include "UIGuestFileTable.h"
42# include "UIGuestControlInterface.h"
43# include "UIHostFileTable.h"
44# include "UIToolBar.h"
45# include "UIVMInformationDialog.h"
46# include "VBoxGlobal.h"
47
48/* COM includes: */
49# include "CFsObjInfo.h"
50# include "CGuest.h"
51# include "CGuestDirectory.h"
52# include "CGuestFsObjInfo.h"
53# include "CGuestProcess.h"
54# include "CGuestSession.h"
55# include "CGuestSessionStateChangedEvent.h"
56#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
57
58/*********************************************************************************************************************************
59* UIFileOperationsList definition. *
60*********************************************************************************************************************************/
61
62class UIFileOperationsList : public QITreeWidget
63{
64 Q_OBJECT;
65public:
66
67 UIFileOperationsList(QWidget *pParent = 0);
68
69private:
70};
71
72/*********************************************************************************************************************************
73* UIGuestSessionCreateWidget definition. *
74*********************************************************************************************************************************/
75
76class UIGuestSessionCreateWidget : public QIWithRetranslateUI<QWidget>
77{
78 Q_OBJECT;
79
80signals:
81
82 void sigCreateSession(QString strUserName, QString strPassword);
83 void sigCloseButtonClick();
84
85public:
86
87 UIGuestSessionCreateWidget(QWidget *pParent = 0);
88 void switchSessionCreateMode();
89 void switchSessionCloseMode();
90
91protected:
92
93 void retranslateUi();
94 void keyPressEvent(QKeyEvent * pEvent);
95
96private slots:
97
98 void sltCreateButtonClick();
99
100private:
101 void prepareWidgets();
102 QILineEdit *m_pUserNameEdit;
103 QILineEdit *m_pPasswordEdit;
104
105 QILabel *m_pUserNameLabel;
106 QILabel *m_pPasswordLabel;
107 QPushButton *m_pCreateButton;
108 QPushButton *m_pCloseButton;
109
110 QHBoxLayout *m_pMainLayout;
111
112};
113
114/*********************************************************************************************************************************
115* UIFileOperationsList implementation. *
116*********************************************************************************************************************************/
117
118UIFileOperationsList::UIFileOperationsList(QWidget *pParent)
119 :QITreeWidget(pParent)
120{}
121
122
123/*********************************************************************************************************************************
124* UIGuestSessionCreateWidget implementation. *
125*********************************************************************************************************************************/
126
127UIGuestSessionCreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */)
128 : QIWithRetranslateUI<QWidget>(pParent)
129 , m_pUserNameEdit(0)
130 , m_pPasswordEdit(0)
131 , m_pUserNameLabel(0)
132 , m_pPasswordLabel(0)
133 , m_pCreateButton(0)
134 , m_pCloseButton(0)
135 , m_pMainLayout(0)
136{
137 prepareWidgets();
138}
139
140void UIGuestSessionCreateWidget::prepareWidgets()
141{
142 m_pMainLayout = new QHBoxLayout(this);
143 if (!m_pMainLayout)
144 return;
145 m_pUserNameEdit = new QILineEdit;
146 if (m_pUserNameEdit)
147 {
148 m_pMainLayout->addWidget(m_pUserNameEdit);
149 }
150 m_pUserNameLabel = new QILabel;
151 if (m_pUserNameLabel)
152 {
153 m_pMainLayout->addWidget(m_pUserNameLabel);
154 }
155 m_pPasswordEdit = new QILineEdit;
156 if (m_pPasswordEdit)
157 {
158 m_pMainLayout->addWidget(m_pPasswordEdit);
159 }
160
161 m_pPasswordLabel = new QILabel;
162 if (m_pPasswordLabel)
163 {
164 m_pMainLayout->addWidget(m_pPasswordLabel);
165 }
166
167 m_pCreateButton = new QPushButton;
168 if (m_pCreateButton)
169 {
170 m_pMainLayout->addWidget(m_pCreateButton);
171 connect(m_pCreateButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltCreateButtonClick);
172 }
173
174 m_pCloseButton = new QPushButton;
175 if (m_pCloseButton)
176 {
177 m_pMainLayout->addWidget(m_pCloseButton);
178 connect(m_pCloseButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sigCloseButtonClick);
179 }
180
181 retranslateUi();
182}
183
184void UIGuestSessionCreateWidget::sltCreateButtonClick()
185{
186 if (m_pUserNameEdit && m_pPasswordEdit)
187 emit sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
188}
189
190void UIGuestSessionCreateWidget::retranslateUi()
191{
192 if (m_pUserNameEdit)
193 {
194 m_pUserNameEdit->setToolTip(UIVMInformationDialog::tr("User name to authenticate session creation"));
195 }
196 if (m_pPasswordEdit)
197 {
198 m_pPasswordEdit->setToolTip(UIVMInformationDialog::tr("Password to authenticate session creation"));
199 }
200 if (m_pUserNameLabel)
201 {
202 m_pUserNameLabel->setToolTip(UIVMInformationDialog::tr("User name to authenticate session creation"));
203 m_pUserNameLabel->setText(UIVMInformationDialog::tr("User name"));
204 }
205 if (m_pPasswordLabel)
206 {
207 m_pPasswordLabel->setToolTip(UIVMInformationDialog::tr("Password to authenticate session creation"));
208 m_pPasswordLabel->setText(UIVMInformationDialog::tr("Password"));
209 }
210 if (m_pCreateButton)
211 m_pCreateButton->setText(UIVMInformationDialog::tr("Create Session"));
212 if (m_pCloseButton)
213 m_pCloseButton->setText(UIVMInformationDialog::tr("Close Session"));
214}
215
216void UIGuestSessionCreateWidget::keyPressEvent(QKeyEvent * pEvent)
217{
218 /* Emit sigCreateSession upon enter press: */
219 if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return)
220 {
221 if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) ||
222 (m_pPasswordEdit && m_pPasswordEdit->hasFocus()))
223 sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
224 }
225 QWidget::keyPressEvent(pEvent);
226}
227
228void UIGuestSessionCreateWidget::switchSessionCreateMode()
229{
230 m_pUserNameEdit->setEnabled(true);
231 m_pPasswordEdit->setEnabled(true);
232 m_pUserNameLabel->setEnabled(true);
233 m_pPasswordLabel->setEnabled(true);
234 m_pCreateButton->setEnabled(true);
235 m_pCloseButton->setEnabled(false);
236}
237
238void UIGuestSessionCreateWidget::switchSessionCloseMode()
239{
240 m_pUserNameEdit->setEnabled(false);
241 m_pPasswordEdit->setEnabled(false);
242 m_pUserNameLabel->setEnabled(false);
243 m_pPasswordLabel->setEnabled(false);
244 m_pCreateButton->setEnabled(false);
245 m_pCloseButton->setEnabled(true);
246}
247
248
249/*********************************************************************************************************************************
250* UIGuestControlFileManager implementation. *
251*********************************************************************************************************************************/
252
253UIGuestControlFileManager::UIGuestControlFileManager(QWidget *pParent, const CGuest &comGuest)
254 : QIWithRetranslateUI<QWidget>(pParent)
255 , m_iMaxRecursionDepth(1)
256 , m_comGuest(comGuest)
257 , m_pMainLayout(0)
258 , m_pVerticalSplitter(0)
259 , m_pLogOutput(0)
260 , m_pToolBar(0)
261 , m_pCopyGuestToHost(0)
262 , m_pCopyHostToGuest(0)
263 , m_pFileTableContainerWidget(0)
264 , m_pFileTableContainerLayout(0)
265 , m_pTabWidget(0)
266 , m_pFileOperationsList(0)
267 , m_pSessionCreateWidget(0)
268 , m_pGuestFileTable(0)
269 , m_pHostFileTable(0)
270{
271 prepareGuestListener();
272 prepareObjects();
273 prepareConnections();
274 retranslateUi();
275}
276
277UIGuestControlFileManager::~UIGuestControlFileManager()
278{
279 if (m_comGuest.isOk() && m_pQtGuestListener && m_comGuestListener.isOk())
280 cleanupListener(m_pQtGuestListener, m_comGuestListener, m_comGuest.GetEventSource());
281 if (m_comGuestSession.isOk() && m_pQtSessionListener && m_comSessionListener.isOk())
282 cleanupListener(m_pQtSessionListener, m_comSessionListener, m_comGuestSession.GetEventSource());
283}
284
285void UIGuestControlFileManager::retranslateUi()
286{
287 if (m_pCopyGuestToHost)
288 {
289 m_pCopyGuestToHost->setText(UIVMInformationDialog::tr("Copy the selected object(s) from guest to host"));
290 m_pCopyGuestToHost->setToolTip(UIVMInformationDialog::tr("Copy the selected object(s) from guest to host"));
291 m_pCopyGuestToHost->setStatusTip(UIVMInformationDialog::tr("Copy the selected object(s) from guest to host"));
292 }
293
294 if (m_pCopyHostToGuest)
295 {
296 m_pCopyHostToGuest->setText(UIVMInformationDialog::tr("Copy the selected object(s) from host to guest"));
297 m_pCopyHostToGuest->setToolTip(UIVMInformationDialog::tr("Copy the selected object(s) from host to guest"));
298 m_pCopyHostToGuest->setStatusTip(UIVMInformationDialog::tr("Copy the selected object(s) from host to guest"));
299 }
300
301
302 m_pTabWidget->setTabText(0, tr("Log"));
303 m_pTabWidget->setTabText(1, tr("File Operations"));
304 m_pTabWidget->setTabText(2, tr("Terminal"));
305
306}
307
308void UIGuestControlFileManager::prepareGuestListener()
309{
310 if (m_comGuest.isOk())
311 {
312 QVector<KVBoxEventType> eventTypes;
313 eventTypes << KVBoxEventType_OnGuestSessionRegistered;
314
315 prepareListener(m_pQtGuestListener, m_comGuestListener,
316 m_comGuest.GetEventSource(), eventTypes);
317 }
318}
319
320void UIGuestControlFileManager::prepareObjects()
321{
322 /* Create layout: */
323 m_pMainLayout = new QVBoxLayout(this);
324 if (!m_pMainLayout)
325 return;
326
327 /* Configure layout: */
328 m_pMainLayout->setSpacing(0);
329
330 m_pSessionCreateWidget = new UIGuestSessionCreateWidget();
331 if (m_pSessionCreateWidget)
332 {
333 m_pMainLayout->addWidget(m_pSessionCreateWidget);
334 }
335
336 m_pVerticalSplitter = new QSplitter;
337 if (m_pVerticalSplitter)
338 {
339 m_pMainLayout->addWidget(m_pVerticalSplitter);
340 m_pVerticalSplitter->setOrientation(Qt::Vertical);
341 m_pVerticalSplitter->setHandleWidth(2);
342 }
343
344 m_pFileTableContainerWidget = new QWidget;
345 m_pFileTableContainerLayout = new QHBoxLayout;
346
347 if (m_pFileTableContainerWidget)
348 {
349 if (m_pFileTableContainerLayout)
350 {
351 m_pFileTableContainerWidget->setLayout(m_pFileTableContainerLayout);
352 m_pFileTableContainerLayout->setSpacing(0);
353 m_pFileTableContainerLayout->setContentsMargins(0, 0, 0, 0);
354 m_pGuestFileTable = new UIGuestFileTable;
355 m_pGuestFileTable->setEnabled(false);
356
357 m_pHostFileTable = new UIHostFileTable;
358 if (m_pHostFileTable)
359 {
360 connect(m_pHostFileTable, &UIHostFileTable::sigLogOutput,
361 this, &UIGuestControlFileManager::sltReceieveLogOutput);
362 m_pFileTableContainerLayout->addWidget(m_pHostFileTable);
363 }
364 prepareToolBar();
365 if (m_pGuestFileTable)
366 {
367 connect(m_pGuestFileTable, &UIGuestFileTable::sigLogOutput,
368 this, &UIGuestControlFileManager::sltReceieveLogOutput);
369 m_pFileTableContainerLayout->addWidget(m_pGuestFileTable);
370 }
371
372 }
373 m_pVerticalSplitter->addWidget(m_pFileTableContainerWidget);
374 }
375
376 m_pTabWidget = new QITabWidget;
377 if (m_pTabWidget)
378 {
379 m_pVerticalSplitter->addWidget(m_pTabWidget);
380 m_pTabWidget->setTabPosition(QTabWidget::South);
381 }
382
383 m_pLogOutput = new QPlainTextEdit;
384 if (m_pLogOutput)
385 {
386 m_pTabWidget->addTab(m_pLogOutput, "Log");
387 m_pLogOutput->setReadOnly(true);
388 }
389
390 m_pFileOperationsList = new UIFileOperationsList;
391 if (m_pFileOperationsList)
392 {
393 m_pTabWidget->addTab(m_pFileOperationsList, "File Operatiions");
394 m_pFileOperationsList->header()->hide();
395 }
396
397 m_pVerticalSplitter->setStretchFactor(0, 3);
398 m_pVerticalSplitter->setStretchFactor(1, 1);
399}
400
401void UIGuestControlFileManager::prepareToolBar()
402{
403 m_pToolBar = new UIToolBar;
404 if (!m_pToolBar)
405 return;
406
407 m_pToolBar->setOrientation(Qt::Vertical);
408 m_pToolBar->setEnabled(false);
409
410 /* Add to dummy QWidget to toolbar to center the action icons vertically: */
411 QWidget *topSpacerWidget = new QWidget(this);
412 topSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
413 topSpacerWidget->setVisible(true);
414 QWidget *bottomSpacerWidget = new QWidget(this);
415 bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
416 bottomSpacerWidget->setVisible(true);
417
418 m_pCopyGuestToHost = new QAction(this);
419 if(m_pCopyGuestToHost)
420 {
421 m_pCopyGuestToHost->setIcon(UIIconPool::iconSet(QString(":/arrow_left_10px_x2.png")));
422 connect(m_pCopyGuestToHost, &QAction::triggered, this, &UIGuestControlFileManager::sltCopyGuestToHost);
423 }
424
425 m_pCopyHostToGuest = new QAction(this);
426 if (m_pCopyHostToGuest)
427 {
428 m_pCopyHostToGuest->setIcon(UIIconPool::iconSet(QString(":/arrow_right_10px_x2.png")));
429 connect(m_pCopyHostToGuest, &QAction::triggered, this, &UIGuestControlFileManager::sltCopyHostToGuest);
430 }
431
432 m_pToolBar->addWidget(topSpacerWidget);
433 m_pToolBar->addAction(m_pCopyGuestToHost);
434 m_pToolBar->addAction(m_pCopyHostToGuest);
435 m_pToolBar->addWidget(bottomSpacerWidget);
436
437 m_pFileTableContainerLayout->addWidget(m_pToolBar);
438}
439
440void UIGuestControlFileManager::prepareConnections()
441{
442 if (m_pQtGuestListener)
443 {
444 connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
445 this, &UIGuestControlFileManager::sltGuestSessionUnregistered);
446 }
447 if (m_pSessionCreateWidget)
448 {
449 connect(m_pSessionCreateWidget, &UIGuestSessionCreateWidget::sigCreateSession,
450 this, &UIGuestControlFileManager::sltCreateSession);
451 connect(m_pSessionCreateWidget, &UIGuestSessionCreateWidget::sigCloseButtonClick,
452 this, &UIGuestControlFileManager::sltCloseSession);
453 }
454}
455
456void UIGuestControlFileManager::sltGuestSessionUnregistered(CGuestSession guestSession)
457{
458 if (guestSession.isNull())
459 return;
460 if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
461 {
462 m_comGuestSession.detach();
463 postSessionClosed();
464 }
465}
466
467void UIGuestControlFileManager::sltCreateSession(QString strUserName, QString strPassword)
468{
469 if (!UIGuestControlInterface::isGuestAdditionsAvailable(m_comGuest))
470 {
471 if (m_pLogOutput)
472 {
473 m_pLogOutput->appendPlainText("Could not find Guest Additions");
474 postSessionClosed();
475 return;
476 }
477 }
478 if (strUserName.isEmpty())
479 {
480 if (m_pLogOutput)
481 m_pLogOutput->appendPlainText("No user name is given");
482 return;
483 }
484 createSession(strUserName, strPassword);
485}
486
487void UIGuestControlFileManager::sltCloseSession()
488{
489 if (!m_comGuestSession.isOk())
490 {
491 m_pLogOutput->appendPlainText("Guest session is not valid");
492 postSessionClosed();
493 return;
494 }
495 if (m_pGuestFileTable)
496 m_pGuestFileTable->reset();
497
498 if (m_comGuestSession.isOk() && m_pQtSessionListener && m_comSessionListener.isOk())
499 cleanupListener(m_pQtSessionListener, m_comSessionListener, m_comGuestSession.GetEventSource());
500
501 m_comGuestSession.Close();
502 m_pLogOutput->appendPlainText("Guest session is closed");
503 postSessionClosed();
504}
505
506void UIGuestControlFileManager::sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent)
507{
508 if (cEvent.isOk() /*&& m_comGuestSession.isOk()*/)
509 {
510 CVirtualBoxErrorInfo cErrorInfo = cEvent.GetError();
511 if (cErrorInfo.isOk())
512 {
513 m_pLogOutput->appendPlainText(cErrorInfo.GetText());
514 }
515 }
516 if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Started)
517 {
518 initFileTable();
519 postSessionCreated();
520 }
521 else
522 {
523 m_pLogOutput->appendPlainText("Session status has changed");
524 }
525}
526
527void UIGuestControlFileManager::sltReceieveLogOutput(QString strOutput)
528{
529 if (m_pLogOutput)
530 m_pLogOutput->appendPlainText(strOutput);
531}
532
533void UIGuestControlFileManager::sltCopyGuestToHost()
534{
535 if (!m_pGuestFileTable || !m_pHostFileTable)
536 return;
537 QString hostDestinationPath = m_pHostFileTable->currentDirectoryPath();
538 m_pGuestFileTable->copyGuestToHost(hostDestinationPath);
539 m_pHostFileTable->refresh();
540}
541
542void UIGuestControlFileManager::sltCopyHostToGuest()
543{
544 if (!m_pGuestFileTable || !m_pHostFileTable)
545 return;
546 QStringList hostSourcePathList = m_pHostFileTable->selectedItemPathList();
547 m_pGuestFileTable->copyHostToGuest(hostSourcePathList);
548 m_pGuestFileTable->refresh();
549}
550
551void UIGuestControlFileManager::initFileTable()
552{
553 if (!m_comGuestSession.isOk() || m_comGuestSession.GetStatus() != KGuestSessionStatus_Started)
554 return;
555 if (!m_pGuestFileTable)
556 return;
557 m_pGuestFileTable->initGuestFileTable(m_comGuestSession);
558}
559
560void UIGuestControlFileManager::postSessionCreated()
561{
562 if (m_pSessionCreateWidget)
563 m_pSessionCreateWidget->switchSessionCloseMode();
564 if (m_pGuestFileTable)
565 m_pGuestFileTable->setEnabled(true);
566 if (m_pToolBar)
567 m_pToolBar->setEnabled(true);
568}
569
570void UIGuestControlFileManager::postSessionClosed()
571{
572 if (m_pSessionCreateWidget)
573 m_pSessionCreateWidget->switchSessionCreateMode();
574 if (m_pGuestFileTable)
575 m_pGuestFileTable->setEnabled(false);
576 if (m_pToolBar)
577 m_pToolBar->setEnabled(false);
578
579}
580
581
582bool UIGuestControlFileManager::createSession(const QString& strUserName, const QString& strPassword,
583 const QString& strDomain /* not used currently */)
584{
585 if (!m_comGuest.isOk())
586 return false;
587 m_comGuestSession = m_comGuest.CreateSession(strUserName, strPassword,
588 strDomain, "File Manager Session");
589
590 if (!m_comGuestSession.isOk())
591 {
592 m_pLogOutput->appendPlainText("Guest session could not be created");
593 return false;
594 }
595
596 m_pLogOutput->appendPlainText("Guest session has been created");
597 if (m_pSessionCreateWidget)
598 m_pSessionCreateWidget->switchSessionCloseMode();
599
600 /* Prepare session listener */
601 QVector<KVBoxEventType> eventTypes;
602 eventTypes << KVBoxEventType_OnGuestSessionStateChanged;
603 //<< KVBoxEventType_OnGuestProcessRegistered;
604 prepareListener(m_pQtSessionListener, m_comSessionListener,
605 m_comGuestSession.GetEventSource(), eventTypes);
606
607 /* Connect to session listener */
608 qRegisterMetaType<CGuestSessionStateChangedEvent>();
609
610
611 connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged,
612 this, &UIGuestControlFileManager::sltGuestSessionStateChanged);
613 /* Wait session to start. For some reason we cannot get GuestSessionStatusChanged event
614 consistently. So we wait: */
615 m_pLogOutput->appendPlainText("Waiting the session to start");
616 const ULONG waitTimeout = 2000;
617 KGuestSessionWaitResult waitResult = m_comGuestSession.WaitFor(KGuestSessionWaitForFlag_Start, waitTimeout);
618 if (waitResult != KGuestSessionWaitResult_Start)
619 {
620 m_pLogOutput->appendPlainText("The session did not start");
621 sltCloseSession();
622 return false;
623 }
624
625 return true;
626}
627
628void UIGuestControlFileManager::prepareListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
629 CEventListener &comEventListener,
630 CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes)
631{
632 if (!comEventSource.isOk())
633 return;
634 /* Create event listener instance: */
635 QtListener.createObject();
636 QtListener->init(new UIMainEventListener, this);
637 comEventListener = CEventListener(QtListener);
638
639 /* Register event listener for CProgress event source: */
640 comEventSource.RegisterListener(comEventListener, eventTypes,
641 gEDataManager->eventHandlingType() == EventHandlingType_Active ? TRUE : FALSE);
642
643 /* If event listener registered as passive one: */
644 if (gEDataManager->eventHandlingType() == EventHandlingType_Passive)
645 {
646 /* Register event sources in their listeners as well: */
647 QtListener->getWrapped()->registerSource(comEventSource, comEventListener);
648 }
649}
650
651void UIGuestControlFileManager::cleanupListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
652 CEventListener &comEventListener,
653 CEventSource comEventSource)
654{
655 if (!comEventSource.isOk())
656 return;
657 /* If event listener registered as passive one: */
658 if (gEDataManager->eventHandlingType() == EventHandlingType_Passive)
659 {
660 /* Unregister everything: */
661 QtListener->getWrapped()->unregisterSources();
662 }
663
664 /* Make sure VBoxSVC is available: */
665 if (!vboxGlobal().isVBoxSVCAvailable())
666 return;
667
668 /* Unregister event listener for CProgress event source: */
669 comEventSource.UnregisterListener(comEventListener);
670}
671
672template<typename T>
673QStringList UIGuestControlFileManager::getFsObjInfoStringList(const T &fsObjectInfo) const
674{
675 QStringList objectInfo;
676 if (!fsObjectInfo.isOk())
677 return objectInfo;
678
679 //objectInfo << QString(UIGuestControlInterface::getFsObjTypeString(fsObjectInfo.GetType()).append("\t"));
680 objectInfo << fsObjectInfo.GetName();
681 //objectInfo << QString::number(fsObjectInfo.GetObjectSize());
682
683 /* Currently I dont know a way to convert these into a meaningful date/time: */
684 // strObjectInfo.append("BirthTime", QString::number(fsObjectInfo.GetBirthTime()));
685 // strObjectInfo.append("ChangeTime", QString::number(fsObjectInfo.GetChangeTime()));
686
687 return objectInfo;
688}
689
690#include "UIGuestControlFileManager.moc"
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette