VirtualBox

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

Last change on this file since 40532 was 39843, checked in by vboxsync, 13 years ago

GuestCtrl: Request (IPC) changes, bugfixes, fixed handle leaks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 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 GuestProcessStreamValue
40{
41public:
42
43 GuestProcessStreamValue() { }
44 GuestProcessStreamValue(const char *pszValue)
45 : mValue(pszValue) {}
46
47 GuestProcessStreamValue(const GuestProcessStreamValue& 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, GuestProcessStreamValue > GuestCtrlStreamPair;
55typedef std::map < Utf8Str, GuestProcessStreamValue > GuestCtrlStreamPairMap;
56typedef std::map < Utf8Str, GuestProcessStreamValue >::iterator GuestCtrlStreamPairMapIter;
57typedef std::map < Utf8Str, GuestProcessStreamValue >::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#ifdef DEBUG
79 void Dump();
80#endif
81
82 int GetInt64Ex(const char *pszKey, int64_t *piVal);
83
84 int64_t GetInt64(const char *pszKey);
85
86 size_t GetCount();
87
88 const char* GetString(const char *pszKey);
89
90 int GetUInt32Ex(const char *pszKey, uint32_t *puVal);
91
92 uint32_t GetUInt32(const char *pszKey);
93
94 int SetValue(const char *pszKey, const char *pszValue);
95
96protected:
97
98 GuestCtrlStreamPairMap m_mapPairs;
99};
100
101/** Vector containing multiple allocated stream pair objects. */
102typedef std::vector< GuestProcessStreamBlock > GuestCtrlStreamObjects;
103typedef std::vector< GuestProcessStreamBlock >::iterator GuestCtrlStreamObjectsIter;
104typedef std::vector< GuestProcessStreamBlock >::const_iterator GuestCtrlStreamObjectsIterConst;
105
106/**
107 * Class for parsing machine-readable guest process output by VBoxService'
108 * toolbox commands ("vbox_ls", "vbox_stat" etc), aka "guest stream".
109 */
110class GuestProcessStream
111{
112
113public:
114
115 GuestProcessStream();
116
117 virtual ~GuestProcessStream();
118
119public:
120
121 int AddData(const BYTE *pbData, size_t cbData);
122
123 void Destroy();
124
125#ifdef DEBUG
126 void Dump(const char *pszFile);
127#endif
128
129 uint32_t GetOffset();
130
131 uint32_t GetSize();
132
133 int ParseBlock(GuestProcessStreamBlock &streamBlock);
134
135protected:
136
137 /** Currently allocated size of internal stream buffer. */
138 uint32_t m_cbAllocated;
139 /** Currently used size of allocated internal stream buffer. */
140 uint32_t m_cbSize;
141 /** Current offset within the internal stream buffer. */
142 uint32_t m_cbOffset;
143 /** Internal stream buffer. */
144 BYTE *m_pbBuffer;
145};
146
147class GuestTask
148{
149
150public:
151
152 enum TaskType
153 {
154 /** Copies a file from host to the guest. */
155 TaskType_CopyFileToGuest = 50,
156 /** Copies a file from guest to the host. */
157 TaskType_CopyFileFromGuest = 55,
158 /** Update Guest Additions by directly copying the required installer
159 * off the .ISO file, transfer it to the guest and execute the installer
160 * with system privileges. */
161 TaskType_UpdateGuestAdditions = 100
162 };
163
164 GuestTask(TaskType aTaskType, Guest *aThat, Progress *aProgress);
165
166 virtual ~GuestTask();
167
168 int startThread();
169
170 static int taskThread(RTTHREAD aThread, void *pvUser);
171 static int uploadProgress(unsigned uPercent, void *pvUser);
172 static HRESULT setProgressErrorInfo(HRESULT hr,
173 ComObjPtr<Progress> pProgress, const char * pszText, ...);
174 static HRESULT setProgressErrorInfo(HRESULT hr,
175 ComObjPtr<Progress> pProgress, ComObjPtr<Guest> pGuest);
176
177 TaskType taskType;
178 ComObjPtr<Guest> pGuest;
179 ComObjPtr<Progress> pProgress;
180 HRESULT rc;
181
182 /* Task data. */
183 Utf8Str strSource;
184 Utf8Str strDest;
185 Utf8Str strUserName;
186 Utf8Str strPassword;
187 ULONG uFlags;
188};
189#endif // ____H_GUESTIMPLPRIVATE
190
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