774 if ( aTotalSilent ) |
791 if ( aTotalSilent ) |
775 { |
792 { |
776 // from back ground checker, choose the IAP to make the internet access silent |
793 // from back ground checker, choose the IAP to make the internet access silent |
777 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin"); |
794 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin"); |
778 |
795 |
779 uint connectionMethodId( 0 ); |
796 uint connectionMethodId( 0 ); |
780 int connMethodId( 0 ); |
797 int connMethodId( 0 ); |
781 |
798 |
782 // Let's first check whether cenrep contains SNAP id other than zero |
799 // Let's first check whether cenrep contains SNAP id other than zero |
783 CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) ); |
800 CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) ); |
784 User::LeaveIfError( |
801 User::LeaveIfError( |
785 cenrep->Get( KIAUpdateAccessPoint, connMethodId ) ); |
802 cenrep->Get( KIAUpdateAccessPoint, connMethodId ) ); |
786 CleanupStack::PopAndDestroy( cenrep ); |
803 CleanupStack::PopAndDestroy( cenrep ); |
787 cenrep = NULL; |
804 cenrep = NULL; |
788 |
805 |
789 RCmManagerExt cmManagerExt; |
806 RCmManagerExt cmManagerExt; |
790 cmManagerExt.OpenL(); |
807 cmManagerExt.OpenL(); |
791 CleanupClosePushL( cmManagerExt ); |
808 CleanupClosePushL( cmManagerExt ); |
792 |
809 |
793 if ( connMethodId == -1 ) |
810 if ( connMethodId == -1 ) |
794 { |
811 { |
795 IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic"); |
812 IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic"); |
796 |
813 |
797 //check what is the default connection by users |
814 //check what is the default connection by users |
798 |
815 |
799 TCmDefConnValue DCSetting; |
816 TCmDefConnValue DCSetting; |
800 cmManagerExt.ReadDefConnL( DCSetting ); |
817 cmManagerExt.ReadDefConnL( DCSetting ); |
801 |
|
802 |
818 |
803 switch ( DCSetting.iType ) |
819 switch ( DCSetting.iType ) |
804 { |
820 { |
805 case ECmDefConnAlwaysAsk: |
821 case ECmDefConnAlwaysAsk: |
806 case ECmDefConnAskOnce: |
822 case ECmDefConnAskOnce: |
807 { |
823 { |
808 //go with the best IAP under internet snap |
824 //go with the best IAP under internet snap |
809 connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt ); |
825 connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt ); |
810 break; |
826 break; |
811 } |
827 } |
812 case ECmDefConnDestination: |
828 case ECmDefConnDestination: |
813 { |
829 { |
814 //go with the best IAP under this snap |
830 //go with the best IAP under this snap |
815 connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId ); |
831 connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, DCSetting.iId ); |
816 break; |
832 break; |
817 } |
833 } |
818 case ECmDefConnConnectionMethod: |
834 case ECmDefConnConnectionMethod: |
819 { |
835 { |
820 //go with the best IAP under this snap |
836 //go with the best IAP under this snap |
821 connectionMethodId = DCSetting.iId; |
837 connectionMethodId = DCSetting.iId; |
822 break; |
838 break; |
823 } |
839 } |
824 } |
840 } |
825 } |
841 } |
826 else if ( connMethodId == 0 ) |
842 else if ( connMethodId == 0 ) |
827 { |
843 { |
828 //no choice from user, we go with the best IAP under Internent SNAP |
844 //no choice from user, we go with the best IAP under Internent SNAP |
829 connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt ); |
845 connectionMethodId = GetBestIAPInAllSNAPsL( cmManagerExt ); |
830 } |
846 } |
831 else |
847 else |
832 { |
848 { |
833 IAUPDATE_TRACE("[IAUPDATE] use chooses a snap"); |
849 IAUPDATE_TRACE("[IAUPDATE] use chooses a snap"); |
834 // It was some SNAP value |
850 // It was some SNAP value |
835 connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId ); |
851 connectionMethodId = GetBestIAPInThisSNAPL( cmManagerExt, connMethodId ); |
836 } |
852 } |
837 |
853 |
838 CleanupStack::PopAndDestroy( &cmManagerExt ); |
854 CleanupStack::PopAndDestroy( &cmManagerExt ); |
839 |
855 |
840 if ( connectionMethodId != 0 ) |
856 if ( connectionMethodId != 0 ) |
841 { |
857 { |
842 TIAUpdateConnectionMethod connectionMethod( |
858 TIAUpdateConnectionMethod connectionMethod( |
843 connectionMethodId, |
859 connectionMethodId, |
844 TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint ); |
860 TIAUpdateConnectionMethod::EConnectionMethodTypeAccessPoint ); |
845 |
861 |
846 iController->SetDefaultConnectionMethodL( connectionMethod ); |
862 iController->SetDefaultConnectionMethodL( connectionMethod ); |
847 } |
863 } |
848 else |
864 else |
849 { |
865 { |
850 //In the totally silent case, if no usable IAP, we complete the check update with 0 updates. |
866 //In the totally silent case, if no usable IAP, we complete the check update with 0 updates. |
851 //the bgchecker will try again later after 1 month. |
867 //the bgchecker will try again later after 1 month. |
852 //The LEAVE will be catched up later and complete the request from background checker. |
868 //The LEAVE will be catched up later and complete the request from background checker. |
853 User::LeaveIfError( KErrNotFound ); |
869 User::LeaveIfError( KErrNotFound ); |
854 |
870 } |
855 //the following code will pop up dialog to ask from user, just for proto |
871 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end"); |
856 /* connectionMethodId = 0; |
|
857 TIAUpdateConnectionMethod connectionMethod( |
|
858 connectionMethodId, TIAUpdateConnectionMethod::EConnectionMethodTypeDefault ); |
|
859 |
|
860 iController->SetDefaultConnectionMethodL( connectionMethod );*/ |
|
861 } |
|
862 |
|
863 |
|
864 |
|
865 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end"); |
|
866 } |
872 } |
867 else |
873 else |
868 { |
874 { |
869 // from grid, use the old logic |
875 // from grid, use the old logic |
870 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin"); |
876 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() begin"); |
871 uint connectionMethodId( 0 ); |
877 uint connectionMethodId( 0 ); |
872 int connMethodId( 0 ); |
878 int connMethodId( 0 ); |
873 |
879 |
874 // Set initial value to always ask |
880 // Set initial value to always ask |
875 int connectionMethodType( TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk ); |
881 int connectionMethodType( TIAUpdateConnectionMethod::EConnectionMethodTypeAlwaysAsk ); |
876 bool needSaving(false); |
882 bool needSaving(false); |
877 |
883 |
878 // Let's first check whether cenrep contains SNAP id other than zero |
884 // Let's first check whether cenrep contains SNAP id other than zero |
879 CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) ); |
885 CRepository* cenrep( CRepository::NewLC( KCRUidIAUpdateSettings ) ); |
880 User::LeaveIfError( |
886 User::LeaveIfError( |
881 cenrep->Get( KIAUpdateAccessPoint, connMethodId ) ); |
887 cenrep->Get( KIAUpdateAccessPoint, connMethodId ) ); |
882 CleanupStack::PopAndDestroy( cenrep ); |
888 CleanupStack::PopAndDestroy( cenrep ); |
883 cenrep = NULL; |
889 cenrep = NULL; |
884 |
890 |
885 if ( connMethodId == -1 ) |
891 if ( connMethodId == -1 ) |
886 { |
892 { |
887 IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic"); |
893 IAUPDATE_TRACE("[IAUPDATE] user chooses default connection, use IAP logic"); |
888 |
894 |
889 connectionMethodId = 0; |
895 connectionMethodId = 0; |
890 connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault; |
896 connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDefault; |
891 } |
897 } |
892 else if ( connMethodId == 0 ) |
898 else if ( connMethodId == 0 ) |
893 { |
899 { |
894 |
900 IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic"); |
895 IAUPDATE_TRACE("[IAUPDATE] use chooses nothing, use internal IAP logic"); |
901 //if nothing is set by user, use our new logic |
896 //if nothing is set by user, use our new logic |
902 //SetDefaultConnectionMethod2L(); |
897 //SetDefaultConnectionMethod2L(); |
903 //return; |
898 //return; |
904 // CenRep didn't contain any SNAP id. Let's try Internet SNAP then. |
899 // CenRep didn't contain any SNAP id. Let's try Internet SNAP then. |
|
900 |
905 |
901 RCmManagerExt cmManagerExt; |
906 RCmManagerExt cmManagerExt; |
902 cmManagerExt.OpenL(); |
907 cmManagerExt.OpenL(); |
903 CleanupClosePushL( cmManagerExt ); |
908 CleanupClosePushL( cmManagerExt ); |
904 iDestIdArray.Reset(); |
909 iDestIdArray.Reset(); |
905 cmManagerExt.AllDestinationsL( iDestIdArray ); |
910 cmManagerExt.AllDestinationsL( iDestIdArray ); |
906 |
911 |
907 for ( int i = 0; i< iDestIdArray.Count(); i++ ) |
912 for ( int i = 0; i< iDestIdArray.Count(); i++ ) |
908 { |
913 { |
909 RCmDestinationExt dest = cmManagerExt.DestinationL( iDestIdArray[i] ); |
914 RCmDestinationExt dest = cmManagerExt.DestinationL( iDestIdArray[i] ); |
910 CleanupClosePushL( dest ); |
915 CleanupClosePushL( dest ); |
911 |
916 |
912 if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) ) |
917 if ( dest.MetadataL( CMManager::ESnapMetadataInternet ) ) |
913 { |
918 { |
914 // Check whether Internet SNAP contains any IAP. |
919 // Check whether Internet SNAP contains any IAP. |
915 if ( dest.ConnectionMethodCount() > 0 ) |
920 if ( dest.ConnectionMethodCount() > 0 ) |
916 { |
921 { |
917 connectionMethodId = iDestIdArray[i]; |
922 connectionMethodId = iDestIdArray[i]; |
918 needSaving = true; |
923 needSaving = true; |
919 IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId ); |
924 IAUPDATE_TRACE_1("[IAUPDATE] connectionMethodId: %d", connectionMethodId ); |
920 } |
925 } |
921 CleanupStack::PopAndDestroy( &dest ); |
926 CleanupStack::PopAndDestroy( &dest ); |
922 break; |
927 break; |
923 } |
928 } |
924 |
929 |
925 CleanupStack::PopAndDestroy( &dest ); |
930 CleanupStack::PopAndDestroy( &dest ); |
926 } |
931 } |
927 iDestIdArray.Reset(); |
932 iDestIdArray.Reset(); |
928 CleanupStack::PopAndDestroy( &cmManagerExt ); |
933 CleanupStack::PopAndDestroy( &cmManagerExt ); |
929 } |
934 } |
930 else |
935 else |
931 { |
936 { |
932 IAUPDATE_TRACE("[IAUPDATE] use chooses a snap"); |
937 IAUPDATE_TRACE("[IAUPDATE] use chooses a snap"); |
933 // It was some SNAP value |
938 // It was some SNAP value |
934 connectionMethodId = connMethodId; |
939 connectionMethodId = connMethodId; |
935 } |
940 } |
936 |
941 |
937 if ( connectionMethodId > 0) |
942 if ( connectionMethodId > 0) |
938 { |
943 { |
939 // We have now some valid SNAP id, either from CenRep or Internet SNAP |
944 // We have now some valid SNAP id, either from CenRep or Internet SNAP |
940 connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination; |
945 connectionMethodType = TIAUpdateConnectionMethod::EConnectionMethodTypeDestination; |
941 // Save to cenrep if needed |
946 // Save to cenrep if needed |
942 if ( needSaving ) |
947 if ( needSaving ) |
943 { |
948 { |
944 cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
949 cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
945 int err = cenrep->StartTransaction( CRepository::EReadWriteTransaction ); |
950 int err = cenrep->StartTransaction( CRepository::EReadWriteTransaction ); |
946 User::LeaveIfError( err ); |
951 User::LeaveIfError( err ); |
947 cenrep->CleanupCancelTransactionPushL(); |
952 cenrep->CleanupCancelTransactionPushL(); |
948 |
953 |
949 connMethodId = connectionMethodId; |
954 connMethodId = connectionMethodId; |
950 err = cenrep->Set( KIAUpdateAccessPoint, connMethodId ); |
955 err = cenrep->Set( KIAUpdateAccessPoint, connMethodId ); |
951 User::LeaveIfError( err ); |
956 User::LeaveIfError( err ); |
952 TUint32 ignore = KErrNone; |
957 TUint32 ignore = KErrNone; |
953 User::LeaveIfError( cenrep->CommitTransaction( ignore ) ); |
958 User::LeaveIfError( cenrep->CommitTransaction( ignore ) ); |
954 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL() |
959 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL() |
955 CleanupStack::PopAndDestroy( cenrep ); |
960 CleanupStack::PopAndDestroy( cenrep ); |
956 } |
961 } |
957 } |
962 } |
958 |
963 |
959 TIAUpdateConnectionMethod connectionMethod( |
964 TIAUpdateConnectionMethod connectionMethod( |
960 connectionMethodId, |
965 connectionMethodId, |
961 static_cast< TIAUpdateConnectionMethod::TConnectionMethodType >( connectionMethodType ) ); |
966 static_cast< TIAUpdateConnectionMethod::TConnectionMethodType >( connectionMethodType ) ); |
962 |
967 |
963 iController->SetDefaultConnectionMethodL( connectionMethod ); |
968 iController->SetDefaultConnectionMethodL( connectionMethod ); |
964 |
969 |
965 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end"); |
970 IAUPDATE_TRACE("[IAUPDATE] IAUpdateEngine::SetDefaultConnectionMethodL() end"); |
966 } |
971 } |
967 |
|
968 } |
972 } |
969 |
973 |
970 |
974 |
971 // --------------------------------------------------------------------------- |
975 // --------------------------------------------------------------------------- |
972 // IAUpdateEngine::GetBestIAPInAllSNAPsL |
976 // IAUpdateEngine::GetBestIAPInAllSNAPsL |