taskswitcher/server/src/tsstorage.cpp
changeset 127 7b66bc3c6dc9
parent 119 50e220be30d1
equal deleted inserted replaced
126:efda7c0771b9 127:7b66bc3c6dc9
    92     if( !IsSupported(aFunction) ) 
    92     if( !IsSupported(aFunction) ) 
    93         {
    93         {
    94         User::Leave( KErrCorrupt );
    94         User::Leave( KErrCorrupt );
    95         }
    95         }
    96     CTsModelItemKeyMsg* msg = CTsModelItemKeyMsg::NewLC( aDataStream );
    96     CTsModelItemKeyMsg* msg = CTsModelItemKeyMsg::NewLC( aDataStream );
    97     OpenTaskMessage == aFunction ? LaunchL( msg->Key() ) : CloseL( msg->Key() );
    97     OpenTaskMessage == aFunction ? Launch( msg->Key() ) : Close( msg->Key() );
    98     CleanupStack::PopAndDestroy( msg );
    98     CleanupStack::PopAndDestroy( msg );
    99     }
    99     }
   100 
   100 
   101 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   102 /**
   102 /**
   131 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   132 /**
   132 /**
   133  * Interface implementation
   133  * Interface implementation
   134  * @see MTsModel::DisplayNameL(TInt)
   134  * @see MTsModel::DisplayNameL(TInt)
   135  */
   135  */
   136 const TDesC& CTsStorage::DisplayNameL( TInt aOffset ) const 
   136 const TDesC& CTsStorage::DisplayName( TInt aOffset ) const 
   137     {
   137     {
   138     return iData[aOffset].DisplayNameL();
   138     return iData[aOffset].DisplayName();
   139     }
   139     }
   140 
   140 
   141 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   142 /**
   142 /**
   143  * Interface implementation
   143  * Interface implementation
   144  * @see MTsModel::IconHandleL(TInt)
   144  * @see MTsModel::IconHandleL(TInt)
   145  */
   145  */
   146 TInt CTsStorage::IconHandleL( TInt aOffset ) const 
   146 TInt CTsStorage::IconHandle( TInt aOffset ) const 
   147     {
   147     {
   148     return iData[aOffset].IconHandleL();
   148     return iData[aOffset].IconHandle();
   149     }
   149     }
   150 
   150 
   151 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   152 /**
   152 /**
   153  * Interface implementation
   153  * Interface implementation
   154  * @see MTsModel::TimestampL(TInt)
   154  * @see MTsModel::TimestampL(TInt)
   155  */
   155  */
   156 TTime CTsStorage::TimestampL( TInt aOffset ) const 
   156 TTime CTsStorage::Timestamp( TInt aOffset ) const 
   157     {
   157     {
   158     return iData[aOffset].TimestampL();
   158     return iData[aOffset].Timestamp();
   159     }
   159     }
   160 
   160 
   161 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   162 /**
   162 /**
   163  * Interface implementation
   163  * Interface implementation
   164  * @see MTsModel::TimestampUpdateL(TInt)
   164  * @see MTsModel::TimestampUpdateL(TInt)
   165  */
   165  */
   166 TTime CTsStorage::TimestampUpdateL( TInt offset ) const 
   166 TTime CTsStorage::TimestampUpdate( TInt offset ) const 
   167 {
   167 {
   168     return iData[offset].TimestampUpdateL();
   168     return iData[offset].TimestampUpdate();
   169 }
   169 }
   170 
   170 
   171 // -----------------------------------------------------------------------------
   171 // -----------------------------------------------------------------------------
   172 /**
   172 /**
   173  * Interface implementation
   173  * Interface implementation
   174  * @see MTsModel::KeyL(TInt)
   174  * @see MTsModel::Key(TInt)
   175  */
   175  */
   176 TTsModelItemKey CTsStorage::KeyL( TInt aoffset ) const 
   176 TTsEntryKey CTsStorage::Key( TInt aoffset ) const 
   177     {
   177     {
   178     return iData[aoffset].KeyL();
   178     return iData[aoffset].Key();
   179     }
   179     }
   180 
   180 
   181 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   182 /**
   182 /**
   183  * Interface implementation
   183  * Interface implementation
   184  * @see MTsModel::IsActiveL(TInt)
   184  * @see MTsModel::IsActive(TInt)
   185  */
   185  */
   186 TBool CTsStorage::IsActiveL( TInt aOffset ) const 
   186 TBool CTsStorage::IsActive( TInt aOffset ) const 
   187     {
   187     {
   188     return iData[aOffset].IsActiveL();
   188     return iData[aOffset].IsActive();
   189     }
   189     }
   190 
   190 
   191 // -----------------------------------------------------------------------------
   191 // -----------------------------------------------------------------------------
   192 /**
   192 /**
   193  * Interface implementation
   193  * Interface implementation
   194  * @see MTsModel::IsClosableL(TInt)
   194  * @see MTsModel::IsClosableL(TInt)
   195  */
   195  */
   196 TBool CTsStorage::IsClosableL( TInt aOffset ) const 
   196 TBool CTsStorage::IsClosable( TInt aOffset ) const 
   197     {
   197     {
   198     return iData[aOffset].IsClosableL();
   198     return iData[aOffset].IsClosable();
   199     }
   199     }
   200 
   200 
   201 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   202 /**
   202 /**
   203  * Interface implementation
   203  * Interface implementation
   204  * @see MTsModel::IsMandatoryL(TInt) const
   204  * @see MTsModel::IsMandatoryL(TInt) const
   205  */
   205  */
   206 TBool CTsStorage::IsMandatoryL( TInt aOffset ) const
   206 TBool CTsStorage::IsMandatory( TInt aOffset ) const
   207     {
   207     {
   208     return iData[aOffset].IsMandatoryL();
   208     return iData[aOffset].IsMandatory();
   209     }
   209     }
   210 
   210 
   211 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   212 /**
   212 /**
   213  * Interface implementation
   213  * Interface implementation
   214  * @see MTsModel::CloseL(TTsModelItemKey)
   214  * @see MTsModel::Close(TTsModelItemKey)
   215  */
   215  */
   216 TBool CTsStorage::CloseL( TTsModelItemKey aKey ) const 
   216 TBool CTsStorage::Close( TTsEntryKey aKey ) const 
   217     {
   217     {
   218     return FindL(aKey).CloseL();
   218     TBool retVal(EFalse);
   219     }
   219     TRAP_IGNORE(retVal = FindL(aKey).Close())
   220 
   220     return retVal;
   221 // -----------------------------------------------------------------------------
   221     }
   222 /**
   222 
   223  * Interface implementation
   223 // -----------------------------------------------------------------------------
   224  * @see MTsModel::launchL(TTsModelItemKey)
   224 /**
   225  */
   225  * Interface implementation
   226 TBool CTsStorage::LaunchL(TTsModelItemKey aKey) const 
   226  * @see MTsModel::Launch(TTsModelItemKey)
   227     {
   227  */
   228     return FindL(aKey).LaunchL(); 
   228 TBool CTsStorage::Launch(TTsEntryKey aKey) const 
   229     }
   229     {
   230 
   230     TBool retVal(EFalse);
   231 // -----------------------------------------------------------------------------
   231     TRAP_IGNORE(retVal = FindL(aKey).Launch())
   232 TTsModelItem CTsStorage::FindL( TTsModelItemKey aKey ) const
   232     return retVal;
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 TTsModelItem CTsStorage::FindL( TTsEntryKey aKey ) const
   233     {
   237     {
   234     for( TInt offset(0); offset < iData.Count(); ++offset ) 
   238     for( TInt offset(0); offset < iData.Count(); ++offset ) 
   235         {
   239         {
   236         if( iData[offset].KeyL() == aKey )
   240         if( iData[offset].Key() == aKey )
   237             {
   241             {
   238             return iData[offset];
   242             return iData[offset];
   239             }
   243             }
   240         }
   244         }
   241     User::Leave(KErrNotFound);
   245     User::Leave(KErrNotFound);
   292     for( TInt prev(0); prev < iData.Count(); ++prev ) 
   296     for( TInt prev(0); prev < iData.Count(); ++prev ) 
   293         {
   297         {
   294         for( TInt next(prev + 1); next < iData.Count(); ++next )
   298         for( TInt next(prev + 1); next < iData.Count(); ++next )
   295             {
   299             {
   296             const TTsModelItem prevItem(iData[prev]), nextItem(iData[next]);
   300             const TTsModelItem prevItem(iData[prev]), nextItem(iData[next]);
   297             if( ( !prevItem.IsMandatoryL() && nextItem.IsMandatoryL() ) ||
   301             if( ( !prevItem.IsMandatory() && nextItem.IsMandatory() ) ||
   298                 ( prevItem.TimestampL() < nextItem.TimestampL() && prevItem.IsMandatoryL() == nextItem.IsMandatoryL() ) )
   302                 ( prevItem.Timestamp() < nextItem.Timestamp() && prevItem.IsMandatory() == nextItem.IsMandatory() ) )
   299                 {
   303                 {
   300                 iData.Remove(prev);
   304                 iData.Remove(prev);
   301                 iData.InsertL(nextItem, prev);
   305                 iData.InsertL(nextItem, prev);
   302                 
   306                 
   303                 iData.Remove(next);
   307                 iData.Remove(next);
   310 
   314 
   311 // -----------------------------------------------------------------------------
   315 // -----------------------------------------------------------------------------
   312 void CTsStorage::TrimDataL()
   316 void CTsStorage::TrimDataL()
   313     {
   317     {
   314     const TInt lastItemOffset(iData.Count() -1);
   318     const TInt lastItemOffset(iData.Count() -1);
   315     if(KTsDataLimit <= lastItemOffset && !iData[lastItemOffset].IsMandatoryL())
   319     if(KTsDataLimit <= lastItemOffset && !iData[lastItemOffset].IsMandatory())
   316         {
   320         {
   317         iData.Remove(lastItemOffset);
   321         iData.Remove(lastItemOffset);
   318         TrimDataL();
   322         TrimDataL();
   319         }
   323         }
   320     }
   324     }