mmshplugins/mmshsettingsuiplugin/src/mussipprofilemodel.cpp
branchRCL_3
changeset 13 a184f3d659e6
parent 2 b31261fd4e04
child 32 73a1feb507fb
equal deleted inserted replaced
11:ff8a573c0e2e 13:a184f3d659e6
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Model for managing SIP profiles.
    14 * Description:  Model for managing SIP profiles.
    15 *  Version     : %version: 16 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: 19 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
       
    20 #include <sipmanagedprofileregistry.h>
       
    21 #include <sipmanagedprofile.h>
    20 
    22 
    21 #include "mussipprofilemodel.h"
    23 #include "mussipprofilemodel.h"
    22 #include "muslogger.h"
    24 #include "muslogger.h"
    23 #include "mussettings.inl"
    25 #include "mussettings.inl"
    24 #include <aknnotewrappers.h>
    26 #include "mussettingsmodel.h"
    25 #include <StringLoader.h>
       
    26 #include <aknview.h>
       
    27 #include <sipmanagedprofileregistry.h>
       
    28 #include <sipmanagedprofile.h>
       
    29 #include <sipprofileregistry.h>
       
    30 #include  "mussettingsmodel.h"
       
    31 
    27 
    32 
    28 
    33 const TInt KUnknownProfileId = 0;
    29 const TInt KUnknownProfileId = 0;
    34 
    30 
    35 /** 
       
    36 * VSC Enable/Disable is of type TBool
       
    37 */
       
    38 const TUint32 KMuSVSCDisable = 200;
       
    39 
       
    40 
    31 
    41 // ======== MEMBER FUNCTIONS ========
    32 // ======== MEMBER FUNCTIONS ========
    42 
    33 
    43 
    34 
    44 // ----------------------------------------------------------------------------
    35 // ----------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------
    45 // ----------------------------------------------------------------------------
    55 //
    46 //
    56 void CMusSIPProfileModel::ConstructL()
    47 void CMusSIPProfileModel::ConstructL()
    57     {
    48     {
    58     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" )
    49     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" )
       
    50             
       
    51     MUS_LOG( "[MUSSET]  Creating CSIPManagedProfileRegistry " )
    59     iEngine = CSIPManagedProfileRegistry::NewL( *this );
    52     iEngine = CSIPManagedProfileRegistry::NewL( *this );
       
    53     MUS_LOG( "[MUSSET]  Done " )
       
    54     MUS_LOG( "[MUSSET]  Getting profiles " )
    60     iEngine->ProfilesL( iProfiles );
    55     iEngine->ProfilesL( iProfiles );
       
    56     MUS_LOG( "[MUSSET]  Done " )
    61     SortProfilesL();
    57     SortProfilesL();
       
    58     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ConstructL()" )
    62     }
    59     }
    63 
    60 
    64 // ----------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------
    65 // 
    62 // 
    66 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
   141         {
   138         {
   142         TBool defProfile( EFalse );
   139         TBool defProfile( EFalse );
   143         TInt error = iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile );
   140         TInt error = iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile );
   144         if ( error == KErrNone && defProfile )
   141         if ( error == KErrNone && defProfile )
   145             {
   142             {
   146         	iProfiles[i]->GetParameter( KSIPProfileId, id );
   143             iProfiles[i]->GetParameter( KSIPProfileId, id );
   147         	break;
   144             break;
   148             }
   145             }
   149         }
   146         }
   150 
   147 
   151     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )",
   148     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )",
   152               id )
   149               id )
   161     {
   158     {
   162     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::DisableProfileL " )        
   159     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::DisableProfileL " )        
   163     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   160     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   164             iEngine->ProfileL( DefaultProfileId()) );
   161             iEngine->ProfileL( DefaultProfileId()) );
   165     CleanupStack::PushL( managedProfile );
   162     CleanupStack::PushL( managedProfile );
   166     //Disable registration from profile.dat file
   163     MUS_LOG( "[MUSSET]  Add registration parameter to profile.dat file " )
   167     MUS_LOG( "Add registration parameter profile.dat file " )
   164     //set autoregistration off (i.e. when needed) => disable profile
   168     TInt err = managedProfile->SetParameter( KMuSVSCDisable, (TBool)ETrue );
   165     User::LeaveIfError( managedProfile->SetParameter( KSIPAutoRegistration, EFalse ) );
   169     User::LeaveIfError(err);
   166     MUS_LOG( "[MUSSET]  Saving profile " )
   170     iEngine->SaveL( *managedProfile );
   167     iEngine->SaveL( *managedProfile );
       
   168     MUS_LOG( "[MUSSET]  Saved" )
   171     CleanupStack::PopAndDestroy( managedProfile );
   169     CleanupStack::PopAndDestroy( managedProfile );
   172     MUS_LOG( "[MUSSET]  <- CMusAvaRegisterAvailability::DisableProfileL " )        
   170     MUS_LOG( "[MUSSET]  <- CMusSIPProfileModel::DisableProfileL " )        
   173     }
   171     }
   174 
   172 
   175 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   176 // Enable SIP Registration.
   174 // Enable SIP Registration.
   177 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   180     {
   178     {
   181     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::EnableProfileL " )        
   179     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::EnableProfileL " )        
   182     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   180     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   183             iEngine->ProfileL( DefaultProfileId() ) );
   181             iEngine->ProfileL( DefaultProfileId() ) );
   184     CleanupStack::PushL( managedProfile );
   182     CleanupStack::PushL( managedProfile );
   185     //Disable registration from profile.dat file
   183     MUS_LOG( "[MUSSET] Add registration parameters to profile.dat file " )
   186     MUS_LOG( "Add registration parameter profile.dat file " )
   184     //set autoregistration on (i.e. always on) => enable profile
   187     TInt err = managedProfile->SetParameter( KMuSVSCDisable, (TBool)EFalse );
   185     User::LeaveIfError( managedProfile->SetParameter( KSIPAutoRegistration, ETrue ) );
   188     User::LeaveIfError(err);
   186     MUS_LOG( "[MUSSET]  Saving profile " )
   189     iEngine->SaveL( *managedProfile );
   187     iEngine->SaveL( *managedProfile );
       
   188     MUS_LOG( "[MUSSET]  Saved" )
   190     CleanupStack::PopAndDestroy( managedProfile );
   189     CleanupStack::PopAndDestroy( managedProfile );
   191     MUS_LOG( "[MUSSET]  <- CMusAvaRegisterAvailability::EnableRegisterL " )        
   190     MUS_LOG( "[MUSSET]  <- CMusSIPProfileModel::EnableRegisterL " )        
   192     }
   191     }
   193 
   192 
   194 // -----------------------------------------------------------------------------
   193 // -----------------------------------------------------------------------------
   195 // if SIP Registration enabled.
   194 // if SIP Registration enabled.
   196 // -----------------------------------------------------------------------------
   195 // -----------------------------------------------------------------------------
   199     {
   198     {
   200     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::ProfileEnabledL " ) 
   199     MUS_LOG( "[MUSSET]  -> CMusSIPProfileModel::ProfileEnabledL " ) 
   201     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   200     CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>(
   202             iEngine->ProfileL( DefaultProfileId() ) );
   201             iEngine->ProfileL( DefaultProfileId() ) );
   203     CleanupStack::PushL( managedProfile );
   202     CleanupStack::PushL( managedProfile );
   204     //Activation status from profile.dat file
   203     TBool enabled;
   205     TBool enabled = EFalse;
   204     MUS_LOG( "[MUSSET]  Getting KSIPAutoRegistration" ) 
   206     MUS_LOG( "Get registration parameter from profile.dat file " )
   205     User::LeaveIfError( 
   207     TInt err = managedProfile->GetParameter( KMuSVSCDisable, enabled ); 
   206             managedProfile->GetParameter( KSIPAutoRegistration, enabled ) );
   208     MUS_LOG1( "KMuSVSCDisable value %d )",
   207     MUS_LOG( "[MUSSET]  Done" ) 
   209             enabled )
   208     MUS_LOG1( "[MUSSET]  KSIPAutoRegistration=%d", enabled ) 
   210     CleanupStack::PopAndDestroy( managedProfile );
   209     CleanupStack::PopAndDestroy( managedProfile );
   211     MUS_LOG( "[MUSSET]  <- CMusAvaRegisterAvailability::ProfileEnabledL " )
   210     MUS_LOG( "[MUSSET]  <- CMusSIPProfileModel::ProfileEnabledL " )
   212     return enabled;
   211     return enabled;
   213     }
   212     }
   214 
   213 
   215 // ----------------------------------------------------------------------------
   214 // ----------------------------------------------------------------------------
   216 // Returns index of the default SIP profile on locally cached array. If default
   215 // Returns index of the default SIP profile on locally cached array. If default