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