multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofile.cpp
changeset 0 1bce908db942
child 12 91f50911ea81
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  INCLUDE FILES
       
    22 #include "sipprofile.h"
       
    23 #include "sipmanagedprofile.h"
       
    24 #include "sipprofileregistry.h"
       
    25 #include "mcetesthelper.h"
       
    26 #include "cmcetls.h"
       
    27 
       
    28 _LIT8( KSIPProfileExtenstionParameter, "%u");
       
    29 const TUint KProfileBufferSize = 25;
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSIPProfile::NewL
       
    36 // Two-phased constructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSIPProfile* CSIPProfile::NewL(CSIPProfileRegistry* aSIPRegistry)
       
    40 	{
       
    41     CSIPProfile* self = CSIPProfile::NewLC (aSIPRegistry);
       
    42     CleanupStack::Pop();
       
    43     return self;
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSIPProfile::NewLC
       
    48 // Two-phased constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CSIPProfile* CSIPProfile::NewLC(CSIPProfileRegistry* aSIPRegistry)
       
    52 	{
       
    53 	CSIPProfile* self = new(ELeave)CSIPProfile(aSIPRegistry);
       
    54     CleanupStack::PushL (self);
       
    55     self->ConstructL ();
       
    56     return self;
       
    57 	}
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CSIPProfile::NewL
       
    61 // Two-phased constructor.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CSIPProfile* CSIPProfile::NewL()
       
    65 	{
       
    66     CSIPProfile* self = new(ELeave)CSIPProfile();
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop();
       
    70     return self;
       
    71 	}
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSIPProfile::~CSIPProfile
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 EXPORT_C CSIPProfile::~CSIPProfile()
       
    78 	{
       
    79 	delete iAORs;
       
    80 	delete iAor;
       
    81     delete iContactParams;
       
    82     delete iDigestRealm;
       
    83     delete iPrivateIdentity;
       
    84     delete iDigestUsername;
       
    85     delete iDigestPassword;
       
    86     delete iRequestUriUser;
       
    87     delete iContactHeader;
       
    88 	}
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CSIPProfile::GetParameter
       
    92 // -----------------------------------------------------------------------------
       
    93 //	
       
    94 EXPORT_C TInt CSIPProfile::GetParameter(TUint32 aParam, TDesC8 const *& aVal ) const
       
    95 	{
       
    96 	CMCETls* tls = CMCETls::Storage();
       
    97 	TInt ret = KErrNone;
       
    98 	if ( tls )
       
    99 	    {
       
   100 	    ret = tls->LeaveError( aParam );
       
   101 	    if ( !ret )
       
   102 	        {
       
   103 	        switch ( aParam )
       
   104 	            {
       
   105 	            case KSIPUserAor:
       
   106 	                {	                
       
   107 	                aVal = iAor;
       
   108 	                break;
       
   109 	                }
       
   110 	            case KSIPDigestRealm:
       
   111 	                {
       
   112 	                aVal = iDigestRealm;
       
   113 	                break;
       
   114 	                }
       
   115 	            case KSIPDigestUserName:
       
   116 	                {
       
   117 	                aVal = iDigestUsername;
       
   118 	                break;
       
   119 	                }
       
   120 	            case KSIPDigestPassword:
       
   121 	                {
       
   122 	                aVal = iDigestPassword;
       
   123 	                break;
       
   124 	                }
       
   125 	            case KSIPPrivateIdentity:
       
   126 	                {
       
   127 	                aVal = iPrivateIdentity;
       
   128 	                break;
       
   129 	                }
       
   130     	         case KSIPContactHeaderUser:
       
   131                     {
       
   132                     aVal = iRequestUriUser;
       
   133                     break;            
       
   134                     }
       
   135 	            case KSIPRegisteredContact:
       
   136 	                {
       
   137 	                aVal = iContactHeader;
       
   138 	                break;
       
   139 	                }
       
   140 
       
   141                default:
       
   142 	                {
       
   143 	                ret = KErrNotFound;
       
   144 	                break;
       
   145 	                }
       
   146 	            }
       
   147 	        }
       
   148 	    }
       
   149 	    
       
   150 	if ( !ret && !aVal )
       
   151 	    {
       
   152 	    ret = KErrNotFound;
       
   153 	    }
       
   154 	return ret;
       
   155 	}	
       
   156 
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CSIPProfile::GetParameter
       
   160 // -----------------------------------------------------------------------------
       
   161 //	
       
   162 EXPORT_C TInt CSIPProfile::GetParameter(TUint32 /*aServerType*/, TUint32 aParam, TDesC8 const *& aVal) const
       
   163     {
       
   164     return GetParameter( aParam, aVal );
       
   165     }
       
   166 
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CSIPProfile::GetParameter
       
   171 // -----------------------------------------------------------------------------
       
   172 //	
       
   173 EXPORT_C TInt CSIPProfile::GetParameter(TUint32 aParam, TUint32& aVal) const
       
   174 	{
       
   175 	CMCETls* tls = CMCETls::Storage();
       
   176 	TInt ret = KErrNone;
       
   177 	if ( tls )
       
   178 	    {
       
   179 	    ret = tls->LeaveError( aParam );
       
   180 	    if ( !ret )
       
   181 	        {
       
   182 	        switch ( aParam )
       
   183 	            {
       
   184 	            default:
       
   185 	                {
       
   186 	                aVal = 1;
       
   187 	                break;
       
   188 	                }
       
   189 	            }
       
   190 	        }
       
   191 	    }
       
   192 	if( aParam == KSIPProfileId )
       
   193 		{
       
   194 		aVal = 1;
       
   195 		}
       
   196 	return ret;
       
   197 	}	
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CSIPProfile::GetParameter
       
   201 // -----------------------------------------------------------------------------
       
   202 //	
       
   203 EXPORT_C TInt CSIPProfile::GetParameter(TUint32 aParam, TBool& aVal) const
       
   204 	{
       
   205 	CMCETls* tls = CMCETls::Storage();
       
   206 	TInt ret = KErrNone;
       
   207 	if ( tls )
       
   208 	    {
       
   209 	    ret = tls->LeaveError( aParam );
       
   210 	    if ( !ret )
       
   211 	        {
       
   212 	        switch ( aParam )
       
   213 	            {
       
   214 	            default:
       
   215 	                {
       
   216 	                aVal = ETrue;
       
   217 	                break;
       
   218 	                }
       
   219 	            }
       
   220 	        }
       
   221 	    }
       
   222 	return ret;
       
   223 	}
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CSIPProfile::GetParameter
       
   227 // -----------------------------------------------------------------------------
       
   228 //	
       
   229 EXPORT_C TInt CSIPProfile::GetParameter(TUint32 aParam, 
       
   230                                         MDesC8Array const *& aVal ) const
       
   231 	{
       
   232 	CMCETls* tls = CMCETls::Storage();
       
   233 	TInt ret = KErrNone;
       
   234 	if ( tls )
       
   235 	    {
       
   236 	    ret = tls->LeaveError( aParam );
       
   237 	    if ( !ret )
       
   238 	        {
       
   239 	        switch ( aParam )
       
   240                 {
       
   241                 case KSIPRegisteredAors:
       
   242                     {
       
   243                     aVal = iAORs;
       
   244                     break;
       
   245                     }
       
   246                 case KSIPContactHeaderParams:
       
   247                     {
       
   248                     aVal = iContactParams;
       
   249                     break;
       
   250                     }
       
   251                 default:
       
   252                     {
       
   253                     ret = KErrNotFound;
       
   254                     break;
       
   255                     }
       
   256                 }
       
   257 	        }
       
   258 	    }
       
   259 	
       
   260 	if ( !ret && !aVal )
       
   261 	    {
       
   262 	    ret = KErrNotFound;
       
   263 	    }
       
   264 	
       
   265 	return ret;
       
   266 	}
       
   267 	
       
   268 // -----------------------------------------------------------------------------
       
   269 // CSIPProfile::CSIPProfile
       
   270 // -----------------------------------------------------------------------------
       
   271 //	
       
   272 CSIPProfile::CSIPProfile(CSIPProfileRegistryBase* aRegistry):
       
   273 	iSIPProfileRegistry(aRegistry), iEnabled(EFalse)
       
   274 	{
       
   275 	}
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CSIPProfile::CSIPProfile
       
   279 // -----------------------------------------------------------------------------
       
   280 //	
       
   281 CSIPProfile::CSIPProfile():
       
   282 	iEnabled(EFalse)
       
   283 	{
       
   284 	}
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CSIPProfile::ConstructL
       
   288 // -----------------------------------------------------------------------------
       
   289 //	
       
   290 void CSIPProfile::ConstructL()
       
   291 	{
       
   292     iAORs = new( ELeave ) CDesC8ArrayFlat( 1 );
       
   293     iAORs->AppendL( KSIPProfileDefAOR );
       
   294     iAor = KSIPProfileDefAOR().AllocL();
       
   295     iContactParams = new( ELeave ) CDesC8ArrayFlat( 1 );
       
   296     iContactParams->AppendL( KFeatureTag );
       
   297     iContactParams->AppendL( KParamValue );
       
   298     iContactHeader = KContactHeaderValue().AllocL();
       
   299     iRequestUriUser = KRequestUriUser().AllocL();
       
   300 	}
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // CSIPProfile::IsContextActive
       
   304 // -----------------------------------------------------------------------------
       
   305 //	
       
   306 TBool CSIPProfile::IsContextActive() const
       
   307 	{
       
   308 	return ETrue;
       
   309 	}
       
   310 	
       
   311 // -----------------------------------------------------------------------------
       
   312 // CSIPProfile::ContextId
       
   313 // -----------------------------------------------------------------------------
       
   314 //	
       
   315 TUint32 CSIPProfile::ContextId() const
       
   316 	{
       
   317 	return 1;
       
   318 	}
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CSIPProfile::SetParam
       
   322 // -----------------------------------------------------------------------------
       
   323 //	
       
   324 void CSIPProfile::SetParam( TUint aParam, HBufC8* aValue )
       
   325     {
       
   326     switch ( aParam )
       
   327         {
       
   328         case KSIPDigestRealm:
       
   329             {
       
   330             delete iDigestRealm;
       
   331             iDigestRealm = aValue;
       
   332             break;
       
   333             }
       
   334         case KSIPDigestPassword:
       
   335             {
       
   336             delete iDigestPassword;
       
   337             iDigestPassword = aValue;
       
   338             break;
       
   339             }
       
   340         case KSIPDigestUserName:
       
   341             {
       
   342             delete iDigestUsername;
       
   343             iDigestUsername = aValue;
       
   344             break;
       
   345             }
       
   346         case KSIPPrivateIdentity:
       
   347             {
       
   348             delete iPrivateIdentity;
       
   349             iPrivateIdentity = aValue;
       
   350             break;            
       
   351             }
       
   352         case KSIPRegisteredContact:
       
   353         	{
       
   354         	delete iContactHeader;
       
   355         	iContactHeader = aValue;
       
   356         	break;
       
   357         	}
       
   358         default:
       
   359             {
       
   360             break;
       
   361             }
       
   362         }
       
   363     }