landmarks/locationlandmarks/clientlib/src/EPos_CPosLandmarkParser.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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: Class used for parsing landmark content.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <ecom/ecom.h>
       
    21 #include "EPos_CPosLandmarkParser.h"
       
    22 #include "EPos_LandmarksUids.hrh"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CPosLandmarkParser::CPosLandmarkParser()
       
    30     {
       
    31     }
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C CPosLandmarkParser* CPosLandmarkParser::NewL(
       
    37     const TDesC8& aContentMimeType)
       
    38     {
       
    39     if ( aContentMimeType.Length() == 0 )
       
    40         {
       
    41         User::Leave( KErrArgument );
       
    42         }
       
    43     
       
    44     TEComResolverParams params;
       
    45     params.SetDataType(aContentMimeType);
       
    46 
       
    47     // Check if any implementation supports this mime type
       
    48     TUid interfaceUid;
       
    49     interfaceUid.iUid = KPosLmParserIfUid;
       
    50 
       
    51     RImplInfoPtrArray implInfoArray;
       
    52     REComSession::ListImplementationsL(interfaceUid, params, implInfoArray);
       
    53     if (implInfoArray.Count() == 0)
       
    54         {
       
    55         User::Leave(KErrNotSupported);
       
    56         }
       
    57     else
       
    58         {
       
    59         implInfoArray.ResetAndDestroy();
       
    60         }
       
    61 
       
    62     HBufC8* strPtr = aContentMimeType.AllocLC();
       
    63 
       
    64     // Send the mime type to the Ecom server
       
    65     // which determines the implementation.
       
    66     TAny* ptr = REComSession::CreateImplementationL(
       
    67         interfaceUid,
       
    68         _FOFF(CPosLandmarkParser, iDtorIdKey),
       
    69         strPtr,
       
    70         params);
       
    71 
       
    72     CleanupStack::PopAndDestroy(strPtr);
       
    73 
       
    74     return reinterpret_cast<CPosLandmarkParser*>(ptr);
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C CPosLandmarkParser::~CPosLandmarkParser()
       
    81     {
       
    82     // Destroy any instance variables and then inform the framework that this
       
    83     // specific instance of the interface has been destroyed.
       
    84     REComSession::DestroyedImplementation(iDtorIdKey);
       
    85     }