1 /* |
|
2 * Copyright (c) 2010 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 |
|
18 |
|
19 #ifndef ACTIVEWRAPPER_H |
|
20 #define ACTIVEWRAPPER_H |
|
21 |
|
22 #include <QObject> |
|
23 #include <e32base.h> |
|
24 |
|
25 class ActiveWrapperPrivate; |
|
26 |
|
27 /*! |
|
28 \class ActiveWrapper |
|
29 \brief Helper class for using active objects in Qt classes. |
|
30 |
|
31 ActiveWrapper is a helper class for using active objects |
|
32 from any Qt class. It wraps a CActive-derived class in an interface |
|
33 that uses Qt's signal-slot mechanism for communicating status changes |
|
34 of the active object. |
|
35 |
|
36 \\sa bluetoothuimodel |
|
37 */ |
|
38 class ActiveWrapper : public QObject |
|
39 { |
|
40 Q_OBJECT |
|
41 friend class ActiveWrapperPrivate; |
|
42 |
|
43 public: |
|
44 explicit ActiveWrapper( int id, |
|
45 int priority = CActive::EPriorityStandard, QObject *parent = NULL ); |
|
46 ~ActiveWrapper(); |
|
47 |
|
48 int getRequestId(); |
|
49 void setRequestId(int reqId); |
|
50 void setActive(); |
|
51 void cancel(); |
|
52 bool isActive(); |
|
53 |
|
54 signals: |
|
55 void requestCompleted( int status, int id ); |
|
56 void cancelRequest( int id ); |
|
57 void error( int status, int id ); |
|
58 |
|
59 private: |
|
60 void emitRequestCompleted( int status, int id ); |
|
61 void emitCancelRequest( int id ); |
|
62 void emitError( int status, int id ); |
|
63 |
|
64 private: |
|
65 ActiveWrapperPrivate *d; |
|
66 |
|
67 }; |
|
68 |
|
69 |
|
70 /*! |
|
71 \class ActiveWrapperPrivate |
|
72 \brief Private class of ActiveWrapper, for using active objects in Qt classes. |
|
73 |
|
74 ActiveWrapperPrivate is a helper class for using active objects |
|
75 from any Qt class. It derives from CActive and allows other classes to use |
|
76 it for passing to asynchronous function calls through its RequestStatus method. |
|
77 |
|
78 \\sa bluetoothuimodel |
|
79 */ |
|
80 class ActiveWrapperPrivate : public CActive |
|
81 { |
|
82 friend class ActiveWrapper; |
|
83 |
|
84 public: |
|
85 explicit ActiveWrapperPrivate( ActiveWrapper *parent, int id, int priority ); |
|
86 ~ActiveWrapperPrivate(); |
|
87 |
|
88 private: |
|
89 virtual void RunL(); |
|
90 virtual void DoCancel(); |
|
91 virtual TInt RunError( TInt error ); |
|
92 |
|
93 private: |
|
94 ActiveWrapper *q; |
|
95 int mRequestId; |
|
96 }; |
|
97 |
|
98 #endif // ACTIVEWRAPPER_H |
|