telephonyserver/etelpacketdata/cetel/pckt_retrieve.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2008-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 // This file contains all the code for the retrieval classes which retrieve variable length 
       
    15 // buffers from the TSY, such as MBMS monitor service list and MBMS sessions. 
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include "pcktretrieve.h"
       
    24 #include <pcktcs.h>
       
    25 #include <etelext.h>
       
    26 
       
    27 //
       
    28 //
       
    29 // Retrieve a list of MBMS monitored service entries 
       
    30 //
       
    31 //
       
    32 EXPORT_C CRetrievePcktMbmsMonitoredServices* CRetrievePcktMbmsMonitoredServices::NewL(RPacketService& aService)
       
    33 /** Creates an instance of the CActive derived CRetrievePcktMbmsMonitoredServices 
       
    34  * class.
       
    35  * @param aService An instance of RPacketService over which the list retrieval class operates.
       
    36  * @return The newly created CRetrievePcktMbmsMonitoredServices class. 
       
    37  * @capability None
       
    38  */
       
    39 	{
       
    40 	CRetrievePcktMbmsMonitoredServices* self = new(ELeave) CRetrievePcktMbmsMonitoredServices(aService);
       
    41 	CleanupStack::PushL(self);
       
    42 	self->ConstructL();
       
    43 	CleanupStack::Pop();
       
    44 	return self;
       
    45 	}
       
    46 	
       
    47 CRetrievePcktMbmsMonitoredServices::CRetrievePcktMbmsMonitoredServices(RPacketService& aService) 
       
    48 :	CAsyncRetrieveWithClientIds(aService.SessionHandle().Handle(), aService.SubSessionHandle()),
       
    49 	iService(aService)
       
    50 /**
       
    51  * Standard constructor; initialises the data members. 
       
    52  */
       
    53 	{
       
    54 	}
       
    55 
       
    56 void CRetrievePcktMbmsMonitoredServices::ConstructL()
       
    57 /**
       
    58  * Part of 2 phase construction, assigns the IPCs to be used 
       
    59  * in 2 phase retrieval mechanism.
       
    60  */
       
    61 	{
       
    62 	iIpcPhase1=EPacketGetMbmsMonitoredServicesPhase1;
       
    63 	iIpcPhase2=EPacketGetMbmsMonitoredServicesPhase2;
       
    64 	iIpcCancel=EPacketGetMbmsMonitoredServicesCancel;
       
    65 	}
       
    66 
       
    67 EXPORT_C CRetrievePcktMbmsMonitoredServices::~CRetrievePcktMbmsMonitoredServices()
       
    68 /** 
       
    69  * The destructor frees all resources owned by the object, prior to its destruction.
       
    70  */
       
    71 	{
       
    72 	Cancel();
       
    73 	delete iResults;
       
    74 	}
       
    75 
       
    76 EXPORT_C CPcktMbmsMonitoredServiceList* CRetrievePcktMbmsMonitoredServices::RetrieveListL()
       
    77 /** 
       
    78  * Provides the client with a handle to the appropriate 
       
    79  * MBMS service availability list class retrieved. The client will call this function 
       
    80  * once Start() has completed.
       
    81  * The ownership of the list object is transferred to the client and the client 
       
    82  * is responsible for eventual deletion of this object.	 
       
    83  *
       
    84  * @leave KErrNotFound If there is no valid list object to return to the client.
       
    85  * @return A handle to the list class retrieved from the store. If there are no entries in 
       
    86  * the list then a handle to an empty list is returned.
       
    87  * @capability ReadDeviceData
       
    88  */
       
    89 	{
       
    90 	if (iResults)
       
    91 		{
       
    92 		// Give ownership of list to caller of this method
       
    93 		CPcktMbmsMonitoredServiceList* ptr=iResults;
       
    94 		iResults = NULL;
       
    95 		return ptr;
       
    96 		}
       
    97 	else
       
    98 		{
       
    99 		User::Leave(KErrNotFound);
       
   100 		return NULL;
       
   101 		}
       
   102 	}
       
   103 	
       
   104 EXPORT_C void CRetrievePcktMbmsMonitoredServices::Start(TRequestStatus& aReqStatus)
       
   105 /** Starts the two-phase list retrieval of all entries within the store.
       
   106  * 
       
   107  * @param aReqStatus On completion, the status of the request; KErrNone if successful, 
       
   108  * KErrNotSupported if the phone does not support access to an MBMS service availability list  
       
   109  * and KErrNotFound if the list does not exist. If the list is empty then KErrNone
       
   110  * is returned.
       
   111  * @capability ReadDeviceData
       
   112  */
       
   113 	{
       
   114 	if (!CompleteIfInUse(aReqStatus))
       
   115 		{
       
   116 	   	delete iResults;
       
   117 		iResults = NULL;
       
   118 		CAsyncRetrieveVariableLengthBufferV2::Start(aReqStatus,&iId,&iId);
       
   119 		}
       
   120 	}
       
   121 		
       
   122 void CRetrievePcktMbmsMonitoredServices::RestoreListL()
       
   123 /**
       
   124  * Restores a list from a buffer that contains the streamed version of the list
       
   125  */
       
   126 	{
       
   127 	iResults=CPcktMbmsMonitoredServiceList::NewL();
       
   128 	iResults->RestoreL(iResultsPtr);
       
   129 	FreeBuffer();
       
   130 	}
       
   131 	
       
   132 void CRetrievePcktMbmsMonitoredServices::CancelReq(TInt aIpc1, TInt aIpc2)
       
   133 /**
       
   134  *  Cancels previously issued request
       
   135  */
       
   136 	{
       
   137 	iService.CancelReq(aIpc1, aIpc2);
       
   138 	}
       
   139 		
       
   140 void CRetrievePcktMbmsMonitoredServices::Get(TInt aIpc, TRequestStatus& aReqStatus, TDes8& aDes1, TDes8& aDes2)
       
   141 /** 
       
   142  * Sends a request through the sub-session this object was created with.
       
   143  */
       
   144 	{
       
   145 	iService.Get(aIpc, aReqStatus, aDes1, aDes2);
       
   146 	}
       
   147 
       
   148 CAsyncRetrieveWithClientIds::CAsyncRetrieveWithClientIds(TInt aSessionHandle, TInt aSubSessionHandle)
       
   149 	{
       
   150 	iId().iSessionHandle = aSessionHandle;
       
   151 	iId().iSubSessionHandle = aSubSessionHandle;
       
   152 	}
       
   153 
       
   154 EXPORT_C CRetrievePcktMbmsSessionList* CRetrievePcktMbmsSessionList::NewL(RPacketMbmsContext& aPcktMbmsContext, RPacketMbmsContext::CMbmsSession& aSessionIdList)
       
   155 /**
       
   156  * Standard 2 phase constructor.
       
   157  * @param aPcktMbmsContext Reference to an open MBMS packet context object.
       
   158  * @param aSessionIdList On completion this holds the list of MBMS sessions.
       
   159  * @return Pointer instance of the class.
       
   160  */
       
   161 	{
       
   162 	return new (ELeave)CRetrievePcktMbmsSessionList(aPcktMbmsContext, aSessionIdList);
       
   163 	}
       
   164 
       
   165 EXPORT_C void CRetrievePcktMbmsSessionList::Start(TRequestStatus& aReqStatus)
       
   166 /**
       
   167  * Starts the 2 phase retrieval. Assigns the IPCs to be used for the 2-phase retrieval mechanism.
       
   168  * @param aReqStatus On return, KErrNone if successful.
       
   169  * @capability ReadDeviceData
       
   170  */
       
   171 	{
       
   172 	if (!CompleteIfInUse(aReqStatus))
       
   173 		{
       
   174 		iIpcPhase1=EPacketGetMbmsSessionListPhase1;
       
   175 		iIpcPhase2=EPacketGetMbmsSessionListPhase2;
       
   176 		iIpcCancel=EPacketGetMbmsSessionListCancel;
       
   177 		CAsyncRetrieveVariableLengthBufferV2::Start(aReqStatus,&iId,&iId); 
       
   178 		}
       
   179 	}
       
   180 void CRetrievePcktMbmsSessionList::Get(TInt aIpc, TRequestStatus& aReqStatus, TDes8& aDes1, TDes8& aDes2)
       
   181 /**
       
   182  * Issues requested IPC to the ETEL/TSY
       
   183  */
       
   184 	{
       
   185 	iPcktMbmsContext.Get(aIpc, aReqStatus, aDes1, aDes2);
       
   186 	}
       
   187 void CRetrievePcktMbmsSessionList::CancelReq(TInt aIpc1, TInt aIpc2)
       
   188 /**
       
   189  * Cancels previously issued request
       
   190  */
       
   191 	{
       
   192 	iPcktMbmsContext.CancelReq(aIpc1,aIpc2);
       
   193 	}
       
   194 void CRetrievePcktMbmsSessionList::RestoreListL()
       
   195 /**
       
   196  * Overload of base class virtual method; de-serializes data retrieved from TSY to 
       
   197  * provided data structure.
       
   198  */
       
   199 	{
       
   200 	iSessionIdList.InternalizeL(iResultsPtr);
       
   201 	FreeBuffer();
       
   202 	}
       
   203 CRetrievePcktMbmsSessionList::CRetrievePcktMbmsSessionList(RPacketMbmsContext& aPcktMbmsContext,RPacketMbmsContext::CMbmsSession& aSessionIdList)
       
   204 :iPcktMbmsContext(aPcktMbmsContext),iSessionIdList(aSessionIdList)
       
   205 /**
       
   206  * Standard constructor; initialises data members and the base class
       
   207  */	
       
   208 	{
       
   209 	iId().iSessionHandle=iPcktMbmsContext.SessionHandle().Handle();
       
   210 	iId().iSubSessionHandle=iPcktMbmsContext.SubSessionHandle();
       
   211 	}
       
   212