VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h@ 38911

Last change on this file since 38911 was 38439, checked in by vboxsync, 14 years ago

GuestCtrl: Removed dead code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/** @file
2 *
3 * VirtualBox Guest Control - Private data definitions / classes.
4 */
5
6/*
7 * Copyright (C) 2011 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#ifndef ____H_GUESTIMPLPRIVATE
19#define ____H_GUESTIMPLPRIVATE
20
21#include <VBox/com/com.h>
22#include <VBox/com/string.h>
23#include <VBox/com/VirtualBox.h>
24
25#include <map>
26#include <vector>
27
28using namespace com;
29
30#ifdef VBOX_WITH_GUEST_CONTROL
31# include <VBox/HostServices/GuestControlSvc.h>
32using namespace guestControl;
33#endif
34
35class Guest;
36class Progress;
37
38/** Structure representing the "value" side of a "key=value" pair. */
39class VBOXGUESTCTRL_STREAMVALUE
40{
41public:
42
43 VBOXGUESTCTRL_STREAMVALUE() { }
44 VBOXGUESTCTRL_STREAMVALUE(const char *pszValue)
45 : mValue(pszValue) {}
46
47 VBOXGUESTCTRL_STREAMVALUE(const VBOXGUESTCTRL_STREAMVALUE& aThat)
48 : mValue(aThat.mValue) {}
49
50 Utf8Str mValue;
51};
52
53/** Map containing "key=value" pairs of a guest process stream. */
54typedef std::pair< Utf8Str, VBOXGUESTCTRL_STREAMVALUE > GuestCtrlStreamPair;
55typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE > GuestCtrlStreamPairMap;
56typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE >::iterator GuestCtrlStreamPairMapIter;
57typedef std::map < Utf8Str, VBOXGUESTCTRL_STREAMVALUE >::const_iterator GuestCtrlStreamPairMapIterConst;
58
59/**
60 * Class representing a block of stream pairs (key=value). Each block in a raw guest
61 * output stream is separated by "\0\0", each pair is separated by "\0". The overall
62 * end of a guest stream is marked by "\0\0\0\0".
63 */
64class GuestProcessStreamBlock
65{
66public:
67
68 GuestProcessStreamBlock();
69
70 //GuestProcessStreamBlock(GuestProcessStreamBlock &);
71
72 virtual ~GuestProcessStreamBlock();
73
74public:
75
76 void Clear();
77
78 int GetInt64Ex(const char *pszKey, int64_t *piVal);
79
80 int64_t GetInt64(const char *pszKey);
81
82 size_t GetCount();
83
84 const char* GetString(const char *pszKey);
85
86 int GetUInt32Ex(const char *pszKey, uint32_t *puVal);
87
88 uint32_t GetUInt32(const char *pszKey);
89
90 int SetValue(const char *pszKey, const char *pszValue);
91
92protected:
93
94 GuestCtrlStreamPairMap m_mapPairs;
95};
96
97/** Vector containing multiple allocated stream pair objects. */
98typedef std::vector< GuestProcessStreamBlock > GuestCtrlStreamObjects;
99typedef std::vector< GuestProcessStreamBlock >::iterator GuestCtrlStreamObjectsIter;
100typedef std::vector< GuestProcessStreamBlock >::const_iterator GuestCtrlStreamObjectsIterConst;
101
102/**
103 * Class for parsing machine-readable guest process output by VBoxService'
104 * toolbox commands ("vbox_ls", "vbox_stat" etc), aka "guest stream".
105 */
106class GuestProcessStream
107{
108
109public:
110
111 GuestProcessStream();
112
113 virtual ~GuestProcessStream();
114
115public:
116
117 int AddData(const BYTE *pbData, size_t cbData);
118
119 void Destroy();
120
121 uint32_t GetOffset();
122
123 int ParseBlock(GuestProcessStreamBlock &streamBlock);
124
125protected:
126
127 /** Currently allocated size of internal stream buffer. */
128 uint32_t m_cbAllocated;
129 /** Currently used size of allocated internal stream buffer. */
130 uint32_t m_cbSize;
131 /** Current offset within the internal stream buffer. */
132 uint32_t m_cbOffset;
133 /** Internal stream buffer. */
134 BYTE *m_pbBuffer;
135};
136
137class GuestTask
138{
139
140public:
141
142 enum TaskType
143 {
144 /** Copies a file from host to the guest. */
145 TaskType_CopyFileToGuest = 50,
146 /** Copies a file from guest to the host. */
147 TaskType_CopyFileFromGuest = 55,
148 /** Update Guest Additions by directly copying the required installer
149 * off the .ISO file, transfer it to the guest and execute the installer
150 * with system privileges. */
151 TaskType_UpdateGuestAdditions = 100
152 };
153
154 GuestTask(TaskType aTaskType, Guest *aThat, Progress *aProgress);
155
156 virtual ~GuestTask();
157
158 int startThread();
159
160 static int taskThread(RTTHREAD aThread, void *pvUser);
161 static int uploadProgress(unsigned uPercent, void *pvUser);
162 static HRESULT setProgressErrorInfo(HRESULT hr,
163 ComObjPtr<Progress> pProgress, const char * pszText, ...);
164 static HRESULT setProgressErrorInfo(HRESULT hr,
165 ComObjPtr<Progress> pProgress, ComObjPtr<Guest> pGuest);
166
167 TaskType taskType;
168 Guest *pGuest;
169 ComObjPtr<Progress> progress;
170 HRESULT rc;
171
172 /* Task data. */
173 Utf8Str strSource;
174 Utf8Str strDest;
175 Utf8Str strUserName;
176 Utf8Str strPassword;
177 ULONG uFlags;
178};
179#endif // ____H_GUESTIMPLPRIVATE
180
Note: See TracBrowser for help on using the repository browser.

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