|
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: Monitors Obex ServiceMan errors. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "obexsmwatcher.h" |
|
19 #include <e32base.h> |
|
20 #include <obexservicemanprop.h> |
|
21 #include <usb/usblogger.h> |
|
22 |
|
23 #ifdef __FLOG_ACTIVE |
|
24 _LIT8(KLogComponent, "UsbObexCcSMW"); |
|
25 #endif |
|
26 |
|
27 /** |
|
28 * @since S60 V5.2 |
|
29 */ |
|
30 CObexSMWatcher* CObexSMWatcher::NewL(MObexSMObserver& aObserver) |
|
31 { |
|
32 LOG_STATIC_FUNC_ENTRY |
|
33 |
|
34 CObexSMWatcher* self = new (ELeave) CObexSMWatcher(aObserver); |
|
35 CleanupStack::PushL( self); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop(self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 /** |
|
42 * |
|
43 */ |
|
44 CObexSMWatcher::~CObexSMWatcher() |
|
45 { |
|
46 LOG_FUNC |
|
47 Cancel(); |
|
48 iObexSMPostInit.Close(); |
|
49 } |
|
50 |
|
51 /** |
|
52 * Performs 2nd phase construction. |
|
53 */ |
|
54 void CObexSMWatcher::ConstructL() |
|
55 { |
|
56 LOG_FUNC |
|
57 |
|
58 TInt err = iObexSMPostInit.Attach(KUidObexSMCategory, KObexSMPostInitErrorProperty); |
|
59 User::LeaveIfError( err); |
|
60 |
|
61 RunL(); |
|
62 } |
|
63 |
|
64 /** |
|
65 * |
|
66 */ |
|
67 |
|
68 CObexSMWatcher::CObexSMWatcher(MObexSMObserver& aObserver) : |
|
69 CActive(CActive::EPriorityStandard), iObserver(aObserver) |
|
70 { |
|
71 LOG_FUNC |
|
72 CActiveScheduler::Add(this); |
|
73 } |
|
74 |
|
75 /** |
|
76 * |
|
77 */ |
|
78 void CObexSMWatcher::RunL() |
|
79 { |
|
80 LOG_FUNC |
|
81 |
|
82 LOGTEXT2(_L8(">>CObexSMWatcher::RunL [iStatus=%d]"), iStatus.Int()); |
|
83 |
|
84 iObexSMPostInit.Subscribe( iStatus ); |
|
85 SetActive(); |
|
86 |
|
87 TInt value = KErrNone; |
|
88 TInt err = iObexSMPostInit.Get(value); |
|
89 if (err == KErrNone && value != KErrNone) |
|
90 { |
|
91 iObserver.MosmError(value); |
|
92 } |
|
93 |
|
94 LOGTEXT(_L8("<<CObexSMWatcher::RunL")); |
|
95 } |
|
96 |
|
97 /** |
|
98 * |
|
99 */ |
|
100 void CObexSMWatcher::DoCancel() |
|
101 { |
|
102 LOG_FUNC |
|
103 iObexSMPostInit.Cancel(); |
|
104 } |