|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 #include <xqconversions.h> |
|
18 #include <qservicemanager.h> |
|
19 #include "tsservicesproviderconfig.h" |
|
20 |
|
21 const char ServicesInterface [] = "com.nokia.qt.taskswitcher.dataprovider"; |
|
22 // ----------------------------------------------------------------------------- |
|
23 CTsServiceProviderConfig* CTsServiceProviderConfig::NewLC() |
|
24 { |
|
25 CTsServiceProviderConfig *self = new (ELeave)CTsServiceProviderConfig(); |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(); |
|
28 return self; |
|
29 } |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 CTsServiceProviderConfig::CTsServiceProviderConfig() |
|
33 { |
|
34 //No implementation required |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 void CTsServiceProviderConfig::ConstructL() |
|
39 { |
|
40 QTM_NAMESPACE::QServiceInterfaceDescriptor *ptr(0); |
|
41 QT_TRYCATCH_LEAVING( |
|
42 QTM_NAMESPACE::QServiceManager serviceManager; |
|
43 const QList<QTM_NAMESPACE::QServiceInterfaceDescriptor> serivces(serviceManager.findInterfaces(QTM_NAMESPACE::QServiceFilter(ServicesInterface))); |
|
44 foreach(QTM_NAMESPACE::QServiceInterfaceDescriptor serviceImplementation, serivces) |
|
45 { |
|
46 ptr = new QTM_NAMESPACE::QServiceInterfaceDescriptor(serviceImplementation); |
|
47 if( 0 != ptr ) |
|
48 { |
|
49 if( KErrNone != iServices.Append( ptr ) ) |
|
50 { |
|
51 delete ptr; |
|
52 } |
|
53 } |
|
54 } |
|
55 ) |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 CTsServiceProviderConfig::~CTsServiceProviderConfig() |
|
60 { |
|
61 for( TInt iter(0); iter < iServices.Count(); ++iter ) |
|
62 { |
|
63 delete static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(iServices[iter]); |
|
64 } |
|
65 iServices.Close(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 TInt CTsServiceProviderConfig::Count() const |
|
70 { |
|
71 return iServices.Count(); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 QObject* CTsServiceProviderConfig::LoadL(TInt aOffset)const |
|
76 { |
|
77 const QTM_NAMESPACE::QServiceInterfaceDescriptor *service |
|
78 = static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(iServices[aOffset]); |
|
79 QObject *retVal(0); |
|
80 QT_TRYCATCH_LEAVING( |
|
81 QTM_NAMESPACE::QServiceManager serviceManager; |
|
82 retVal = serviceManager.loadInterface(*service); ) |
|
83 User::LeaveIfNull( retVal ); |
|
84 return retVal; |
|
85 } |