realtimenetprots/sipfw/ProfileAgent/Client/Src/SIPProfileITCHelper.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        : sipprofileitchelper
       
    15 // Part of     : SIP Profile Client
       
    16 // implementation
       
    17 // Version     : 1.0
       
    18 // INCLUDE FILES
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 #include "SIPProfileITCHelper.h"
       
    24 #include "SIPRemoteProfile.h"
       
    25 #include "sipconcreteprofile.h"
       
    26 #include "sipconcreteprofileholder.h"
       
    27 #include "sipprofileslots.h"
       
    28 #include "sipprofileplugins.h"
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSIPProfileITCHelper::CSIPProfileITCHelper
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CSIPProfileITCHelper::CSIPProfileITCHelper(RSIPProfile& aSipProfile) 
       
    37  : iSip (aSipProfile)
       
    38 	{
       
    39 	}
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CSIPProfileITCHelper::SendL
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CSIPProfileITCHelper::SendL(TIpcArgs& aArgs, TSipProfileItcFunctions aFunction)
       
    46 	{
       
    47 	User::LeaveIfError(iSip.Send(aArgs, aFunction));
       
    48 	}
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CSIPProfileITCHelper::SendL
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CSIPProfileITCHelper::SendL(
       
    55 	TSIPProfileSlots& aIds, TSipProfileItcFunctions aITCFunction)
       
    56 	{
       
    57 	User::LeaveIfError(Send(aIds,aITCFunction));
       
    58 	}
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CSIPProfileITCHelper::SendL
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CSIPProfileITCHelper::SendL(TSIPProfileSlots& aIds, 
       
    65 								  TSipProfileItcFunctions aITCFunction, 
       
    66 								  const TDesC8& aNarrator)
       
    67 	{
       
    68 	HBufC8* narrator = aNarrator.AllocLC();
       
    69 	TPtr8 narratorPtr = narrator->Des();
       
    70 	iITCMsgArgs.Set(ESipProfileItcArgNarrator, &narratorPtr);
       
    71     
       
    72 	User::LeaveIfError(Send(aIds,aITCFunction));
       
    73 	CleanupStack::PopAndDestroy(narrator);
       
    74 	}
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CSIPProfileITCHelper::SendL
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CSIPProfileITCHelper::SendL(TSipProfileItcFunctions aITCFunction,
       
    81 						   const CSIPConcreteProfile& aProfile)
       
    82 	{
       
    83     CBufFlat* buf = ExternalizeLC (aProfile);
       
    84     TPtr8 externalized = buf->Ptr(0);
       
    85     iITCMsgArgs.Set (ESipProfileItcArgProfile, &externalized);
       
    86 	User::LeaveIfError(iSip.Send(iITCMsgArgs,aITCFunction));
       
    87 
       
    88     CleanupStack::PopAndDestroy(buf);
       
    89 	}
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSIPProfileITCHelper::SendL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CSIPProfileITCHelper::SendL(TSIPProfileSlots& aIds,
       
    96 						   TSipProfileItcFunctions aITCFunction,
       
    97 						   const CSIPConcreteProfile& aProfile)
       
    98 	{
       
    99     CBufFlat* buf = ExternalizeLC (aProfile);
       
   100     TPtr8 externalized = buf->Ptr(0);
       
   101     iITCMsgArgs.Set(ESipProfileItcArgProfile, &externalized);
       
   102 
       
   103     SendL (aIds,aITCFunction);
       
   104     CleanupStack::PopAndDestroy(buf);
       
   105 	}
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSIPProfileITCHelper::Send
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TInt CSIPProfileITCHelper::Send(
       
   112 	TSIPProfileSlots& aIds, TSipProfileItcFunctions aITCFunction)
       
   113 	{
       
   114     TPckgBuf<TSIPProfileSlots> sipIdsPckg(aIds);
       
   115 	iITCMsgArgs.Set(ESipProfileItcArgSlots, &sipIdsPckg);
       
   116 
       
   117     TInt err = iSip.Send(iITCMsgArgs,aITCFunction);
       
   118 	aIds = sipIdsPckg();
       
   119 	return err;
       
   120 	}
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CSIPProfileITCHelper::ExternalizeLC
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 template<class T> CBufFlat* CSIPProfileITCHelper::ExternalizeLC(
       
   127 	const T& aElements)
       
   128 	{
       
   129 	CBufFlat* buf = CBufFlat::NewL(100);
       
   130 	CleanupStack::PushL(buf);
       
   131 	RBufWriteStream writeStream(*buf,0);
       
   132 	writeStream.PushL();
       
   133 	aElements.ExternalizeL(writeStream);
       
   134 	CleanupStack::Pop(1); // writeStream
       
   135 	writeStream.Close();
       
   136     return buf;
       
   137 	}