1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This contains CTestMessWatcher which starts the message watchers |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TestMessWatcher.h" |
|
19 |
|
20 _LIT(KWatcherExe, "z:\\system\\libs\\watcher.exe"); |
|
21 |
|
22 CTestMessWatcher* CTestMessWatcher::NewL(TInt aPriority) |
|
23 { |
|
24 CTestMessWatcher* self = new (ELeave) CTestMessWatcher(aPriority); |
|
25 CleanupStack::PushL(self); |
|
26 |
|
27 self->ConstructL(); |
|
28 |
|
29 CleanupStack::Pop(self); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CTestMessWatcher::~CTestMessWatcher() |
|
34 { |
|
35 Cancel(); |
|
36 iTimer.Close(); |
|
37 if (iConstructed) |
|
38 iWatcher.Kill(KErrNone); |
|
39 |
|
40 iWatcher.Close(); |
|
41 } |
|
42 |
|
43 CTestMessWatcher::CTestMessWatcher(TInt aPriority) |
|
44 : CActive(aPriority) |
|
45 , iConstructed(EFalse) |
|
46 { |
|
47 CActiveScheduler::Add(this); |
|
48 } |
|
49 |
|
50 void CTestMessWatcher::ConstructL() |
|
51 { |
|
52 TInt ret=iWatcher.Create(KWatcherExe, KNullDesC); |
|
53 switch ( ret ) |
|
54 { |
|
55 case KErrNone: |
|
56 iWatcher.Resume(); |
|
57 iConstructed = ETrue; |
|
58 case KErrAlreadyExists: |
|
59 break; |
|
60 default: |
|
61 User::Leave(ret); |
|
62 } |
|
63 } |
|
64 |
|
65 void CTestMessWatcher::RunL() |
|
66 { |
|
67 } |
|
68 |
|
69 void CTestMessWatcher::DoCancel() |
|
70 { |
|
71 iTimer.Cancel(); |
|
72 iStatus=KErrCancel; |
|
73 } |
|