1 | /* $Id: CloudUserProfilesImpl.h 73337 2018-07-23 22:05:26Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2018 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 |
|
---|
19 | #ifndef ____H_CLOUDUSERPROFILESIMPL
|
---|
20 | #define ____H_CLOUDUSERPROFILESIMPL
|
---|
21 |
|
---|
22 | //#include <map>
|
---|
23 | #include <vector>
|
---|
24 |
|
---|
25 | /* VBox includes */
|
---|
26 | #include "CloudClientImpl.h"
|
---|
27 | #include "CloudUserProfilesWrap.h"
|
---|
28 | #include "UnattendedScript.h"
|
---|
29 |
|
---|
30 | /* VBox forward declarations */
|
---|
31 | class SimpleConfigFile;
|
---|
32 |
|
---|
33 | class CloudUserProfiles : public CloudUserProfilesWrap
|
---|
34 | {
|
---|
35 | public:
|
---|
36 | CloudUserProfiles();
|
---|
37 | virtual ~CloudUserProfiles();
|
---|
38 | HRESULT FinalConstruct();
|
---|
39 | void FinalRelease();
|
---|
40 | HRESULT init(VirtualBox *aVirtualBox);
|
---|
41 | void uninit();
|
---|
42 |
|
---|
43 | protected:
|
---|
44 | ComPtr<VirtualBox> const mParent; /**< Strong reference to the parent object (VirtualBox/IMachine). */
|
---|
45 |
|
---|
46 | public:
|
---|
47 | HRESULT getProvider(CloudProviderId_T *aProvider);
|
---|
48 | HRESULT createCloudClient(const com::Utf8Str &aProfileName,
|
---|
49 | ComPtr<ICloudClient> &aCloudClient);
|
---|
50 | HRESULT createProfile(const com::Utf8Str &aProfileName,
|
---|
51 | const std::vector<com::Utf8Str> &aNames,
|
---|
52 | const std::vector<com::Utf8Str> &aValues);
|
---|
53 | HRESULT updateProfile(const com::Utf8Str &aProfileName,
|
---|
54 | const std::vector<com::Utf8Str> &aNames,
|
---|
55 | const std::vector<com::Utf8Str> &aValues);
|
---|
56 | HRESULT getStoredProfilesNames(std::vector<com::Utf8Str> &aProfilesNames);
|
---|
57 | HRESULT getProfileProperties(const com::Utf8Str &aProfileName,
|
---|
58 | std::vector<com::Utf8Str> &aReturnNames,
|
---|
59 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
60 | HRESULT getPropertyDescription(const com::Utf8Str &aName,
|
---|
61 | com::Utf8Str &aDescription);
|
---|
62 |
|
---|
63 | virtual HRESULT getSupportedPropertiesNames(std::vector<com::Utf8Str> &aPropertiesNames);
|
---|
64 | virtual HRESULT readProfiles(const Utf8Str &strConfigPath);
|
---|
65 |
|
---|
66 | };
|
---|
67 |
|
---|
68 |
|
---|
69 | class OCIUserProfiles :
|
---|
70 | public CloudUserProfiles
|
---|
71 | {
|
---|
72 | public:
|
---|
73 | OCIUserProfiles();
|
---|
74 | ~OCIUserProfiles();
|
---|
75 |
|
---|
76 | HRESULT getProvider(CloudProviderId_T *aProvider)
|
---|
77 | {
|
---|
78 | *aProvider = CloudProviderId_OCI;
|
---|
79 | return S_OK;
|
---|
80 | }
|
---|
81 |
|
---|
82 | HRESULT createCloudClient(const com::Utf8Str &aProfileName,
|
---|
83 | ComPtr<ICloudClient> &aCloudClient);
|
---|
84 | HRESULT createProfile(const com::Utf8Str &aProfileName,
|
---|
85 | const std::vector<com::Utf8Str> &aNames,
|
---|
86 | const std::vector<com::Utf8Str> &aValues);
|
---|
87 | HRESULT updateProfile(const com::Utf8Str &aProfileName,
|
---|
88 | const std::vector<com::Utf8Str> &aNames,
|
---|
89 | const std::vector<com::Utf8Str> &aValues);
|
---|
90 | HRESULT getStoredProfilesNames(std::vector<com::Utf8Str> &aProfilesNames);
|
---|
91 | HRESULT getProfileProperties(const com::Utf8Str &aProfileName,
|
---|
92 | std::vector<com::Utf8Str> &aReturnNames,
|
---|
93 | std::vector<com::Utf8Str> &aReturnValues);
|
---|
94 | HRESULT getPropertyDescription(const com::Utf8Str &aName,
|
---|
95 | com::Utf8Str &aDescription);
|
---|
96 | HRESULT getSupportedPropertiesNames(std::vector<com::Utf8Str> &aPropertiesNames);
|
---|
97 |
|
---|
98 | HRESULT readProfiles(const Utf8Str &strConfigPath);
|
---|
99 |
|
---|
100 | private:
|
---|
101 | HRESULT i_createProfile(const com::Utf8Str &aProfileName,
|
---|
102 | const std::map <Utf8Str, Utf8Str> &aProfile);
|
---|
103 | HRESULT i_updateProfile(const com::Utf8Str &aProfileName,
|
---|
104 | const std::map <Utf8Str, Utf8Str> &aProfile);
|
---|
105 | HRESULT i_getProfileProperties(const com::Utf8Str &aName,
|
---|
106 | std::map <Utf8Str, Utf8Str> &aProfileName);
|
---|
107 | private:
|
---|
108 | Utf8Str mStrConfigPath;
|
---|
109 | SimpleConfigFile *mpProfiles;
|
---|
110 | };
|
---|
111 |
|
---|
112 |
|
---|
113 | class SimpleConfigFile : public GeneralTextScript
|
---|
114 | {
|
---|
115 | protected:
|
---|
116 | std::map < Utf8Str, std::map <Utf8Str, Utf8Str> > mSections;
|
---|
117 |
|
---|
118 | public:
|
---|
119 | explicit SimpleConfigFile(VirtualBoxBase *pSetError, const char *pszFilename = NULL);
|
---|
120 | virtual ~SimpleConfigFile();
|
---|
121 |
|
---|
122 | HRESULT parse();
|
---|
123 | //////////////////New functions//////////////////////////////
|
---|
124 | HRESULT addSection(const Utf8Str &aSectionName, const std::map <Utf8Str, Utf8Str>& section);
|
---|
125 |
|
---|
126 | size_t getNumberOfSections() const
|
---|
127 | {
|
---|
128 | return mSections.size();
|
---|
129 | }
|
---|
130 |
|
---|
131 | std::vector <Utf8Str> getSectionsNames() const;
|
---|
132 | std::map <Utf8Str, Utf8Str> getSectionByName (const Utf8Str &strSectionName) const;
|
---|
133 | bool isSectionExist(const Utf8Str &strSectionName) const;
|
---|
134 | HRESULT updateSection (const Utf8Str &strSectionName,
|
---|
135 | const std::map <Utf8Str, Utf8Str> &newSection);
|
---|
136 | //////////////////New functions//////////////////////////////
|
---|
137 | };
|
---|
138 | #endif // !____H_CLOUDUSERPROFILESIMPL
|
---|
139 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|
140 |
|
---|