Merge "Add to check the invalid provider" into tizen_2.1
[platform/framework/native/appfw.git] / src / system / FSys_SystemInfoImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FSys_SystemInfoImpl.cpp
19  * @brief               This is the implementation file for _SystemInfoImpl class.
20  */
21 #include <unique_ptr.h>
22
23 #include <FBaseBoolean.h>
24 #include <FBaseInteger.h>
25 #include <FBaseColHashMap.h>
26
27 #include <FBase_NativeError.h>
28 #include <FIo_RegistryImpl.h>
29 #include <FSys_SystemInfoImpl.h>
30 #include <FIo_AppServiceIpcMessages.h>
31 #include <FIo_IpcClient.h>
32
33 #include "FSys_Types.h"
34 #include "FSys_SystemClient.h"
35 #include "FSys_CommunicationDispatcherClient.h"
36
37 using namespace std;
38
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Io;
42
43 namespace Tizen { namespace System
44 {
45
46 static const wchar_t* _REGISTRY_PATH = L"/opt/usr/etc/system_info_cache.ini";
47 static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation";
48
49 //Bluetooth
50 static const wchar_t* _BLUETOOTH = L"http://tizen.org/feature/network.bluetooth";
51 static const wchar_t* _BLUETOOTH_SUPPORTED = L"BluetoothSupported";
52
53 //Camera
54
55 static const wchar_t* _CAMERA_FRONT = L"http://tizen.org/feature/camera.front";
56
57 static const wchar_t* _CAMERA_BACK = L"http://tizen.org/feature/camera.back";
58
59 static const wchar_t* _CAMERA_COUNT = L"CameraCount";
60
61 //DUID
62 static const wchar_t* _DUID = L"http://tizen.org/system/duid";
63 static const wchar_t* _DEVICE_ID = L"DUID";
64
65 //FM Radio
66 static const wchar_t* _FMRADIO = L"http://tizen.org/feature/fmradio";
67 static const wchar_t* _FM_RADIO_SUPPORTED = L"FmRadioSupported";
68
69 //Keyboard
70 static const wchar_t* _KEYBOARD_TYPE = L"KeyboardType";
71 static const wchar_t* _INPUT_KEYBOARD_LAYOUT = L"http://tizen.org/feature/input.keyboard.layout";
72
73 //Location
74 static const wchar_t* _GPS_SUPPORTED = L"GPSSupported";
75 static const wchar_t* _LOCATION_GPS = L"http://tizen.org/feature/location.gps";
76 static const wchar_t* _WPS_SUPPORTED = L"WPSSupported";
77 static const wchar_t* _LOCATION_WPS = L"http://tizen.org/feature/location.wps";
78
79 //Model name
80 static const wchar_t* _MODELNAME = L"http://tizen.org/system/model_name";
81 static const wchar_t* _MODEL_NAME = L"ModelName";
82
83 //Multi point
84 static const wchar_t* _MULTIPOINTTOUCH_POINTCOUNT = L"http://tizen.org/feature/multi_point_touch.point_count";
85 static const wchar_t* _MULTIPOINT_TOUCH_COUNT = L"MultiPointTouchCount";
86
87 //NFC
88 static const wchar_t* _NETWORK_NFC = L"http://tizen.org/feature/network.nfc";
89 static const wchar_t* _NFC_SUPPORTED = L"NFCSupported";
90
91 //Opengles
92 static const wchar_t* _OPENGLES_VERSION_1_1 = L"http://tizen.org/feature/opengles.version.1_1";
93 static const wchar_t* _OPENGLES_VERSION_2_0 = L"http://tizen.org/feature/opengles.version.2_0";
94 static const wchar_t* _OPENGL_ES_VERSION = L"OpenGLESVersion";
95
96 // Screen
97 static const wchar_t* _SCREEN_BPP = L"http://tizen.org/feature/screen.bpp";
98 static const wchar_t* _SCREEN_BITS_PER_PIXEL = L"ScreenBitsPerPixel";
99 static const wchar_t* _SCREEN_DPI = L"http://tizen.org/feature/screen.dpi";
100 static const wchar_t* _SCREEN_HEIGHT = L"http://tizen.org/feature/screen.height";
101 static const wchar_t* _SCREENHEIGHT = L"ScreenHeight";
102 static const wchar_t* _SCREEN_WIDTH = L"http://tizen.org/feature/screen.width";
103 static const wchar_t* _SCREENWIDTH = L"ScreenWidth";
104 static const wchar_t* _SCREENDPI = L"ScreenDPI";
105
106 //HDMI RCA
107 static const wchar_t* _SCREEN_OUTPUT_RCA = L"http://tizen.org/feature/screen.output.rca";
108 static const wchar_t* _TV_OUT_SUPPORTED = L"TvOutSupported";
109
110 //Sound
111 static const wchar_t* _SOUND_MEDIA_VOLUME_MAX = L"http://tizen.org/system/sound.media.volume.resolution.max";
112 static const wchar_t* _MAX_MEDIA_SOUND_VOLUME = L"MaxMediaSoundVolume";
113 static const wchar_t* _SOUND_NOTIFICATION_VOLUME_MAX = L"http://tizen.org/system/sound.notification.volume.resolution.max";
114 static const wchar_t* _MAX_NOTIFICATION_SOUND_VOLUME = L"MaxNotificationSoundVolume";
115 static const wchar_t* _SOUND_RINGTONE_VOLUME_MAX = L"http://tizen.org/system/sound.ringtone.volume.resolution.max";
116 static const wchar_t* _MAX_RINGTONE_SOUND_VOLUME = L"MaxRingtoneSoundVolume";
117 static const wchar_t* _SOUND_SYSTEM_VOLUME_MAX = L"http://tizen.org/system/sound.system.volume.resolution.max";
118 static const wchar_t* _MAX_SYSTEM_SOUND_VOLUME = L"MaxSystemSoundVolume";
119
120 //Telephony
121 static const wchar_t* _TELEPHONY = L"http://tizen.org/feature/network.telephony";
122 static const wchar_t* _TELEPHONY_SERVICE_GSM = L"http://tizen.org/feature/network.telephony.service.gsm";
123 static const wchar_t* _TELEPHONY_SERVICE_GPRS = L"http://tizen.org/feature/network.telephony.service.gprs";
124 static const wchar_t* _TELEPHONY_SERVICE_EDGE = L"http://tizen.org/feature/network.telephony.service.edge";
125 static const wchar_t* _TELEPHONY_SERVICE_UMTS = L"http://tizen.org/feature/network.telephony.service.umts";
126 static const wchar_t* _TELEPHONY_SERVICE_HSDPA = L"http://tizen.org/feature/network.telephony.service.hsdpa";
127 static const wchar_t* _TELEPHONY_SERVICE_HSUPA = L"http://tizen.org/feature/network.telephony.service.hsupa";
128 static const wchar_t* _TELEPHONY_SERVICE_HSPA = L"http://tizen.org/feature/network.telephony.service.hspa";
129 static const wchar_t* _TELEPHONY_SERVICE_LTE = L"http://tizen.org/feature/network.telephony.service.lte";
130 static const wchar_t* _TELEPHONY_SERVICE_CDMA = L"http://tizen.org/feature/network.telephony.service.cdma";
131 static const wchar_t* _NETWORK_TYPE = L"NetworkType";
132 static const wchar_t* _NETWORK_EMERGENCY = L"Emergency";
133 static const wchar_t* _NETWORK_NO_SERVICE = L"NoService";
134
135 //WIFI
136 static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi";
137 static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported";
138 static const wchar_t* _WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct";
139 static const wchar_t* _WIFI_DIRECT_SUPPORTED = L"WiFiDirectSupported";
140
141 //Version
142 static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version";
143 static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version";
144 static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version";
145 static const wchar_t* _BUILD_STRING = L"http://tizen.org/system/build.string";
146
147 static const wchar_t* _WAC_VERSION = L"WACVersion";
148 static const wchar_t* _SUPPORTED = L"Supported";
149 static const wchar_t* _UNSUPPORTED = L"Unsupported";
150
151 static bool firstRequest = false;
152 static HashMap integerList(SingleObjectDeleter);
153 static HashMap boolList(SingleObjectDeleter);
154 static HashMap stringList(SingleObjectDeleter);
155
156 void
157 PrepareCache(void)
158 {
159         if(firstRequest == false)
160         {
161                 integerList.Construct();
162                 boolList.Construct();
163                 stringList.Construct();
164                 firstRequest = true;
165         }
166 }
167
168 String
169 _SystemInfoImpl::ConvertToTizen(const String& key)
170 {
171         String code(key);
172
173         if(code == _DEVICE_ID)
174         {
175                 code = _DUID;
176         }
177         else if(code == _MODEL_NAME)
178         {
179                 code = _MODELNAME;
180         }
181         else if(code == _KEYBOARD_TYPE)
182         {
183                 code = _INPUT_KEYBOARD_LAYOUT;
184         }
185         else if(code == _SCREEN_BITS_PER_PIXEL)
186         {
187                 code = _SCREEN_BPP;
188         }
189         else if(code == _SCREENHEIGHT)
190         {
191                 code = _SCREEN_HEIGHT;
192         }
193         else if(code == _SCREENWIDTH)
194         {
195                 code = _SCREEN_WIDTH;
196         }
197         else if(code == _SCREENDPI)
198         {
199                 code = _SCREEN_DPI;
200         }
201         else if(code == _MAX_SYSTEM_SOUND_VOLUME)
202         {
203                 code = _SOUND_SYSTEM_VOLUME_MAX;
204         }
205         else if(code == _MAX_MEDIA_SOUND_VOLUME)
206         {
207                 code = _SOUND_MEDIA_VOLUME_MAX;
208         }
209         else if(code == _MAX_RINGTONE_SOUND_VOLUME)
210         {
211                 code = _SOUND_RINGTONE_VOLUME_MAX;
212         }
213         else if(code == _MAX_NOTIFICATION_SOUND_VOLUME)
214         {
215                 code = _SOUND_NOTIFICATION_VOLUME_MAX;
216         }
217         else if(code == _MULTIPOINT_TOUCH_COUNT)
218         {
219                 code = _MULTIPOINTTOUCH_POINTCOUNT;
220         }
221         else if(code == _BLUETOOTH_SUPPORTED)
222         {
223                 code = _BLUETOOTH;
224         }
225         else if(code == _GPS_SUPPORTED)
226         {
227                 code = _LOCATION_GPS;
228         }
229         else if(code == _WPS_SUPPORTED)
230         {
231                 code = _LOCATION_WPS;
232         }
233         else if(code == _WIFI_SUPPORTED)
234         {
235                 code = _WIFI;
236         }
237         else if(code == _WIFI_DIRECT_SUPPORTED)
238         {
239                 code = _WIFI_DIRECT;
240         }
241         else if(code == _FM_RADIO_SUPPORTED)
242         {
243                 code = _FMRADIO;
244         }
245         else if(code == _TV_OUT_SUPPORTED)
246         {
247                 code = _SCREEN_OUTPUT_RCA;
248         }
249         else if(code == _NFC_SUPPORTED)
250         {
251                 code = _NETWORK_NFC;
252         }
253         return code;
254 }
255
256 result
257 _SystemInfoImpl::GetSysInfo(const String& key, String& value)
258 {
259         result r = E_OBJ_NOT_FOUND;
260         String tizenKey = ConvertToTizen(key);
261
262         if (firstRequest == false)
263         {
264                 PrepareCache();
265         }
266
267         String* pValue = (String*)stringList.GetValue(key);
268
269         if(pValue != null)
270         {
271                 value = *pValue;
272                 r = E_SUCCESS;
273         }
274
275         if (key == _NETWORK_TYPE) //Compatibility
276         {
277                 bool supported = false;
278                 GetSysInfo(_TELEPHONY, supported);
279                 if(supported == false)
280                 {
281                         value = _NETWORK_EMERGENCY;
282                 }
283
284                 bool supportedGsm = false;
285                 bool supportedGprs = false;
286                 bool supportedEdge = false;
287                 bool supportedUmts = false;
288                 bool supportedHsdpa = false;
289                 bool supportedHsupa = false;
290                 bool supportedHspa = false;
291                 bool supportedLte = false;
292                 bool supportedCdma = false;
293
294                 GetSysInfo(_TELEPHONY_SERVICE_GSM, supportedGsm);
295                 GetSysInfo(_TELEPHONY_SERVICE_GPRS, supportedGprs);
296                 GetSysInfo(_TELEPHONY_SERVICE_EDGE, supportedEdge);
297                 GetSysInfo(_TELEPHONY_SERVICE_UMTS, supportedUmts);
298                 GetSysInfo(_TELEPHONY_SERVICE_HSDPA, supportedHsdpa);
299                 GetSysInfo(_TELEPHONY_SERVICE_HSUPA, supportedHsupa);
300                 GetSysInfo(_TELEPHONY_SERVICE_HSPA, supportedHspa);
301                 GetSysInfo(_TELEPHONY_SERVICE_LTE, supportedLte);
302                 GetSysInfo(_TELEPHONY_SERVICE_CDMA, supportedCdma);
303
304                 value.Clear();
305                 if(supportedGsm == false && supportedGprs == false
306                         && supportedEdge == false && supportedUmts == false
307                         && supportedHsdpa == false && supportedHsupa == false
308                         && supportedHspa == false && supportedLte == false
309                         && supportedCdma == false)
310                 {
311                         value = _NETWORK_NO_SERVICE;
312                 }
313                 else if(supportedGsm == true)
314                 {
315                         value.Append(L"GSM");
316                 }
317                 else if(supportedGprs == true)
318                 {
319                         if(value.GetLength() > 0)
320                                 value.Append(L" | ");
321
322                         value.Append(L"GPRS");
323                 }
324                 else if(supportedEdge == true)
325                 {
326                         if(value.GetLength() > 0)
327                                 value.Append(L" | ");
328
329                         value.Append(L"EDGE");
330                 }
331                 else if(supportedUmts == true)
332                 {
333                         if(value.GetLength() > 0)
334                                 value.Append(L" | ");
335
336                         value.Append(L"UMTS");
337                 }
338                 else if(supportedHsdpa == true)
339                 {
340                         if(value.GetLength() > 0)
341                                 value.Append(L" | ");
342
343                         value.Append(L"HSDPA");
344                 }
345                 else if(supportedHsupa == true)
346                 {
347                         if(value.GetLength() > 0)
348                                 value.Append(L" | ");
349
350                         value.Append(L"HSUPA");
351                 }
352                 else if(supportedHspa == true)
353                 {
354                         if(value.GetLength() > 0)
355                                 value.Append(L" | ");
356
357                         value.Append(L"HSPA");
358                 }
359                 else if(supportedLte == true)
360                 {
361                         if(value.GetLength() > 0)
362                                 value.Append(L" | ");
363
364                         value.Append(L"LTE");
365                 }
366                 else if(supportedCdma == true)
367                 {
368                         if(value.GetLength() > 0)
369                                 value.Append(L" | ");
370
371                         value.Append(L"CDMA");
372                 }
373                 r = E_SUCCESS;
374         }
375         else if (key == _OPENGL_ES_VERSION)
376         {
377                 bool opengles_11 = false;
378                 bool opengles_20 = false;
379
380                 GetSysInfo(_OPENGLES_VERSION_1_1, opengles_11);
381                 GetSysInfo(_OPENGLES_VERSION_2_0, opengles_20);
382
383                 if(opengles_11 == true)
384                 {
385                         value.Append(L"1.1");
386                 }
387                 else if(opengles_20 == true)
388                 {
389                         if(value.GetLength() > 0)
390                                 value.Append(L" | ");
391
392                         value.Append(L"2.0");
393                 }
394                 r = E_SUCCESS;
395         }
396         else if(key == _BLUETOOTH_SUPPORTED)
397         {
398                 bool supported = false;
399                 GetSysInfo(_BLUETOOTH, supported);
400                 if(supported == false)
401                         value = _SUPPORTED;
402                 else
403                         value = _UNSUPPORTED;
404                 r = E_SUCCESS;
405         }
406         else if (key == _GPS_SUPPORTED)
407         {
408                 bool supported = false;
409                 GetSysInfo(_LOCATION_GPS, supported);
410                 if(supported == false)
411                         value = _SUPPORTED;
412                 else
413                         value = _UNSUPPORTED;
414                 r = E_SUCCESS;
415         }
416         else if (key == _WIFI_SUPPORTED)
417         {
418                 bool supported = false;
419                 GetSysInfo(_WIFI, supported);
420                 if(supported == false)
421                         value = _SUPPORTED;
422                 else
423                         value = _UNSUPPORTED;
424                 r = E_SUCCESS;
425         }
426         else if (key == _WAC_VERSION)
427         {
428                 value.Clear();
429                 r = E_SUCCESS;
430         }
431         else if (key == _PLATFORM_NATIVE_API_VERSION || key == _PLATFORM_WEB_API_VERSION || key == _PLATFORM_VERSION || key == _BUILD_STRING)
432         {
433                 r = E_OBJ_NOT_FOUND;
434         }
435         else
436         {
437                 r = GetFromRegistry(tizenKey, value);
438
439                 if(r != E_SUCCESS)
440                 {
441                         _SystemClient* pSystemClient = _SystemClient::GetInstance();
442                         r = pSystemClient->GetValue(key, value);
443                 }
444         }
445         if( r == E_SUCCESS)
446         {
447                 stringList.Add(new String(key), new String(value));
448         }
449         return r;
450 }
451
452 result
453 _SystemInfoImpl::GetSysInfo(const String& key, int& value)
454 {
455         result r = E_SUCCESS;
456         String tizenKey = ConvertToTizen(key);
457
458         if (firstRequest == false)
459         {
460                 PrepareCache();
461         }
462
463         Integer* pValue = (Integer*)integerList.GetValue(key);
464
465         if(pValue != null)
466         {
467                 value = pValue->value;
468                 return E_SUCCESS;
469         }
470
471         if (key == _CAMERA_COUNT)
472         {
473                 bool supported = false;
474                 int cameraCount = 0;
475
476                 GetSysInfo(_CAMERA_FRONT, supported);
477                 if(supported == true)
478                         cameraCount++;
479
480                 GetSysInfo(_CAMERA_BACK, supported);
481                 if(supported == true)
482                         cameraCount++;
483
484                 value = cameraCount;
485         }
486         else
487         {
488                 r = GetFromRegistry(tizenKey, value);
489                 if(r != E_SUCCESS)
490                 {
491                         _SystemClient* pSystemClient = _SystemClient::GetInstance();
492                         r = pSystemClient->GetValue(key, value);
493                 }
494         }
495
496         if(r == E_SUCCESS)
497         {
498                 integerList.Add(new String(key), new Integer(value));
499         }
500
501         return r;
502 }
503
504 result
505 _SystemInfoImpl::GetSysInfo(const String& key, long long& value)
506 {
507         return E_OBJ_NOT_FOUND;
508 }
509
510 result
511 _SystemInfoImpl::GetSysInfo(const String& key, double& value)
512 {
513         return E_OBJ_NOT_FOUND;
514 }
515
516 result
517 _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
518 {
519         result r = E_SUCCESS;
520         String tizenKey = ConvertToTizen(key);
521
522         if (firstRequest == false)
523         {
524                 PrepareCache();
525         }
526
527         Boolean* pValue = (Boolean*)boolList.GetValue(key);
528
529         if(pValue != null)
530         {
531                 value = pValue->value;
532                 return E_SUCCESS;
533         }
534
535         r = GetFromRegistry(tizenKey, value);
536         if(r != E_SUCCESS)
537         {
538                 _SystemClient* pSystemClient = _SystemClient::GetInstance();
539                 r = pSystemClient->GetValue(key, value);
540         }
541         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
542
543         if(r == E_SUCCESS)
544         {
545                 boolList.Add(new String(key), new Boolean(value));
546         }
547
548         return r;
549 }
550
551 result
552 _SystemInfoImpl::GetSysInfo(const String& key, UuId& value)
553 {
554         return E_OBJ_NOT_FOUND;
555 }
556
557 Collection::IList*
558 _SystemInfoImpl::GetSysInfoValuesN(const String& key, SystemInfoValueType type)
559 {
560         SetLastResult(E_OBJ_NOT_FOUND);
561         return null;
562 }
563
564 result
565 _SystemInfoImpl::GetPlatformVersion(String& platformVersion)
566 {
567         result r = E_SUCCESS;
568         String tizenKey(_PLATFORM_VERSION);
569
570         r = GetFromRegistry(tizenKey, platformVersion);
571         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
572         return r;
573 }
574
575 result
576 _SystemInfoImpl::GetBuildInfo(String& buildInfo)
577 {
578         result r = E_SUCCESS;
579         String tizenKey(_BUILD_STRING);
580
581         r = GetFromRegistry(tizenKey, buildInfo);
582         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
583         return r;
584 }
585
586 result
587 _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion)
588 {
589         result r = E_SUCCESS;
590         String tizenKey(_PLATFORM_NATIVE_API_VERSION);
591
592         r = GetFromRegistry(tizenKey, nativeApiVersion);
593         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
594         return r;
595 }
596
597 result
598 _SystemInfoImpl::GetWebApiVersion(String& webApiVersion)
599 {
600         result r = E_SUCCESS;
601         String tizenKey(_PLATFORM_WEB_API_VERSION);
602
603         r = GetFromRegistry(tizenKey, webApiVersion);
604         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
605         return r;
606 }
607
608 result
609 _SystemInfoImpl::GetImei(String& imei)
610 {
611         result r = E_SUCCESS;
612
613         ArrayList requestMessage;
614         ArrayList responseMessage;
615
616         _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
617
618         _IpcClient* pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
619         SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance.");
620
621         requestMessage.Construct();
622         responseMessage.Construct();
623
624         String serviceId(_SYSTEM_SERVICE_ID);
625         String commandId(L"osp.system.command.get.imei.internal");
626
627         requestMessage.Add(serviceId);
628         requestMessage.Add(commandId);
629
630         unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessage, &responseMessage));
631         SysTryReturnResult(NID_SYS, pMsg != null, E_OUT_OF_MEMORY, "It is failed to create Ipc message");
632
633         r = pIpcClient->SendRequest(pMsg.get());
634         SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to send ipc message. [%s]", GetErrorMessage(r));
635
636         unique_ptr<String> pResult((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA));
637         unique_ptr<String> pImei((String*)responseMessage.GetAt(_SYSTEM_RESPONSE_DATA+1));
638
639         SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "It is failed to receive result on IPC response message.");
640         SysTryReturnResult(NID_SYS, pImei != null, E_SYSTEM, "It is failed to receive IMEI value on IPC response message.");
641
642         SysTryReturnResult(NID_SYS, *pResult != _SYSTEM_RESULT_PRIVILEGED, E_PRIVILEGE_DENIED, "It is failed to get privilege.");
643         SysTryReturnResult(NID_SYS, *pResult == _SYSTEM_RESULT_OK, E_SYSTEM, "It is failed to get IMEI value.");
644
645         imei = *pImei;
646         return r;
647 }
648
649 result
650 _SystemInfoImpl::GetFromRegistry(const String& key, String& value)
651 {
652         result r = E_SUCCESS;
653         _RegistryImpl _reg;
654         String valStr;
655
656         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
657         SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " RegistryImpl construct is failed");
658
659         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
660         SysTryReturnResult(NID_SYS, r == E_SUCCESS , r, " Registry GetValue is failed");
661
662         if(valStr == L"true" || valStr == L"false")
663         {
664                 return E_OBJ_NOT_FOUND;
665         }
666         else
667         {
668                 value = valStr;
669         }
670
671         return E_SUCCESS;
672 }
673
674 result
675 _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
676 {
677         result r = E_SUCCESS;
678         _RegistryImpl _reg;
679         String valStr;
680         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
681         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
682
683         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
684         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
685         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
686         r = Integer::Parse(valStr, value);
687         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, " Integer::Parse() is failed");
688         return E_SUCCESS;
689 }
690
691 result
692 _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
693 {
694         result r = E_SUCCESS;
695         _RegistryImpl _reg;
696         String valStr;
697         r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
698         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
699
700         r = _reg.GetValue(_SYSTEM_INFO_SESSION, key, valStr);
701         SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " Registry GetValue is failed");
702         SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, " Registry GetValue is failed");
703         if(valStr == L"true")
704         {
705                 value = true;
706         }
707         else if(valStr == L"false")
708         {
709                 value = false;
710         }
711         else
712         {
713                 return E_OBJ_NOT_FOUND;
714         }
715         return E_SUCCESS;
716 }
717
718 _SystemInfoImpl*
719 _SystemInfoImpl::GetInstance(SystemInfo& systeminfo)
720 {
721         return systeminfo.__pSystemInfoImpl;
722 }
723 const _SystemInfoImpl*
724 _SystemInfoImpl::GetInstance(const SystemInfo& systeminfo)
725 {
726         return systeminfo.__pSystemInfoImpl;
727 }
728 } } // Tizen::System