localisation/apparchitecture/ServiceRegistry/ServiceRegistry.cpp
branchSymbian3
changeset 57 b8d18c84f71c
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // ServiceRegistry.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "ServiceRegistry.h"
       
    19 
       
    20 /** Constructs a new CServiceRegistry object.
       
    21 
       
    22 @return A new CServiceRegistry object.
       
    23 @publishedPartner
       
    24 @released
       
    25 */
       
    26 EXPORT_C CServiceRegistry* CServiceRegistry::NewL()
       
    27 	{
       
    28 	CServiceRegistry* self = new(ELeave) CServiceRegistry();
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 /** Destructor 
       
    36 @publishedPartner
       
    37 @released
       
    38 */
       
    39 EXPORT_C CServiceRegistry::~CServiceRegistry()
       
    40 	{
       
    41 	iApaLsSession.Close();	
       
    42 	}
       
    43 
       
    44 /** Constructor 
       
    45 @publishedPartner
       
    46 @released
       
    47 */		
       
    48 CServiceRegistry::CServiceRegistry()
       
    49 	{	
       
    50 	}
       
    51 	
       
    52 /** Second phase constructor. 
       
    53 @publishedPartner
       
    54 @released
       
    55 */	
       
    56 void CServiceRegistry::ConstructL()
       
    57 	{	
       
    58 	User::LeaveIfError(iApaLsSession.Connect());
       
    59 	}
       
    60 		
       
    61 /** Adds a default association to the registry.
       
    62 @param aServiceUid The uid of the service.
       
    63 @param aDataType The datatype.
       
    64 @param aDefaultAppUid The uid of the application that supports the
       
    65 datatype and the service.
       
    66 @return A standard error code.
       
    67 @capability WriteDeviceData
       
    68 @publishedPartner
       
    69 @released
       
    70 */	
       
    71 EXPORT_C TInt CServiceRegistry::SetDefault(TUid aServiceUid, const TDataType& aDataType, 
       
    72 	TUid aDefaultAppUid)
       
    73 	{
       
    74 	return iApaLsSession.InsertDataMapping(aDataType, KDataTypePriorityNormal, aDefaultAppUid, aServiceUid);
       
    75 	}
       
    76 	
       
    77 /** Deletes an association from the registry.
       
    78 @param aServiceUid The uid of the service.
       
    79 @param aDataType The datatype.
       
    80 @return KErrNotFound if the association doesn't exist or any other standard error code.
       
    81 @capability WriteDeviceData
       
    82 @publishedPartner
       
    83 @released
       
    84 */	
       
    85 EXPORT_C TInt CServiceRegistry::RemoveEntry(TUid aServiceUid, const TDataType& aDataType)
       
    86 	{	
       
    87 	return iApaLsSession.DeleteDataMapping(aDataType, aServiceUid);
       
    88 	}
       
    89 	
       
    90 /** Gets the default association from the registry.
       
    91 @param aServiceUid The uid of the service.
       
    92 @param aDataType The datatype.
       
    93 @param aDefaultAppUid The uid of the default application, or KNullUid if the
       
    94 the association doesn't exist.
       
    95 @return KErrNotFound if the association doesn't exist or any other standard error code.
       
    96 @publishedPartner
       
    97 @released
       
    98 */	
       
    99 EXPORT_C TInt CServiceRegistry::GetDefault(TUid aServiceUid, const TDataType& aDataType,
       
   100 	TUid& aDefaultAppUid)
       
   101 	{	
       
   102 	return iApaLsSession.GetAppByDataType(aDataType, aServiceUid, aDefaultAppUid);
       
   103 	}
       
   104