tstaskmonitor/utils/src/tsfswentry.cpp
author hgs
Fri, 14 May 2010 17:24:44 +0300
changeset 94 dbb8300717f7
child 83 156f692b1687
permissions -rw-r--r--
201019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  Task list entry
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#define __E32SVR_H__
hgs
parents:
diff changeset
    19
#include "tsfswentry.h"
hgs
parents:
diff changeset
    20
#include <s32strm.h>
hgs
parents:
diff changeset
    21
#include <fbs.h>
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    24
// CTsFswEntry::NewL
hgs
parents:
diff changeset
    25
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    26
//
hgs
parents:
diff changeset
    27
CTsFswEntry* CTsFswEntry::NewL()
hgs
parents:
diff changeset
    28
    {
hgs
parents:
diff changeset
    29
    CTsFswEntry* self = NewLC();
hgs
parents:
diff changeset
    30
    CleanupStack::Pop( self );
hgs
parents:
diff changeset
    31
    return self;
hgs
parents:
diff changeset
    32
    }
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    35
// CTsFswEntry::NewLC
hgs
parents:
diff changeset
    36
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    37
//
hgs
parents:
diff changeset
    38
CTsFswEntry* CTsFswEntry::NewLC()
hgs
parents:
diff changeset
    39
    {
hgs
parents:
diff changeset
    40
    CTsFswEntry* self = new ( ELeave ) CTsFswEntry;
hgs
parents:
diff changeset
    41
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    42
    return self;
hgs
parents:
diff changeset
    43
    }
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    46
// CTsFswEntry::~CTsFswEntry
hgs
parents:
diff changeset
    47
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    48
//
hgs
parents:
diff changeset
    49
CTsFswEntry::~CTsFswEntry()
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
    delete iAppName;
hgs
parents:
diff changeset
    52
    delete iAppIconBitmap;
hgs
parents:
diff changeset
    53
    delete iAppIconMask;
hgs
parents:
diff changeset
    54
    }
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    57
// CTsFswEntry::SetWgId
hgs
parents:
diff changeset
    58
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    59
//
hgs
parents:
diff changeset
    60
void CTsFswEntry::SetWgId( TInt aWgId )
hgs
parents:
diff changeset
    61
    {
hgs
parents:
diff changeset
    62
    iWgId = aWgId;
hgs
parents:
diff changeset
    63
    }
hgs
parents:
diff changeset
    64
hgs
parents:
diff changeset
    65
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    66
// CTsFswEntry::SetAppUid
hgs
parents:
diff changeset
    67
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
//
hgs
parents:
diff changeset
    69
void CTsFswEntry::SetAppUid( const TUid& aUid )
hgs
parents:
diff changeset
    70
    {
hgs
parents:
diff changeset
    71
    iAppUid = aUid;
hgs
parents:
diff changeset
    72
    }
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    75
// CTsFswEntry::SetAppNameL
hgs
parents:
diff changeset
    76
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
//
hgs
parents:
diff changeset
    78
void CTsFswEntry::SetAppNameL( const TDesC& aAppName )
hgs
parents:
diff changeset
    79
    {
hgs
parents:
diff changeset
    80
    delete iAppName; iAppName = 0;
hgs
parents:
diff changeset
    81
    iAppName = aAppName.AllocL();
hgs
parents:
diff changeset
    82
    }
hgs
parents:
diff changeset
    83
hgs
parents:
diff changeset
    84
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    85
// CTsFswEntry::SetSystemApp
hgs
parents:
diff changeset
    86
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    87
//
hgs
parents:
diff changeset
    88
void CTsFswEntry::SetCloseableApp( TBool aValue )
hgs
parents:
diff changeset
    89
    {
hgs
parents:
diff changeset
    90
    iCloseableApp = aValue;
hgs
parents:
diff changeset
    91
    }
hgs
parents:
diff changeset
    92
hgs
parents:
diff changeset
    93
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    94
// CTsFswEntry::SetAppIconHandles
hgs
parents:
diff changeset
    95
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
    96
//
hgs
parents:
diff changeset
    97
void CTsFswEntry::SetAppIcon( CFbsBitmap* aBitmap, CFbsBitmap* aMask )
hgs
parents:
diff changeset
    98
    {
hgs
parents:
diff changeset
    99
    iAppIconBitmap = aBitmap;
hgs
parents:
diff changeset
   100
    iAppIconMask = aMask;
hgs
parents:
diff changeset
   101
    }
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   104
// CTsFswEntry::WgId
hgs
parents:
diff changeset
   105
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   106
//
hgs
parents:
diff changeset
   107
