sapi_sysinfo/src/sysinfolists.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:  List implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include"sysinfolists.h"
       
    20 #include"sysinfointerface.h"
       
    21 #include"sysinfo.h"
       
    22 
       
    23 using namespace LIW ;
       
    24 const TInt KStartItemIndex = -1;
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CSysInfoAccList::CSysInfoAccList
       
    28 // Parameterised constructor
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 
       
    32 CSysInfoAccList::CSysInfoAccList(const CAccList* aAccList )
       
    33                                 :iAccList(aAccList),
       
    34                                 iCount(iAccList->Count()),
       
    35                                 iCurrent(KStartItemIndex)
       
    36     {
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CSysInfoAccList::NewL
       
    41 // Two-phased constructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CSysInfoAccList* CSysInfoAccList::NewL(const CAccList* aAccList )
       
    45     {
       
    46     return new( ELeave ) CSysInfoAccList(aAccList);
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CSysInfoAccList::~CSysInfoAccList
       
    51 // Class destructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CSysInfoAccList::~CSysInfoAccList()
       
    55     {
       
    56     delete iAccList;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CSysInfoAccList::Reset
       
    61 // Resets the iterator to point to the beginning of list
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 
       
    65 void CSysInfoAccList::Reset()
       
    66     {
       
    67     iCurrent = KStartItemIndex;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CSysInfoAccList::NextL
       
    72 // Constructs the next media item in the form of a map
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 TBool CSysInfoAccList::NextL(TLiwVariant& aItem)
       
    76     {
       
    77     iCurrent++;
       
    78     if( iCurrent<iCount )
       
    79         {
       
    80         const CAccessoryInfo* temp;
       
    81         iAccList->AtL( iCurrent,temp );
       
    82 
       
    83         CAccessoryInfo* accItem = (CAccessoryInfo*) temp;
       
    84         CleanupStack::PushL( accItem );
       
    85         CLiwDefaultMap *outputMap = NULL;
       
    86         CSysInfoInterface::ConvertSysData2AiwParamL(accItem,(CLiwMap*&)outputMap);
       
    87         CleanupStack::PopAndDestroy(accItem);
       
    88 
       
    89         //Place output map on cleanup stack.
       
    90         CleanupClosePushL(*outputMap);
       
    91         aItem.SetL( TLiwVariant( outputMap ) );
       
    92         CleanupStack::PopAndDestroy(outputMap);
       
    93         return ETrue;
       
    94         }
       
    95     else
       
    96         {
       
    97         return EFalse;
       
    98         }
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CSysInfoConnList::CSysInfoConnList
       
   103 // Parameterised constructor
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 CSysInfoConnList::CSysInfoConnList(const CConnectionList* aConnList )
       
   107                                             :iConnList(aConnList),
       
   108                                             iCount(iConnList->Count()),
       
   109                                             iCurrent(KStartItemIndex)
       
   110     {
       
   111     }
       
   112 // ---------------------------------------------------------------------------
       
   113 // CSysInfoAccList::NewL
       
   114 // Two-phased constructor
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 CSysInfoConnList* CSysInfoConnList::NewL(const CConnectionList* aConnList )
       
   118     {
       
   119     return new( ELeave ) CSysInfoConnList(aConnList);
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CSysInfoAccList::~CSysInfoAccList
       
   124 // Class destructor
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CSysInfoConnList::~CSysInfoConnList()
       
   128     {
       
   129     delete iConnList;
       
   130     iConnList = NULL ;
       
   131     }
       
   132     
       
   133 // ---------------------------------------------------------------------------
       
   134 // CSysInfoAccList::Reset
       
   135 // Resets the iterator to point to the beginning of list
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CSysInfoConnList::Reset()
       
   139     {
       
   140     iCurrent = KStartItemIndex;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CSysInfoAccList::NextL
       
   145 // Constructs the next media item in the form of a map
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 TBool CSysInfoConnList::NextL( TLiwVariant& aItem )
       
   149     {
       
   150     iCurrent++;
       
   151 
       
   152     if( iCurrent<iCount )
       
   153         {
       
   154         const CConnectionInfo* temp;
       
   155         iConnList->At( iCurrent,temp );
       
   156 
       
   157         CConnectionInfo* connItem = (CConnectionInfo*) temp;
       
   158         CLiwDefaultMap *outputMap = NULL;
       
   159 
       
   160         CSysInfoInterface::CSysInfoInterface::ConvertSysData2AiwParamL(
       
   161                                             connItem,(CLiwMap*&)outputMap );
       
   162         CleanupClosePushL(*outputMap);
       
   163         aItem.SetL(TLiwVariant(outputMap));
       
   164         CleanupStack::PopAndDestroy(outputMap);
       
   165         return ETrue;
       
   166         }
       
   167     else
       
   168         {
       
   169         return EFalse;
       
   170         }
       
   171     }
       
   172 //End of file