mmsharing/mmshengine/src/mussipprofilehandler.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 0 f0cf47e981f9
child 23 bc78a40cd63c
equal deleted inserted replaced
21:33a5d2bbf6fc 22:73a1feb507fb
    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.
    15 *
    18 *
    16 */
    19 */
    17 
    20 
    18 
    21 
    19 // USER
    22 // USER
    29 #include <sipprofile.h>
    32 #include <sipprofile.h>
    30 #include <sipprofileregistry.h>
    33 #include <sipprofileregistry.h>
    31 #include <sipprofilealrcontroller.h>
    34 #include <sipprofilealrcontroller.h>
    32 #include <uri8.h>
    35 #include <uri8.h>
    33 
    36 
    34 
       
    35 
       
    36 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    37 //
    38 //
    38 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    39 //
    40 //
    40 CMusSipProfileHandler* CMusSipProfileHandler::NewL( MMusSipProfileUser& aUser )
    41 CMusSipProfileHandler* CMusSipProfileHandler::NewL( MMusSipProfileUser& aUser )
    45     self->ConstructL();
    46     self->ConstructL();
    46     CleanupStack::Pop( self);
    47     CleanupStack::Pop( self);
    47     return self;
    48     return self;
    48     }
    49     }
    49 
    50 
    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 
       
    79 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    80 //
    79 //
    81 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    82 //
    81 //
    83 CMusSipProfileHandler::~CMusSipProfileHandler()
    82 CMusSipProfileHandler::~CMusSipProfileHandler()
    87     delete iProfileRegistry;
    86     delete iProfileRegistry;
    88     delete iSip;
    87     delete iSip;
    89     MUS_LOG( "mus: [ENGINE]     CMusSipProfileHandler::~CMusSipProfileHandler()" )
    88     MUS_LOG( "mus: [ENGINE]     CMusSipProfileHandler::~CMusSipProfileHandler()" )
    90     }
    89     }
    91 
    90 
    92 
       
    93 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    94 //
    92 //
    95 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    96 //
    94 //
    97 void CMusSipProfileHandler::CreateProfileL( TUint32 aSipProfileId )
    95 void CMusSipProfileHandler::CreateProfileL( TUint32 aSipProfileId )
   103         }
   101         }
   104     else
   102     else
   105         {
   103         {
   106         profile = iProfileRegistry->DefaultProfileL();
   104         profile = iProfileRegistry->DefaultProfileL();
   107         }
   105         }
   108     CleanupStack::PushL( profile );
   106        
   109     TBool profileRegistered = EFalse;   
       
   110     User::LeaveIfError( profile->GetParameter( KSIPProfileRegistered,
       
   111                                                    profileRegistered  ) );
       
   112     CleanupStack::Pop( profile );   
       
   113     delete iSipProfile;
   107     delete iSipProfile;
   114     iSipProfile = profile;
   108     iSipProfile = profile;
   115     }
   109     }
   116 
   110 
   117 
       
   118 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   119 //
   112 //
   120 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   121 //
   114 //
   122 CSIPProfile* CMusSipProfileHandler::Profile()
   115 CSIPProfile* CMusSipProfileHandler::Profile()
   123     {
   116     {
   124     return iSipProfile;
   117     return iSipProfile;
   125     }
   118     }
   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 
       
   196 
   119 
   197 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   198 //
   121 //
   199 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   200 //
   123 //
   204     
   127     
   205     __ASSERT_ALWAYS( iSipProfile != NULL, User::Leave( KErrNotReady ) );
   128     __ASSERT_ALWAYS( iSipProfile != NULL, User::Leave( KErrNotReady ) );
   206 
   129 
   207     const MDesC8Array* aors = NULL;
   130     const MDesC8Array* aors = NULL;
   208     User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) );
   131     User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) );
   209     if( !aors || aors->MdcaCount() <= 0 ) 
   132     __ASSERT_ALWAYS( aors && aors->MdcaCount() > 0, 
   210         {    
   133                      User::Leave( KErrArgument ) );
   211         User::Leave( KErrArgument );            
   134     
   212         }
       
   213     TUriParser8 parser;
   135     TUriParser8 parser;
   214     User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) );
   136     User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) );
   215     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::UserFromProfileLC()" )
   137     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::UserFromProfileLC()" )
   216     
   138     
   217     return CUri8::NewLC( parser );
   139     return CUri8::NewLC( parser );
   227     TRAP_IGNORE( iProfileAlrController->RefreshIapAvailabilityL( ProfileId() ) )
   149     TRAP_IGNORE( iProfileAlrController->RefreshIapAvailabilityL( ProfileId() ) )
   228     }
   150     }
   229 
   151 
   230 
   152 
   231 // -----------------------------------------------------------------------------
   153 // -----------------------------------------------------------------------------
       
   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 // -----------------------------------------------------------------------------
   232 //
   176 //
   233 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   234 //
   178 //
   235 void CMusSipProfileHandler::ProfileRegistryEventOccurred(
   179 void CMusSipProfileHandler::ProfileRegistryEventOccurred(
   236     TUint32 /*aProfileId*/,
   180     TUint32 aProfileId,
   237     MSIPProfileRegistryObserver::TEvent /*aEvent*/ )
   181     MSIPProfileRegistryObserver::TEvent aEvent )
   238     {
   182     {
       
   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         }
   239     }
   198     }
   240 
   199 
   241 
   200 
   242 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   243 //
   202 //
   247     TUint32 /*aProfileId*/,
   206     TUint32 /*aProfileId*/,
   248     TInt /*aError*/)
   207     TInt /*aError*/)
   249     {
   208     {
   250     }
   209     }
   251 
   210 
       
   211 
   252 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   253 //
   213 //
   254 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   255 //
   215 //
   256 void CMusSipProfileHandler::IncomingRequest( 
   216 void CMusSipProfileHandler::IncomingRequest( 
   294     {
   254     {
   295     // Ownership transferred, should not ever be called by SIP though
   255     // Ownership transferred, should not ever be called by SIP though
   296     delete aTransaction; 
   256     delete aTransaction; 
   297     }
   257     }
   298 
   258 
   299 
       
   300 // -----------------------------------------------------------------------------
   259 // -----------------------------------------------------------------------------
   301 //
   260 //
   302 // -----------------------------------------------------------------------------
   261 // -----------------------------------------------------------------------------
   303 //
   262 //
   304 void CMusSipProfileHandler::IncomingResponse(
   263 void CMusSipProfileHandler::IncomingResponse(
   305     CSIPClientTransaction& /*aTransaction*/)
   264     CSIPClientTransaction& /*aTransaction*/)
   306     {
   265     {
   307     }
   266     }
   308 
       
   309 
   267 
   310 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   311 //
   269 //
   312 // -----------------------------------------------------------------------------
   270 // -----------------------------------------------------------------------------
   313 //
   271 //
   315     CSIPClientTransaction& /*aTransaction*/,
   273     CSIPClientTransaction& /*aTransaction*/,
   316     CSIPDialogAssocBase& /*aDialogAssoc*/)
   274     CSIPDialogAssocBase& /*aDialogAssoc*/)
   317     {
   275     {
   318     }
   276     }
   319 
   277 
   320 
       
   321 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   322 //
   279 //
   323 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   324 //
   281 //
   325 void CMusSipProfileHandler::IncomingResponse( 
   282 void CMusSipProfileHandler::IncomingResponse( 
   328     {
   285     {
   329     // Ownership transferred, should not ever be called by SIP though
   286     // Ownership transferred, should not ever be called by SIP though
   330     delete aDialogAssoc;     
   287     delete aDialogAssoc;     
   331     }
   288     }
   332 
   289 
   333 
       
   334 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   335 //
   291 //
   336 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   337 //
   293 //
   338 void CMusSipProfileHandler::IncomingResponse( 
   294 void CMusSipProfileHandler::IncomingResponse( 
   339     CSIPClientTransaction& /*aTransaction*/,
   295     CSIPClientTransaction& /*aTransaction*/,
   340     CSIPRegistrationBinding& /*aRegistration*/ )
   296     CSIPRegistrationBinding& /*aRegistration*/ )
   341     {
   297     {
   342     }
   298     }
   343     
       
   344 
   299 
   345 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   346 //
   301 //
   347 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   348 //
   303 //
   349 void CMusSipProfileHandler::ErrorOccured( 
   304 void CMusSipProfileHandler::ErrorOccured( 
   350     TInt /*aError*/,
   305     TInt /*aError*/,
   351     CSIPTransactionBase& /*aTransaction*/ )
   306     CSIPTransactionBase& /*aTransaction*/ )
   352     {
   307     {
   353     }
   308     }
   354 
       
   355 
   309 
   356 // -----------------------------------------------------------------------------
   310 // -----------------------------------------------------------------------------
   357 //
   311 //
   358 // -----------------------------------------------------------------------------
   312 // -----------------------------------------------------------------------------
   359 //
   313 //
   362     CSIPClientTransaction& /*aTransaction*/,
   316     CSIPClientTransaction& /*aTransaction*/,
   363     CSIPRegistrationBinding& /*aRegistration*/ )
   317     CSIPRegistrationBinding& /*aRegistration*/ )
   364     {
   318     {
   365     }
   319     }
   366 
   320 
   367 
       
   368 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   369 //
   322 //
   370 // -----------------------------------------------------------------------------
   323 // -----------------------------------------------------------------------------
   371 //
   324 //
   372 void CMusSipProfileHandler::ErrorOccured( 
   325 void CMusSipProfileHandler::ErrorOccured( 
   374     CSIPTransactionBase& /*aTransaction*/,
   327     CSIPTransactionBase& /*aTransaction*/,
   375     CSIPDialogAssocBase& /*aDialogAssoc*/ )                                     
   328     CSIPDialogAssocBase& /*aDialogAssoc*/ )                                     
   376     {
   329     {
   377     }
   330     }
   378 
   331 
   379 
       
   380 // -----------------------------------------------------------------------------
   332 // -----------------------------------------------------------------------------
   381 //
   333 //
   382 // -----------------------------------------------------------------------------
   334 // -----------------------------------------------------------------------------
   383 //
   335 //
   384 void CMusSipProfileHandler::ErrorOccured( 
   336 void CMusSipProfileHandler::ErrorOccured( 
   385     TInt /*aError*/, 
   337     TInt /*aError*/, 
   386     CSIPRefresh& /*aSIPRefresh*/ )
   338     CSIPRefresh& /*aSIPRefresh*/ )
   387     {
   339     {
   388     }
   340     }
   389 
   341 
   390 
       
   391 // -----------------------------------------------------------------------------
   342 // -----------------------------------------------------------------------------
   392 //
   343 //
   393 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   394 //
   345 //
   395 void CMusSipProfileHandler::ErrorOccured( 
   346 void CMusSipProfileHandler::ErrorOccured( 
   396     TInt /*aError*/,
   347     TInt /*aError*/,
   397     CSIPRegistrationBinding& /*aRegistration*/ )                                
   348     CSIPRegistrationBinding& /*aRegistration*/ )                                
   398     {
   349     {
   399     }
   350     }
   400 
   351 
   401 
       
   402 // -----------------------------------------------------------------------------
   352 // -----------------------------------------------------------------------------
   403 //
   353 //
   404 // -----------------------------------------------------------------------------
   354 // -----------------------------------------------------------------------------
   405 //
   355 //
   406 void CMusSipProfileHandler::ErrorOccured( 
   356 void CMusSipProfileHandler::ErrorOccured( 
   407     TInt /*aError*/,
   357     TInt /*aError*/,
   408     CSIPDialogAssocBase& /*aDialogAssoc*/ )                
   358     CSIPDialogAssocBase& /*aDialogAssoc*/ )                
   409     {
   359     {
   410     }
   360     }
   411 
       
   412 
   361 
   413 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   414 //
   363 //
   415 // -----------------------------------------------------------------------------
   364 // -----------------------------------------------------------------------------
   416 //
   365 //
   417 void CMusSipProfileHandler::InviteCompleted( 
   366 void CMusSipProfileHandler::InviteCompleted( 
   418     CSIPClientTransaction& /*aTransaction*/ )
   367     CSIPClientTransaction& /*aTransaction*/ )
   419     {
   368     {
   420     }
   369     }
   421 
   370 
   422 
       
   423 // -----------------------------------------------------------------------------
   371 // -----------------------------------------------------------------------------
   424 //
   372 //
   425 // -----------------------------------------------------------------------------
   373 // -----------------------------------------------------------------------------
   426 //
   374 //
   427 void CMusSipProfileHandler::InviteCanceled( 
   375 void CMusSipProfileHandler::InviteCanceled( 
   428                                     CSIPServerTransaction& /*aTransaction*/ )
   376     CSIPServerTransaction& /*aTransaction*/ )
   429     {
   377     {
   430     MUS_LOG( "mus: [ENGINE]      CMusSipProfileHandler::CSIPServerTransaction")
   378     }
   431     }
       
   432 
       
   433 
   379 
   434 // -----------------------------------------------------------------------------
   380 // -----------------------------------------------------------------------------
   435 //
   381 //
   436 // -----------------------------------------------------------------------------
   382 // -----------------------------------------------------------------------------
   437 //
   383 //
   438 void CMusSipProfileHandler::ConnectionStateChanged( 
   384 void CMusSipProfileHandler::ConnectionStateChanged( 
   439     CSIPConnection::TState /*aState*/ )
   385     CSIPConnection::TState /*aState*/ )
   440     {
   386     {
   441     }
   387     }
   442 
       
   443 
   388 
   444 // -----------------------------------------------------------------------------
   389 // -----------------------------------------------------------------------------
   445 // CMusSipProfileHandler::AlrEvent
   390 // CMusSipProfileHandler::AlrEvent
   446 // From MSipProfileAlrObserver
   391 // From MSipProfileAlrObserver
   447 // -----------------------------------------------------------------------------
   392 // -----------------------------------------------------------------------------