|
1 // Copyright (c) 2000-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 // |
|
15 |
|
16 #include <f32file.h> |
|
17 #include <watcher.h> |
|
18 #include "testwatcher.h" |
|
19 |
|
20 #define KTestDelay 5000000 |
|
21 _LIT(KTestFile, "c:\\ECOMTESTWATCHER"); |
|
22 |
|
23 //********************************** |
|
24 // Globals |
|
25 //********************************** |
|
26 |
|
27 |
|
28 //********************************** |
|
29 // CTestWatcher |
|
30 //********************************** |
|
31 |
|
32 // static |
|
33 |
|
34 #include <ecom/implementationproxy.h> |
|
35 |
|
36 const TImplementationProxy ImplementationTable[] = |
|
37 { |
|
38 IMPLEMENTATION_PROXY_ENTRY(0x10008D9D, CTestWatcher::NewL) |
|
39 }; |
|
40 |
|
41 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
42 { |
|
43 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
44 |
|
45 return ImplementationTable; |
|
46 } |
|
47 |
|
48 CTestWatcher* CTestWatcher::NewL(TAny* aWatcherParams) |
|
49 { |
|
50 TWatcherParams* params = reinterpret_cast<TWatcherParams*>(aWatcherParams); |
|
51 CTestWatcher* self = new (ELeave) CTestWatcher(EPriorityStandard, params->iFs, params->iLog); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 CTestWatcher::CTestWatcher(TInt aPriority, RFs& aFs, CWatcherLog& aLog) |
|
59 : CTimer(aPriority), iLog(aLog), iFs(aFs) |
|
60 { |
|
61 CActiveScheduler::Add(this); |
|
62 } |
|
63 |
|
64 CTestWatcher::~CTestWatcher() |
|
65 { |
|
66 Cancel(); |
|
67 } |
|
68 |
|
69 void CTestWatcher::ConstructL() |
|
70 { |
|
71 TRAPD(err, CTimer::ConstructL(); After(KTestDelay)); |
|
72 RDebug::Print(_L("Constructed test watcher with error %d"), err); |
|
73 User::LeaveIfError(err); |
|
74 } |
|
75 |
|
76 void CTestWatcher::RunL() |
|
77 { |
|
78 iLog.Printf(_L("EcomTestWatcher: Creating test file")); |
|
79 |
|
80 RFile file; |
|
81 TInt err = file.Replace(iFs, KTestFile, EFileShareExclusive); |
|
82 |
|
83 if (err) |
|
84 err = file.Create(iFs, KTestFile, EFileShareExclusive); |
|
85 |
|
86 if (!err) |
|
87 { |
|
88 file.Write(_L8("Hello\n")); |
|
89 file.Flush(); |
|
90 file.Close(); |
|
91 } |
|
92 |
|
93 After(KTestDelay); |
|
94 } |
|
95 |