16 |
16 |
17 #include "s60dependency.h" |
17 #include "s60dependency.h" |
18 #include "cmtppictbridgeusbconnection.h" |
18 #include "cmtppictbridgeusbconnection.h" |
19 #include "cmtppictbridgeprinter.h" |
19 #include "cmtppictbridgeprinter.h" |
20 #include "ptpdef.h" |
20 #include "ptpdef.h" |
|
21 #include "OstTraceDefinitions.h" |
|
22 #include "mtpdebug.h" |
|
23 #ifdef OST_TRACE_COMPILER_IN_USE |
|
24 #include "cmtppictbridgeusbconnectionTraces.h" |
|
25 #endif |
|
26 |
21 |
27 |
22 const TInt KNotAssigned=0; |
28 const TInt KNotAssigned=0; |
23 // -------------------------------------------------------------------------- |
29 // -------------------------------------------------------------------------- |
24 // |
30 // |
25 // |
31 // |
52 // |
58 // |
53 // -------------------------------------------------------------------------- |
59 // -------------------------------------------------------------------------- |
54 // |
60 // |
55 void CMTPPictBridgeUsbConnection::ConstructL() |
61 void CMTPPictBridgeUsbConnection::ConstructL() |
56 { |
62 { |
57 __FLOG_OPEN(KMTPSubsystem, KPtpServerLog); |
63 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_CONSTRUCTL_ENTRY ); |
58 __FLOG(_L8("CMTPPictBridgeUsbConnection::ConstructL")); |
64 LEAVEIFERROR(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality), |
59 User::LeaveIfError(iProperty.Attach(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality)); |
65 OstTrace1( TRACE_ERROR, CMTPPICTBRIDGEUSBCONNECTION_CONSTRUCTL, |
|
66 "Attaches to the specified property failed. Error code %d", munged_err)); |
|
67 |
|
68 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_CONSTRUCTL_EXIT ); |
60 } |
69 } |
61 |
70 |
62 // -------------------------------------------------------------------------- |
71 // -------------------------------------------------------------------------- |
63 // |
72 // |
64 // -------------------------------------------------------------------------- |
73 // -------------------------------------------------------------------------- |
65 // |
74 // |
66 CMTPPictBridgeUsbConnection::~CMTPPictBridgeUsbConnection() |
75 CMTPPictBridgeUsbConnection::~CMTPPictBridgeUsbConnection() |
67 { |
76 { |
68 __FLOG(_L8(">> CMTPPictBridgeUsbConnection::~")); |
77 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_CMTPPICTBRIDGEUSBCONNECTION_DES_ENTRY ); |
69 Cancel(); |
78 Cancel(); |
70 iProperty.Close(); |
79 iProperty.Close(); |
71 __FLOG(_L8("<< CMTPPictBridgeUsbConnection::~")); |
80 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_CMTPPICTBRIDGEUSBCONNECTION_DES_EXIT ); |
72 __FLOG_CLOSE; |
|
73 } |
81 } |
74 |
82 |
75 // -------------------------------------------------------------------------- |
83 // -------------------------------------------------------------------------- |
76 // |
84 // |
77 // -------------------------------------------------------------------------- |
85 // -------------------------------------------------------------------------- |
78 // |
86 // |
79 void CMTPPictBridgeUsbConnection::Listen() |
87 void CMTPPictBridgeUsbConnection::Listen() |
80 { |
88 { |
81 __FLOG(_L8(">> CMTPPictBridgeUsbConnection::Listen")); |
89 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_LISTEN_ENTRY ); |
82 if(!IsActive()) |
90 if(!IsActive()) |
83 { |
91 { |
84 __FLOG(_L8(" CMTPPictBridgeUsbConnection AO is NOT active and run AO")); |
92 OstTrace0( TRACE_NORMAL, CMTPPICTBRIDGEUSBCONNECTION_LISTEN, " CMTPPictBridgeUsbConnection AO is NOT active and run AO"); |
85 iProperty.Subscribe(iStatus); |
93 iProperty.Subscribe(iStatus); |
86 SetActive(); |
94 SetActive(); |
87 if(ConnectionClosed()) // we listen to the disconnection only if connected to the printer |
95 if(ConnectionClosed()) // we listen to the disconnection only if connected to the printer |
88 { |
96 { |
89 iPrinter.ConnectionClosed(); |
97 iPrinter.ConnectionClosed(); |
90 Cancel(); |
98 Cancel(); |
91 } |
99 } |
92 } |
100 } |
93 __FLOG(_L8("<< CMTPPictBridgeUsbConnection::Listen")); |
101 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_LISTEN_EXIT ); |
94 } |
102 } |
95 |
103 |
96 // -------------------------------------------------------------------------- |
104 // -------------------------------------------------------------------------- |
97 // |
105 // |
98 // -------------------------------------------------------------------------- |
106 // -------------------------------------------------------------------------- |
100 TBool CMTPPictBridgeUsbConnection::ConnectionClosed() |
108 TBool CMTPPictBridgeUsbConnection::ConnectionClosed() |
101 { |
109 { |
102 TInt personality=KNotAssigned; |
110 TInt personality=KNotAssigned; |
103 TInt ret = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, personality); |
111 TInt ret = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, personality); |
104 |
112 |
105 __FLOG_VA((_L8("CMTPPictBridgeUsbConnection::ConnectionClosed() current personality = %d, previous personality = %d"), personality, iPreviousPersonality)); |
113 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEUSBCONNECTION_CONNECTIONCLOSED, |
|
114 " current personality = %d, previous personality = %d", personality, iPreviousPersonality ); |
106 if ((ret == KErrNone && personality == KUsbPersonalityIdMS) |
115 if ((ret == KErrNone && personality == KUsbPersonalityIdMS) |
107 || (iPreviousPersonality != KNotAssigned && personality != iPreviousPersonality)) |
116 || (iPreviousPersonality != KNotAssigned && personality != iPreviousPersonality)) |
108 { |
117 { |
109 if((personality != KUsbPersonalityIdPCSuiteMTP)&&(personality != KUsbPersonalityIdMTP)) |
118 if((personality != KUsbPersonalityIdPCSuiteMTP)&&(personality != KUsbPersonalityIdMTP)) |
110 { |
119 { |
111 __FLOG_VA((_L8("****WARNING!!! PTP server detects the USB connection closed!"))); |
120 OstTrace0( TRACE_WARNING, DUP1_CMTPPICTBRIDGEUSBCONNECTION_CONNECTIONCLOSED, |
|
121 "****WARNING!!! PTP server detects the USB connection closed!" ); |
112 return ETrue; |
122 return ETrue; |
113 } |
123 } |
114 } |
124 } |
115 |
125 |
116 iPreviousPersonality = personality; |
126 iPreviousPersonality = personality; |
123 // |
133 // |
124 // -------------------------------------------------------------------------- |
134 // -------------------------------------------------------------------------- |
125 // |
135 // |
126 void CMTPPictBridgeUsbConnection::DoCancel() |
136 void CMTPPictBridgeUsbConnection::DoCancel() |
127 { |
137 { |
128 __FLOG(_L8("CMTPPictBridgeUsbConnection::DoCancel()")); |
138 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_DOCANCEL_ENTRY ); |
129 iProperty.Cancel(); |
139 iProperty.Cancel(); |
|
140 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_DOCANCEL_EXIT ); |
130 } |
141 } |
131 |
142 |
132 // -------------------------------------------------------------------------- |
143 // -------------------------------------------------------------------------- |
133 // |
144 // |
134 // -------------------------------------------------------------------------- |
145 // -------------------------------------------------------------------------- |
135 // |
146 // |
136 void CMTPPictBridgeUsbConnection::RunL() |
147 void CMTPPictBridgeUsbConnection::RunL() |
137 { |
148 { |
138 __FLOG_VA((_L8(">>>CMTPPictBridgeUsbConnection::RunL %d"),iStatus.Int())); |
149 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_RUNL_ENTRY ); |
|
150 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEUSBCONNECTION_RUNL, "iStatus %d", iStatus.Int() ); |
139 |
151 |
140 TBool closed = EFalse; |
152 TBool closed = EFalse; |
141 if( iStatus == KErrNone ) |
153 if( iStatus == KErrNone ) |
142 { |
154 { |
143 closed=ConnectionClosed(); |
155 closed=ConnectionClosed(); |
150 if(iStatus != KErrCancel && !closed) // if connection not closed, keep on listening |
162 if(iStatus != KErrCancel && !closed) // if connection not closed, keep on listening |
151 { |
163 { |
152 Listen(); |
164 Listen(); |
153 } |
165 } |
154 |
166 |
155 __FLOG(_L8("<<<CMTPPictBridgeUsbConnection::RunL")); |
167 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_RUNL_EXIT ); |
156 } |
168 } |
157 |
169 |
158 // -------------------------------------------------------------------------- |
170 // -------------------------------------------------------------------------- |
159 // |
171 // |
160 // -------------------------------------------------------------------------- |
172 // -------------------------------------------------------------------------- |
161 // |
173 // |
162 #ifdef __FLOG_ACTIVE |
174 #ifdef OST_TRACE_COMPILER_IN_USE |
163 TInt CMTPPictBridgeUsbConnection::RunError(TInt aErr) |
175 TInt CMTPPictBridgeUsbConnection::RunError(TInt aErr) |
164 #else |
176 #else |
165 TInt CMTPPictBridgeUsbConnection::RunError(TInt /*aErr*/) |
177 TInt CMTPPictBridgeUsbConnection::RunError(TInt /*aErr*/) |
166 #endif |
178 #endif |
167 { |
179 { |
168 __FLOG_VA((_L8(">>>CMTPPictBridgeUsbConnection::RunError %d"), aErr)); |
180 OstTraceFunctionEntry0( CMTPPICTBRIDGEUSBCONNECTION_RUNERROR_ENTRY ); |
|
181 OstTraceDef1( OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CMTPPICTBRIDGEUSBCONNECTION_RUNERROR, |
|
182 "error code %d", aErr); |
|
183 OstTraceFunctionExit0( CMTPPICTBRIDGEUSBCONNECTION_RUNERROR_EXIT ); |
169 return KErrNone; |
184 return KErrNone; |
170 } |
185 } |
171 |
186 |