locationmanager/ReverseGeocode/inc/internalreversegeocode.h
changeset 36 aa5a574040a4
child 43 c5e73110f733
equal deleted inserted replaced
35:f727727520eb 36:aa5a574040a4
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Implementaion class for the CReverseGeocode class.
       
    15 */
       
    16 #ifndef _INTERNALREVERSEGEOCODE_H_
       
    17 #define _INTERNALREVERSEGEOCODE_H_
       
    18 
       
    19 #include <coemain.h>
       
    20 
       
    21 #include "reversegeocode.h"
       
    22 #include "xmlhandler.h"
       
    23 #include "clientengine.h"
       
    24 #include "connectiontimerhandler.h"
       
    25 
       
    26 
       
    27 /*
       
    28  * Internal implementation class for the CReverseGeocode class.
       
    29  */
       
    30 NONSHARABLE_CLASS( CInternalReverseGeocode ) : public CReverseGeocode, 
       
    31                     public MClientObserver, 
       
    32                     public MXmlHandlerObserver,
       
    33                     public MConnectionTimeoutHandlerInterface
       
    34     {
       
    35 public:
       
    36     /**
       
    37         * Factory function to create the instance
       
    38         * @param aObserver The observer instance that is to be notified when reverse geocoding is over
       
    39         * @return A pointer to the CInternalReverseGeocode instance
       
    40         */
       
    41     static CInternalReverseGeocode* NewL( MReverseGeocodeObserver& aObserver );
       
    42 
       
    43     /**
       
    44         * Gets the address for the given geo-coordinaates.
       
    45         * @param aLocality  The locality information
       
    46         *		   aOption    The connection option whether 	its silent or not
       
    47         */			
       
    48     virtual void GetAddressByCoordinateL( TLocality aLocality, const TConnectionOption aOption );
       
    49 
       
    50     /**
       
    51         * Checks if a silent connection is allowed
       
    52         * @return ETrue If silentconnection is allowed
       
    53         */	
       
    54     virtual TBool SilentConnectionAllowed();
       
    55     
       
    56     
       
    57     /**
       
    58         * Helper function to get the appropriate language for the request.
       
    59         * @param aLanguage  The language for the request 
       
    60         */    
       
    61     void GetLanguageForTheRequest( TDes8& aLanguage );
       
    62 
       
    63 
       
    64     /**
       
    65         * destructor
       
    66         *
       
    67         */	
       
    68     ~CInternalReverseGeocode();
       
    69 
       
    70     // MConnectionTimeoutHandlerInterface
       
    71     /**
       
    72         * Closes the connection once it times out
       
    73         * @param aErrorCode The Error code
       
    74         */    
       
    75     void HandleTimedoutEvent(TInt aErrorCode);
       
    76     
       
    77 protected:
       
    78    
       
    79     /**
       
    80         * Second phase construction
       
    81         */    
       
    82     void ConstructL();
       
    83         
       
    84     
       
    85     /**
       
    86         * First phase construction.
       
    87         * @param aObserver The observer instance that is to be notified when reverse geocoding is over
       
    88         */    
       
    89     CInternalReverseGeocode( MReverseGeocodeObserver& aObserver );
       
    90         
       
    91     //From MClientObserver
       
    92     /**
       
    93         * callback which notifies progess of HTTP request
       
    94         * @param aEvent The Httpstatus
       
    95         */    
       
    96     void ClientEvent( const THttpStatus& aEvent );
       
    97 	
       
    98     /**
       
    99         * callback through which the HTTP body data is recieved. 
       
   100         * @param aBodyData The body recieved
       
   101         */	
       
   102     void ClientBodyReceived(const TDesC8& aBodyData);
       
   103 
       
   104     /*
       
   105     * Get registrer network country code
       
   106     *
       
   107     * @return current register n/w info
       
   108     */
       
   109     RMobilePhone::TMobilePhoneNetworkInfoV2& GetCurrentRegisterNw();
       
   110 
       
   111     //From MXmlHandlerObserver    
       
   112     /**
       
   113         * callback which notifys the completion of parsing.
       
   114         * @param aError The err code
       
   115         * 		   aAddressInfo The address info obtained after parsing
       
   116         */    
       
   117     void OnParseCompletedL( TInt aError, MAddressInfo& aAddressInfo ); 
       
   118     
       
   119     /*
       
   120     * UE is registered to home network?
       
   121     *
       
   122     * @return ETrue if UE is registered at home network else EFalse
       
   123     */
       
   124     TBool IsRegisteredAtHomeNetwork();
       
   125 
       
   126 
       
   127     /*
       
   128     * Get home network country code
       
   129     * @param aHomeNwInfoAvailableFlag ETrue if home n/w info available else EFalse
       
   130     * @return user home n/w info
       
   131     */
       
   132     const RMobilePhone::TMobilePhoneNetworkInfoV1& 
       
   133         GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag);
       
   134 
       
   135 private:
       
   136 
       
   137     /**
       
   138         * Starts the timer
       
   139         */		
       
   140     void StartTimer();
       
   141 
       
   142     /**
       
   143         * Closes the http connection and notifies the observer
       
   144         */	
       
   145     void CloseConnection();
       
   146 
       
   147 private:
       
   148     CXmlHandler *iXmlHandler;
       
   149     CClientEngine *iClientEngine;
       
   150     CInternalAddressInfo *iAddressInfo;
       
   151     HBufC8* iXMLBuf;
       
   152     MReverseGeocodeObserver& iObserver;
       
   153     CConnectionTimerHandler*      iTimer;
       
   154 	
       
   155 	// Optimize the buffer len..??
       
   156     TBuf8<KMaxFileName> iQueryString;
       
   157     TBuf8<KMaxFileName> iAuthCode;
       
   158     TBuf8<KMaxFileName> iRefURL;
       
   159     TBuf8<KMaxFileName> iLang;
       
   160     TBool iStartTimerFlag;
       
   161 };
       
   162 
       
   163 #endif //_INTERNALREVERSEGEOCODE_H_
       
   164 
       
   165 // End of file