|
1 /* |
|
2 * Copyright (c) 2006, 2007 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: This class implements functions of setting personality to |
|
15 * MTP. |
|
16 * Version : %version: 10.1.4 % |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include <e32debug.h> |
|
22 #include "dpsptpnotifier.h" |
|
23 #include "dpsusbnotifier.h" |
|
24 #include "dpsconst.h" |
|
25 |
|
26 #ifdef _DEBUG |
|
27 # define IF_DEBUG(t) {RDebug::t;} |
|
28 #else |
|
29 # define IF_DEBUG(t) |
|
30 #endif |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CDpsPtpNotifier* CDpsPtpNotifier::NewL(CDpsUsbNotifier* aParent) |
|
37 { |
|
38 IF_DEBUG(Print(_L("CDpsPtpNotifier::NewL"))); |
|
39 CDpsPtpNotifier* self = new(ELeave) CDpsPtpNotifier(aParent); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CDpsPtpNotifier::CDpsPtpNotifier(CDpsUsbNotifier* aParent) : |
|
48 CActive(EPriorityNormal), iNotifier(aParent) |
|
49 { |
|
50 IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::Ctor"))); |
|
51 CActiveScheduler::Add(this); |
|
52 IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::Ctor"))); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CDpsPtpNotifier::~CDpsPtpNotifier() |
|
60 { |
|
61 IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::"))); |
|
62 Cancel(); |
|
63 IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::~"))); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CDpsPtpNotifier::ChangePtpPersonality() |
|
71 { |
|
72 IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::ChangePtpPersonality"))); |
|
73 if (!IsActive()) |
|
74 { |
|
75 iNotifier->iUsbW.SetPersonality(iStatus, KUsbPersonalityIdMTP, ETrue); |
|
76 SetActive(); |
|
77 } |
|
78 IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::ChangePtpPersonality"))); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CDpsPtpNotifier::RunL() |
|
86 { |
|
87 IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::RunL %d"), iStatus.Int())); |
|
88 if (KErrNone == iStatus.Int()) |
|
89 { |
|
90 iNotifier->iPersonality = KUsbPersonalityIdMTP; |
|
91 TInt ret = iNotifier->ConnectState(); |
|
92 if (ret != KErrNone) |
|
93 { |
|
94 IF_DEBUG(Print(_L("error happened %d"), ret)); |
|
95 } |
|
96 } |
|
97 iNotifier->PtpNotify(iStatus.Int()); |
|
98 IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::RunL"))); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CDpsPtpNotifier::DoCancel() |
|
106 { |
|
107 IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::DoCancel"))); |
|
108 iNotifier->iUsbW.CancelSetPersonality(); |
|
109 IF_DEBUG(Print(_L("<<<CDpsPtpNotifier::DoCancel"))); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CDpsPtpNotifier::RunError(TInt aErr) |
|
117 { |
|
118 IF_DEBUG(Print(_L("CDpsPtpNotifier::RunError"))); |
|
119 return aErr; |
|
120 } |