mmsharing/mmshengine/src/mussipprofilehandler.cpp
branchRCL_3
changeset 23 bc78a40cd63c
parent 22 73a1feb507fb
--- a/mmsharing/mmshengine/src/mussipprofilehandler.cpp	Tue Aug 31 15:12:07 2010 +0300
+++ b/mmsharing/mmshengine/src/mussipprofilehandler.cpp	Wed Sep 01 12:31:01 2010 +0100
@@ -12,9 +12,6 @@
 * Contributors:
 *
 * Description:  Utilities to get and set profile used with SWIS.
-*  Part of     : Mus For S60 v3.2
-*  Description : Utilities to get and set profile used with SWIS.
-*  Version     : %version: 11.1.5 % << Don't touch! Updated by Synergy at check-out.
 *
 */
 
@@ -34,6 +31,8 @@
 #include <sipprofilealrcontroller.h>
 #include <uri8.h>
 
+
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -48,6 +47,7 @@
     return self;
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -75,6 +75,7 @@
     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::ConstructL()" )
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -88,6 +89,7 @@
     MUS_LOG( "mus: [ENGINE]     CMusSipProfileHandler::~CMusSipProfileHandler()" )
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -103,11 +105,16 @@
         {
         profile = iProfileRegistry->DefaultProfileL();
         }
-       
+    CleanupStack::PushL( profile );
+    TBool profileRegistered = EFalse;   
+    User::LeaveIfError( profile->GetParameter( KSIPProfileRegistered,
+                                                   profileRegistered  ) );
+    CleanupStack::Pop( profile );   
     delete iSipProfile;
     iSipProfile = profile;
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -117,6 +124,76 @@
     return iSipProfile;
     }
 
+#if 0 //TODO: should this be removed?
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+CSIPProfile& CMusSipProfileHandler::SipProfileL( TInt aSipProfileId )
+    {
+    MUS_LOG1( "mus: [ENGINE]     -> CMusSipProfileHandler::SipProfileL(),\
+              od #%d", aSipProfileId )
+
+    if ( !iSipProfile )
+        {        
+        if ( aSipProfileId != 0 )
+            {
+            iSipProfile = iProfileRegistry->ProfileL( aSipProfileId );
+            }
+        else
+            {
+            iSipProfile = iProfileRegistry->DefaultProfileL();
+            }
+        }
+
+    // The parameter val indicates if the profile can be immediately
+    // used for creating a session, or if the client must wait for
+    // the profile to be registered.
+    TBool profileRegistered = EFalse;
+    
+    User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered,
+                                                   profileRegistered  ) );
+                                                       
+    if ( !profileRegistered )
+        {
+
+        #if (defined (__WINS__) || defined(__WINSCW__))
+        
+        iProfileRegistry->EnableL( *iSipProfile, *this );            
+
+        User::LeaveIfError( iSipProfile->GetParameter( KSIPProfileRegistered,
+                                                       profileRegistered  ) );
+                                               
+        if( !profileRegistered )
+            {
+            CActiveScheduler::Start();
+
+            User::LeaveIfError( iSipProfile->GetParameter( 
+                                                    KSIPProfileRegistered,
+                                                    profileRegistered  ) );
+            
+            if ( !profileRegistered )
+                {
+                User::Leave( KErrNotReady );
+                }
+            }
+
+        #else
+
+        User::Leave( KErrNotReady );
+
+        #endif
+
+        }
+    
+        
+    MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::SipProfileL()" )
+    
+    return *iSipProfile;
+    }
+#endif
+
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -129,9 +206,10 @@
 
     const MDesC8Array* aors = NULL;
     User::LeaveIfError( iSipProfile->GetParameter( KSIPRegisteredAors, aors ) );
-    __ASSERT_ALWAYS( aors && aors->MdcaCount() > 0, 
-                     User::Leave( KErrArgument ) );
-    
+    if( !aors || aors->MdcaCount() <= 0 ) 
+        {    
+        User::Leave( KErrArgument );            
+        }
     TUriParser8 parser;
     User::LeaveIfError( parser.Parse( aors->MdcaPoint( 0 ) ) );
     MUS_LOG( "mus: [ENGINE]  <- CMusSipProfileHandler::UserFromProfileLC()" )
@@ -151,50 +229,13 @@
 
 
 // -----------------------------------------------------------------------------
-// This function should never be called before creating a profile, but such
-// a situation will be considered as pending registration.
-// -----------------------------------------------------------------------------
-//
-TBool CMusSipProfileHandler::IsRegistered()
-    {
-    MUS_LOG( "mus: [ENGINE]  -> CMusSipProfileHandler::IsRegistered()" )
-    
-    TBool profileRegistered = EFalse;   
-    if ( iSipProfile ) 
-        {
-        iSipProfile->GetParameter( KSIPProfileRegistered, profileRegistered  );  
-        }
-    
-    MUS_LOG1( "mus: [ENGINE]  <- CMusSipProfileHandler::IsRegistered( %d )",
-              profileRegistered )
-    
-    return profileRegistered;
-    }
-
-
-// -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
 //
 void CMusSipProfileHandler::ProfileRegistryEventOccurred(
-    TUint32 aProfileId,
-    MSIPProfileRegistryObserver::TEvent aEvent )
+    TUint32 /*aProfileId*/,
+    MSIPProfileRegistryObserver::TEvent /*aEvent*/ )
     {
-    if ( iSipProfile && aProfileId == ProfileId() )
-        {
-        switch ( aEvent )
-            {
-            case MSIPProfileRegistryObserver::EProfileRegistered:
-                {
-                iUser.ProfileRegistered();
-                break;
-                }
-            default:
-                {
-                break;
-                }
-            }
-        }
     }
 
 
@@ -208,7 +249,6 @@
     {
     }
 
-
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -256,6 +296,7 @@
     delete aTransaction; 
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -265,6 +306,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -275,6 +317,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -287,6 +330,7 @@
     delete aDialogAssoc;     
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -296,6 +340,7 @@
     CSIPRegistrationBinding& /*aRegistration*/ )
     {
     }
+    
 
 // -----------------------------------------------------------------------------
 //
@@ -307,6 +352,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -318,6 +364,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -329,6 +376,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -339,6 +387,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -349,6 +398,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -359,6 +409,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -368,15 +419,18 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
 //
 void CMusSipProfileHandler::InviteCanceled( 
-    CSIPServerTransaction& /*aTransaction*/ )
+                                    CSIPServerTransaction& /*aTransaction*/ )
     {
+    MUS_LOG( "mus: [ENGINE]      CMusSipProfileHandler::CSIPServerTransaction")
     }
 
+
 // -----------------------------------------------------------------------------
 //
 // -----------------------------------------------------------------------------
@@ -386,6 +440,7 @@
     {
     }
 
+
 // -----------------------------------------------------------------------------
 // CMusSipProfileHandler::AlrEvent
 // From MSipProfileAlrObserver