locationsystemui/locationsysui/locverifier/src/lpdrequestao.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2002 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:  Active object which ensures that current call stack is run to
       
    15 *                completion before a new request is handled
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "lpdrequestao.h"
       
    22 #include "lpdverifierplugin.h"
       
    23 #include <lbs/epos_cposrequestor.h>
       
    24 #include <lbs/epos_rposrequestorstack.h>
       
    25 #include <AknNotifierAppServer.h>
       
    26 #include <eikenv.h>
       
    27 #include <eiknotapi.h>
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CLpdRequestAO::CLpdRequestAO
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CLpdRequestAO::CLpdRequestAO( CLpdVerifierPlugin& aPlugin )
       
    38     : CActive( CActive::EPriorityHigh ), iPlugin( aPlugin )
       
    39     {
       
    40 	}
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CLpdRequestAO::NewL
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CLpdRequestAO* CLpdRequestAO::NewL( CLpdVerifierPlugin& aPlugin )
       
    48 	{
       
    49     CLpdRequestAO* self = new( ELeave ) CLpdRequestAO( aPlugin );
       
    50     CActiveScheduler::Add(self);
       
    51 
       
    52     CAknNotifierAppServer* AknNServer = 
       
    53         static_cast<CAknNotifierAppServer*>(CEikonEnv::Static()->AppServer());
       
    54     AknNServer->UnbalanceReferenceCountForNotif(aPlugin.NotifierBase()->Info().iUid,ETrue);
       
    55     // Nothing to do in the Second Phase Constructor
       
    56     return self;
       
    57 	}
       
    58 
       
    59 // Destructor
       
    60 CLpdRequestAO::~CLpdRequestAO()
       
    61 	{
       
    62     Cancel();
       
    63     iNotificationQue.ResetAndDestroy();
       
    64     iNotificationQue.Close();
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CLpdRequestAO::ScheduleRequest
       
    69 // (other items were commented in a header).
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CLpdRequestAO::ScheduleRequest()
       
    73     {	     
       
    74     Cancel();
       
    75     SetActive();
       
    76     TRequestStatus* status = &iStatus;
       
    77     User::RequestComplete( status, KErrNone );            
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CLpdRequestAO::RunL
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CLpdRequestAO::RunL()
       
    86     {	    
       
    87     // Let's call the non-leaving method so that plugin
       
    88     // takes care of error handling.
       
    89     RArray<TPosQNRequestId> requests;
       
    90     CleanupClosePushL( requests );
       
    91     iPlugin.GetRequestsL( requests );
       
    92     if ( requests.Count() == 0 )
       
    93     	{
       
    94     	if( iNotificationQue.Count() )
       
    95     	    {
       
    96         	iPlugin.FreeQueryResources();
       
    97         	CLpdNotifReqInfo* notifInfo = iNotificationQue[0];
       
    98         	iPlugin.NotifyCancellationL(notifInfo->Source(),
       
    99         								notifInfo->Reason(),
       
   100         								notifInfo->Decision(),
       
   101         								notifInfo->Requestors());
       
   102     	    iNotificationQue.Remove(0);
       
   103     	    delete notifInfo;
       
   104     	    iNotificationQue.Compress();
       
   105     	    }
       
   106         else
       
   107             {
       
   108     	    CAknNotifierAppServer* AknNServer = 
       
   109                 static_cast<CAknNotifierAppServer*>(CEikonEnv::Static()->AppServer());
       
   110             AknNServer->UnbalanceReferenceCountForNotif(iPlugin.NotifierBase()->Info().iUid,EFalse);
       
   111     	    iPlugin.HandleNextRequest();
       
   112             }
       
   113     	}
       
   114     else
       
   115     	{
       
   116 	    iPlugin.HandleNextRequest();
       
   117     	}
       
   118     CleanupStack::PopAndDestroy();
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CLpdRequestAO::DoCancel
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CLpdRequestAO::DoCancel()
       
   127     {
       
   128     // Not important with this AO
       
   129 	}
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CLpdRequestAO::EnqueueRequestL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CLpdRequestAO::EnqueueRequestL( TPosRequestSource aSource,
       
   137 								    TPosVerifyCancelReason aReason,
       
   138 								    TPosRequestDecision aDecision,
       
   139 								    RPosRequestorStack* aRequestors )
       
   140 	{
       
   141 	CLpdNotifReqInfo* notifReqInfo = CLpdNotifReqInfo::NewL(aSource, 
       
   142 													  aReason,
       
   143 													  aDecision,
       
   144 													  aRequestors);
       
   145 	
       
   146 	// The ownership is transferred to iNotificationQue
       
   147 	iNotificationQue.Append(notifReqInfo);
       
   148 	}
       
   149 	
       
   150 //  End of File