locationmanager/geotagger/src/cinternalgeotagger.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 14:44:37 +0300
changeset 36 aa5a574040a4
child 40 910a23996aa0
child 45 a93990e5815e
child 54 a3cc46f37772
permissions -rw-r--r--
Revision: 201025 Kit: 2010127

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  A class responsible for geotagging of media files in background.
*
*/

#include <e32cmn.h> 
#include <lbserrors.h>
#include <lbssatellite.h>
#include <ecom.h>

#include "locationmanagerdebug.h"
#include "mdeconstants.h"
#include "mdesession.h"
#include "cinternalgeotagger.h"
#include "reversegeocoderplugin.h"

using namespace MdeConstants;

_LIT ( KCountry, "country:");   // country:india 
const TUid KReverseGeoCodeUid = {0x2002DD12};

// --------------------------------------------------------------------------
// CInternalGeoTagger::NewL
// --------------------------------------------------------------------------
//
EXPORT_C CInternalGeoTagger* CInternalGeoTagger::NewL( CMdESession* aMdeSession,
            MGeoTaggerObserver* aObserver )
    {
    CInternalGeoTagger* self = 
            new (ELeave) CInternalGeoTagger( aMdeSession, aObserver );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }
        
// --------------------------------------------------------------------------
// CInternalGeoTagger::CInternalGeoTagger
// --------------------------------------------------------------------------
//  
CInternalGeoTagger::CInternalGeoTagger( CMdESession* aMdeSession,
        MGeoTaggerObserver* aObserver )
                        : iMdeSession(aMdeSession),
                        iLocationQuery(NULL),
                        iRelationQuery(NULL),
                        iTagQuery(NULL),
                        iIndex(0),
                        iSessionReady( EFalse ),
                        iObserver( aObserver ),
                        iTagCreator(NULL),
                        iASW(NULL),
                        iTagPendingHandlerFlag(EFalse),
                        iRevGeocoderPlugin(NULL)
#ifdef LOC_GEOTAGGING_CELLID	
						,iGeoConverter(NULL)
