summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
blob: 24a764fa78f282a18d6b22707325487670f5595d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* $Id$ */
/** @file
 * VBox Qt GUI - UIVirtualMachineItemCloud class declaration.
 */

/*
 * Copyright (C) 2006-2022 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h
#define FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* GUI includes: */
#include "UIVirtualMachineItem.h"

/* COM includes: */
#include "COMEnums.h"
#include "CCloudMachine.h"

/* Forward declarations: */
class UIProgressTask;

/** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */
class UIVirtualMachineItemCloud : public UIVirtualMachineItem
{
    Q_OBJECT;

signals:

    /** Notifies listeners about refresh started. */
    void sigRefreshStarted();
    /** Notifies listeners about refresh finished. */
    void sigRefreshFinished();

public:

    /** Constructs fake cloud VM item of certain @a enmState. */
    UIVirtualMachineItemCloud(UIFakeCloudVirtualMachineItemState enmState);
    /** Constructs real cloud VM item on the basis of taken @a comCloudMachine. */
    UIVirtualMachineItemCloud(const CCloudMachine &comCloudMachine);
    /** Destructs cloud VM item. */
    virtual ~UIVirtualMachineItemCloud() RT_OVERRIDE;

    /** @name Arguments.
      * @{ */
        /** Returns cached cloud machine object. */
        CCloudMachine machine() const { return m_comCloudMachine; }
    /** @} */

    /** @name Data attributes.
      * @{ */
        /** Returns cached machine state. */
        KCloudMachineState machineState() const { return m_enmMachineState; }

        /** Defines fake cloud item @a enmState. */
        void setFakeCloudItemState(UIFakeCloudVirtualMachineItemState enmState);
        /** Returns fake cloud item state. */
        UIFakeCloudVirtualMachineItemState fakeCloudItemState() const { return m_enmFakeCloudItemState; }

        /** Defines fake cloud item @a strErrorMessage. */
        void setFakeCloudItemErrorMessage(const QString &strErrorMessage);
        /** Returns fake cloud item error message. */
        QString fakeCloudItemErrorMessage() const { return m_strFakeCloudItemErrorMessage; }

        /** Updates cloud VM info async way, @a fDelayed if requested or instant otherwise.
          * @param  fSubscribe  Brings whether this update should be performed periodically. */
        void updateInfoAsync(bool fDelayed, bool fSubscribe = false);
        /** Stop periodical updates previously requested. */
        void stopAsyncUpdates();
        /** Makes sure async info update is finished.
          * @note  This method creates own event-loop to avoid blocking calling thread event processing,
          *        so it's safe to call it from the GUI thread, ofc the method itself will be blocked. */
        void waitForAsyncInfoUpdateFinished();
    /** @} */

    /** @name Update stuff.
      * @{ */
        /** Recaches machine data. */
        virtual void recache() RT_OVERRIDE;
        /** Recaches machine item pixmap. */
        virtual void recachePixmap() RT_OVERRIDE;
    /** @} */

    /** @name Validation stuff.
      * @{ */
        /** Returns whether this item is editable. */
        virtual bool isItemEditable() const RT_OVERRIDE;
        /** Returns whether this item is removable. */
        virtual bool isItemRemovable() const RT_OVERRIDE;
        /** Returns whether this item is saved. */
        virtual bool isItemSaved() const RT_OVERRIDE;
        /** Returns whether this item is powered off. */
        virtual bool isItemPoweredOff() const RT_OVERRIDE;
        /** Returns whether this item is started. */
        virtual bool isItemStarted() const RT_OVERRIDE;
        /** Returns whether this item is running. */
        virtual bool isItemRunning() const RT_OVERRIDE;
        /** Returns whether this item is running headless. */
        virtual bool isItemRunningHeadless() const RT_OVERRIDE;
        /** Returns whether this item is paused. */
        virtual bool isItemPaused() const RT_OVERRIDE;
        /** Returns whether this item is stuck. */
        virtual bool isItemStuck() const RT_OVERRIDE;
        /** Returns whether this item can be switched to. */
        virtual bool isItemCanBeSwitchedTo() const RT_OVERRIDE;
    /** @} */

protected:

    /** @name Event handling.
      * @{ */
        /** Handles translation event. */
        virtual void retranslateUi() RT_OVERRIDE;
    /** @} */

private slots:

        /** Handles signal about cloud VM info refresh progress is done. */
        void sltHandleRefreshCloudMachineInfoDone();

private:

    /** @name Prepare/Cleanup cascade.
      * @{ */
        /** Prepares all. */
        void prepare();
        /** Cleanups all. */
        void cleanup();
    /** @} */

    /** @name Arguments.
      * @{ */
        /** Holds cached cloud machine object. */
        CCloudMachine  m_comCloudMachine;
    /** @} */

    /** @name Data attributes.
      * @{ */
        /** Holds cached machine state. */
        KCloudMachineState  m_enmMachineState;

        /** Holds fake cloud item state. */
        UIFakeCloudVirtualMachineItemState  m_enmFakeCloudItemState;
        /** Holds fake cloud item error message. */
        QString                             m_strFakeCloudItemErrorMessage;

        /** Holds whether we plan to refresh info. */
        bool            m_fRefreshScheduled;
        /** Holds the refresh progress-task instance. */
        UIProgressTask *m_pProgressTaskRefresh;
    /** @} */
};

#endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h */