mmsharing/mmshengine/src/mussipprofilehandler.cpp
branchRCL_3
changeset 23 bc78a40cd63c
parent 22 73a1feb507fb
equal deleted inserted replaced
22:73a1feb507fb 23:bc78a40cd63c
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Utilities to get and set profile used with SWIS.
    14 * Description:  Utilities to get and set profile used with SWIS.
    15 *  Part of     : Mus For S60 v3.2
       
    16 *  Description : Utilities to get and set profile used with SWIS.
       
    17 *  Version     : %version: 11.1.5 % << Don't touch! Updated by Synergy at check-out.
       
    18 *
    15 *
    19 */
    16 */
    20 
    17 
    21 
    18 
    22 // USER
    19 // USER
    32 #include <sipprofile.h>
    29 #include <sipprofile.h>
    33 #include <sipprofileregistry.h>
    30 #include <sipprofileregistry.h>
    34 #include <sipprofilealrcontroller.h>
    31 #include <sipprofilealrcontroller.h>
    35 #include <uri8.h>
    32 #include <uri8.h>
    36 
    33 
       
    34 
       
    35 
    37 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    38 //
    37 //
    39 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    40 //
    39 //
    41 CMusSipProfileHandler* CMusSipProfileHandler::NewL( MMusSipProfileUser& aUser )
    40 CMusSipProfileHandler* CMusSipProfileHandler::NewL( MMusSipProfileUser& aUser )
    46     self->ConstructL();
    45     self->ConstructL();
    47     CleanupStack::Pop( self);
    46     CleanupStack::Pop( self);
    48     return self;
    47     return self;
    49     }
    48     }
    50 
    49 
       
    50 
    51 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    52 //
    52 //
    53 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    54 //
    54 //
    55 CMusSipProfileHandler::CMusSipProfileHandler( MMusSipProfileUser& aUser )
    55 CMusSipProfileHandler::CMusSipProfileHandler( MMusSipProfileUser& aUser )
    73         CSipProfileAlrController::NewL( *iProfileRegistry , *this );
    73         CSipProfileAlrController::NewL( *iProfileRegistry , *this );
    74     
    74     
    75     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::ConstructL()" )
    75     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::ConstructL()" )
    76     }
    76     }
    77 
    77 
       
    78 
    78 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    79 //
    80 //
    80 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    81 //
    82 //
    82 CMusSipProfileHandler::~CMusSipProfileHandler()
    83 CMusSipProfileHandler::~CMusSipProfileHandler()
    86     delete iProfileRegistry;
    87     delete iProfileRegistry;
    87     delete iSip;
    88     delete iSip;
    88     MUS_LOG( "mus: [ENGINE]     CMusSipProfileHandler::~CMusSipProfileHandler()" )
    89     MUS_LOG( "mus: [ENGINE]     CMusSipProfileHandler::~CMusSipProfileHandler()" )
    89     }
    90     }
    90 
    91 
       
    92 
    91 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    92 //
    94 //
    93 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
    94 //
    96 //
    95 void CMusSipProfileHandler::CreateProfileL( TUint32 aSipProfileId )
    97 void CMusSipProfileHandler::CreateProfileL( TUint32 aSipProfileId )
   101         }
   103         }
   102     else
   104     else
   103         {
   105         {
   104         profile = iProfileRegistry->DefaultProfileL();
   106         profile = iProfileRegistry->DefaultProfileL();
   105         }
   107         }
   106        
   108     CleanupStack::PushL( profile );
       
   109     TBool profileRegistered = EFalse;   
       
   110     User::LeaveIfError( profile->GetParameter( KSIPProfileRegistered,
       
   111                                                    profileRegistered  ) );
       
   112     CleanupStack::Pop( profile );   
   107     delete iSipProfile;
   113     delete iSipProfile;
   108     iSipProfile = profile;
   114     iSipProfile = profile;
   109     }
   115     }
   110 
   116 
       
   117 
   111 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   112 //
   119 //
   113 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   114 //
   121 //
   115 CSIPProfile* CMusSipProfileHandler::Profile()
   122 CSIPProfile* CMusSipProfileHandler::Profile()
   116     {
   123     {
   117     return iSipProfile;
   124     return iSipProfile;
   118     }
   125     }
       
   126 
       
   127 #if 0 //TODO: should this be removed?
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 CSIPProfile& CMusSipProfileHandler::SipProfileL( TInt aSipProfileId )
       
   133     {
       
   134     MUS_LOG1( "mus: [ENGINE]     -> CMusSipProfileHandler::SipProfileL(),\
       
   135               od #%d", aSipProfileId )
       
   136 
       
   137     if ( !iSipProfile )
       
   138         {        
       
   139         if ( aSipProfileId != 0 )
       
   140             {
       
   141             iSipProfile = iProfileRegistry->ProfileL( aSipProfileId );
       
   142             }
       
   143         else
       
   144             {
       
   145             iSipProfile = iProfileRegistry->DefaultProfileL();
       
   146             }
       
   147         }
       
   148 
       
   149     // The parameter val indicates if the profile can be immediately
       
   150     // used for creating a session, or if the client must wait for
       
   151     // the profile to be registered.
       
   152     TBool profileRegistered = EFalse;
       
   153     
       
   154     User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered,
       
   155                                                    profileRegistered  ) );
       
   156                                                        
       
   157     if ( !profileRegistered )
       
   158         {
       
   159 
       
   160         #if (defined (__WINS__) || defined(__WINSCW__))
       
   161         
       
   162         iProfileRegistry->EnableL( *iSipProfile, *this );            
       
   163 
       
   164         User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered,
       
   165                                                        profileRegistered  ) );
       
   166                                                
       
   167         if( !profileRegistered )
       
   168             {
       
   169             CActiveScheduler::Start();
       
   170 
       
   171             User::LeaveIfError( iSipProfile->GetParameter( 
       
   172                                                     KSIPProfileRegistered,
       
   173                                                     profileRegistered  ) );
       
   174             
       
   175             if ( !profileRegistered )
       
   176                 {
       
   177                 User::Leave( KErrNotReady );
       
   178                 }
       
   179             }
       
   180 
       
   181         #else
       
   182 
       
   183         User::Leave( KErrNotReady );
       
   184 
       
   185         #endif
       
   186 
       
   187         }
       
   188     
       
   189         
       
   190     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::SipProfileL()" )
       
   191     
       
   192     return *iSipProfile;
       
   193     }
       
   194 #endif
       
   195 
   119 
   196 
   120 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   121 //
   198 //
   122 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   123 //
   200 //
   127     
   204     
   128     __ASSERT_ALWAYS( iSipProfile != NULL, User::Leave( KErrNotReady ) );
   205     __ASSERT_ALWAYS( iSipProfile != NULL, User::Leave( KErrNotReady ) );
   129 
   206 
   130     const MDesC8Array* aors = NULL;
   207     const MDesC8Array* aors = NULL;
   131     User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) );
   208     User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) );
   132     __ASSERT_ALWAYS( aors && aors->MdcaCount() > 0, 
   209     if( !aors || aors->MdcaCount() <= 0 ) 
   133                      User::Leave( KErrArgument ) );
   210         {    
   134     
   211         User::Leave( KErrArgument );            
       
   212         }
   135     TUriParser8 parser;
   213     TUriParser8 parser;
   136     User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) );
   214     User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) );
   137     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::UserFromProfileLC()" )
   215     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::UserFromProfileLC()" )
   138     
   216     
   139     return CUri8::NewLC( parser );
   217     return CUri8::NewLC( parser );
   149     TRAP_IGNORE( iProfileAlrController->RefreshIapAvailabilityL( ProfileId() ) )
   227     TRAP_IGNORE( iProfileAlrController->RefreshIapAvailabilityL( ProfileId() ) )
   150     }
   228     }
   151 
   229 
   152 
   230 
   153 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   154 // This function should never be called before creating a profile, but such
       
   155 // a situation will be considered as pending registration.
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 TBool CMusSipProfileHandler::IsRegistered()
       
   159     {
       
   160     MUS_LOG( "mus: [ENGINE]  -> CMusSipProfileHandler::IsRegistered()" )
       
   161     
       
   162     TBool profileRegistered = EFalse;   
       
   163     if ( iSipProfile ) 
       
   164         {
       
   165         iSipProfile->GetParameter( KSIPProfileRegistered, profileRegistered  );  
       
   166         }
       
   167     
       
   168     MUS_LOG1( "mus: [ENGINE]  <- CMusSipProfileHandler::IsRegistered( %d )",
       
   169               profileRegistered )
       
   170     
       
   171     return profileRegistered;
       
   172     }
       
   173 
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 //
   232 //
   177 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   178 //
   234 //
   179 void CMusSipProfileHandler::ProfileRegistryEventOccurred(
   235 void CMusSipProfileHandler::ProfileRegistryEventOccurred(
   180     TUint32 aProfileId,
   236     TUint32 /*aProfileId*/,
   181     MSIPProfileRegistryObserver::TEvent aEvent )
   237     MSIPProfileRegistryObserver::TEvent /*aEvent*/ )
   182     {
   238     {
   183     if ( iSipProfile && aProfileId == ProfileId() )
       
   184         {
       
   185         switch ( aEvent )
       
   186             {
       
   187             case MSIPProfileRegistryObserver::EProfileRegistered:
       
   188                 {
       
   189                 iUser.ProfileRegistered();
       
   190                 break;
       
   191                 }
       
   192             default:
       
   193                 {
       
   194                 break;
       
   195                 }
       
   196             }
       
   197         }
       
   198     }
   239     }
   199 
   240 
   200 
   241 
   201 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   202 //
   243 //
   206     TUint32 /*aProfileId*/,
   247     TUint32 /*aProfileId*/,
   207     TInt /*aError*/)
   248     TInt /*aError*/)
   208     {
   249     {
   209     }
   250     }
   210 
   251 
   211 
       
   212 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   213 //
   253 //
   214 // -----------------------------------------------------------------------------
   254 // -----------------------------------------------------------------------------
   215 //
   255 //
   216 void CMusSipProfileHandler::IncomingRequest( 
   256 void CMusSipProfileHandler::IncomingRequest( 
   254     {
   294     {
   255     // Ownership transferred, should not ever be called by SIP though
   295     // Ownership transferred, should not ever be called by SIP though
   256     delete aTransaction; 
   296     delete aTransaction; 
   257     }
   297     }
   258 
   298 
       
   299 
   259 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   260 //
   301 //
   261 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   262 //
   303 //
   263 void CMusSipProfileHandler::IncomingResponse(
   304 void CMusSipProfileHandler::IncomingResponse(
   264     CSIPClientTransaction& /*aTransaction*/)
   305     CSIPClientTransaction& /*aTransaction*/)
   265     {
   306     {
   266     }
   307     }
       
   308 
   267 
   309 
   268 // -----------------------------------------------------------------------------
   310 // -----------------------------------------------------------------------------
   269 //
   311 //
   270 // -----------------------------------------------------------------------------
   312 // -----------------------------------------------------------------------------
   271 //
   313 //
   273     CSIPClientTransaction& /*aTransaction*/,
   315     CSIPClientTransaction& /*aTransaction*/,
   274     CSIPDialogAssocBase& /*aDialogAssoc*/)
   316     CSIPDialogAssocBase& /*aDialogAssoc*/)
   275     {
   317     {
   276     }
   318     }
   277 
   319 
       
   320 
   278 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   279 //
   322 //
   280 // -----------------------------------------------------------------------------
   323 // -----------------------------------------------------------------------------
   281 //
   324 //
   282 void CMusSipProfileHandler::IncomingResponse( 
   325 void CMusSipProfileHandler::IncomingResponse( 
   285     {
   328     {
   286     // Ownership transferred, should not ever be called by SIP though
   329     // Ownership transferred, should not ever be called by SIP though
   287     delete aDialogAssoc;     
   330     delete aDialogAssoc;     
   288     }
   331     }
   289 
   332 
       
   333 
   290 // -----------------------------------------------------------------------------
   334 // -----------------------------------------------------------------------------
   291 //
   335 //
   292 // -----------------------------------------------------------------------------
   336 // -----------------------------------------------------------------------------
   293 //
   337 //
   294 void CMusSipProfileHandler::IncomingResponse( 
   338 void CMusSipProfileHandler::IncomingResponse( 
   295     CSIPClientTransaction& /*aTransaction*/,
   339     CSIPClientTransaction& /*aTransaction*/,
   296     CSIPRegistrationBinding& /*aRegistration*/ )
   340     CSIPRegistrationBinding& /*aRegistration*/ )
   297     {
   341     {
   298     }
   342     }
       
   343     
   299 
   344 
   300 // -----------------------------------------------------------------------------
   345 // -----------------------------------------------------------------------------
   301 //
   346 //
   302 // -----------------------------------------------------------------------------
   347 // -----------------------------------------------------------------------------
   303 //
   348 //
   304 void CMusSipProfileHandler::ErrorOccured( 
   349 void CMusSipProfileHandler::ErrorOccured( 
   305     TInt /*aError*/,
   350     TInt /*aError*/,
   306     CSIPTransactionBase& /*aTransaction*/ )
   351     CSIPTransactionBase& /*aTransaction*/ )
   307     {
   352     {
   308     }
   353     }
       
   354 
   309 
   355 
   310 // -----------------------------------------------------------------------------
   356 // -----------------------------------------------------------------------------
   311 //
   357 //
   312 // -----------------------------------------------------------------------------
   358 // -----------------------------------------------------------------------------
   313 //
   359 //
   316     CSIPClientTransaction& /*aTransaction*/,
   362     CSIPClientTransaction& /*aTransaction*/,
   317     CSIPRegistrationBinding& /*aRegistration*/ )
   363     CSIPRegistrationBinding& /*aRegistration*/ )
   318     {
   364     {
   319     }
   365     }
   320 
   366 
       
   367 
   321 // -----------------------------------------------------------------------------
   368 // -----------------------------------------------------------------------------
   322 //
   369 //
   323 // -----------------------------------------------------------------------------
   370 // -----------------------------------------------------------------------------
   324 //
   371 //
   325 void CMusSipProfileHandler::ErrorOccured( 
   372 void CMusSipProfileHandler::ErrorOccured( 
   327     CSIPTransactionBase& /*aTransaction*/,
   374     CSIPTransactionBase& /*aTransaction*/,
   328     CSIPDialogAssocBase& /*aDialogAssoc*/ )                                     
   375     CSIPDialogAssocBase& /*aDialogAssoc*/ )                                     
   329     {
   376     {
   330     }
   377     }
   331 
   378 
       
   379 
   332 // -----------------------------------------------------------------------------
   380 // -----------------------------------------------------------------------------
   333 //
   381 //
   334 // -----------------------------------------------------------------------------
   382 // -----------------------------------------------------------------------------
   335 //
   383 //
   336 void CMusSipProfileHandler::ErrorOccured( 
   384 void CMusSipProfileHandler::ErrorOccured( 
   337     TInt /*aError*/, 
   385     TInt /*aError*/, 
   338     CSIPRefresh& /*aSIPRefresh*/ )
   386     CSIPRefresh& /*aSIPRefresh*/ )
   339     {
   387     {
   340     }
   388     }
   341 
   389 
       
   390 
   342 // -----------------------------------------------------------------------------
   391 // -----------------------------------------------------------------------------
   343 //
   392 //
   344 // -----------------------------------------------------------------------------
   393 // -----------------------------------------------------------------------------
   345 //
   394 //
   346 void CMusSipProfileHandler::ErrorOccured( 
   395 void CMusSipProfileHandler::ErrorOccured( 
   347     TInt /*aError*/,
   396     TInt /*aError*/,
   348     CSIPRegistrationBinding& /*aRegistration*/ )                                
   397     CSIPRegistrationBinding& /*aRegistration*/ )                                
   349     {
   398     {
   350     }
   399     }
   351 
   400 
       
   401 
   352 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   353 //
   403 //
   354 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   355 //
   405 //
   356 void CMusSipProfileHandler::ErrorOccured( 
   406 void CMusSipProfileHandler::ErrorOccured( 
   357     TInt /*aError*/,
   407     TInt /*aError*/,
   358     CSIPDialogAssocBase& /*aDialogAssoc*/ )                
   408     CSIPDialogAssocBase& /*aDialogAssoc*/ )                
   359     {
   409     {
   360     }
   410     }
   361 
   411 
       
   412 
   362 // -----------------------------------------------------------------------------
   413 // -----------------------------------------------------------------------------
   363 //
   414 //
   364 // -----------------------------------------------------------------------------
   415 // -----------------------------------------------------------------------------
   365 //
   416 //
   366 void CMusSipProfileHandler::InviteCompleted( 
   417 void CMusSipProfileHandler::InviteCompleted( 
   367     CSIPClientTransaction& /*aTransaction*/ )
   418     CSIPClientTransaction& /*aTransaction*/ )
   368     {
   419     {
   369     }
   420     }
   370 
   421 
       
   422 
   371 // -----------------------------------------------------------------------------
   423 // -----------------------------------------------------------------------------
   372 //
   424 //
   373 // -----------------------------------------------------------------------------
   425 // -----------------------------------------------------------------------------
   374 //
   426 //
   375 void CMusSipProfileHandler::InviteCanceled( 
   427 void CMusSipProfileHandler::InviteCanceled( 
   376     CSIPServerTransaction& /*aTransaction*/ )
   428                                     CSIPServerTransaction& /*aTransaction*/ )
   377     {
   429     {
   378     }
   430     MUS_LOG( "mus: [ENGINE]      CMusSipProfileHandler::CSIPServerTransaction")
       
   431     }
       
   432 
   379 
   433 
   380 // -----------------------------------------------------------------------------
   434 // -----------------------------------------------------------------------------
   381 //
   435 //
   382 // -----------------------------------------------------------------------------
   436 // -----------------------------------------------------------------------------
   383 //
   437 //
   384 void CMusSipProfileHandler::ConnectionStateChanged( 
   438 void CMusSipProfileHandler::ConnectionStateChanged( 
   385     CSIPConnection::TState /*aState*/ )
   439     CSIPConnection::TState /*aState*/ )
   386     {
   440     {
   387     }
   441     }
       
   442 
   388 
   443 
   389 // -----------------------------------------------------------------------------
   444 // -----------------------------------------------------------------------------
   390 // CMusSipProfileHandler::AlrEvent
   445 // CMusSipProfileHandler::AlrEvent
   391 // From MSipProfileAlrObserver
   446 // From MSipProfileAlrObserver
   392 // -----------------------------------------------------------------------------
   447 // -----------------------------------------------------------------------------