blob: a0d30a001cb7540a212d78bd6604d537d39b5f38 [file] [log] [blame]
Patrick Benavoli68a91282011-08-31 11:23:23 +02001/* <auto_header>
2 * <FILENAME>
3 *
4 * INTEL CONFIDENTIAL
5 * Copyright © 2011 Intel
6 * Corporation All Rights Reserved.
7 *
8 * The source code contained or described herein and all documents related to
9 * the source code ("Material") are owned by Intel Corporation or its suppliers
10 * or licensors. Title to the Material remains with Intel Corporation or its
11 * suppliers and licensors. The Material contains trade secrets and proprietary
12 * and confidential information of Intel or its suppliers and licensors. The
13 * Material is protected by worldwide copyright and trade secret laws and
14 * treaty provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed, or
16 * disclosed in any way without Intel’s prior express written permission.
17 *
18 * No license under any patent, copyright, trade secret or other intellectual
19 * property right is granted to or conferred upon you by disclosure or delivery
20 * of the Materials, either expressly, by implication, inducement, estoppel or
21 * otherwise. Any license under such intellectual property rights must be
22 * express and approved by Intel in writing.
23 *
24 * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
25 * CREATED: 2011-06-01
26 * UPDATED: 2011-07-27
27 *
28 *
29 * </auto_header>
30 */
31#include <iostream>
32#include "ParameterMgr.h"
33#include "ParameterMgrPlatformConnector.h"
34#include <semaphore.h>
35
36using namespace std;
37
38#ifdef SIMULATION
39const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/projects/qt/parameter-framework/XML";
40#else
41const char* gpcParameterFrameworkConfigurationFolderPath = "/etc/parameter-framework";
42#endif
43
44//#define SIMPLE_TEST
45
46int main(int argc, char *argv[])
47{
48#ifndef SIMPLE_TEST
49 if (argc != 4) {
50
51 cerr << "Wrong number of arguments" << endl;
52
53 return -1;
54 }
55#else
56 if (argc < 2) {
57
58 cerr << "Missing arguments" << endl;
59
60 return -1;
61 }
62#endif
63 string strError;
64
65 //CParameterMgrPlatformConnector parameterMgrPlatformConnector(argv[1]);
66 CParameterMgr parameterMgr(gpcParameterFrameworkConfigurationFolderPath, argv[1]);
67
68 // Load data structure
69 if (!parameterMgr.load(strError)) {
70
71 cerr << strError << endl;
72
73 return -1;
74 }
75
76 // Init flow
77 if (!parameterMgr.init(strError)) {
78
79 cerr << strError << endl;
80
81 return -1;
82 }
83#ifndef SIMPLE_TEST
84 // Set Tuning Mode on
85 if (!parameterMgr.setTuningMode(true, strError)) {
86
87 cerr << strError << endl;
88
89 return -1;
90 }
91
92 // Restore some configuration
93 if (!parameterMgr.restoreConfiguration("Multimedia.OutputDevice.Private.Selected", "Earpiece", strError)) {
94
95 cerr << strError << endl;
96
97 return -1;
98 }
99 // Save some configuration
100 if (!parameterMgr.saveConfiguration("Multimedia.OutputDevice.Public.Selected", "IHF", strError)) {
101
102 cerr << strError << endl;
103
104 return -1;
105 }
106
107 // Log content
108 string strContent;
109 parameterMgr.logStructureContent(strContent);
110
111 cout << strContent;
112
113 //parameterMgr.setValueSpaceRaw(true);
114
115 string strValue;
116 if (!parameterMgr.getValue(argv[2], strValue, strError)) {
117
118 cerr << strError << endl;
119
120 return -1;
121 }
122 cout << "Before setting: " << strValue << endl;
123
124 if (!parameterMgr.setValue(argv[2], argv[3], strError)) {
125
126 cerr << strError << endl;
127
128 return -1;
129 }
130
131 if (!parameterMgr.getValue(argv[2], strValue, strError)) {
132
133 cerr << strError << endl;
134
135 return -1;
136 }
137 cout << "After setting: " << strValue << endl;
138
139 // Save some configuration
140 if (!parameterMgr.saveConfiguration("Multimedia.OutputDevice.Private.Selected", "WiredSpeakers", strError)) {
141
142 cerr << strError << endl;
143
144 return -1;
145 }
146
147 // Save some configuration
148 if (!parameterMgr.saveConfiguration("Multimedia.OutputDevice.Private.Selected", "BluetoothSCO", strError)) {
149
150 cerr << strError << endl;
151
152 return -1;
153 }
154 // Export configurations
155 if (!parameterMgr.exportDomainsXml(string(gpcParameterFrameworkConfigurationFolderPath) + "/Settings/Audio/AudioSettingsExport.xml", true, strError)) {
156
157 cerr << strError << endl;
158
159 return -1;
160 }
161 // Import configurations
162 if (!parameterMgr.importDomainsXml(string(gpcParameterFrameworkConfigurationFolderPath) + "/Settings/Audio/AudioSettingsExport.xml", true, strError)) {
163
164 cerr << strError << endl;
165
166 return -1;
167 }
168
169 // Export configuration as binary
170 if (!parameterMgr.exportDomainsBinary(string(gpcParameterFrameworkConfigurationFolderPath) + "/Settings/Audio/AudioSettingsExport.bin", strError)) {
171
172 cerr << strError << endl;
173
174 return -1;
175 }
176
177 // Import configuration as binary
178 if (!parameterMgr.importDomainsBinary(string(gpcParameterFrameworkConfigurationFolderPath) + "/Settings/Audio/AudioSettingsExport.bin", strError)) {
179
180 cerr << strError << endl;
181
182 return -1;
183 }
184
185 // Set Tuning Mode off
186 if (!parameterMgr.setTuningMode(false, strError)) {
187
188 cerr << strError << endl;
189
190 return -1;
191 }
192#endif
193 // Block here
194 sem_t sem;
195
196 sem_init(&sem, false, 0);
197
198 sem_wait(&sem);
199
200 sem_destroy(&sem);
201
202 return 0;
203}
204