#endif						
    {
    iMdeSessionOwnFlag = (iMdeSession == NULL);
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::ConstructL
// --------------------------------------------------------------------------
//    
void CInternalGeoTagger::ConstructL()
    {
    LOG("CInternalGeoTagger::ConstructL ,begin");
    if(iMdeSession != NULL)
        {
		LOG("Not owning mds session");
        iMdeSessionOwnFlag = EFalse;
        //object is not owning iMdeSession
        iTagCreator = CTagCreator::NewL();
        iSessionReady = ETrue;
        
        iTagCreator->SetSession( iMdeSession );
        }
    else
        {
        iMdeSessionOwnFlag = ETrue;
        iASW = new (ELeave) CActiveSchedulerWait();
        iMdeSession = CMdESession::NewL( *this );
        //for creating tags
        iTagCreator = CTagCreator::NewL();
        
        iASW->Start();
        delete iASW;
        iASW = NULL;
        }
    
    //for reverse geocoding (geo-tagging)
    
    if (!iRevGeocoderPlugin)
            {
           
		   TRAP_IGNORE(
            iRevGeocoderPlugin = reinterpret_cast<CReverseGeoCoderPlugin*>(
               REComSession::CreateImplementationL(KReverseGeoCodeUid, iDtorKey));)
 
            if(iRevGeocoderPlugin)
            	{
               	iRevGeocoderPlugin->AddObserverL(*this); 
 
              }
 
            }

    LOG("CInternalGeoTagger::ConstructL ,end");
    }
    
// --------------------------------------------------------------------------
// CInternalGeoTagger::~CInternalGeoTagger
// --------------------------------------------------------------------------
//    
CInternalGeoTagger::~CInternalGeoTagger()
    {  
    LOG("CInternalGeoTagger::~CInternalGeoTagger ,begin");
#ifdef LOC_GEOTAGGING_CELLID
    if(iGeoConverter)
        {
        delete iGeoConverter;
        iGeoConverter = NULL;
        }
#endif    
	if(iRelationQuery)
		{
		iRelationQuery->RemoveObserver(*this);
		iRelationQuery->Cancel();
		delete iRelationQuery;
		}
	if(iLocationQuery)
		{
		iLocationQuery->RemoveObserver(*this);
		iLocationQuery->Cancel();
		delete iLocationQuery;
		}
	if(iTagQuery)
		{
		iTagQuery->RemoveObserver(*this);
		iTagQuery->Cancel();
		delete iTagQuery;
		}	
    delete iRevGeocoderPlugin;
    iRevGeocoderPlugin = NULL;
    REComSession::DestroyedImplementation(iDtorKey);	
    if(iMdeSessionOwnFlag)
        {
    	delete iMdeSession;
        delete iASW;
        }
    LOG("CInternalGeoTagger::~CInternalGeoTagger ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::CreateGeoTags
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::CreateGeoTagsL( const TConnectionOption aOption )
    {  
    LOG("CInternalGeoTagger::CreateGeoTagsL ,begin");
    if ( !IsSessionReady() )
        {
        User::Leave( KErrNotReady );
        }
    
    iConnectionOption = aOption;
    iIndex = 0;
    GetAllLocationsL();
    
    LOG("CInternalGeoTagger::CreateGeoTagsL ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::HandleSessionOpened
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
    {
    LOG("CInternalGeoTagger::HandleSessionOpened ,begin");
    if ( iMdeSessionOwnFlag && iASW && iASW->IsStarted() )
        {
        iASW->AsyncStop();
        }
    
    if ( KErrNone == aError )
        {
        iSessionReady = ETrue;
        
        iTagCreator->SetSession( iMdeSession );
        }
    else if(iMdeSessionOwnFlag)
        {
        delete iMdeSession;
        iMdeSession = NULL;
        }
    LOG("CInternalGeoTagger::HandleSessionOpened ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::HandleSessionError
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/)
    {
    LOG("CInternalGeoTagger::HandleSessionError ,begin");
    if ( iMdeSessionOwnFlag && iASW && iASW->IsStarted() )
        {
        iASW->AsyncStop();
        }
    iSessionReady = EFalse;
    if(iMdeSessionOwnFlag)
    	{
	    delete iMdeSession;
	    iMdeSession = NULL;
    	}
    LOG("CInternalGeoTagger::HandleSessionError ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::IsSessionReady
// --------------------------------------------------------------------------
//
TBool CInternalGeoTagger::IsSessionReady()
    {
    return iSessionReady;
    }


// --------------------------------------------------------------------------
// CInternalGeoTagger::GetRelationObjectsL()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::GetRelationObjectsL(TItemId aLocID)
	{
    LOG("CInternalGeoTagger::GetRelationObjectsL ,begin");
	CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL();
	CMdEObjectDef& imageObjDef = namespaceDef.GetObjectDefL( Image::KImageObject );
	
	if(iRelationQuery)
		{
		iRelationQuery->RemoveObserver(*this);
		iRelationQuery->Cancel();
		delete iRelationQuery;
    	iRelationQuery = NULL;
		}
    
    iRelationQuery = iMdeSession->NewRelationQueryL( namespaceDef, this );
    User::LeaveIfNull( iRelationQuery );

    iRelationQuery->SetResultMode( EQueryResultModeItem );
    
    // both left and right condition must match
    CMdERelationCondition& filterCond = iRelationQuery->Conditions().
    		AddRelationConditionL( ERelationConditionSideRight );

    // left one must be any image object.
    filterCond.LeftL().AddObjectConditionL( imageObjDef );

    // right one must be this location object 
    filterCond.RightL().AddObjectConditionL( aLocID );

    iRelationQuery->FindL(); // results to a call to HandleQueryCompleted()
    LOG("CInternalGeoTagger::GetRelationObjectsL ,end");
	}

// --------------------------------------------------------------------------
// CInternalGeoTagger::HandleQueryNewResults()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::HandleQueryNewResults(CMdEQuery& /*aQuery*/, TInt /*aFirstNewItemIndex*/, 
		TInt /*aNewItemCount*/)
	{
	LOG("CInternalGeoTagger::HandleQueryNewResults ,begin");
	}

// --------------------------------------------------------------------------
// CInternalGeoTagger::HandleQueryCompleted()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::HandleQueryCompleted(CMdEQuery& aQuery, TInt aError)
    {
    LOG("CInternalGeoTagger::HandleQueryCompleted ,begin");

    TInt count = aQuery.Count();
    LOG1("CInternalGeoTagger::HandleQueryCompleted count: %d", count);
        
    if ( &aQuery == iLocationQuery )
        {
        if ( count )
            {
            iLocationId = iLocationQuery->ResultId( iIndex++ );
            TRAP_IGNORE( GetRelationObjectsL( iLocationId ) );
            }
        else 
            {
            iIndex = 0;
            iObserver->GeoTaggingCompleted( aError );
            if(iTagPendingHandlerFlag)
                {
                iTagPendingHandlerFlag = EFalse;
                iObserver->PendingGeoTagReqComplete(KErrNone);
                }
            }  
        }
    else if ( &aQuery == iRelationQuery )
        {
        //if it is a relation query, then update gps info of location object.
     
        if ( iRelationQuery->Count() )
            {
            TInt err = KErrNone;
            TRAP(err, StartGeoTaggingL( ) );              
            if(err != KErrNone)
                {
                IterateNextLocation();
                }
            }
        else
            {
            IterateNextLocation();
            }
        
        }
		
    else if ( &aQuery == iTagQuery )
        {
                       
        if ( LocationTagExists() )  //nothing to do for this location
            {
            IterateNextLocation();  //Go through next location
            }
        else   //do reverse geocoding
            {          
            if(iTagPendingHandlerFlag)
                {
                iIndex = 0;
                iTagPendingHandlerFlag = EFalse;
                iObserver->PendingGeoTagReqComplete(KErrNotFound);
                return;
                }

            //Find the address for this geo-coordinate
            if(GPSInfoExists())
                {
                // GPS info exist go for reverse geo coding.
                if(iRevGeocoderPlugin)
    			    {
                    TRAP_IGNORE( 
    				iRevGeocoderPlugin->GetAddressByCoordinateL
    				   ( iLocationData.iPosition, iConnectionOption ) );
    				}
    			else
    			    {
                    IterateNextLocation();  //Go through next location
    			    }
    			}
    		else
    		    {
        		if ( iLocationData.iNetworkInfo.iCellId > 0 && 
        				iLocationData.iNetworkInfo.iLocationAreaCode > 0 &&
        				iLocationData.iNetworkInfo.iCountryCode.Length() > 0 &&
        				iLocationData.iNetworkInfo.iNetworkId.Length() > 0 )
        			{
        			// valid n/w information.. go for cell id based geo coding.
#ifdef LOC_GEOTAGGING_CELLID
                    TInt err = KErrNone;
                    if(iGeoConverter == NULL)
                       {
                       TRAP(err, iGeoConverter = CGeoConverter::NewL(*this));
                       }
                   
                    if(err == KErrNone && iGeoConverter != NULL)
                       {
                       TRAP(err, iGeoConverter->ConvertL(iLocationData.iNetworkInfo);)
                       }
                   if(err != KErrNone)
                       {
                       HandleConversionError(err);	
                       }
#else
                    IterateNextLocation();  //Go through next location
#endif                    
        			}
        		else
        		    {
                    IterateNextLocation();  //Go through next location
        		    }
    		    }
            }
        
        }

    LOG("CInternalGeoTagger::HandleQueryCompleted ,end");
    }


// --------------------------------------------------------------------------
// CInternalGeoTagger::GPSInfoExists()
// --------------------------------------------------------------------------
//
TBool CInternalGeoTagger::GPSInfoExists()
    {
    LOG("CInternalGeoTagger::GPSInfoExists");
    TBool gpsInfoExists = EFalse;
    if ( !Math::IsNaN( iLocationData.iPosition.Latitude() ) && 
                !Math::IsNaN( iLocationData.iPosition.Longitude() ))  //lat, long is there
        {
        
		LOG("Valid lat/lon\n");
        gpsInfoExists = ETrue;
        }
    return gpsInfoExists;
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::StartGeoTagging()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::StartGeoTaggingL( )
    {       
    LOG("CInternalGeoTagger::StartGeoTaggingL ,start");
    GetLocationInfoL();
    
    CMdERelation& relation = iRelationQuery->Result( 0 );
    
    GetTagsL( relation.LeftObjectId() );

	LOG("CInternalGeoTagger::StartGeoTaggingL ,end");
    }
// --------------------------------------------------------------------------
// CInternalGeoTagger::GetLocationInfoL()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::GetLocationInfoL()
    {
    LOG("CInternalGeoTagger::GetLocationInfoL, begin");

    CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL();

    CMdEObjectDef& locationObjectDef = namespaceDef.GetObjectDefL( Location::KLocationObject );
    
    CMdEPropertyDef& latitudeDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KLatitudeProperty );
    CMdEPropertyDef& longitudeDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KLongitudeProperty );
    CMdEPropertyDef& cellIdDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KCellIdProperty );
    CMdEPropertyDef& lacCodeDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KLocationAreaCodeProperty );
    CMdEPropertyDef& countryCodeDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KCountryCodeProperty );
    CMdEPropertyDef& networkCodeDef = locationObjectDef.GetPropertyDefL( 
                                        Location::KNetworkCodeProperty );
    
    CMdEObject* locationObject = NULL;
    CMdEProperty* latProp = NULL;
    CMdEProperty* lonProp = NULL;
    CMdEProperty* cellProp = NULL;
    CMdEProperty* lacProp = NULL;
    CMdEProperty* countryProp = NULL;
    CMdEProperty* networkProp = NULL;
       
    locationObject = iMdeSession->GetObjectL( iLocationId, locationObjectDef );
    
    locationObject->Property( latitudeDef, latProp, 0 );
    locationObject->Property( longitudeDef, lonProp, 0 );
    if ( latProp && lonProp )
        {
        iLocationData.iPosition.SetCoordinate( latProp->Real64ValueL(), 
                                               lonProp->Real64ValueL() );
        }
    
    locationObject->Property( cellIdDef, cellProp, 0 );
    locationObject->Property( lacCodeDef, lacProp, 0 );
    locationObject->Property( countryCodeDef, countryProp, 0 );
    locationObject->Property( networkCodeDef, networkProp, 0 );
    if ( cellProp && lacProp && countryProp && networkProp)
        {
        iLocationData.iNetworkInfo.iCellId = cellProp->Uint32ValueL();
        iLocationData.iNetworkInfo.iLocationAreaCode = lacProp->Uint32ValueL();
        iLocationData.iNetworkInfo.iCountryCode = countryProp->TextValueL();
        iLocationData.iNetworkInfo.iNetworkId = networkProp->TextValueL();
        
        }

	LOG("CInternalGeoTagger::GetLocationInfoL ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::LocationTagExists()
// --------------------------------------------------------------------------
//
TBool CInternalGeoTagger::LocationTagExists()
    {
    LOG("CInternalGeoTagger::LocationTagExists ,begin");
                           
    TBool tagFound = EFalse;
    TInt error = KErrNone;
    const TInt count = iTagQuery->Count();
                
    for ( TInt i = 0; i < count; i++ )
        {
        CMdERelation& relation =  static_cast<CMdERelation&>( iTagQuery->ResultItem( i ) );
                    
        TItemId tagId = relation.RightObjectId(); 
        CMdEObject* object = NULL;
        TRAP_IGNORE( object = iMdeSession->GetObjectL( tagId ) );
        
        error = object->Uri().Find( KCountry );
        if ( error == KErrNone )
            {
            i = count;
            tagFound = ETrue;
            }
        }
                
           
	LOG("CInternalGeoTagger::LocationTagExists ,end");
    return tagFound;

    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::AddressInfo()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::AddressInfoL( const TItemId aCountryTagId, const TItemId aCityTagId )
    {
    LOG("CInternalGeoTagger::AddressInfoL ,begin");
                               
    const TInt count = iRelationQuery->Count();
    
    for ( TInt i = 0; i < count; i++ )
        {
        CMdERelation& relation = iRelationQuery->Result( i );
        TItemId imageId = relation.LeftObjectId(); 
        
        if ( !GPSInfoExists() )   //to update EXIF
            {
            // update relation timestamp, composer will then update exif data   
            TTime timestamp( 0 );
            timestamp.UniversalTime();
            relation.SetLastModifiedDate( timestamp );     
            iMdeSession->UpdateRelationL( relation );
            }
        
        iTagCreator->AttachTagsL( imageId, aCountryTagId, aCityTagId  );
        }

   LOG("CInternalGeoTagger::AddressInfoL ,end");
    }


// --------------------------------------------------------------------------
// CInternalGeoTagger::IterateNextLocation()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::IterateNextLocation()
    {
    LOG("CInternalGeoTagger::IterateNextLocation ,begin");
                                   
    if (iIndex < iLocationQuery->Count())
        {
        iLocationId = iLocationQuery->ResultId( iIndex++ );
        TRAP_IGNORE( GetRelationObjectsL( iLocationId ) );
        }
    else
        {
        if ( iObserver )
            {
            iIndex = 0;
            TInt error = KErrNone;
            iObserver->GeoTaggingCompleted( error );
            if(iTagPendingHandlerFlag)
                {
                iTagPendingHandlerFlag = EFalse;
                iObserver->PendingGeoTagReqComplete(KErrNone);
                }
            }
        }
	LOG("CInternalGeoTagger::IterateNextLocation ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::GetAllLocationsL()
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::GetAllLocationsL()
    {
    LOG("CInternalGeoTagger::GetAllLocationsL ,begin");

    CMdENamespaceDef& defaultNamespaceDef = iMdeSession->GetDefaultNamespaceDefL();
    CMdEObjectDef& locObjDef = defaultNamespaceDef.GetObjectDefL( 
                               MdeConstants::Location::KLocationObject );
    CMdEPropertyDef& cellIdPropDef = locObjDef.GetPropertyDefL( 
                               MdeConstants::Location::KCellIdProperty );

	if(iLocationQuery)
		{
		iLocationQuery->RemoveObserver(*this);
		iLocationQuery->Cancel();
		delete iLocationQuery;
		iLocationQuery = NULL;
		}
    // query objects with object definition "Image"
    iLocationQuery = iMdeSession->NewObjectQueryL( defaultNamespaceDef, locObjDef, this );
    
    //Define the result order
    iLocationQuery->AppendOrderRuleL(TMdEOrderRule(cellIdPropDef, ESortAscending));
     
    iLocationQuery->SetResultMode( EQueryResultModeId );
    iLocationQuery->FindL();

  LOG("CInternalGeoTagger::GetAllLocationsL ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::ReverseGeocodeComplete()
//  Get address details like street, city, state, etc.
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::ReverseGeocodeComplete( TInt& aErrorcode, MAddressInfo& aAddressInfo )
    {
    LOG("CInternalGeoTagger::ReverseGeocodeComplete ,begin");
    TItemId countryTagId(0);
    TItemId cityTagId(0);
    
    // create country and city tags
    if( aErrorcode == KErrNone )
        {
        TPtrC countryPtr( aAddressInfo.GetCountryName() ); 
        TPtrC cityPtr( aAddressInfo.GetCity() );
        
        TRAP_IGNORE( iTagCreator->CreateLocationTagsL( countryPtr, countryTagId, cityPtr, cityTagId ) );
		
        TRAP_IGNORE(AddressInfoL( countryTagId, cityTagId ));
        
        IterateNextLocation();
        }
    else
        {
        //handle error
        if ( iObserver )
            {
            iIndex = 0;
            iObserver->GeoTaggingCompleted( aErrorcode );
            }
        }
   
    
    LOG("CInternalGeoTagger::ReverseGeocodeComplete ,end");
    }

// --------------------------------------------------------------------------
// CInternalGeoTagger::GetTagsL()
// Get tags related to this image/video object
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::GetTagsL( TItemId aImageID )
    {
    LOG("CInternalGeoTagger::GetTagsL ,begin");
    CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL();
    CMdEObjectDef& tagObjectDef = namespaceDef.GetObjectDefL( Tag::KTagObject );
        
	if(iTagQuery)
		{
		iTagQuery->RemoveObserver(*this);
		iTagQuery->Cancel();
		delete iTagQuery;
        iTagQuery = NULL;
		}	
        
    iTagQuery = iMdeSession->NewRelationQueryL( namespaceDef, this );
    User::LeaveIfNull( iTagQuery );

    iTagQuery->SetResultMode( EQueryResultModeItem );
        
    // both left and right condition must match
    CMdERelationCondition& filterCond = iTagQuery->Conditions().
    AddRelationConditionL( ERelationConditionSideRight );

    // left one must be this image object.
    filterCond.LeftL().AddObjectConditionL( aImageID );

    // right one must be tag object 
    filterCond.RightL().AddObjectConditionL( tagObjectDef );

    iTagQuery->FindL(); // results to a call to HandleQueryCompleted()
    LOG("CInternalGeoTagger::GetTagsL ,end");
    }

#ifdef LOC_GEOTAGGING_CELLID	
// --------------------------------------------------------------------------
// CInternalGeoTagger::ConversionCompletedL()
// --------------------------------------------------------------------------
//

void CInternalGeoTagger::ConversionCompletedL( const TInt aError, 
                    TLocality& aPosition )
    {
    LOG1("CInternalGeoTagger::ConversionCompletedL, begin. Error - %d", aError);
    if(aError == KErrNone)
        {
        iLocationData.iPosition.SetCoordinate
                ( aPosition.Latitude(), aPosition.Longitude());
        if(iRevGeocoderPlugin)
		    {
           	iRevGeocoderPlugin->GetAddressByCoordinateL
			   ( iLocationData.iPosition, iConnectionOption ) ;
			}
		else
		    {
            IterateNextLocation();  //Go through next location
		    }
       }
	else
	    {
        IterateNextLocation();  //Go through next location
	    }
    LOG("CInternalGeoTagger::ConversionCompletedL, end");
    }


//-----------------------------------------------------------------
// CInternalGeoTagger::HandleConversionError
//------------------------------------------------------------------
//
void CInternalGeoTagger::HandleConversionError(TInt aError)
	{
    LOG("CInternalGeoTagger::HandleConversionError, begin");
    ARG_USED(aError);
    IterateNextLocation();  //Go through next location
    LOG("CInternalGeoTagger::HandleConversionError, end");
	}

#endif

// --------------------------------------------------------------------------
// CInternalGeoTagger::PendingGeoTagsL()
// Is there any untagged photos with location info?.
// --------------------------------------------------------------------------
//
void CInternalGeoTagger::PendingGeoTagsL( TBool aTagInProgress )
    {
    LOG("CInternalGeoTagger::PendingGeoTagsL ,begin");
    iIndex = 0;
    if ( aTagInProgress )
        {
        //Tagging is going through location trail, so photo does not need to do tagging now
        LOG("Geo tagging in progress.\n");
        iObserver->PendingGeoTagReqComplete( KErrInUse );
        }
    else
        {
        if(!iTagPendingHandlerFlag)
            {
            LOG("Processing the request.\n");
            // tag pending request is not going on
            iTagPendingHandlerFlag = ETrue;
            CreateGeoTagsL();
            }
        else
            {
            // req osn progress, don't do anything.
            LOG("Request in progress.\n");
            iObserver->PendingGeoTagReqComplete( KErrInUse );
            }
        }
    LOG("CInternalGeoTagger::PendingGeoTagsL ,end");
    }

// ----------------------------------------------------------------------------
// CInternalGeoTagger::GetCurrentRegisterNw()
// ---------------------------------------------------------------------------- 
RMobilePhone::TMobilePhoneNetworkInfoV2& CInternalGeoTagger::GetCurrentRegisterNw()
    {
    LOG( "CInternalGeoTagger::GetCurrentRegisterNw ,begin" );
    return iObserver->GetCurrentRegisterNw();
    }

// ----------------------------------------------------------------------------
// CInternalGeoTagger::IsRegisteredAtHomeNetwork()
// ---------------------------------------------------------------------------- 
TBool CInternalGeoTagger::IsRegisteredAtHomeNetwork()
    {
    LOG( "CInternalGeoTagger::IsRegisteredAtHomeNetwork" );
    return iObserver->IsRegisteredAtHomeNetwork();
    }

// ----------------------------------------------------------------------------
// CInternalGeoTagger::GetHomeNetworkInfo()
// ----------------------------------------------------------------------------
const RMobilePhone::TMobilePhoneNetworkInfoV1& 
        CInternalGeoTagger::GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag)
    {
    LOG( "CInternalReverseGeocode::GetHomeNetworkInfo" );
    return iObserver->GetHomeNetworkInfo(aHomeNwInfoAvailableFlag);
    }

// End of file