supl/locationsuplfw/gateway/src/epos_csuplsessionrequest.cpp
changeset 0 667063e416a2
child 18 d746aee05493
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:   Asynchronous SUPL session request
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 
       
    23 #include "epos_suplterminalerrors.h"
       
    24 #include "epos_csuplprotocolmanagerbase.h"
       
    25 #include "epos_csuplsessionbase.h"
       
    26 #include "epos_csuplglobal.h"
       
    27 #include "epos_csuplsessionmanager.h"
       
    28 #include "epos_csuplserverpanic.h"
       
    29 #include "epos_msuplsessionobserver.h"
       
    30 #include "epos_mnetinitiatedobserver.h"
       
    31 #include "epos_csuplsessionrequest.h"
       
    32 #include "epos_suplterminalconstants.h"
       
    33 
       
    34 
       
    35 // CONSTANTS
       
    36 //#ifdef _DEBUG
       
    37 _LIT(KTraceFileName, "SUPL_GW::epos_csuplsessionrequest.cpp");
       
    38 //#endif
       
    39 
       
    40 // ================= LOCAL FUNCTIONS ========================
       
    41  
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 //
       
    47 CSuplSessionRequest::CSuplSessionRequest(CSuplSessionManager& aSessnMgr, CSuplSessionBase* aSuplSessn, MSuplSessionObserver* aObserver):
       
    48     CActive(EPriorityStandard),
       
    49     iRequestPhase(ESuplReqInactive),
       
    50     iObserver(aObserver),
       
    51     iSessnMgr(aSessnMgr),
       
    52     iSuplSessn(aSuplSessn)    
       
    53     {
       
    54     DEBUG_TRACE("CSuplSessionRequest::CSuplSessionRequest", __LINE__)
       
    55     CActiveScheduler::Add(this);
       
    56     
       
    57     }
       
    58 CSuplSessionRequest::CSuplSessionRequest(CSuplSessionManager& aSessnMgr, CSuplSessionBase* aSuplSessn, MNetInitiatedObserver* aObserver):
       
    59     CActive(EPriorityStandard),
       
    60     iRequestPhase(ESuplReqInactive),
       
    61     iNetObserver(aObserver),
       
    62     iSessnMgr(aSessnMgr),
       
    63     iSuplSessn(aSuplSessn)
       
    64     {
       
    65     DEBUG_TRACE("CSuplSessionRequest::CSuplSessionRequest", __LINE__)
       
    66     CActiveScheduler::Add(this);
       
    67     
       
    68     }
       
    69 
       
    70 // EPOC default constructor can leave.
       
    71 void CSuplSessionRequest::ConstructL()
       
    72     {
       
    73     }
       
    74 
       
    75 // Two-phased constructor.
       
    76 CSuplSessionRequest* CSuplSessionRequest::NewL(CSuplSessionManager& aSessnMgr, CSuplSessionBase* aSuplSessn, MSuplSessionObserver* aObserver)
       
    77     {
       
    78     DEBUG_TRACE("CSuplSessionRequest::NewL", __LINE__)
       
    79     CSuplSessionRequest* self = new (ELeave) CSuplSessionRequest(aSessnMgr, aSuplSessn, aObserver);
       
    80     CleanupStack::PushL(self);
       
    81     self->ConstructL();
       
    82     CleanupStack::Pop(self);
       
    83     return self;
       
    84     }
       
    85 CSuplSessionRequest* CSuplSessionRequest::NewL(CSuplSessionManager& aSessnMgr, CSuplSessionBase* aSuplSessn, MNetInitiatedObserver* aObserver)
       
    86     {
       
    87     DEBUG_TRACE("CSuplSessionRequest::NewL", __LINE__)
       
    88     CSuplSessionRequest* self = new (ELeave) CSuplSessionRequest(aSessnMgr, aSuplSessn, aObserver);
       
    89     CleanupStack::PushL(self);
       
    90     self->ConstructL();
       
    91     CleanupStack::Pop(self);
       
    92     return self;
       
    93     }
       
    94 // Destructor
       
    95 CSuplSessionRequest::~CSuplSessionRequest()
       
    96     {
       
    97     DEBUG_TRACE("CSuplSessionRequest::~CSuplSessionRequest", __LINE__)
       
    98 	if (IsActive())      
       
    99       	Cancel();
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CSuplSessionRequest::MakeSuplSessionRequestL
       
   104 //
       
   105 // (other items were commented in a header).
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 void CSuplSessionRequest::MakeSuplSessionRequestL(CSuplSessionBase* aSuplSessn, TInt aSetCaps, TInt aReqId, TBool aFirstReq)
       
   109     {
       
   110     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionRequestL", __LINE__)
       
   111     iRequestPhase = ESuplSessionRequest;
       
   112 	iStatus = KRequestPending;
       
   113 	TBool fallBack = ETrue;
       
   114 	TBuf<KMaxHslpAddressLength> aHslpAddress (KNullDesC);
       
   115 	
       
   116 	iSessnMgr.RunSuplSessionL(aSuplSessn, iStatus, aHslpAddress, fallBack, aSetCaps, aReqId, aFirstReq);
       
   117 	SetActive();
       
   118     }
       
   119 // ---------------------------------------------------------
       
   120 // CSuplSessionRequest::MakeSuplSessionRequestL
       
   121 //
       
   122 // (other items were commented in a header).
       
   123 // ---------------------------------------------------------
       
   124 //
       
   125 void CSuplSessionRequest::MakeSuplSessionRequestL(CSuplSessionBase* aSuplSessn, TInt aSetCaps, TInt aReqId, TSuplTerminalQop& aQop, TBool aFirstReq)
       
   126     {
       
   127     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionRequestL", __LINE__)
       
   128     iRequestPhase = ESuplSessionRequest;
       
   129 	iStatus = KRequestPending;
       
   130 	TBool fallBack = ETrue;
       
   131 	TBuf<KMaxHslpAddressLength> aHslpAddress ( KNullDesC);
       
   132 	
       
   133 	iSessnMgr.RunSuplSessionL(aSuplSessn, iStatus, aHslpAddress, fallBack, aSetCaps, aReqId, aQop, aFirstReq);
       
   134 	SetActive();
       
   135     }
       
   136 
       
   137 void CSuplSessionRequest::MakeSuplSessionRequestL(CSuplSessionBase* aSuplSessn,const TDesC& aHslpAddress, TBool aFallBack, TInt aSetCaps, TInt aReqId, TBool aFirstReq)
       
   138     {
       
   139     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionRequestL", __LINE__)
       
   140     iRequestPhase = ESuplSessionRequest;
       
   141     iStatus = KRequestPending;
       
   142     iSessnMgr.RunSuplSessionL(aSuplSessn, iStatus, aHslpAddress, aFallBack, aSetCaps, aReqId, aFirstReq);
       
   143 	SetActive();
       
   144     }
       
   145 
       
   146 void CSuplSessionRequest::MakeSuplSessionRequestL(CSuplSessionBase* aSuplSessn,const TDesC& aHslpAddress, TBool aFallBack, TInt aSetCaps, TInt aReqId, TSuplTerminalQop& aQop, TBool aFirstReq)
       
   147     {
       
   148     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionRequestL", __LINE__)
       
   149     iRequestPhase = ESuplSessionRequest;
       
   150     iStatus = KRequestPending;
       
   151     iSessnMgr.RunSuplSessionL(aSuplSessn, iStatus, aHslpAddress, aFallBack, aSetCaps, aReqId, aQop, aFirstReq);
       
   152     SetActive();
       
   153     }  
       
   154     
       
   155 // ---------------------------------------------------------
       
   156 // CSuplSessionRequest::ForwardMessageRequestL
       
   157 //
       
   158 // (other items were commented in a header).
       
   159 // ---------------------------------------------------------
       
   160 //    
       
   161 void CSuplSessionRequest::ForwardMessageRequestL(
       
   162 			CSuplSessionBase* aSuplSessn,
       
   163 			TInt aHandle,
       
   164 			HBufC8* clientBuf
       
   165 		)
       
   166 	{
       
   167 	DEBUG_TRACE("CSuplSessionRequest::ForwardMessageRequestL", __LINE__)
       
   168 	iHandle=aHandle;
       
   169 	iRequestPhase=ESuplForwardMessage;
       
   170 	iStatus=KRequestPending;
       
   171 	iSessnMgr.ForwardMessageL(aSuplSessn,iStatus, clientBuf);
       
   172 	SetActive();	
       
   173 	}
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // CSuplSessionRequest::CancelRunSessionRequest
       
   177 //
       
   178 // (other items were commented in a header).
       
   179 // ---------------------------------------------------------
       
   180 //
       
   181 void CSuplSessionRequest::CancelRunSessionRequest()
       
   182     {
       
   183     DEBUG_TRACE("CSuplSessionRequest::CancelRunSessionRequest", __LINE__)
       
   184     iRequestPhase = ESuplCancelRunSessionRequest;
       
   185 	iSessnMgr.CancelRunSession(iSuplSessn);
       
   186 	//SetActive();
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // CSuplSessionRequest::NotifyServerShutdown
       
   191 //
       
   192 // (other items were commented in a header).
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 void CSuplSessionRequest::NotifyServerShutdown()
       
   196     {
       
   197     DEBUG_TRACE("CSuplSessionRequest::NotifyServerShutdown", __LINE__)
       
   198     if (IsActive())
       
   199         {
       
   200 		iObserver->CompleteRunSession(KErrServerTerminated);
       
   201         Cancel();
       
   202         }
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------
       
   206 // CSuplSessionRequest::RunL
       
   207 //
       
   208 // (other items were commented in a header).
       
   209 // ---------------------------------------------------------
       
   210 //
       
   211 void CSuplSessionRequest::RunL()
       
   212     {
       
   213     DEBUG_TRACE("CSuplSessionRequest::RunL", __LINE__)
       
   214     TInt err = iStatus.Int();
       
   215     switch (iRequestPhase)
       
   216         {
       
   217         case ESuplStartTriggerRequest:
       
   218         case ESuplStopTriggerRequest:
       
   219         	{
       
   220 			iRequestPhase = ESuplReqInactive;
       
   221 			iObserver->CompleteTriggerRunSession(err);			
       
   222         	break;
       
   223         	}
       
   224         case ESuplTriggerFiredNotifyRequest:
       
   225         	{
       
   226 			iRequestPhase = ESuplReqInactive;
       
   227 			iObserver->CompleteTriggerFiredNotifyRequest(err);			
       
   228         	break;
       
   229         	}
       
   230         case ESuplSessionRequest:
       
   231             {
       
   232 			iRequestPhase = ESuplReqInactive;
       
   233 			iObserver->CompleteRunSession(err);
       
   234             break;
       
   235             }
       
   236        case ESuplCancelRunSessionRequest:
       
   237             {
       
   238 			iRequestPhase = ESuplReqInactive;
       
   239 			iObserver->CompleteRunSession(err);
       
   240             break;
       
   241             }
       
   242         case ESuplForwardMessage:
       
   243         	{	
       
   244         	iRequestPhase = ESuplReqInactive;
       
   245         	iNetObserver->CompleteForwardMessageL(iHandle);
       
   246         	break;
       
   247         	}
       
   248 
       
   249         default :
       
   250             DebugPanic(EPosSuplServerPanicRequestInconsistency);
       
   251         }
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------
       
   255 // CSuplSessionRequest::RunError
       
   256 //
       
   257 // (other items were commented in a header).
       
   258 // ---------------------------------------------------------
       
   259 //
       
   260 TInt CSuplSessionRequest::RunError(TInt /*aError*/)
       
   261     {
       
   262     DEBUG_TRACE("CSuplSessionRequest::RunError", __LINE__)
       
   263     return KErrNone;
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------
       
   267 // CSuplSessionRequest::DoCancel
       
   268 //
       
   269 // (other items were commented in a header).
       
   270 // ---------------------------------------------------------
       
   271 //
       
   272 void CSuplSessionRequest::DoCancel()
       
   273     {
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------
       
   277 // CSuplSessionRequest::CompleteSelf
       
   278 //
       
   279 // (other items were commented in a header).
       
   280 // ---------------------------------------------------------
       
   281 //
       
   282 void CSuplSessionRequest::CompleteSelf(TInt aReason)
       
   283     {
       
   284     DEBUG_TRACE("CSuplSessionRequest::CompleteSelf", __LINE__)
       
   285     TRequestStatus* status = &iStatus;
       
   286     User::RequestComplete(status, aReason);
       
   287     }
       
   288     
       
   289 // ---------------------------------------------------------
       
   290 // CSuplSessionRequest::ProtocolHUnloaded
       
   291 //
       
   292 // (other items were commented in a header).
       
   293 // ---------------------------------------------------------
       
   294 //     
       
   295 void CSuplSessionRequest::ProtocolHUnloaded() 
       
   296 	{	
       
   297 	DEBUG_TRACE("CSuplSessionRequest::ProtocolHUnloaded Start", __LINE__)
       
   298 	//Cancel();		
       
   299 	iSessnMgr.DestroySession(iSuplSessn);
       
   300 	iSuplSessn = NULL;
       
   301 	DEBUG_TRACE("CSuplSessionRequest::ProtocolHUnloaded End", __LINE__)	
       
   302 	}  
       
   303     
       
   304 // ---------------------------------------------------------
       
   305 // CSuplSessionRequest::MakeSuplSessionTriggerringRequestL
       
   306 //
       
   307 // (other items were commented in a header).
       
   308 // ---------------------------------------------------------
       
   309 //
       
   310 void CSuplSessionRequest::MakeSuplSessionTriggerringRequestL(
       
   311 				CSuplSessionBase* aSuplSessn, 
       
   312 				TSuplTerminalPeriodicTrigger& aPTrigger,
       
   313 				TInt aSetCaps, 
       
   314 				TInt aReqId)
       
   315     {
       
   316     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionTriggerringRequestL", __LINE__)
       
   317     iRequestPhase = ESuplStartTriggerRequest;	
       
   318 	iStatus = KRequestPending;
       
   319 	TBuf<KMaxHslpAddressLength> hslpAddress ( KNullDesC );
       
   320 	TBool fallBack = ETrue;
       
   321 	iSessnMgr.StartTriggerSessionL(
       
   322 		aSuplSessn, 
       
   323 		iStatus, 
       
   324 		aPTrigger,
       
   325 		hslpAddress,
       
   326 		fallBack,
       
   327 		aSetCaps, 
       
   328 		aReqId );	
       
   329 	SetActive();
       
   330     }
       
   331     
       
   332 // ---------------------------------------------------------
       
   333 // CSuplSessionRequest::MakeSuplStartTriggerRequestRequestL
       
   334 //
       
   335 // (other items were commented in a header).
       
   336 // ---------------------------------------------------------
       
   337 //
       
   338 void CSuplSessionRequest::MakeSuplSessionTriggerringRequestL(
       
   339 				CSuplSessionBase* aSuplSessn, 
       
   340 				TSuplTerminalPeriodicTrigger& aPTrigger,
       
   341 				const TDesC& aHslpAddress, 
       
   342 				TBool aFallBack,
       
   343 				TInt aSetCaps, 
       
   344 				TInt aReqId)
       
   345     {
       
   346     DEBUG_TRACE("CSuplSessionRequest::MakeSuplSessionTriggerringRequestL", __LINE__)    
       
   347     iRequestPhase = ESuplStartTriggerRequest;	
       
   348 	iStatus = KRequestPending;	
       
   349 	iSessnMgr.StartTriggerSessionL(
       
   350 		aSuplSessn, 
       
   351 		iStatus, 
       
   352 		aPTrigger,
       
   353 		aHslpAddress,
       
   354 		aFallBack,
       
   355 		aSetCaps, 
       
   356 		aReqId );		
       
   357 	SetActive();
       
   358     }
       
   359     
       
   360 // ---------------------------------------------------------
       
   361 // CSuplSessionRequest::NotifyTriggerFiredRequestL
       
   362 //
       
   363 // (other items were commented in a header).
       
   364 // ---------------------------------------------------------
       
   365 //
       
   366 void CSuplSessionRequest::NotifyTriggerFiredRequestL(
       
   367 			CSuplSessionBase* aSuplSessn, 
       
   368 			TSuplTriggerFireInfo& aFireInfo
       
   369 		)
       
   370 	{	
       
   371     iRequestPhase = ESuplTriggerFiredNotifyRequest;	
       
   372 	iStatus = KRequestPending;	
       
   373 	iSessnMgr.NotifyTriggerFired(
       
   374 		aSuplSessn, 
       
   375 		iStatus, 
       
   376 		aFireInfo);		
       
   377 	SetActive();		
       
   378 	}
       
   379 		
       
   380 // ---------------------------------------------------------
       
   381 // CSuplSessionRequest::CancelTriggerringRequest
       
   382 //
       
   383 // (other items were commented in a header).
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 void CSuplSessionRequest::CancelTriggerringRequest()
       
   387     {
       
   388     DEBUG_TRACE("CSuplSessionRequest::CancelTriggerringRequest", __LINE__)
       
   389     iRequestPhase = ESuplStopTriggerRequest;
       
   390     iSessnMgr.CancelTriggerringSession(iSuplSessn);	
       
   391 	//SetActive();
       
   392     }
       
   393     
       
   394 //  End of File