|
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: XQPluginLoader stub |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "stub/inc/xqpluginloader.h" |
|
19 #include "stub/inc/xqplugininfo.h" |
|
20 #include "testviewplugin.h" |
|
21 |
|
22 QHash<int, MpxViewPlugin*> XQPluginLoader::mPluginList; |
|
23 int XQPluginLoader::mFailToLoadPluginUid = -1; |
|
24 |
|
25 XQPluginLoader::XQPluginLoader(int uid, QObject* parent) |
|
26 { |
|
27 mUid = uid; |
|
28 } |
|
29 |
|
30 XQPluginLoader::~XQPluginLoader() |
|
31 { |
|
32 |
|
33 } |
|
34 |
|
35 bool XQPluginLoader::listImplementations(const QString &interfaceName, |
|
36 QList<XQPluginInfo > &impls) |
|
37 { |
|
38 return true; |
|
39 } |
|
40 |
|
41 QObject* XQPluginLoader::instance() |
|
42 { |
|
43 if(mUid == mFailToLoadPluginUid) |
|
44 { |
|
45 return 0; |
|
46 } |
|
47 |
|
48 if(!mPluginList.contains(mUid)) |
|
49 { |
|
50 mPluginList[mUid] = new TestViewPlugin(); |
|
51 } |
|
52 |
|
53 return mPluginList[mUid]; |
|
54 } |
|
55 |
|
56 void XQPluginLoader::cleanup() |
|
57 { |
|
58 QHash<int, MpxViewPlugin*>::const_iterator i = mPluginList.constBegin(); |
|
59 while(i != mPluginList.constEnd()) |
|
60 { |
|
61 TestViewPlugin *view = dynamic_cast<TestViewPlugin*>(i.value()); |
|
62 if(view) |
|
63 view->destroyView(); |
|
64 delete i.value(); |
|
65 ++i; |
|
66 } |
|
67 } |
|
68 |
|
69 /** |
|
70 * Sets plugin load to fail. |
|
71 */ |
|
72 void XQPluginLoader::setPluginLoadFailure(int uid) |
|
73 { |
|
74 mFailToLoadPluginUid = uid; |
|
75 } |