locationsystemui/locationsysui/privacyverifiernotifierui/locnotificationengine/src/locrequestorutilsresolver.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:  Implementation of location notification engine class. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 
       
    22 #include "locrequestorutilsresolver.h"
       
    23 #include "qlocnotificationengine.h"
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <barsread.h>
       
    27 
       
    28 
       
    29 #include <lbs/epos_cposrequestor.h>
       
    30 #include <lbs/epos_cposservicerequestor.h>
       
    31 #include <lbs/epos_cposcontactrequestor.h>
       
    32 
       
    33 
       
    34 
       
    35 
       
    36 // ============= CLocRequestorUtilsResolver MEMBER FUNCTIONS =================
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CLocRequestorUtilsResolver::NewL
       
    40 // 2 Phase Constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CLocRequestorUtilsResolver* CLocRequestorUtilsResolver::NewL()
       
    44 	{
       
    45 	CLocRequestorUtilsResolver* self = 
       
    46 							new(ELeave) CLocRequestorUtilsResolver();
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL();
       
    49 	CleanupStack::Pop(self);
       
    50     return self;
       
    51 	}
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // destructor
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CLocRequestorUtilsResolver::~CLocRequestorUtilsResolver()
       
    58 	{
       
    59 	delete iEngine;
       
    60 	iEngine = NULL;
       
    61 	}
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // The method resolves requestors by delegating requests to QPosRequestorData
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 EXPORT_C void CLocRequestorUtilsResolver::ResolveRequestorsL( 
       
    68 	RPointerArray<CPosRequestor>& aRequestors )
       
    69 	{
       
    70     //resolve requestors one by one by extracting the idFormat and idString 
       
    71     //from the requestor array
       
    72     TInt count = aRequestors.Count();
       
    73     for(TInt iter = 0; iter < count; ++iter)
       
    74         {        
       
    75         CPosRequestor::TRequestorIdFormat idFormat = aRequestors[iter]->RequestorIdFormat();        
       
    76         QPosRequestorData::IdFormat qposidformat;
       
    77          switch(idFormat)
       
    78         {
       
    79 
       
    80         case CPosRequestor::EIdFormatGenericName:
       
    81              qposidformat=QPosRequestorData::EIdFormatGenericName;
       
    82              break;	
       
    83              
       
    84         case CPosRequestor::EIdFormatPhoneNumber:
       
    85             qposidformat=QPosRequestorData::EIdFormatPhoneNumber;
       
    86              break;
       
    87         case CPosRequestor::EIdFormatUrl:
       
    88             qposidformat=QPosRequestorData::EIdFormatUrl;
       
    89               break;
       
    90         case CPosRequestor::EIdFormatEmail:
       
    91             qposidformat=QPosRequestorData::EIdFormatEmail;
       
    92              break;
       
    93         case CPosRequestor::EIdFormatSIPUrl:
       
    94             qposidformat=QPosRequestorData::EIdFormatSIPUrl;
       
    95              break;
       
    96         case CPosRequestor::EIdFormatIMSPublicIdentity:
       
    97             qposidformat=QPosRequestorData::EIdFormatIMSPublicIdentity;
       
    98              break;
       
    99         case CPosRequestor::EIdFormatMIN:
       
   100             qposidformat=QPosRequestorData::EIdFormatMIN;
       
   101              break;
       
   102         case CPosRequestor::EIdFormatMDN:
       
   103             qposidformat=QPosRequestorData::EIdFormatMDN;
       
   104              break;
       
   105         case  CPosRequestor::EIdFormatUnknown:
       
   106         default:
       
   107             qposidformat=QPosRequestorData::EIdFormatUnknown; 
       
   108              break;
       
   109             }    
       
   110         //right now the phonebook has fields corresponding to  email,phone number, URL only
       
   111         //other cases are not supported by the phonebook
       
   112         if(qposidformat == QPosRequestorData::EIdFormatEmail ||
       
   113                 qposidformat == QPosRequestorData::EIdFormatPhoneNumber ||
       
   114                 qposidformat == QPosRequestorData::EIdFormatUrl ) 
       
   115             {
       
   116             //convert TDes to QString
       
   117             QString qReqString((QChar*)aRequestors[iter]->RequestorIdString().Ptr(),aRequestors[iter]->RequestorIdString().Length());
       
   118             
       
   119             QPosRequestorData posRequestor;
       
   120             posRequestor.setPosRequestorData(qposidformat,qReqString);
       
   121             
       
   122             iEngine->processRequestors(posRequestor); 
       
   123 
       
   124             QString retString;        
       
   125             posRequestor.getPosRequestorData(qposidformat,retString);
       
   126             
       
   127             //convert QString to TDes
       
   128             TPtrC16 textPtr(reinterpret_cast<const TUint16*>(retString.utf16()));
       
   129 
       
   130             aRequestors[iter]->SetRequestorIdL(idFormat,textPtr);
       
   131             }
       
   132         }
       
   133 	}
       
   134 	
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // CLocRequestorUtilsResolver::CLocRequestorUtilsResolver
       
   138 // C++ default constructor can NOT contain any code, that
       
   139 // might leave.
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 CLocRequestorUtilsResolver::CLocRequestorUtilsResolver()
       
   143 	{
       
   144 	// Nothing to do.
       
   145 	}
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CLocRequestorUtilsResolver::ConstructL
       
   149 // Symbian Second Phase COnstructor
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CLocRequestorUtilsResolver::ConstructL()
       
   153 	{
       
   154     try
       
   155 	    {
       
   156 	    iEngine = new QLocNotificationEngine();
       
   157 		}
       
   158 	catch( int error )
       
   159 		{
       
   160 		// Memory alloc failure
       
   161 		User::Leave(KErrNoMemory);
       
   162 		}	
       
   163 	}
       
   164 
       
   165 //  End of File
       
   166