tstaskmonitor/client/s60/src/tstaskmonitor_p.cpp
changeset 104 9b022b1f357c
parent 83 156f692b1687
equal deleted inserted replaced
103:b99b84bcd2d1 104:9b022b1f357c
    15 *
    15 *
    16 */
    16 */
    17 #include "tstaskmonitor_p.h"
    17 #include "tstaskmonitor_p.h"
    18 #include "tstaskmonitor.h"
    18 #include "tstaskmonitor.h"
    19 
    19 
       
    20 #include <eikenv.h>
       
    21 
    20 #include "tstaskmonitorclient.h"
    22 #include "tstaskmonitorclient.h"
    21 #include "tsapplicationtask.h"
    23 #include "tsapplicationtask.h"
    22 
    24 
    23 #include "tsutils.h"
    25 #include "tsutils.h"
    24 using TaskSwitcher::CleanupResetAndDestroyPushL;
    26 using TaskSwitcher::CleanupResetAndDestroyPushL;
    25 
    27 
    26 TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) : q_ptr(q), mClient(0)
    28 TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) : q_ptr(q), mClient(0), mWsSession(CEikonEnv::Static()->WsSession())
    27 {
    29 {
    28     QT_TRAP_THROWING(mClient = CTsTaskMonitorClient::NewL());
    30     QT_TRAP_THROWING(mClient = CTsTaskMonitorClient::NewL());
    29     mClient->Subscribe(*this);
    31     mClient->Subscribe(*this);
    30 }
    32 }
    31 
    33 
    38 QList< QSharedPointer<TsTask> > TsTaskMonitorPrivate::taskList()
    40 QList< QSharedPointer<TsTask> > TsTaskMonitorPrivate::taskList()
    39 {
    41 {
    40     QList< QSharedPointer<TsTask> > tasks;
    42     QList< QSharedPointer<TsTask> > tasks;
    41 
    43 
    42     QT_TRAP_THROWING (    
    44     QT_TRAP_THROWING (    
    43         RPointerArray<CTsFswEntry> entries;   
    45         RPointerArray<CTsEntry> entries;   
    44         CleanupResetAndDestroyPushL<CTsFswEntry>(entries);
    46         CleanupResetAndDestroyPushL<CTsEntry>(entries);
    45         mClient->TaskListL(entries);
    47         mClient->TaskListL(entries);
    46         
    48         
    47         // TsTask claims ownership of CTsFswEntry, so we have to remove entries from 
    49         // TsTask claims ownership of CTsFswEntry, so we have to remove entries from 
    48         // entries array after adding task to tasks array to prevent double delete of
    50         // entries array after adding task to tasks array to prevent double delete of
    49         // CTsFswEntry objects in case of leave (for example due to OOM) in the middle 
    51         // CTsFswEntry objects in case of leave (for example due to OOM) in the middle 
    50         // of the loop below.
    52         // of the loop below.
    51         while (entries.Count()) {
    53         while (entries.Count()) {
    52             CTsFswEntry *firstEntry = entries[0];
    54             CTsEntry *firstEntry = entries[0];
    53             CleanupStack::PushL(firstEntry);
    55             CleanupStack::PushL(firstEntry);
    54             entries.Remove(0);
    56             entries.Remove(0);
    55             
    57             
    56             // @todo switch by entry type
    58             // @todo switch by entry type
    57             QT_TRYCATCH_LEAVING(tasks.append(QSharedPointer<TsTask>(new TsApplicationTask(firstEntry))));
    59             QT_TRYCATCH_LEAVING(tasks.append(QSharedPointer<TsTask>(new TsApplicationTask(mWsSession, firstEntry))));
    58             
    60             
    59             CleanupStack::Pop(firstEntry);
    61             CleanupStack::Pop(firstEntry);
    60         }
    62         }
    61         
    63         
    62         CleanupStack::PopAndDestroy(&entries);    
    64         CleanupStack::PopAndDestroy(&entries);