networkprotocolmodules/suplprotocolmodule/SuplProtocol/src/suplsessioncompleter.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     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 provides the implementation of a class that
       
    15 // completes sessions with LBS asynchronously.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22  @deprecated
       
    23 */
       
    24 
       
    25 
       
    26 #include "suplsessioncompleter.h"
       
    27 #include "suplprotocolmanager.h"
       
    28 #include "supldevloggermacros.h"
       
    29 
       
    30 /** Static constructor.
       
    31 @return A new instance of the CSuplSessionCompleter class.
       
    32 */  
       
    33 CSuplSessionCompleter* CSuplSessionCompleter::NewL(MSuplProtocolManagerObserver& aGateway)
       
    34 	{
       
    35 	SUPLLOG(ELogP1, "CSuplSessionCompleter::NewL() Begin\n");
       
    36 	CSuplSessionCompleter* self = new (ELeave) CSuplSessionCompleter(aGateway);
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(self);
       
    40 	SUPLLOG(ELogP1, "CSuplSessionCompleter::NewL() End\n");
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 
       
    45 /** Standard constructor.
       
    46 */  
       
    47 CSuplSessionCompleter::CSuplSessionCompleter(MSuplProtocolManagerObserver& aGateway): CActive(EPriorityLow),
       
    48 							iGateway(aGateway)
       
    49 	{
       
    50 	SUPLLOG(ELogP1, "CSuplSessionCompleter::CSuplSessionCompleter() Begin\n");
       
    51 	SUPLLOG(ELogP1, "CSuplSessionCompleter::CSuplSessionCompleter() End\n");
       
    52 	}
       
    53 
       
    54 
       
    55 /** Standard destructor.
       
    56 */  
       
    57 CSuplSessionCompleter::~CSuplSessionCompleter()
       
    58 	{
       
    59 	SUPLLOG(ELogP1, "CSuplSessionCompleter::~CSuplSessionCompleter() Begin\n");
       
    60 	iSessionInfo.Reset();
       
    61 	SUPLLOG(ELogP1, "CSuplSessionCompleter::~CSuplSessionCompleter() End\n");
       
    62 	}
       
    63 
       
    64 
       
    65 /** Private second-stage constructor.
       
    66 */  
       
    67 void CSuplSessionCompleter::ConstructL()
       
    68 	{
       
    69 	SUPLLOG(ELogP1, "CSuplSessionCompleter::ConstructL() Begin\n");
       
    70 	CActiveScheduler::Add(this);
       
    71 	SUPLLOG(ELogP1, "CSuplSessionCompleter::ConstructL() End\n");
       
    72 	}
       
    73 
       
    74 
       
    75 /** Store a session Id for later completion
       
    76 */  
       
    77 void CSuplSessionCompleter::CompleteSession(const TLbsNetSessionId& aSessionId, TInt aError)
       
    78 	{
       
    79 	SUPLLOG(ELogP1, "CSuplSessionCompleter::CompleteSession() Begin\n");
       
    80 
       
    81 	TSuplCompleteDetails completionInfo;
       
    82 	completionInfo.iSessionId = aSessionId;
       
    83 	completionInfo.iError = aError;
       
    84 	
       
    85 	TRAPD(err,iSessionInfo.InsertL(completionInfo,0));
       
    86 	if (err != KErrNone)
       
    87 		{
       
    88 		// It is not possible to complete asynchronously,
       
    89 		// so send a session complete indication now.
       
    90 		iGateway.SessionCompleteInd(aSessionId, aError);
       
    91 		}
       
    92 	else
       
    93 		{
       
    94 		ActivateCompleter();
       
    95 		}
       
    96 	SUPLLOG(ELogP1, "CSuplSessionCompleter::CompleteSession() End\n");
       
    97 	}
       
    98 	
       
    99 	
       
   100 /** Store a session Id for later completion
       
   101 */  
       
   102 void CSuplSessionCompleter::RunError()
       
   103 	{
       
   104 	SUPLLOG(ELogP1, "CSuplSessionCompleter::RunError() Begin\n");
       
   105 	// Not much can be done.		
       
   106 	SUPLLOG(ELogP1, "CSuplSessionCompleter::RunError() End\n");
       
   107 	}
       
   108 	
       
   109 /**
       
   110 */
       
   111 void CSuplSessionCompleter::DoCancel()
       
   112 	{
       
   113 	SUPLLOG(ELogP1, "CSuplSessionCompleter::DoCancel() Begin\n");
       
   114 		
       
   115 	SUPLLOG(ELogP1, "CSuplSessionCompleter::DoCancel() End\n");
       
   116 	}
       
   117 
       
   118 /** Take the next session Id stored and
       
   119 send a session complete to LBS
       
   120 */  
       
   121 void CSuplSessionCompleter::RunL()
       
   122 	{
       
   123 	SUPLLOG(ELogP1, "CSuplSessionCompleter::RunL() Begin\n");
       
   124 	TLbsNetSessionId sessionId;
       
   125 	TInt sessionErr = KErrNone;
       
   126 	if(iSessionInfo.Count() > 0)
       
   127 		{
       
   128 		sessionId = iSessionInfo[iSessionInfo.Count() - 1].iSessionId;
       
   129 		sessionErr = iSessionInfo[iSessionInfo.Count() - 1].iError;
       
   130 		iSessionInfo.Remove(iSessionInfo.Count() - 1);
       
   131 		}
       
   132 
       
   133 	iGateway.SessionCompleteInd(sessionId, sessionErr);
       
   134 	
       
   135 	if(iSessionInfo.Count()>0)
       
   136 		{
       
   137 		ActivateCompleter();	
       
   138 		}
       
   139 	SUPLLOG(ELogP1, "CSuplSessionCompleter::RunL() End\n");
       
   140 	}
       
   141 
       
   142 void CSuplSessionCompleter::ActivateCompleter()
       
   143 	{
       
   144 	SUPLLOG(ELogP1, "CSuplSessionCompleter::ActivateCompleter() Begin\n");
       
   145 	if(!IsActive())
       
   146 		{
       
   147 		TRequestStatus* localStatus = &iStatus;
       
   148 		iStatus = KRequestPending;
       
   149 		SetActive();
       
   150 		User::RequestComplete(localStatus, KErrNone);
       
   151 		}	
       
   152 	SUPLLOG(ELogP1, "CSuplSessionCompleter::ActivateCompleter() End\n");
       
   153 	}