TInt CTsFswEntry::WgId() const
hgs
parents:
diff changeset
   108
    {
hgs
parents:
diff changeset
   109
    return iWgId;
hgs
parents:
diff changeset
   110
    }
hgs
parents:
diff changeset
   111
hgs
parents:
diff changeset
   112
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   113
// CTsFswEntry::AppUid
hgs
parents:
diff changeset
   114
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   115
//
hgs
parents:
diff changeset
   116
TUid CTsFswEntry::AppUid() const
hgs
parents:
diff changeset
   117
    {
hgs
parents:
diff changeset
   118
    return iAppUid;
hgs
parents:
diff changeset
   119
    }
hgs
parents:
diff changeset
   120
hgs
parents:
diff changeset
   121
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   122
// CTsFswEntry::AppName
hgs
parents:
diff changeset
   123
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   124
//
hgs
parents:
diff changeset
   125
const TDesC& CTsFswEntry::AppName() const
hgs
parents:
diff changeset
   126
    {
hgs
parents:
diff changeset
   127
    return iAppName ? *iAppName : KNullDesC();
hgs
parents:
diff changeset
   128
    }
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   131
// CTsFswEntry::SystemApp
hgs
parents:
diff changeset
   132
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   133
//
hgs
parents:
diff changeset
   134
TBool CTsFswEntry::CloseableApp() const
hgs
parents:
diff changeset
   135
    {
hgs
parents:
diff changeset
   136
    return iCloseableApp;
hgs
parents:
diff changeset
   137
    }
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   140
// CTsFswEntry::AppIconBitmapHandle
hgs
parents:
diff changeset
   141
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   142
//
hgs
parents:
diff changeset
   143
CFbsBitmap* CTsFswEntry::AppIconBitmap() const
hgs
parents:
diff changeset
   144
    {
hgs
parents:
diff changeset
   145
    return iAppIconBitmap;
hgs
parents:
diff changeset
   146
    }
hgs
parents:
diff changeset
   147
hgs
parents:
diff changeset
   148
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   149
// CTsFswEntry::AppIconMaskHandle
hgs
parents:
diff changeset
   150
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   151
//
hgs
parents:
diff changeset
   152
CFbsBitmap* CTsFswEntry::AppIconMask() const
hgs
parents:
diff changeset
   153
    {
hgs
parents:
diff changeset
   154
    return iAppIconMask;
hgs
parents:
diff changeset
   155
    }
hgs
parents:
diff changeset
   156
hgs
parents:
diff changeset
   157
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   158
// CTsFswEntry::ExternalizeL
hgs
parents:
diff changeset
   159
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   160
//
hgs
parents:
diff changeset
   161
void CTsFswEntry::ExternalizeL( RWriteStream& aStream )
hgs
parents:
diff changeset
   162
    {
hgs
parents:
diff changeset
   163
    aStream.WriteInt32L( iWgId );
hgs
parents:
diff changeset
   164
    aStream.WriteInt32L( iAppUid.iUid );
hgs
parents:
diff changeset
   165
    aStream << AppName();
hgs
parents:
diff changeset
   166
    aStream.WriteInt32L( iCloseableApp );
hgs
parents:
diff changeset
   167
    if ( iAppIconBitmap )
hgs
parents:
diff changeset
   168
        {
hgs
parents:
diff changeset
   169
        aStream.WriteInt32L( iAppIconBitmap->Handle() );
hgs
parents:
diff changeset
   170
        }
hgs
parents:
diff changeset
   171
    else
hgs
parents:
diff changeset
   172
        {
hgs
parents:
diff changeset
   173
        aStream.WriteInt32L( KErrNotFound );
hgs
parents:
diff changeset
   174
        }
hgs
parents:
diff changeset
   175
    
hgs
parents:
diff changeset
   176
   if ( iAppIconMask )
hgs
parents:
diff changeset
   177
        {
hgs
parents:
diff changeset
   178
        aStream.WriteInt32L( iAppIconMask->Handle() );
hgs
parents:
diff changeset
   179
        }
hgs
parents:
diff changeset
   180
    else
hgs
parents:
diff changeset
   181
        {
hgs
parents:
diff changeset
   182
        aStream.WriteInt32L( KErrNotFound );
hgs
parents:
diff changeset
   183
        }
hgs
parents:
diff changeset
   184
    }
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   187
// CTsFswEntry::InternalizeL
hgs
parents:
diff changeset
   188
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   189
//
hgs
parents:
diff changeset
   190
