|
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 ptr = new QTM_NAMESPACE::QServiceInterfaceDescriptor(serviceImplementation); |
|
46 if(0 != ptr) { |
|
47 if(KErrNone != mServices.Append(ptr)) { |
|
48 delete ptr; |
|
49 } |
|
50 } |
|
51 } |
|
52 //) |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 CTsServiceProviderConfig::~CTsServiceProviderConfig() |
|
57 { |
|
58 for(TInt iter(0); iter < mServices.Count(); ++iter){ |
|
59 delete static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(mServices[iter]); |
|
60 } |
|
61 mServices.Close(); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 TInt CTsServiceProviderConfig::count() const |
|
66 { |
|
67 return mServices.Count(); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 QObject* CTsServiceProviderConfig::loadL(TInt offset)const |
|
72 { |
|
73 const QTM_NAMESPACE::QServiceInterfaceDescriptor *service |
|
74 = static_cast<QTM_NAMESPACE::QServiceInterfaceDescriptor *>(mServices[offset]); |
|
75 QObject *retVal(0); |
|
76 QT_TRYCATCH_LEAVING( |
|
77 QTM_NAMESPACE::QServiceManager serviceManager; |
|
78 retVal = serviceManager.loadInterface(*service); |
|
79 ); |
|
80 User::LeaveIfNull(retVal); |
|
81 return retVal; |
|
82 } |