458 } |
469 } |
459 } |
470 } |
460 #if !defined(QT_NO_DBUS) |
471 #if !defined(QT_NO_DBUS) |
461 QDBusConnection systemDbusConnection = QDBusConnection::systemBus(); |
472 QDBusConnection systemDbusConnection = QDBusConnection::systemBus(); |
462 |
473 |
|
474 #if defined(Q_WS_MAEMO_6) |
|
475 const QString service = "com.nokia.csd.CSNet"; |
|
476 const QString servicePath = "/com/nokia/csd/csnet"; |
|
477 |
|
478 /* CSD: network cell */ |
|
479 QDBusInterface ifc(service, servicePath, "com.nokia.csd.CSNet.NetworkCell", systemDbusConnection); |
|
480 |
|
481 QVariant cellLac = ifc.property("CellLac"); |
|
482 currentLac = cellLac.isValid() ? cellLac.value<int>() : -1; |
|
483 |
|
484 QVariant cellId = ifc.property("CellId"); |
|
485 currentCellId = cellId.isValid() ? cellId.value<int>() : -1; |
|
486 |
|
487 QVariant cellType = ifc.property("CellType"); |
|
488 QString currentCellType = cellType.isValid() ? cellType.value<QString>() : ""; |
|
489 |
|
490 if (currentCellType == "GSM") |
|
491 radioAccessTechnology = 1; |
|
492 else if (currentCellType == "WCDMA") |
|
493 radioAccessTechnology = 2; |
|
494 |
|
495 /* CSD: network operator */ |
|
496 QDBusInterface ifc2(service, servicePath, "com.nokia.csd.CSNet.NetworkOperator", systemDbusConnection); |
|
497 |
|
498 QVariant mcc = ifc2.property("OperatorMCC"); |
|
499 currentMCC = mcc.isValid() ? mcc.value<QString>() : ""; |
|
500 |
|
501 QVariant mnc = ifc2.property("OperatorMNC"); |
|
502 currentMNC = mnc.isValid() ? mnc.value<QString>() : ""; |
|
503 |
|
504 QVariant operatorName = ifc2.property("OperatorName"); |
|
505 currentOperatorName = operatorName.isValid() ? operatorName.value<QString>() : ""; |
|
506 |
|
507 /* CSD: signal strength */ |
|
508 QDBusInterface ifc3(service, servicePath, "com.nokia.csd.CSNet.SignalStrength", systemDbusConnection); |
|
509 |
|
510 QVariant signalStrength = ifc3.property("SignalPercent"); |
|
511 cellSignalStrength = signalStrength.isValid() ? signalStrength.value<int>() : -1; |
|
512 |
|
513 /* CSD: network registration */ |
|
514 QDBusInterface ifc4(service, servicePath, "com.nokia.csd.CSNet.NetworkRegistration", systemDbusConnection); |
|
515 |
|
516 QVariant registrationStatus = ifc4.property("RegistrationStatus"); |
|
517 QString status = registrationStatus.isValid() ? registrationStatus.value<QString>() : ""; |
|
518 |
|
519 if (status == "Home") { |
|
520 currentCellNetworkStatus = QSystemNetworkInfo::HomeNetwork; |
|
521 } else if (status == "Roaming") { |
|
522 currentCellNetworkStatus = QSystemNetworkInfo::Roaming; |
|
523 } else if (status == "Searching") { |
|
524 currentCellNetworkStatus = QSystemNetworkInfo::Searching; |
|
525 } else if (status == "Offline" || status == "NoSim" || status == "PowerOff" || status == "PowerSave" || status == "NoCoverage") { |
|
526 currentCellNetworkStatus = QSystemNetworkInfo::NoNetworkAvailable; |
|
527 } else if (status == "Rejected") { |
|
528 currentCellNetworkStatus = QSystemNetworkInfo::Denied; |
|
529 } else { |
|
530 currentCellNetworkStatus = QSystemNetworkInfo::UndefinedStatus; |
|
531 } |
|
532 |
|
533 /* Signal handlers */ |
|
534 if (!systemDbusConnection.connect(service, servicePath, "com.nokia.csd.CSNet.SignalStrength", "SignalStrengthChanged", |
|
535 this, SLOT(slotSignalStrengthChanged(int, int)))) { |
|
536 qDebug() << "unable to connect SignalStrengthChanged"; |
|
537 } |
|
538 if (!systemDbusConnection.connect(service, servicePath, "com.nokia.csd.CSNet.NetworkOperator", "OperatorChanged", |
|
539 this, SLOT(slotOperatorChanged(const QString&,const QString&)))) { |
|
540 qDebug() << "unable to connect (OperatorChanged"; |
|
541 } |
|
542 if (!systemDbusConnection.connect(service, servicePath, "com.nokia.csd.CSNet.NetworkOperator", "OperatorNameChanged", |
|
543 this, SLOT(slotOperatorNameChanged(const QString&)))) { |
|
544 qDebug() << "unable to connect OperatorNameChanged"; |
|
545 } |
|
546 if (!systemDbusConnection.connect(service, servicePath, "com.nokia.csd.CSNet.NetworkRegistration", "RegistrationChanged", |
|
547 this, SLOT(slotRegistrationChanged(const QString&)))) { |
|
548 qDebug() << "unable to connect RegistrationChanged"; |
|
549 } |
|
550 if (!systemDbusConnection.connect(service, servicePath, "com.nokia.csd.CSNet.NetworkCell", "CellChanged", |
|
551 this, SLOT(slotCellChanged(const QString&,int,int)))) { |
|
552 qDebug() << "unable to connect CellChanged"; |
|
553 } |
|
554 #else |
|
555 /* Maemo 5 */ |
463 QDBusInterface connectionInterface("com.nokia.phone.net", |
556 QDBusInterface connectionInterface("com.nokia.phone.net", |
464 "/com/nokia/phone/net", |
557 "/com/nokia/phone/net", |
465 "Phone.Net", |
558 "Phone.Net", |
466 systemDbusConnection); |
559 systemDbusConnection); |
467 if (!connectionInterface.isValid()) { |
560 if (!connectionInterface.isValid()) { |
569 qWarning() << "unable to connect to bluetoothNetworkStatusCheck (2)"; |
664 qWarning() << "unable to connect to bluetoothNetworkStatusCheck (2)"; |
570 } |
665 } |
571 #endif |
666 #endif |
572 } |
667 } |
573 |
668 |
574 void QSystemNetworkInfoPrivate::cellNetworkSignalStrengthChanged(uchar var1, uchar) |
669 #if defined(Q_WS_MAEMO_6) |
|
670 // Slots only available in Maemo6 |
|
671 |
|
672 void QSystemNetworkInfoPrivate::slotSignalStrengthChanged(int percent, int /*dbm*/) |
575 { |
673 { |
576 QSystemNetworkInfo::NetworkMode mode = QSystemNetworkInfo::UnknownMode; |
674 QSystemNetworkInfo::NetworkMode mode = QSystemNetworkInfo::UnknownMode; |
577 cellSignalStrength = var1; |
675 cellSignalStrength = percent; |
578 |
676 |
579 if (radioAccessTechnology == 1) |
677 if (radioAccessTechnology == 1) |
580 mode = QSystemNetworkInfo::GsmMode; |
678 mode = QSystemNetworkInfo::GsmMode; |
581 if (radioAccessTechnology == 2) |
679 if (radioAccessTechnology == 2) |
582 mode = QSystemNetworkInfo::WcdmaMode; |
680 mode = QSystemNetworkInfo::WcdmaMode; |
583 |
681 |
584 if (mode != QSystemNetworkInfo::UnknownMode) |
682 if (mode != QSystemNetworkInfo::UnknownMode) |
585 emit networkSignalStrengthChanged(mode, cellSignalStrength); |
683 emit networkSignalStrengthChanged(mode, cellSignalStrength); |
586 } |
684 } |
587 |
685 |
588 void QSystemNetworkInfoPrivate::networkModeChanged(int newRadioAccessTechnology) |
686 void QSystemNetworkInfoPrivate::slotOperatorChanged(const QString &mnc, const QString &mcc) |
589 { |
687 { |
590 QSystemNetworkInfo::NetworkMode newMode = QSystemNetworkInfo::UnknownMode; |
688 if (currentMCC != mcc) { |
591 radioAccessTechnology = newRadioAccessTechnology; |
689 currentMCC = mcc; |
592 |
690 emit currentMobileCountryCodeChanged(currentMCC); |
593 if (radioAccessTechnology == 1) |
691 } |
594 newMode = QSystemNetworkInfo::GsmMode; |
692 if (currentMNC != mnc) { |
595 if (radioAccessTechnology == 2) |
693 currentMNC = mnc; |
596 newMode = QSystemNetworkInfo::WcdmaMode; |
694 emit currentMobileNetworkCodeChanged(currentMNC); |
597 |
695 } |
598 if (newMode != QSystemNetworkInfo::UnknownMode) |
696 } |
599 emit networkModeChanged(newMode); |
697 |
600 } |
698 void QSystemNetworkInfoPrivate::slotOperatorNameChanged(const QString &name) |
601 |
|
602 void QSystemNetworkInfoPrivate::operatorNameChanged(uchar, QString name, QString, uint, uint) |
|
603 { |
699 { |
604 currentOperatorName = name; |
700 currentOperatorName = name; |
605 if (radioAccessTechnology == 1) |
701 if (radioAccessTechnology == 1) |
606 emit networkNameChanged(QSystemNetworkInfo::GsmMode, currentOperatorName); |
702 emit networkNameChanged(QSystemNetworkInfo::GsmMode, currentOperatorName); |
607 if (radioAccessTechnology == 2) |
703 if (radioAccessTechnology == 2) |
608 emit networkNameChanged(QSystemNetworkInfo::WcdmaMode, currentOperatorName); |
704 emit networkNameChanged(QSystemNetworkInfo::WcdmaMode, currentOperatorName); |
609 } |
705 } |
610 |
706 |
611 void QSystemNetworkInfoPrivate::registrationStatusChanged(uchar var1, ushort var2, uint var3, uint var4, uint var5, uchar, uchar) |
707 void QSystemNetworkInfoPrivate::slotRegistrationChanged(const QString &status) |
612 { |
708 { |
613 int newCellNetworkStatus = var1; |
709 int newCellNetworkStatus = -1; |
614 int newLac = var2; |
710 |
615 int newCellId = var3; |
711 if (status == "Home") { |
616 QString newMobileCountryCode; |
712 newCellNetworkStatus = QSystemNetworkInfo::HomeNetwork; |
617 QString newMobileNetworkCode; |
713 } else if (status == "Roaming") { |
618 newMobileCountryCode.setNum(var4); |
714 newCellNetworkStatus = QSystemNetworkInfo::Roaming; |
619 newMobileNetworkCode.setNum(var5); |
715 } else if (status == "Searching") { |
|
716 newCellNetworkStatus = QSystemNetworkInfo::Searching; |
|
717 } else if (status == "Offline" || status == "NoSim" || status == "PowerOff" || status == "PowerSave" || status == "NoCoverage") { |
|
718 newCellNetworkStatus = QSystemNetworkInfo::NoNetworkAvailable; |
|
719 } else if (status == "Rejected") { |
|
720 newCellNetworkStatus = QSystemNetworkInfo::Denied; |
|
721 } else { |
|
722 newCellNetworkStatus = QSystemNetworkInfo::UndefinedStatus; |
|
723 } |
620 |
724 |
621 if (currentCellNetworkStatus != newCellNetworkStatus) { |
725 if (currentCellNetworkStatus != newCellNetworkStatus) { |
622 currentCellNetworkStatus = newCellNetworkStatus; |
726 currentCellNetworkStatus = newCellNetworkStatus; |
623 if (radioAccessTechnology == 1) |
727 if (radioAccessTechnology == 1) |
624 emit networkStatusChanged(QSystemNetworkInfo::GsmMode, |
728 emit networkStatusChanged(QSystemNetworkInfo::GsmMode, |
625 networkStatus(QSystemNetworkInfo::GsmMode)); |
729 networkStatus(QSystemNetworkInfo::GsmMode)); |
626 if (radioAccessTechnology == 2) |
730 if (radioAccessTechnology == 2) |
627 emit networkStatusChanged(QSystemNetworkInfo::WcdmaMode, |
731 emit networkStatusChanged(QSystemNetworkInfo::WcdmaMode, |
628 networkStatus(QSystemNetworkInfo::WcdmaMode)); |
732 networkStatus(QSystemNetworkInfo::WcdmaMode)); |
629 } |
733 } |
|
734 } |
|
735 |
|
736 void QSystemNetworkInfoPrivate::slotCellChanged(const QString &type, int id, int lac) |
|
737 { |
|
738 QSystemNetworkInfo::NetworkMode mode = QSystemNetworkInfo::UnknownMode; |
|
739 int newRadioAccessTechnology = 0; |
|
740 if (type == "GSM") { |
|
741 mode = QSystemNetworkInfo::GsmMode; |
|
742 newRadioAccessTechnology = 1; |
|
743 } else if (type == "WCDMA") { |
|
744 mode = QSystemNetworkInfo::WcdmaMode; |
|
745 newRadioAccessTechnology = 2; |
|
746 } |
|
747 |
|
748 if (newRadioAccessTechnology != radioAccessTechnology) { |
|
749 radioAccessTechnology = newRadioAccessTechnology; |
|
750 emit networkModeChanged(mode); |
|
751 } |
|
752 if (currentCellId != id) { |
|
753 currentCellId = id; |
|
754 } |
|
755 if (currentLac != lac) { |
|
756 currentLac = lac; |
|
757 } |
|
758 } |
|
759 |
|
760 #endif /* Maemo 6 */ |
|
761 |
|
762 #if defined(Q_WS_MAEMO_5) |
|
763 // Slots only available in Maemo5 |
|
764 |
|
765 void QSystemNetworkInfoPrivate::cellNetworkSignalStrengthChanged(uchar var1, uchar) |
|
766 { |
|
767 QSystemNetworkInfo::NetworkMode mode = QSystemNetworkInfo::UnknownMode; |
|
768 cellSignalStrength = var1; |
|
769 |
|
770 if (radioAccessTechnology == 1) |
|
771 mode = QSystemNetworkInfo::GsmMode; |
|
772 if (radioAccessTechnology == 2) |
|
773 mode = QSystemNetworkInfo::WcdmaMode; |
|
774 |
|
775 if (mode != QSystemNetworkInfo::UnknownMode) |
|
776 emit networkSignalStrengthChanged(mode, cellSignalStrength); |
|
777 } |
|
778 |
|
779 void QSystemNetworkInfoPrivate::networkModeChanged(int newRadioAccessTechnology) |
|
780 { |
|
781 QSystemNetworkInfo::NetworkMode newMode = QSystemNetworkInfo::UnknownMode; |
|
782 radioAccessTechnology = newRadioAccessTechnology; |
|
783 |
|
784 if (radioAccessTechnology == 1) |
|
785 newMode = QSystemNetworkInfo::GsmMode; |
|
786 if (radioAccessTechnology == 2) |
|
787 newMode = QSystemNetworkInfo::WcdmaMode; |
|
788 |
|
789 if (newMode != QSystemNetworkInfo::UnknownMode) |
|
790 emit networkModeChanged(newMode); |
|
791 } |
|
792 |
|
793 void QSystemNetworkInfoPrivate::operatorNameChanged(uchar, QString name, QString, uint, uint) |
|
794 { |
|
795 currentOperatorName = name; |
|
796 if (radioAccessTechnology == 1) |
|
797 emit networkNameChanged(QSystemNetworkInfo::GsmMode, currentOperatorName); |
|
798 if (radioAccessTechnology == 2) |
|
799 emit networkNameChanged(QSystemNetworkInfo::WcdmaMode, currentOperatorName); |
|
800 } |
|
801 |
|
802 void QSystemNetworkInfoPrivate::registrationStatusChanged(uchar var1, ushort var2, uint var3, uint var4, uint var5, uchar, uchar) |
|
803 { |
|
804 int newCellNetworkStatus = var1; |
|
805 int newLac = var2; |
|
806 int newCellId = var3; |
|
807 QString newMobileCountryCode; |
|
808 QString newMobileNetworkCode; |
|
809 newMobileCountryCode.setNum(var4); |
|
810 newMobileNetworkCode.setNum(var5); |
|
811 |
|
812 if (currentCellNetworkStatus != newCellNetworkStatus) { |
|
813 currentCellNetworkStatus = newCellNetworkStatus; |
|
814 if (radioAccessTechnology == 1) |
|
815 emit networkStatusChanged(QSystemNetworkInfo::GsmMode, |
|
816 networkStatus(QSystemNetworkInfo::GsmMode)); |
|
817 if (radioAccessTechnology == 2) |
|
818 emit networkStatusChanged(QSystemNetworkInfo::WcdmaMode, |
|
819 networkStatus(QSystemNetworkInfo::WcdmaMode)); |
|
820 } |
630 if (currentLac != newLac) { |
821 if (currentLac != newLac) { |
631 currentLac = newLac; |
822 currentLac = newLac; |
632 } |
823 } |
633 if (currentCellId != newCellId) { |
824 if (currentCellId != newCellId) { |
634 currentCellId = newCellId; |
825 currentCellId = newCellId; |
815 return QSystemDeviceInfo::UnknownProfile; |
1008 return QSystemDeviceInfo::UnknownProfile; |
816 } |
1009 } |
817 |
1010 |
818 QString QSystemDeviceInfoPrivate::imei() |
1011 QString QSystemDeviceInfoPrivate::imei() |
819 { |
1012 { |
820 #if !defined(QT_NO_DBUS) |
1013 #if !defined(QT_NO_DBUS) |
821 QDBusInterface connectionInterface("com.nokia.phone.SIM", |
1014 #if defined(Q_WS_MAEMO_6) |
|
1015 QString dBusService = "com.nokia.csd.Info"; |
|
1016 #else |
|
1017 /* Maemo 5 */ |
|
1018 QString dBusService = "com.nokia.phone.SIM"; |
|
1019 #endif |
|
1020 QDBusInterface connectionInterface(dBusService, |
822 "/com/nokia/csd/info", |
1021 "/com/nokia/csd/info", |
823 "com.nokia.csd.Info", |
1022 "com.nokia.csd.Info", |
824 QDBusConnection::systemBus()); |
1023 QDBusConnection::systemBus()); |
825 if(!connectionInterface.isValid()) { |
|
826 qWarning() << "interfacenot valid"; |
|
827 } |
|
828 |
|
829 QDBusReply< QString > reply = connectionInterface.call("GetIMEINumber"); |
1024 QDBusReply< QString > reply = connectionInterface.call("GetIMEINumber"); |
830 return reply.value(); |
1025 return reply.value(); |
831 |
1026 #endif |
832 #endif |
1027 return ""; |
833 return "Not Available"; |
|
834 } |
1028 } |
835 |
1029 |
836 QString QSystemDeviceInfoPrivate::imsi() |
1030 QString QSystemDeviceInfoPrivate::imsi() |
837 { |
1031 { |
|
1032 #if defined(Q_WS_MAEMO_6) |
|
1033 /* Maemo 6 */ |
|
1034 #if !defined(QT_NO_DBUS) |
|
1035 QDBusInterface connectionInterface("com.nokia.csd.SIM", |
|
1036 "/com/nokia/csd/sim", |
|
1037 "com.nokia.csd.SIM.Identity", |
|
1038 QDBusConnection::systemBus()); |
|
1039 QDBusReply< QString > reply = connectionInterface.call("GetIMSI"); |
|
1040 return reply.value(); |
|
1041 #endif |
|
1042 return ""; |
|
1043 #else |
|
1044 /* Maemo 5 */ |
838 return GConfItem("/system/nokia/location/sim_imsi").value().toString(); |
1045 return GConfItem("/system/nokia/location/sim_imsi").value().toString(); |
|
1046 #endif |
839 } |
1047 } |
840 |
1048 |
841 QSystemDeviceInfo::SimStatus QSystemDeviceInfoPrivate::simStatus() |
1049 QSystemDeviceInfo::SimStatus QSystemDeviceInfoPrivate::simStatus() |
842 { |
1050 { |
843 GConfItem locationValues("/system/nokia/location"); |
1051 QSystemDeviceInfo::SimStatus simStatus = QSystemDeviceInfo::SimNotAvailable; |
844 const QStringList locationKeys = locationValues.listEntries(); |
1052 QString imsi = QSystemDeviceInfoPrivate::imsi(); |
845 QStringList result; |
1053 if (imsi.length() > 0) { |
846 int count = 0; |
1054 simStatus = QSystemDeviceInfo::SingleSimAvailable; |
847 foreach (const QString str, locationKeys) { |
1055 } |
848 if (str.contains("sim_imsi")) |
1056 return simStatus; |
849 count++; |
|
850 } |
|
851 |
|
852 if(count == 1) { |
|
853 return QSystemDeviceInfo::SingleSimAvailable; |
|
854 } else if (count == 2) { |
|
855 return QSystemDeviceInfo::DualSimAvailable; |
|
856 } |
|
857 return QSystemDeviceInfo::SimNotAvailable; |
|
858 } |
1057 } |
859 |
1058 |
860 bool QSystemDeviceInfoPrivate::isDeviceLocked() |
1059 bool QSystemDeviceInfoPrivate::isDeviceLocked() |
861 { |
1060 { |
862 #if !defined(QT_NO_DBUS) |
1061 #if !defined(QT_NO_DBUS) |