3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dpl/log/log.h>
24 #include <network-cm-intf.h>
25 #include <Commons/Exception.h>
26 #include <CommonsJavaScript/Converter.h>
27 #include <CommonsJavaScript/PrivateObject.h>
28 #include "Systeminfo.h"
30 using namespace TizenApis::Api::Systeminfo;
31 using namespace WrtDeviceApis::CommonsJavaScript;
32 using namespace WrtDeviceApis::Commons;
37 namespace Systeminfo {
41 void PowerValueCallback(keynode_t *node, void *event_ptr)
44 ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TPYE_POWER);
48 void DisplayValueCallback(keynode_t *node, void *event_ptr)
51 ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DISPLAY);
55 void NetworkValueCallback(keynode_t *node, void *event_ptr)
58 ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK);
62 void NetworkEventCallback (net_event_info_t* event_cb, void* user_data)
68 #define STORAGE_INTERNAL_PATH "/opt/media"
69 #define STORAGE_SDCARD_PATH "/opt/storage/sdcard"
70 #define STORAGE_USBHOST_PATH "/opt/storage/usb"
71 #define MODEL_VERSION_LENGTH 5
74 STORAGE_TYPE_UNKNOWN = 0,
75 STORAGE_TYPE_INTERNAL = 1,
77 STORAGE_TYPE_USBHOST = 3
80 Systeminfo::OptionalProperty Systeminfo::m_Property;
82 Systeminfo::Systeminfo() : m_networkRegist(REGIST_NOT)
84 EventMgrPtr eventMgrPtr(new EventMgr());
85 m_EventMgrPtr = eventMgrPtr;
86 if (m_Property.IsNull()) {
87 mapProperties properties;
88 properties["Power"] = BasePropertyPtr(new Power());
89 m_Property = properties;
90 (*m_Property)["Cpu"] = BasePropertyPtr(new Cpu());
91 (*m_Property)["Storage"] = BasePropertyPtr(new Storage());
92 (*m_Property)["Display"] = BasePropertyPtr(new Display());
93 (*m_Property)["Device"] = BasePropertyPtr(new Device());
94 (*m_Property)["WifiNetwork"] = BasePropertyPtr(new WifiNetwork());
95 (*m_Property)["CellularNetwork"] = BasePropertyPtr(new CellularNetwork());
98 if (net_register_client((net_event_cb_t) NetworkEventCallback, (void *)this) != NET_ERR_NONE) {
99 LogError("registration is failed");
103 Systeminfo::~Systeminfo()
105 m_EventMgrPtr->clearAllEvent();
106 net_deregister_client();
109 bool Systeminfo::isPropertyValid(JSContextRef context, JSValueRef property)
111 Converter converter(context);
113 std::string l_property = converter.toString(property);
114 mapProperties::iterator it = (*m_Property).find(l_property);
115 if (it == (*m_Property).end()) {
116 LogError("not existing property");
123 void Systeminfo::get(const EventGetSysteminfoPtr& event)
125 EventRequestReceiver<EventGetSysteminfo>::PostRequest(event);
128 void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
130 if(event->getWatchType() == WATCH_TPYE_UNKNOWN) {
131 LogDebug("watch method is not supported");
135 event->setSysteminfoPtr(this);
136 m_EventMgrPtr->addEvent(event, event->getWatchType());
138 EventRequestReceiver<EventWatchSysteminfo>::PostRequest(event);
141 void Systeminfo::clearWatch(const int id)
143 int watchType = m_EventMgrPtr->getWatchType(id);
145 case WATCH_TPYE_POWER:
146 if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
147 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback);
148 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback);
151 case WATCH_TYPE_DISPLAY:
152 if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
153 vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
156 case WATCH_TPYE_WIFINETWORK:
157 if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
158 vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback);
159 if (m_networkRegist == REGIST_WIFI) {
160 vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
161 m_networkRegist = REGIST_NOT;
162 } else if (m_networkRegist== REGIST_ALL) {
163 m_networkRegist = REGIST_CELLULAR;
167 case WATCH_TPYE_CELLULARNETWORK:
168 if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
169 if (m_networkRegist == REGIST_CELLULAR) {
170 vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
171 m_networkRegist = REGIST_NOT;
172 } else if (m_networkRegist== REGIST_ALL) {
173 m_networkRegist = REGIST_WIFI;
179 m_EventMgrPtr->removeEvent(id, watchType);
182 BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef property)
184 Converter converter(context);
185 std::string l_property = converter.toString(property);
186 mapProperties::iterator it = (*m_Property).find(l_property);
187 if (it == (*m_Property).end()) {
188 LogError("not existing property");
189 Throw(InvalidArgumentException);
190 return BasePropertyPtr(NULL);
196 void Systeminfo::getWatchValue(const int watchType)
198 if (watchType == WATCH_TPYE_POWER) {
199 EventPowerList eventList = m_EventMgrPtr->getEventPowerList();
200 for (EventPowerList::iterator it = eventList.begin(); it != eventList.end(); it++) {
201 (*it)->getWatchValue();
203 } else if (watchType == WATCH_TYPE_DISPLAY) {
204 EventDisplayList eventList = m_EventMgrPtr->getEventDisplayList();
205 for (EventDisplayList::iterator it = eventList.begin(); it != eventList.end(); it++) {
206 (*it)->getWatchValue();
208 } else if (watchType == WATCH_TYPE_NETWORK) {
209 EventWifiNetworkList eventListWifi = m_EventMgrPtr->getEventWifiNetworkList();
210 EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
211 if (eventListWifi.size() > 0) {
212 for (EventWifiNetworkList::iterator it = eventListWifi.begin(); it != eventListWifi.end(); it++) {
213 (*it)->getWatchValue();
216 if (eventListCellular.size() > 0) {
217 for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
218 (*it)->getWatchValue();
224 void Systeminfo::OnRequestReceived(const EventGetSysteminfoPtr& event)
226 event->processGetValue();
229 void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
231 WatchOption watchOption = event->getWatchOption();
233 event->switchToManualAnswer();
234 event->setCancelAllowed(true);
236 switch(event->getWatchType()) {
237 case WATCH_TPYE_POWER:
238 if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
239 vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback, (void *)this);
240 vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback, (void *)this);
243 case WATCH_TYPE_DISPLAY:
244 if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
245 vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback, (void *)this);
248 case WATCH_TPYE_WIFINETWORK:
249 if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
250 vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback, (void *)this);
251 if (m_networkRegist == REGIST_NOT) {
252 vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
253 m_networkRegist = REGIST_WIFI;
254 } else if (m_networkRegist== REGIST_CELLULAR) {
255 m_networkRegist = REGIST_ALL;
259 case WATCH_TPYE_CELLULARNETWORK:
260 if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
261 if (m_networkRegist == REGIST_NOT) {
262 vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
263 m_networkRegist = REGIST_CELLULAR;
264 } else if (m_networkRegist== REGIST_WIFI) {
265 m_networkRegist = REGIST_ALL;
270 event->processGetValue();
274 ////////////////////////////////////////////////////////////////////////////////////////
276 Systeminfo::EventMgr::EventMgr()
280 Systeminfo::EventMgr::~EventMgr()
284 void Systeminfo::EventMgr::clearAllEvent()
286 DPL::Mutex::ScopedLock lock(&m_synchro);
288 LogDebug("removing all registered events, unRemoved power event=" << m_eventPowerList.size()
289 << " unRemoved display event=" << m_eventDisplayList.size() << " unRemoved wifi network event=" << m_eventWifiNetworkList.size()
290 << " unRemoved cellular network event=" << m_eventCelluarNetworkList.size());
291 while (!m_eventPowerList.empty()) {
292 EventWatchSysteminfoPtr event = m_eventPowerList.front();
293 LogDebug("removing EventId=" << event->getId());
295 m_eventPowerList.pop_front();
297 while (!m_eventDisplayList.empty()) {
298 EventWatchSysteminfoPtr event = m_eventDisplayList.front();
299 LogDebug("removing EventId=" << event->getId());
301 m_eventDisplayList.pop_front();
303 while (!m_eventWifiNetworkList.empty()) {
304 EventWatchSysteminfoPtr event = m_eventWifiNetworkList.front();
305 LogDebug("removing EventId=" << event->getId());
307 m_eventWifiNetworkList.pop_front();
309 while (!m_eventCelluarNetworkList.empty()) {
310 EventWatchSysteminfoPtr event = m_eventCelluarNetworkList.front();
311 LogDebug("removing EventId=" << event->getId());
313 m_eventCelluarNetworkList.pop_front();
317 void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg, const int watchType)
319 DPL::Mutex::ScopedLock lock(&m_synchro);
321 if (watchType == WATCH_TPYE_POWER) {
322 m_eventPowerList.push_back(arg);
323 LogDebug("Event power list size=" << m_eventPowerList.size());
324 } else if (watchType == WATCH_TYPE_DISPLAY) {
325 m_eventDisplayList.push_back(arg);
326 LogDebug("Event display list size=" << m_eventDisplayList.size());
327 } else if (watchType == WATCH_TPYE_WIFINETWORK) {
328 m_eventWifiNetworkList.push_back(arg);
329 LogDebug("Event wifi network list size=" << m_eventWifiNetworkList.size());
330 } else if (watchType == WATCH_TPYE_CELLULARNETWORK) {
331 m_eventCelluarNetworkList.push_back(arg);
332 LogDebug("Event cellular network list size=" << m_eventCelluarNetworkList.size());
336 void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
338 DPL::Mutex::ScopedLock lock(&m_synchro);
339 LogDebug("Event id : " << id);
341 EventWatchSysteminfoPtr event(NULL);
343 LogDebug("trying to delete event, id=" << id);
345 if (watchType == WATCH_TPYE_POWER) {
346 for (EventPowerList::iterator it = m_eventPowerList.begin(); it != m_eventPowerList.end(); it++) {
347 if (id == (*it)->getId()) {
353 LogError("event id not in the list, nothing to do");
357 LogDebug("event power list size=" << m_eventPowerList.size());
358 m_eventPowerList.remove(event);
359 LogDebug( "event removed, event power list size=" << m_eventPowerList.size());
360 } else if (watchType == WATCH_TYPE_DISPLAY) {
361 for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
362 if (id == (*it)->getId()) {
368 LogError("event id not in the list, nothing to do");
372 LogDebug("event display list size=" << m_eventDisplayList.size());
373 m_eventDisplayList.remove(event);
374 LogDebug( "event removed, event display list size=" << m_eventDisplayList.size());
375 } else if (watchType == WATCH_TPYE_WIFINETWORK) {
376 for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
377 if (id == (*it)->getId()) {
383 LogError("event id not in the list, nothing to do");
387 LogDebug("event wifi network list size=" << m_eventWifiNetworkList.size());
388 m_eventWifiNetworkList.remove(event);
389 LogDebug( "event removed, event wifi network list size=" << m_eventCelluarNetworkList.size());
390 } else if (watchType == WATCH_TPYE_WIFINETWORK) {
391 for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
392 if (id == (*it)->getId()) {
398 LogError("event id not in the list, nothing to do");
402 LogDebug("event cellular network list size=" << m_eventCelluarNetworkList.size());
403 m_eventCelluarNetworkList.remove(event);
404 LogDebug( "event removed, event cellular network list size=" << m_eventCelluarNetworkList.size());
408 const int Systeminfo::EventMgr::getWatchType(const int id)
410 DPL::Mutex::ScopedLock lock(&m_synchro);
412 EventWatchSysteminfoPtr event(NULL);
414 for (EventPowerList::iterator it = m_eventPowerList.begin(); it != m_eventPowerList.end(); it++) {
415 if (id == (*it)->getId()) {
421 for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
422 if (id == (*it)->getId()) {
428 for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
429 if (id == (*it)->getId()) {
435 for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
436 if (id == (*it)->getId()) {
443 LogError("event id not in the list, nothing to do");
444 return WATCH_TPYE_UNKNOWN;
447 return event->getWatchType();
450 EventPowerList Systeminfo::EventMgr::getEventPowerList()
452 return m_eventPowerList;
455 EventDisplayList Systeminfo::EventMgr::getEventDisplayList()
457 return m_eventDisplayList;
460 EventWifiNetworkList Systeminfo::EventMgr::getEventWifiNetworkList()
462 return m_eventWifiNetworkList;
465 EventCellularNetworkList Systeminfo::EventMgr::getEventCellularNetworkList()
467 return m_eventCelluarNetworkList;
470 ////////////////////////////////////////////////////////////////////////////////////////
472 PROPERTY_GET_SYSTEMINFO_DEFINITION(Power) {
473 PowerProperties powerPtr;
478 if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &value) != 0) {
479 return JSValueMakeNull(context);
481 powerPtr.level = (double)(value)/100;
484 if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value2) != 0) {
485 return JSValueMakeNull(context);
487 powerPtr.isCharging = (value2 == 0) ? false : true;
490 return Tizen1_0::JSPowerInfo::createJSObject(context, powerPtr);
493 PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
494 Converter converter(context);
496 CpuProperties cpuPtr;
498 char line[LINE_MAX] = {0};
500 bool matched = false;
502 pipe = popen("top -b -n1", "r");
505 LogDebug("file open is failed ");
506 return JSValueMakeNull(context);
509 pcrecpp::RE re("(\\d+).(\\d+)%id");
510 pcrecpp::RE re2("(\\d+)% idle");
512 while (fgets(line, LINE_MAX-1, pipe)) {
513 if (re.PartialMatch(line, &a, &b)||re2.PartialMatch(line, &a)) {
523 cpuPtr.load = (double)1;
526 cpuPtr.load = (double)(a+1)/100;
528 cpuPtr.load = (double)(a)/100;
531 return Tizen1_0::JSCpuInfo::createJSObject(context, cpuPtr);
533 return JSValueMakeNull(context);
538 PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
539 Converter converter(context);
545 StorageProperties units[3];
547 if (statfs(STORAGE_INTERNAL_PATH, &fs) < 0) {
548 return JSValueMakeNull(context);
551 units[storageCnt].type = "INTERNAL";
552 units[storageCnt].capacity = (unsigned long)(fs.f_bsize * fs.f_blocks);
553 units[storageCnt].availableCapacity = (unsigned long)(fs.f_bsize * fs.f_bavail);
554 units[storageCnt].isRemoveable = false;
556 if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
557 if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED) {
559 if (statfs(STORAGE_SDCARD_PATH, &fs) < 0) {
560 return JSValueMakeNull(context);
562 units[storageCnt].type = "MMC";
563 units[storageCnt].capacity = (unsigned long)(fs.f_bsize * fs.f_blocks);
564 units[storageCnt].availableCapacity = (unsigned long)(fs.f_bsize * fs.f_bavail);
565 units[storageCnt].isRemoveable = true;
569 if(vconf_get_int(VCONFKEY_SYSMAN_USB_HOST_STATUS, &usbhostState) == 0) {
570 if(usbhostState == VCONFKEY_SYSMEN_USB_HOST_CONNECTED) {
572 if (statfs(STORAGE_USBHOST_PATH, &fs) < 0) {
573 return JSValueMakeNull(context);
575 units[storageCnt].type = "USBHOST";
576 units[storageCnt].capacity = (unsigned long)(fs.f_bsize * fs.f_blocks);
577 units[storageCnt].availableCapacity = (unsigned long)(fs.f_bsize * fs.f_bavail);
578 units[storageCnt].isRemoveable = true;
584 std::vector<JSObjectRef> storageList;
586 for (int i=0; i<storageCnt; i++) {
587 storageList.push_back(Tizen1_0::JSStorageInfo::createJSObject(context, units[i]));
588 LogDebug("make array");
591 return JSObjectMakeArray(context, storageCnt, storageList.data(), NULL);
594 PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
595 Converter converter(context);
597 DisplayProperties display;
598 int brightness=0, dotsPerInchX=0, dotsPerInchY=0, physicalW=0, physicalH=0, resolutionW=0, resolutionH=0;
600 FILE* pipe = popen("xdpyinfo", "r");
602 return JSValueMakeNull(context);
605 if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness) == 0) {
606 display.brightness = (double)(brightness)/24;
609 pcrecpp::RE reResolution("dimensions:\\s+(\\d+)x(\\d+)");
610 pcrecpp::RE rePhysical("(\\d+)x(\\d+)\\s+millimeters");
611 pcrecpp::RE reDot("resolution:\\s+(\\d+)x(\\d+)");
612 char line[LINE_MAX] = {0};
613 while (fgets(line, LINE_MAX-1, pipe)) {
614 if (reResolution.PartialMatch(line, &resolutionW, &resolutionH)) {
615 display.resolutionWidth = resolutionW;
616 display.resolutionHeight = resolutionH;
618 if (rePhysical.PartialMatch(line, &physicalW, &physicalH)) {
619 display.physicalWidth = physicalW;
620 display.physicalHeight = physicalH;
622 if (reDot.PartialMatch(line, &dotsPerInchX, &dotsPerInchY)) {
623 display.dotsPerInchWidth = dotsPerInchX;
624 display.dotsPerInchHeight = dotsPerInchY;
630 return Tizen1_0::JSDisplayInfo::createJSObject(context, display);
633 PROPERTY_GET_SYSTEMINFO_DEFINITION(Device) {
634 Converter converter(context);
635 DeviceProperties device;
638 value = vconf_get_str(VCONFKEY_TELEPHONY_IMEI);
640 LogDebug("vconf_get_str failed");
645 std::ifstream file("/usr/etc/info.ini");
647 std::string result = "";
648 std::string tmpResult = "";
651 LogDebug("Device info file not found.");
653 while ((std::getline(file, line).rdstate() & (std::ifstream::failbit | std::ifstream::eofbit)) == 0) {
654 if (pcrecpp::RE("Build=(\\w+)_(\\w+)").PartialMatch(line, &result, &tmpResult)) {
655 device.version = result + "_" + tmpResult;
656 if (result.length() > MODEL_VERSION_LENGTH) {
657 result = result.substr(0, MODEL_VERSION_LENGTH);
659 device.model = "GT-" + result;
666 return Tizen1_0::JSDeviceInfo::createJSObject(context, device);
669 PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
670 Converter converter(context);
671 WifiNetworkProperties wifiNetwork;
672 net_profile_info_t ProfInfo;
677 if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) == 0) {
678 if (status == VCONFKEY_NETWORK_WIFI) {
679 wifiNetwork.status = "ON";
680 ipAddr = vconf_get_str(VCONFKEY_NETWORK_IP);
682 wifiNetwork.ipAddress = ipAddr;
684 memset(&ProfInfo, 0, sizeof(net_profile_info_t));
685 if (net_get_active_net_info(&ProfInfo) == NET_ERR_NONE) {
686 if(ProfInfo.profile_type == NET_DEVICE_WIFI) {
687 wifiNetwork.ssid = ProfInfo.ProfileInfo.Wlan.essid;
688 if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &strength) != 0) {
689 LogDebug("vconf_get_int failed");
691 wifiNetwork.signalStrength = (double)(strength/4);
696 wifiNetwork.status = "OFF";
699 return Tizen1_0::JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
702 PROPERTY_GET_SYSTEMINFO_DEFINITION(CellularNetwork) {
703 Converter converter(context);
704 CellularNetworkProperties cellularNetwork;
705 net_profile_info_t ProfInfo;
707 int cellid = 0, lac = 0;
712 if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) == 0) {
713 if (status == VCONFKEY_NETWORK_CELLULAR) {
714 cellularNetwork.status = "ON";
715 ipAddr = vconf_get_str(VCONFKEY_NETWORK_IP);
717 cellularNetwork.ipAddress = ipAddr;
719 memset(&ProfInfo, 0, sizeof(net_profile_info_t));
720 if (net_get_active_net_info(&ProfInfo) == NET_ERR_NONE) {
721 if(ProfInfo.profile_type == NET_DEVICE_CELLULAR) {
722 cellularNetwork.apn = ProfInfo.ProfileInfo.Pdp.Apn;
724 if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn) != 0) {
725 LogDebug("vconf_get_int failed");
727 cellularNetwork.mcc = plmn / 1000;
728 cellularNetwork.mnc = plmn % 1000;
731 switch(ProfInfo.ProfileInfo.Pdp.ServiceType) {
732 case NET_SERVICE_UNKNOWN :
733 cellularNetwork.serviceType = "UNKNOWN";
735 case NET_SERVICE_INTERNET :
736 cellularNetwork.serviceType = "INTERNET";
738 case NET_SERVICE_MMS :
739 cellularNetwork.serviceType = "MMS";
741 case NET_SERVICE_WAP :
742 cellularNetwork.serviceType = "WAP";
744 case NET_SERVICE_PREPAID_INTERNET :
745 cellularNetwork.serviceType = "PREPAID_INTERNET";
747 case NET_SERVICE_PREPAID_MMS :
748 cellularNetwork.serviceType = "PREPAID_MMS";
752 LogDebug("cellularNetwork.type : " << cellularNetwork.serviceType);
754 if (vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &cellid) == 0) {
755 cellularNetwork.cellid = cellid;
758 if (vconf_get_int(VCONFKEY_TELEPHONY_LAC, &lac) != 0) {
759 cellularNetwork.lac = lac;
762 if (vconf_get_int(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &isRoaming) != 0) {
763 cellularNetwork.isRoaming = (isRoaming == 0) ? false : true;
768 cellularNetwork.status = "OFF";
771 return Tizen1_0::JSCellularNetworkInfo::createJSObject(context, cellularNetwork);