|
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: cahandlerspreloader.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QTimer> |
|
19 |
|
20 #include <caentry.h> |
|
21 |
|
22 #include "caclient_defines.h" |
|
23 #include "cahandlerproxy.h" |
|
24 #include "cahandlerspreloader.h" |
|
25 |
|
26 /*! |
|
27 Constructor. |
|
28 \param pointer to a parent object. |
|
29 */ |
|
30 CaHandlersPreloader::CaHandlersPreloader( |
|
31 CaHandlerProxy *handlerProxy, |
|
32 QObject *parent): |
|
33 QObject(parent), |
|
34 mTimer(NULL), |
|
35 mHandlerProxy(handlerProxy) |
|
36 { |
|
37 mHandlersToLoad << |
|
38 URL_ENTRY_TYPE_NAME << |
|
39 TEMPLATED_APPLICATION_ENTRY_TYPE_NAME << |
|
40 APPLICATION_ENTRY_TYPE_NAME; |
|
41 |
|
42 mTimer = new QTimer(this); |
|
43 connect(mTimer, SIGNAL(timeout()), this, SLOT(preloadHandlersWhenIdle())); |
|
44 mTimer->start(0); // NOTE: zero for idle |
|
45 } |
|
46 |
|
47 /*! |
|
48 Destructor. |
|
49 */ |
|
50 CaHandlersPreloader::~CaHandlersPreloader() |
|
51 { |
|
52 mTimer->stop(); |
|
53 delete mTimer; |
|
54 } |
|
55 |
|
56 /*! |
|
57 Preload a single handler from a list during the idle time. |
|
58 */ |
|
59 void CaHandlersPreloader::preloadHandlersWhenIdle() |
|
60 { |
|
61 if (!mHandlersToLoad.isEmpty()) { |
|
62 mHandlerProxy->getHandler(mHandlersToLoad.takeLast()); |
|
63 } else { |
|
64 mTimer->stop(); |
|
65 } |
|
66 } |
|
67 |