taskswitcher/contextengine/tsfswserver/utils/src/tsfswentry.cpp
changeset 4 4d54b72983ae
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Task list entry
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "tsfswentry.h"
       
    20 #include <s32strm.h>
       
    21 
       
    22 // --------------------------------------------------------------------------
       
    23 // CTsFswEntry::NewL
       
    24 // --------------------------------------------------------------------------
       
    25 //
       
    26 EXPORT_C CTsFswEntry* CTsFswEntry::NewL()
       
    27     {
       
    28     CTsFswEntry* self = NewLC();
       
    29     CleanupStack::Pop( self );
       
    30     return self;
       
    31     }
       
    32 
       
    33 // --------------------------------------------------------------------------
       
    34 // CTsFswEntry::NewLC
       
    35 // --------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CTsFswEntry* CTsFswEntry::NewLC()
       
    38     {
       
    39     CTsFswEntry* self = new ( ELeave ) CTsFswEntry;
       
    40     CleanupStack::PushL( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 // --------------------------------------------------------------------------
       
    45 // CTsFswEntry::~CTsFswEntry
       
    46 // --------------------------------------------------------------------------
       
    47 //
       
    48 CTsFswEntry::~CTsFswEntry()
       
    49     {
       
    50     delete iAppName;
       
    51     }
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // CTsFswEntry::SetWgId
       
    55 // --------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C void CTsFswEntry::SetWgId( TInt aWgId )
       
    58     {
       
    59     iWgId = aWgId;
       
    60     }
       
    61 
       
    62 // --------------------------------------------------------------------------
       
    63 // CTsFswEntry::SetAppUid
       
    64 // --------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C void CTsFswEntry::SetAppUid( const TUid& aUid )
       
    67     {
       
    68     iAppUid = aUid;
       
    69     }
       
    70 
       
    71 // --------------------------------------------------------------------------
       
    72 // CTsFswEntry::SetAppNameL
       
    73 // --------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void CTsFswEntry::SetAppNameL( const TDesC& aAppName )
       
    76     {
       
    77     delete iAppName; iAppName = 0;
       
    78     iAppName = aAppName.AllocL();
       
    79     }
       
    80 
       
    81 // --------------------------------------------------------------------------
       
    82 // CTsFswEntry::SetScreenshotHandle
       
    83 // --------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C void CTsFswEntry::SetScreenshotHandle( TInt aHandle )
       
    86     {
       
    87     iScreenshotHandle = aHandle;
       
    88     }
       
    89 
       
    90 // --------------------------------------------------------------------------
       
    91 // CTsFswEntry::SetAlwaysShown
       
    92 // --------------------------------------------------------------------------
       
    93 //
       
    94 EXPORT_C void CTsFswEntry::SetAlwaysShown( TBool aValue )
       
    95     {
       
    96     iAlwaysShown = aValue;
       
    97     }
       
    98 
       
    99 // --------------------------------------------------------------------------
       
   100 // CTsFswEntry::SetSystemApp
       
   101 // --------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C void CTsFswEntry::SetSystemApp( TBool aValue )
       
   104     {
       
   105     iSystemApp = aValue;
       
   106     }
       
   107 
       
   108 // --------------------------------------------------------------------------
       
   109 // CTsFswEntry::SetWidget
       
   110 // --------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C void CTsFswEntry::SetWidget( TBool aValue )
       
   113     {
       
   114     iWidget = aValue;
       
   115     }
       
   116 
       
   117 // --------------------------------------------------------------------------
       
   118 // CTsFswEntry::SetAppIconHandles
       
   119 // --------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void CTsFswEntry::SetAppIconHandles( TInt aBitmapHandle, TInt aMaskHandle )
       
   122     {
       
   123     iAppIconBitmapHandle = aBitmapHandle;
       
   124     iAppIconMaskHandle = aMaskHandle;
       
   125     }
       
   126 
       
   127 // --------------------------------------------------------------------------
       
   128 // CTsFswEntry::WgId
       
   129 // --------------------------------------------------------------------------
       
   130 //
       
   131 EXPORT_C TInt CTsFswEntry::WgId() const
       
   132     {
       
   133     return iWgId;
       
   134     }
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // CTsFswEntry::AppUid
       
   138 // --------------------------------------------------------------------------
       
   139 //
       
   140 EXPORT_C TUid CTsFswEntry::AppUid() const
       
   141     {
       
   142     return iAppUid;
       
   143     }
       
   144 
       
   145 // --------------------------------------------------------------------------
       
   146 // CTsFswEntry::AppName
       
   147 // --------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C const TDesC& CTsFswEntry::AppName() const
       
   150     {
       
   151     return iAppName ? *iAppName : KNullDesC();
       
   152     }
       
   153 
       
   154 // --------------------------------------------------------------------------
       
   155 // CTsFswEntry::ScreenshotHandle
       
   156 // --------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C TInt CTsFswEntry::ScreenshotHandle() const
       
   159     {
       
   160     return iScreenshotHandle;
       
   161     }
       
   162 
       
   163 // --------------------------------------------------------------------------
       
   164 // CTsFswEntry::AlwaysShown
       
   165 // --------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C TBool CTsFswEntry::AlwaysShown() const
       
   168     {
       
   169     return iAlwaysShown;
       
   170     }
       
   171 
       
   172 // --------------------------------------------------------------------------
       
   173 // CTsFswEntry::SystemApp
       
   174 // --------------------------------------------------------------------------
       
   175 //
       
   176 EXPORT_C TBool CTsFswEntry::SystemApp() const
       
   177     {
       
   178     return iSystemApp;
       
   179     }
       
   180 
       
   181 // --------------------------------------------------------------------------
       
   182 // CTsFswEntry::Widget
       
   183 // --------------------------------------------------------------------------
       
   184 //
       
   185 EXPORT_C TBool CTsFswEntry::Widget() const
       
   186     {
       
   187     return iWidget;
       
   188     }
       
   189 
       
   190 // --------------------------------------------------------------------------
       
   191 // CTsFswEntry::AppIconBitmapHandle
       
   192 // --------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C TInt CTsFswEntry::AppIconBitmapHandle() const
       
   195     {
       
   196     return iAppIconBitmapHandle;
       
   197     }
       
   198 
       
   199 // --------------------------------------------------------------------------
       
   200 // CTsFswEntry::AppIconMaskHandle
       
   201 // --------------------------------------------------------------------------
       
   202 //
       
   203 EXPORT_C TInt CTsFswEntry::AppIconMaskHandle() const
       
   204     {
       
   205     return iAppIconMaskHandle;
       
   206     }
       
   207 
       
   208 // --------------------------------------------------------------------------
       
   209 // CTsFswEntry::ExternalizeL
       
   210 // --------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C void CTsFswEntry::ExternalizeL( RWriteStream& aStream )
       
   213     {
       
   214     aStream.WriteInt32L( iWgId );
       
   215     aStream.WriteInt32L( iAppUid.iUid );
       
   216     aStream << AppName();
       
   217     aStream.WriteInt32L( iScreenshotHandle );
       
   218     aStream.WriteInt32L( iAlwaysShown );
       
   219     aStream.WriteInt32L( iSystemApp );
       
   220     aStream.WriteInt32L( iWidget );
       
   221     aStream.WriteInt32L( iAppIconBitmapHandle );
       
   222     aStream.WriteInt32L( iAppIconMaskHandle );
       
   223     }
       
   224 
       
   225 // --------------------------------------------------------------------------
       
   226 // CTsFswEntry::InternalizeL
       
   227 // --------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C void CTsFswEntry::InternalizeL( RReadStream& aStream )
       
   230     {
       
   231     iWgId = aStream.ReadInt32L();
       
   232     iAppUid = TUid::Uid( aStream.ReadInt32L() );
       
   233     delete iAppName; iAppName = 0;
       
   234     iAppName = HBufC::NewL( aStream, KMaxTInt );
       
   235     iScreenshotHandle = aStream.ReadInt32L();
       
   236     iAlwaysShown = aStream.ReadInt32L();
       
   237     iSystemApp = aStream.ReadInt32L();
       
   238     iWidget = aStream.ReadInt32L();
       
   239     iAppIconBitmapHandle = aStream.ReadInt32L();
       
   240     iAppIconMaskHandle = aStream.ReadInt32L();
       
   241     }
       
   242 
       
   243 // --------------------------------------------------------------------------
       
   244 // CTsFswEntry::ExternalizeArrayL
       
   245 // --------------------------------------------------------------------------
       
   246 //
       
   247 EXPORT_C void CTsFswEntry::ExternalizeArrayL( RWriteStream& aStream,
       
   248         const RTsFswArray& aArray )
       
   249     {
       
   250     TInt count = aArray.Count();
       
   251     aStream.WriteInt32L( count );
       
   252     for ( TInt i = 0; i < count; ++i )
       
   253         {
       
   254         aArray[i]->ExternalizeL( aStream );
       
   255         }
       
   256     }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 // CTsFswEntry::InternalizeArrayL
       
   260 // --------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C void CTsFswEntry::InternalizeArrayL( RReadStream& aStream,
       
   263         RTsFswArray& aArray )
       
   264     {
       
   265     aArray.ResetAndDestroy();
       
   266     TInt count = aStream.ReadInt32L();
       
   267     for ( TInt i = 0; i < count; ++i )
       
   268         {
       
   269         CTsFswEntry* entry = CTsFswEntry::NewLC();
       
   270         entry->InternalizeL( aStream );
       
   271         aArray.AppendL( entry );
       
   272         CleanupStack::Pop( entry );
       
   273         }
       
   274     }
       
   275 
       
   276 
       
   277 // end of file