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 #ifndef USBUIMODELACTIVE_H |
|
19 #define USBUIMODELACTIVE_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <e32base.h> |
|
23 #include <usbwatcher.h> |
|
24 |
|
25 class UsbUiModelActivePrivate; |
|
26 |
|
27 /*! |
|
28 \class UsbUiModelActive |
|
29 \brief Helper class for using active objects in Qt classes. |
|
30 |
|
31 UsbUiModelActive 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 */ |
|
37 class UsbUiModelActive : public QObject |
|
38 { |
|
39 Q_OBJECT |
|
40 friend class UsbUiModelActivePrivate; |
|
41 |
|
42 public: |
|
43 explicit UsbUiModelActive( int priority = CActive::EPriorityStandard, |
|
44 QObject *parent = NULL ); |
|
45 ~UsbUiModelActive(); |
|
46 |
|
47 inline TRequestStatus &RequestStatus(); |
|
48 inline void SetActive(); |
|
49 inline void Cancel(); |
|
50 inline bool IsActive(); |
|
51 |
|
52 public: |
|
53 /* |
|
54 * Sets the the selected personality through usbwatcher |
|
55 * @param personality is the personality to be set |
|
56 */ |
|
57 void SetUsbPersonality(int personality); |
|
58 /* |
|
59 * cancels the personality set in usbwatcher |
|
60 */ |
|
61 void CancelSetPersonality(); |
|
62 |
|
63 signals: |
|
64 void requestCompleted( int status ); |
|
65 |
|
66 private: |
|
67 /*! |
|
68 * emits a signal when the request is completed |
|
69 * @param status is the error |
|
70 */ |
|
71 void emitRequestCompleted( int status ); |
|
72 |
|
73 private: |
|
74 UsbUiModelActivePrivate *d; |
|
75 |
|
76 /** Handle to USBWatcher for setting the personality */ |
|
77 RUsbWatcher iUsbWatcher; |
|
78 }; |
|
79 |
|
80 |
|
81 /*! |
|
82 \class UsbUiModelActivePrivate |
|
83 \brief Private class of UsbUiModelActive, for using active objects in Qt classes. |
|
84 |
|
85 UsbUiModelActivePrivate is a helper class for using active objects |
|
86 from any Qt class. It derives from CActive and allows other classes to use |
|
87 it for passing to asynchronous function calls through its RequestStatus method. |
|
88 |
|
89 */ |
|
90 class UsbUiModelActivePrivate : public CActive |
|
91 { |
|
92 friend class UsbUiModelActive; |
|
93 |
|
94 public: |
|
95 explicit UsbUiModelActivePrivate( UsbUiModelActive *parent, int priority ); |
|
96 ~UsbUiModelActivePrivate(); |
|
97 |
|
98 private: |
|
99 virtual void RunL(); |
|
100 virtual void DoCancel(); |
|
101 virtual TInt RunError( TInt aError ); |
|
102 |
|
103 private: |
|
104 UsbUiModelActive *q; |
|
105 |
|
106 }; |
|
107 |
|
108 inline bool UsbUiModelActive::IsActive() |
|
109 { |
|
110 return d->IsActive(); |
|
111 } |
|
112 |
|
113 inline TRequestStatus &UsbUiModelActive::RequestStatus() |
|
114 { |
|
115 return d->iStatus; |
|
116 } |
|
117 |
|
118 inline void UsbUiModelActive::SetActive() |
|
119 { |
|
120 d->SetActive(); |
|
121 } |
|
122 |
|
123 inline void UsbUiModelActive::Cancel() |
|
124 { |
|
125 d->Cancel(); |
|
126 } |
|
127 |
|
128 #endif /* USBUIMODELACTIVE_H */ |
|