realtimenetprots/sipfw/ProfileAgent/Server/Src/SipProfileCSSessionHelper.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : sipprofilecssessionhelper
       
    15 // Part of     : SIP Profile Server
       
    16 // implementation
       
    17 // Version     : 1.0
       
    18 // INCLUDE FILES
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 #include <s32mem.h>
       
    24 #include "sipprofilecs.h"
       
    25 #include "SipProfileCSServer.h"
       
    26 #include "SipProfileCSSessionHelper.h"
       
    27 #include "sipconcreteprofile.h"
       
    28 #include "sipconcreteprofileholder.h"
       
    29 #include "sipprofileslots.h"
       
    30 #include "sipprofileplugins.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSIPProfileCSSessionHelper::ServiceFunction
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 int CSIPProfileCSSessionHelper::ServiceFunction(const RMessage2& aMessage) const
       
    39 	{
       
    40 	return aMessage.Function();
       
    41 	}
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CSIPProfileCSSessionHelper::CompleteService
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CSIPProfileCSSessionHelper::CompleteService(
       
    48 	const RMessage2& aMessage, TInt aCode) const
       
    49 	{
       
    50 	aMessage.Complete(aCode);
       
    51 	}
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CSIPProfileCSSessionHelper::IPCArgTUintL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 TUint CSIPProfileCSSessionHelper::IPCArgTUintL(
       
    58 	TSipProfileItcArguments aIpcArgIndex,
       
    59     const RMessage2&  aMessage) const
       
    60 	{
       
    61     TUint value(0);
       
    62     switch (static_cast<TInt>(aIpcArgIndex))
       
    63 		{
       
    64         case 0: value = aMessage.Int0(); break;
       
    65         case 1: value = aMessage.Int1(); break;
       
    66         case 2: value = aMessage.Int2(); break;
       
    67         case 3: value = aMessage.Int3(); break;
       
    68         default: User::Leave(KErrArgument); break;
       
    69 		}
       
    70     return value; 
       
    71 	}
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSIPProfileCSSessionHelper::ReadLC
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 HBufC8* CSIPProfileCSSessionHelper::ReadLC(
       
    78 	TSipProfileItcArguments aItcArgIndex,
       
    79 	const RMessage2&  aMessage) const
       
    80 	{
       
    81     TInt length = aMessage.GetDesLength(aItcArgIndex);
       
    82     __ASSERT_ALWAYS(length >= 0, User::Leave(KErrArgument));
       
    83 
       
    84     HBufC8* buf = HBufC8::NewLC(length);
       
    85 	TPtr8 bufPtr(buf->Des());
       
    86     aMessage.ReadL(aItcArgIndex, bufPtr);
       
    87     
       
    88     return buf;
       
    89 	}
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSIPProfileCSSessionHelper::ReadSipIdsL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TSIPProfileSlots CSIPProfileCSSessionHelper::ReadSipIdsL(
       
    96 	const RMessage2& aMessage) const
       
    97 	{
       
    98     TPckgBuf<TSIPProfileSlots> sipIdsPckg;
       
    99     aMessage.ReadL(ESipProfileItcArgSlots, sipIdsPckg);
       
   100     return sipIdsPckg();
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CSIPProfileCSSessionHelper::WriteL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CSIPProfileCSSessionHelper::WriteL(
       
   108 	const RMessage2& aMessage,
       
   109     const TSIPProfileSlots& aIds)
       
   110 	{
       
   111     TPckgBuf<TSIPProfileSlots> sipIdsPckg(aIds);
       
   112     WriteL(ESipProfileItcArgSlots, aMessage, sipIdsPckg);
       
   113 	}
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CSIPProfileCSSessionHelper::WriteL
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CSIPProfileCSSessionHelper::WriteL(TSipProfileItcArguments aItcArgIndex,
       
   120 	const RMessage2&  aMessage,
       
   121 	const TDesC8&    aDes)
       
   122 	{
       
   123     TInt length = aMessage.GetDesMaxLength(aItcArgIndex);
       
   124     __ASSERT_ALWAYS(length >= aDes.Length(), User::Leave (KErrOverflow));
       
   125     aMessage.WriteL (aItcArgIndex, aDes);
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CSIPProfileCSSessionHelper::ReadSIPProfileTypeInfoL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CSIPProfileCSSessionHelper::ReadSIPProfileTypeInfoL(
       
   133     const RMessage2& aMessage,
       
   134     TSIPProfileTypeInfo& aTypeInfo) const
       
   135     {
       
   136 	HBufC8* type = ReadLC(ESipProfileItcArgNarrator,aMessage);
       
   137 
       
   138 	__ASSERT_ALWAYS(type->Length() <= aTypeInfo.iSIPProfileName.MaxLength(),
       
   139 	                User::Leave(KErrArgument));
       
   140 
       
   141 	aTypeInfo.iSIPProfileName = *type;
       
   142 	aTypeInfo.iSIPProfileClass = 
       
   143 	    static_cast<TSIPProfileTypeInfo::TSIPProfileClass>(
       
   144 	        IPCArgTUintL(ESipProfileItcArgType, aMessage));
       
   145 		
       
   146 	CleanupStack::PopAndDestroy(type);	    
       
   147     }