locationsystemui/locationsysui/privacyverifiernotifierui/locverifier/src/lpdrequestorprocessor.cpp
branchRCL_3
changeset 44 2b4ea9893b66
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Processes requestor related data.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "lpdrequestorprocessor.h"
       
    21 #include "contactresolversession.h"
       
    22 
       
    23 #include "locverifierdlgdebug.h"
       
    24 #include <lbs/epos_cposrequestor.h>
       
    25 #include <lbs/epos_cposcontactrequestor.h>
       
    26 #include <lbs/epos_cposservicerequestor.h>
       
    27 #include <epos_cposprivacynotifier.h>
       
    28 
       
    29 
       
    30 // Unnamed namespace for local definitions
       
    31 
       
    32 const TInt KRequestorsGranularity = 5;
       
    33 #ifdef _DEBUG
       
    34 _LIT( KPanicText, "CLpdRequestorProcessor" );
       
    35 enum TPanicCode
       
    36     {
       
    37     KLpdErrGeneral = 1
       
    38     };
       
    39 #endif
       
    40 
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ===============================
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CLpdRequestorProcessor::CLpdRequestorProcessor
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CLpdRequestorProcessor::CLpdRequestorProcessor() 
       
    51 : iRequestors( KRequestorsGranularity)
       
    52     {
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CLpdRequestorProcessor::NewL
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CLpdRequestorProcessor* CLpdRequestorProcessor::NewL()
       
    61     {
       
    62     CLpdRequestorProcessor* self = new( ELeave ) CLpdRequestorProcessor;
       
    63     // Nothing to do in the Second Phase Constructor
       
    64     return self;
       
    65     }
       
    66     
       
    67 // Destructor
       
    68 CLpdRequestorProcessor::~CLpdRequestorProcessor()
       
    69     {
       
    70     iRequestors.ResetAndDestroy();
       
    71     iRequestors.Close();
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CLpdRequestorProcessor::ReadRequestorsL
       
    76 // (other items were commented in a header).
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TBool CLpdRequestorProcessor::ReadRequestorsL(
       
    80     const CPosPrivacyNotifier& aPosNotifier )
       
    81     {
       
    82     LOCVERIFIERDLGDEBUG( "+CLpdGlobalPluginDialog::ReadRequestorsL" );
       
    83     __ASSERT_DEBUG( aPosNotifier.CurrentRequest() != KPosNullQNRequestId,
       
    84                     HandleAssertErrorL() );
       
    85 
       
    86     this->ResetAndDestroyRequestors();
       
    87     
       
    88     TBool allRequestorIdsValid = ETrue;
       
    89    
       
    90     // Let's read the requestors associated with the current request:
       
    91     TInt nofRequestors = aPosNotifier.RequestorCountL();
       
    92 
       
    93     for ( TInt i = 0; i < nofRequestors; i++ )
       
    94         {
       
    95         CPosRequestor* requestor = aPosNotifier.RequestorLC( i );
       
    96         
       
    97         if ( RequestorIdValid( *requestor ) )
       
    98             { // mark that some requestor id is invalid
       
    99             allRequestorIdsValid = EFalse;
       
   100             }
       
   101                
       
   102         User::LeaveIfError( iRequestors.Append( requestor ) );
       
   103         CleanupStack::Pop( requestor ); // iRequestors owns now the requestor
       
   104         }
       
   105 
       
   106     if ( nofRequestors == 0 )
       
   107         {
       
   108         allRequestorIdsValid = EFalse; // zero requestors == invalid
       
   109         }
       
   110 
       
   111      RContactResolverSession resSession;
       
   112      TInt err = resSession.Connect();
       
   113     
       
   114      // If any error in connection,dont leave.Use un-resolved requestors
       
   115      if( KErrNone == err )
       
   116      	{
       
   117      	resSession.ResolveRequestorsL(iRequestors);
       
   118      	}
       
   119      resSession.Close();
       
   120        
       
   121     LOCVERIFIERDLGDEBUG( "-CLpdGlobalPluginDialog::ReadRequestorsL" );
       
   122     return allRequestorIdsValid;
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CLpdRequestorProcessor::ResetAndDestroyRequestors
       
   127 // (other items were commented in a header).
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CLpdRequestorProcessor::ResetAndDestroyRequestors()
       
   131     {
       
   132     iRequestors.ResetAndDestroy();
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CLpdRequestorProcessor::RequestorIdValid
       
   137 // (other items were commented in a header).
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 TBool CLpdRequestorProcessor::RequestorIdValid(
       
   141     const CPosRequestor& aRequestor )
       
   142     {
       
   143     return( aRequestor.RequestorIdFormat() != CPosRequestor::EIdFormatUnknown );
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CLpdRequestorProcessor::HandleAssertErrorL
       
   148 // (other items were commented in a header).
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CLpdRequestorProcessor::HandleAssertErrorL() const
       
   152     {
       
   153     #ifdef _DEBUG
       
   154         User::Panic( KPanicText, KLpdErrGeneral );
       
   155     #else
       
   156         User::Leave( KErrCorrupt );
       
   157     #endif
       
   158     }
       
   159 // end of file