30 // ----------------------------------------------------------------------------- |
30 // ----------------------------------------------------------------------------- |
31 // InvokeNotifiersL - This function is called to notify servers on any event |
31 // InvokeNotifiersL - This function is called to notify servers on any event |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 LOCAL_D void InvokeNotifiersL(RFile& aTaskFile) |
33 LOCAL_D void InvokeNotifiersL(RFile& aTaskFile) |
34 { |
34 { |
35 FLOG(_L("DmEventHandler InvokeNotifiersL >>")); |
35 _DMEVNT_DEBUG(_L("DmEventHandler InvokeNotifiersL >>")); |
36 |
36 |
37 CFileStore* store; |
37 CFileStore* store; |
38 RStoreReadStream instream; |
38 RStoreReadStream instream; |
39 // Get tasks from scheduler's store |
39 // Get tasks from scheduler's store |
40 store = CDirectFileStore::FromLC(aTaskFile); |
40 store = CDirectFileStore::FromLC(aTaskFile); |
41 instream.OpenLC(*store,store->Root()); |
41 instream.OpenLC(*store,store->Root()); |
42 TInt count = instream.ReadInt32L(); |
42 TInt count = instream.ReadInt32L(); |
43 FLOG(_L("SwInstallhandler task count %d"),count ); |
43 _DMEVNT_DEBUG(_L("SwInstallhandler task count %d"),count ); |
44 |
44 |
45 CScheduledTask* task = CScheduledTask::NewLC(instream); |
45 CScheduledTask* task = CScheduledTask::NewLC(instream); |
46 HBufC* b = const_cast<HBufC*>(&(task->Data())); |
46 HBufC* b = const_cast<HBufC*>(&(task->Data())); |
47 TPtr ptr = b->Des(); |
47 TPtr ptr = b->Des(); |
48 TName taskname(ptr); |
48 TName taskname(ptr); |
50 CleanupStack::PopAndDestroy (task); |
50 CleanupStack::PopAndDestroy (task); |
51 CleanupStack::PopAndDestroy( &instream ); |
51 CleanupStack::PopAndDestroy( &instream ); |
52 CleanupStack::PopAndDestroy( store ); |
52 CleanupStack::PopAndDestroy( store ); |
53 |
53 |
54 |
54 |
55 FLOG(_L("Waiting for completion...")); |
55 _DMEVNT_DEBUG(_L("Waiting for completion...")); |
56 CDmEventScheduler* sch = CDmEventScheduler::NewLC(); |
56 CDmEventScheduler* sch = CDmEventScheduler::NewLC(); |
57 sch->WaitAndCreateConditionScheduleL(taskname); |
57 sch->WaitAndCreateConditionScheduleL(taskname); |
58 CleanupStack::PopAndDestroy(sch); |
58 CleanupStack::PopAndDestroy(sch); |
59 |
59 |
60 FLOG(_L("DmEventHandler InvokeNotifiersL <<")); |
60 _DMEVNT_DEBUG(_L("DmEventHandler InvokeNotifiersL <<")); |
61 } |
61 } |
62 |
62 |
63 |
63 |
64 // ----------------------------------------------------------------------------- |
64 // ----------------------------------------------------------------------------- |
65 // ExecuteL - This function is called to check if check the purpose of invocation |
65 // ExecuteL - This function is called to check if check the purpose of invocation |
66 // of this executable |
66 // of this executable |
67 // ----------------------------------------------------------------------------- |
67 // ----------------------------------------------------------------------------- |
68 LOCAL_D TInt ExecuteL() |
68 LOCAL_D TInt ExecuteL() |
69 { |
69 { |
70 FLOG(_L("DmEventHandler ExecuteL...>>")); |
70 _DMEVNT_DEBUG(_L("DmEventHandler ExecuteL...>>")); |
71 TInt err = KErrNoMemory; |
71 TInt err = KErrNoMemory; |
72 |
72 |
73 RFile file; |
73 RFile file; |
74 |
74 |
75 // Adopt the task file from the Task Scheduler |
75 // Adopt the task file from the Task Scheduler |
76 err = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(), |
76 err = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(), |
77 TScheduledTaskFile::FileHandleIndex()); |
77 TScheduledTaskFile::FileHandleIndex()); |
78 FLOG(_L(" err %d"),err ); |
78 _DMEVNT_DEBUG(_L(" err %d"),err ); |
79 |
79 |
80 |
80 |
81 if (KErrNone == err) |
81 if (KErrNone == err) |
82 { |
82 { |
83 TRAP(err, InvokeNotifiersL(file)); |
83 TRAP(err, InvokeNotifiersL(file)); |
84 FLOG(_L("Error = %d"), err); |
84 _DMEVNT_DEBUG(_L("Error = %d"), err); |
85 } |
85 } |
86 else if (KErrNotFound == err) |
86 else if (KErrNotFound == err) |
87 { |
87 { |
88 //If err =-1, certain that there is no task scheduled. So, start and register the condition schedule |
88 //If err =-1, certain that there is no task scheduled. So, start and register the condition schedule |
89 CDmEventScheduler* sch = CDmEventScheduler::NewLC(); |
89 CDmEventScheduler* sch = CDmEventScheduler::NewLC(); |
93 else |
93 else |
94 __LEAVE_IF_ERROR(err); |
94 __LEAVE_IF_ERROR(err); |
95 |
95 |
96 file.Close(); |
96 file.Close(); |
97 |
97 |
98 FLOG(_L("DmEventHandler ExecuteL...<<")); |
98 _DMEVNT_DEBUG(_L("DmEventHandler ExecuteL...<<")); |
99 return err; |
99 return err; |
100 } |
100 } |
101 |
101 |
102 |
102 |
103 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
104 // Execute - This is called by the entry point |
104 // Execute - This is called by the entry point |
105 // ----------------------------------------------------------------------------- |
105 // ----------------------------------------------------------------------------- |
106 LOCAL_D TInt Execute() |
106 LOCAL_D TInt Execute() |
107 { |
107 { |
108 __UHEAP_MARK; |
108 __UHEAP_MARK; |
109 FLOG(_L("DmEventHandler Execute() >>")); |
109 _DMEVNT_DEBUG(_L("DmEventHandler Execute() >>")); |
110 |
110 |
111 TInt err = KErrNoMemory; |
111 TInt err = KErrNoMemory; |
112 |
112 |
113 // construct and install active scheduler |
113 // construct and install active scheduler |
114 CActiveScheduler* scheduler = new CActiveScheduler; |
114 CActiveScheduler* scheduler = new CActiveScheduler; |