datasourcemodules/bluetoothgpspositioningmodule/btgpsconfig/src/lbsbtgpsconfig.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2008-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 // LBS Bluetooth GPS Configuration API
       
    15 //
       
    16 
       
    17 #include <lbs/lbsbtgpsconfig.h>
       
    18 #include "lbsbtgpsconfigimpl.h"
       
    19 
       
    20 
       
    21 /** Get the observer interface version
       
    22 @return The current version of the observer interface
       
    23 @publishedPartner
       
    24 @prototype
       
    25 */
       
    26 EXPORT_C TVersion MLbsBtGpsConfigObserver::Version() const
       
    27 	{
       
    28 	return TVersion(1, 0, 0);
       
    29 	}
       
    30 	
       
    31 
       
    32 /**	This methods is reserved for future expansion and should not be used
       
    33 
       
    34 @param aFunctionNumber Reserved for future expansion
       
    35 @param aPtr1 Reserved for future expansion
       
    36 @param aPtr2 Reserved for future expansion
       
    37 
       
    38 Currently not implemented.
       
    39 
       
    40 */								
       
    41 EXPORT_C TAny* MLbsBtGpsConfigObserver::ExtendedInterface(TInt /*aFunctionNumber*/, TAny* /*aPtr1*/, TAny* /*aPtr2*/)
       
    42 	{
       
    43 	return NULL;
       
    44 	}
       
    45 
       
    46 
       
    47 /** Static constructor (without observer)
       
    48 Creates an instance of the LBS Bluetooth GPS Configuration API.
       
    49 This version is for clients that do not require configuration update notifications.
       
    50 
       
    51 @return A newly constructed CLbsBtGpsConfig object.
       
    52 
       
    53 @leave KErrPermissionDenied Client does not have the required capabilities.
       
    54 
       
    55 @capability LocalServices
       
    56 
       
    57 @publishedPartner
       
    58 @prototype
       
    59 */
       
    60 EXPORT_C CLbsBtGpsConfig* CLbsBtGpsConfig::NewL()
       
    61 	{
       
    62 	CLbsBtGpsConfig* self = new (ELeave) CLbsBtGpsConfig();
       
    63     CleanupStack::PushL(self);
       
    64     self->ConstructL(NULL);
       
    65     CleanupStack::Pop(self);
       
    66     return self;
       
    67 	}
       
    68 
       
    69 
       
    70 /** Static constructor (with observer)
       
    71 Creates an instance of the LBS Bluetooth GPS Configuration API, specifying a callback
       
    72 to recieve update notifications.
       
    73 
       
    74 @param aObserver [IN] Observer which will recieve update notifications.
       
    75 
       
    76 @return A newly constructed CLbsBtGpsConfig object.
       
    77 
       
    78 @leave KErrPermissionDenied Client does not have the required capabilities.
       
    79 
       
    80 @see MLbsBtGpsConfigObserver
       
    81 
       
    82 @capability LocalServices
       
    83 
       
    84 @publishedPartner
       
    85 @prototype
       
    86 */
       
    87 EXPORT_C CLbsBtGpsConfig* CLbsBtGpsConfig::NewL(MLbsBtGpsConfigObserver& aObserver)
       
    88 	{
       
    89 	CLbsBtGpsConfig* self = new (ELeave) CLbsBtGpsConfig();
       
    90     CleanupStack::PushL(self);
       
    91     self->ConstructL(&aObserver);
       
    92     CleanupStack::Pop(self);
       
    93     return self;
       
    94 	}
       
    95 
       
    96 
       
    97 /** Destructor 
       
    98 @publishedPartner
       
    99 @prototype
       
   100 */
       
   101 EXPORT_C CLbsBtGpsConfig::~CLbsBtGpsConfig()
       
   102 	{
       
   103 	delete iImpl;
       
   104 	}
       
   105 
       
   106 
       
   107 /** Returns the number of devices present in the list
       
   108 
       
   109 @param aCount [Out] Revieves the number of devices in the list.
       
   110 
       
   111 @return KErrNone if the operation succeeded.
       
   112 		KErrPermissionDenied if the client does not have the required capabilities.
       
   113 
       
   114 @capability LocalServices
       
   115 
       
   116 @publishedPartner
       
   117 @prototype
       
   118 */
       
   119 EXPORT_C TInt CLbsBtGpsConfig::GetDeviceCount(TInt& aCount)
       
   120 	{
       
   121 	return iImpl->GetDeviceCount(aCount);
       
   122 	}
       
   123 
       
   124 
       
   125 /** Adds a new device at the specified position index within the list
       
   126 
       
   127 @param aAddress [In] Address of the new device.
       
   128 @param aPosition [In] Position in the list at which to add the device (where 0 indicates the start of the list).
       
   129 @param aKey [Out] Recieves the unique key assigned to identify the new device.
       
   130 
       
   131 The new device will assume the specified position in the list, shifting exsiting devices at this position or below 
       
   132 one place towards the end of the list in order to achieve this.
       
   133 
       
   134 Specifying aPosition = 0 will result in the device being added to the start of the list.
       
   135 Specifying aPosition >= DeviceCount() will result in the device being added to the end of the list.
       
   136 
       
   137 @return KErrNone if the operation succeeded.
       
   138 		KErrAlreadyExists if an entry with the same address is already present in the list.
       
   139 		KErrOverflow if there is no space left to add another entry.
       
   140 		KErrPermissionDenied if the client does not have the required capabilities.
       
   141 
       
   142 @capability LocalServices
       
   143 @capability WriteDeviceData
       
   144 
       
   145 @publishedPartner
       
   146 @prototype
       
   147 */
       
   148 EXPORT_C TInt CLbsBtGpsConfig::AddDevice(const TBTDevAddr& aAddress, TInt aPosition, TLbsBtGpsEntryKey& aKey)
       
   149 	{
       
   150 	return iImpl->AddDevice(aAddress, aPosition, aKey);
       
   151 	}
       
   152 
       
   153 
       
   154 /** Removes a device from the list
       
   155 
       
   156 @param aKey [In] The key identifying the device.
       
   157 
       
   158 @return KErrNone if the operation succeeded.
       
   159 		KErrNotFound if the specified device is not present in the list.
       
   160 		KErrPermissionDenied if the client does not have the required capabilities.
       
   161 
       
   162 @capability LocalServices
       
   163 @capability WriteDeviceData
       
   164 
       
   165 @publishedPartner
       
   166 @prototype
       
   167 */
       
   168 EXPORT_C TInt CLbsBtGpsConfig::RemoveDevice(TLbsBtGpsEntryKey aKey)
       
   169 	{
       
   170 	return iImpl->RemoveDevice(aKey);
       
   171 	}
       
   172 
       
   173 
       
   174 /** Empties the device list, removing all device entries
       
   175 
       
   176 @return KErrNone if the operation succeeded.
       
   177 		KErrPermissionDenied if the client does not have the required capabilities.
       
   178 
       
   179 @capability LocalServices
       
   180 @capability WriteDeviceData
       
   181 
       
   182 @publishedPartner
       
   183 @prototype
       
   184 */
       
   185 EXPORT_C TInt CLbsBtGpsConfig::EmptyDeviceList()
       
   186 	{
       
   187 	return iImpl->EmptyDeviceList();
       
   188 	}
       
   189 
       
   190 
       
   191 /** Reorders a device in the list by specifying a new position index
       
   192 
       
   193 @param aKey [In] The key identifying the device.
       
   194 @param aNewPosition [In] New position index for the device in the list (where 0 indicates the start of the list).
       
   195 
       
   196 The device identified by the key will assume the specified position in the list, shifting exsiting devices as
       
   197 required in order to achieve this.
       
   198 
       
   199 Specifying aNewPosition = 0 will result in the device being moved to the start of the list.
       
   200 Specifying aNewPosition >= DeviceCount() will result in the device being moved to the end of the list.
       
   201 
       
   202 When a device is moved towards the start of the list, other devices located between the old and new positions 
       
   203 will be shifted towards the end of the list by one place. For example, starting with a list {A,B,C,D,E}, moving 
       
   204 device D to position 1 would result in {A,D,B,C,E}. 
       
   205 
       
   206 Similarly, when a device is moved towards the end of the list, other devices located between the old and new
       
   207 positions will be shifted towards the start of the list by one place. For example, starting with a list {A,B,C,D,E},
       
   208 moving device B to position 3 would result in {A,C,D,B,E}
       
   209 
       
   210 @return KErrNone if the operation succeeded.
       
   211 		ErrNotFound if the specified device is not present in the list.
       
   212 		KErrPermissionDenied if the client does not have the required capabilities.
       
   213 
       
   214 @capability LocalServices
       
   215 @capability WriteDeviceData
       
   216 
       
   217 @publishedPartner
       
   218 @prototype
       
   219 */
       
   220 EXPORT_C TInt CLbsBtGpsConfig::ReorderDevice(TLbsBtGpsEntryKey aKey, TInt aNewPosition)
       
   221 	{
       
   222 	return iImpl->ReorderDevice(aKey, aNewPosition);
       
   223 	}
       
   224 
       
   225 
       
   226 /** Retrieves the list of devices
       
   227 
       
   228 @param aList [Out] Reference to an empty RPointerArray to populate with device entries from the list.
       
   229 
       
   230 The passed list is populated with TLbsBtGpsDeviceInfo objects containing information for each device
       
   231 in the list. Ownership of these objects is returned, so they should be deleted by the client when they
       
   232 are no longer needed (this can be done easily using RPointerArray::ResetAndDestroy).
       
   233 
       
   234 @leave KErrPermissionDenied if the client does not have the required capabilities.
       
   235 
       
   236 @capability LocalServices
       
   237 
       
   238 @publishedPartner
       
   239 @prototype
       
   240 */
       
   241 EXPORT_C void CLbsBtGpsConfig::GetDeviceListL(RPointerArray<TLbsBtGpsDeviceInfo>& aList)
       
   242 	{
       
   243 	iImpl->GetDeviceListL(aList);
       
   244 	}
       
   245 	
       
   246 
       
   247 /** Class constructor 
       
   248 */
       
   249 CLbsBtGpsConfig::CLbsBtGpsConfig()
       
   250 	{
       
   251 	
       
   252 	}
       
   253 
       
   254 
       
   255 /** Second phase constructor 
       
   256 
       
   257 @param aObserver [IN] Optional observer, which will recieve update notifications.
       
   258 
       
   259 @leave KErrPermissionDenied Client does not have the required capabilities.
       
   260 
       
   261 */
       
   262 void CLbsBtGpsConfig::ConstructL(MLbsBtGpsConfigObserver* aObserver)
       
   263 	{
       
   264 	iImpl = CLbsBtGpsConfigImpl::NewL(aObserver);
       
   265 	}
       
   266 
       
   267 
       
   268 /**	This methods is reserved for future expansion and should not be used
       
   269 
       
   270 @param aFunctionNumber Reserved for future expansion
       
   271 @param aPtr1 Reserved for future expansion
       
   272 @param aPtr2 Reserved for future expansion
       
   273 
       
   274 @capability LocalServices
       
   275 
       
   276 */								
       
   277 EXPORT_C TAny* CLbsBtGpsConfig::ExtendedInterface(TInt aFunctionNumber, TAny* aPtr1, TAny* aPtr2)
       
   278 	{
       
   279 	return iImpl->ExtendedInterface(aFunctionNumber, aPtr1, aPtr2);
       
   280 	}