void CTsFswEntry::InternalizeL( RReadStream& aStream )
hgs
parents:
diff changeset
   191
    {
hgs
parents:
diff changeset
   192
    iWgId = aStream.ReadInt32L();
hgs
parents:
diff changeset
   193
    iAppUid = TUid::Uid( aStream.ReadInt32L() );
hgs
parents:
diff changeset
   194
    delete iAppName; iAppName = NULL;
hgs
parents:
diff changeset
   195
    iAppName = HBufC::NewL( aStream, KMaxTInt );
hgs
parents:
diff changeset
   196
    iCloseableApp = aStream.ReadInt32L();
hgs
parents:
diff changeset
   197
    TInt appIconBitmapHandle = aStream.ReadInt32L();
hgs
parents:
diff changeset
   198
    TInt appIconMaskHandle = aStream.ReadInt32L();
hgs
parents:
diff changeset
   199
    if ( appIconBitmapHandle != KErrNotFound )
hgs
parents:
diff changeset
   200
        {
hgs
parents:
diff changeset
   201
        iAppIconBitmap = new (ELeave) CFbsBitmap;
hgs
parents:
diff changeset
   202
        iAppIconBitmap->Duplicate( appIconBitmapHandle );  
hgs
parents:
diff changeset
   203
        }
hgs
parents:
diff changeset
   204
    if ( appIconMaskHandle != KErrNotFound )    
hgs
parents:
diff changeset
   205
        {
hgs
parents:
diff changeset
   206
        iAppIconMask = new (ELeave) CFbsBitmap;
hgs
parents:
diff changeset
   207
        iAppIconMask->Duplicate( appIconMaskHandle );  
hgs
parents:
diff changeset
   208
        }
hgs
parents:
diff changeset
   209
    }
hgs
parents:
diff changeset
   210
hgs
parents:
diff changeset
   211
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   212
// CTsFswEntry::ExternalizeArrayL
hgs
parents:
diff changeset
   213
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   214
//
hgs
parents:
diff changeset
   215
void CTsFswEntry::ExternalizeArrayL( RWriteStream& aStream,
hgs
parents:
diff changeset
   216
        const RTsFswArray& aArray )
hgs
parents:
diff changeset
   217
    {
hgs
parents:
diff changeset
   218
    TInt count = aArray.Count();
hgs
parents:
diff changeset
   219
    aStream.WriteInt32L( count );
hgs
parents:
diff changeset
   220
    for ( TInt i = 0; i < count; ++i )
hgs
parents:
diff changeset
   221
        {
hgs
parents:
diff changeset
   222
        aArray[i]->ExternalizeL( aStream );
hgs
parents:
diff changeset
   223
        }
hgs
parents:
diff changeset
   224
    }
hgs
parents:
diff changeset
   225
hgs
parents:
diff changeset
   226
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   227
// CTsFswEntry::InternalizeArrayL
hgs
parents:
diff changeset
   228
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   229
//
hgs
parents:
diff changeset
   230
void CTsFswEntry::InternalizeArrayL( RReadStream& aStream,
hgs
parents:
diff changeset
   231
        RTsFswArray& aArray )
hgs
parents:
diff changeset
   232
    {
hgs
parents:
diff changeset
   233
    aArray.ResetAndDestroy();
hgs
parents:
diff changeset
   234
    TInt count = aStream.ReadInt32L();    for ( TInt i = 0; i < count; ++i )
hgs
parents:
diff changeset
   235
        {
hgs
parents:
diff changeset
   236
        CTsFswEntry* entry = CTsFswEntry::NewLC();
hgs
parents:
diff changeset
   237
        entry->InternalizeL( aStream );
hgs
parents:
diff changeset
   238
        aArray.AppendL( entry );
hgs
parents:
diff changeset
   239
        CleanupStack::Pop( entry );
hgs
parents:
diff changeset
   240
        }
hgs
parents:
diff changeset
   241
    }
hgs
parents:
diff changeset
   242
hgs
parents:
diff changeset
   243
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   244
// CTsFswEntry::Type
hgs
parents:
diff changeset
   245
// --------------------------------------------------------------------------
hgs
parents:
diff changeset
   246
//
hgs
parents:
diff changeset
   247
TAppType CTsFswEntry::Type() const
hgs
parents:
diff changeset
   248
    {
hgs
parents:
diff changeset
   249
    return EApp;
hgs
parents:
diff changeset
   250
    }
hgs
parents:
diff changeset
   251
// end of file