IMPSengine/datautils/src/impsfields.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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 "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: 
       
    15 * imps fields class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <s32strm.h>     // streams 
       
    22 #include    <e32def.h>
       
    23 #include    "impsconst.h"
       
    24 #include    "impsfields.h"
       
    25 #include    "impsdatautils.h"
       
    26 #include    "impsvariant.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 //
       
    32 CImpsFields::CImpsFields()
       
    33     {
       
    34     }
       
    35 
       
    36 // Symbian OS default constructor can leave.
       
    37 void CImpsFields::ConstructL()
       
    38     {
       
    39     iData = CImpsData::NewL( );
       
    40     Reset( );
       
    41     }
       
    42 
       
    43 // Two-phased constructor.
       
    44 EXPORT_C CImpsFields* CImpsFields::NewL()
       
    45     {
       
    46     CImpsFields* self = new ( ELeave ) CImpsFields;
       
    47     
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop();
       
    51 
       
    52     return self;
       
    53     }
       
    54 
       
    55     
       
    56 // Destructor
       
    57 EXPORT_C CImpsFields::~CImpsFields()
       
    58     {
       
    59     // notice: Do remember to update this list when you change the type of members!
       
    60     Reset();
       
    61     delete iData;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CImpsFields::SetSessionIdL
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 EXPORT_C void CImpsFields::SetSessionIdL( 
       
    69     const TDesC& aId )
       
    70     {
       
    71     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
    72 
       
    73     TImpsDataUtils::SetSessionIDL( myAc, aId );
       
    74     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // CImpsFields::SessionIdL
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 EXPORT_C TPtrC CImpsFields::SessionIdL()
       
    82     {
       
    83     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
    84 
       
    85     TPtrC id;
       
    86     TImpsDataUtils::GetSessionIDL( myAc, id );
       
    87     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
    88     return id;
       
    89     }
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CImpsFields::SetSessionTypeL
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 EXPORT_C void CImpsFields::SetSessionTypeL( TImpsSessionType aType )
       
    97     {
       
    98     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
    99 
       
   100     TImpsDataUtils::SetSessionTypeL( myAc, aType );
       
   101     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CImpsFields::SessionTypeL
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 EXPORT_C TImpsSessionType CImpsFields::SessionTypeL()
       
   109     {
       
   110     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
   111 
       
   112     TImpsSessionType id;
       
   113     TImpsDataUtils::GetSessionTypeL( myAc, id );
       
   114     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
   115     return id;
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CImpsFields::SetTidL
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void CImpsFields::SetTidL( 
       
   123     const TDesC& aId )
       
   124     {
       
   125     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
   126 
       
   127     TImpsDataUtils::SetTransactionIDL( myAc, aId );
       
   128     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // CImpsFields::TidL
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 EXPORT_C TPtrC CImpsFields::TidL()
       
   136     {
       
   137     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
   138 
       
   139     TPtrC id;
       
   140     TImpsDataUtils::GetTransactionIDL( myAc, id );
       
   141     CleanupStack::PopAndDestroy(1);     // >>> myAc
       
   142     return id;
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------
       
   146 // CImpsFields::Reset
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 EXPORT_C void CImpsFields::Reset( )
       
   150     {
       
   151     iMsgType = 0;
       
   152     
       
   153     iStatus = 0;
       
   154 
       
   155     if ( iData )
       
   156         {
       
   157         iData->Reset( );
       
   158         }
       
   159         
       
   160     iCspVersion = EImpsCspVersion11;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CImpsFields::Size
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 EXPORT_C TInt CImpsFields::Size() const
       
   168     {
       
   169 
       
   170     TInt sizeEntry = Align4( KImpsPackedCopyData );
       
   171 
       
   172     // notice: update this always when class defrinition changes
       
   173     TInt sizeStrings = 0;
       
   174     TInt size =  sizeEntry + sizeStrings + ( KImpsPackedFieldsNbr * sizeof(TInt32) );
       
   175 
       
   176     size += iData->Size( ) + (2 * sizeof (TInt) );   //size,count
       
   177     return size;
       
   178     }
       
   179 
       
   180 #ifdef _DEBUG
       
   181 
       
   182 // ---------------------------------------------------------
       
   183 // CImpsFields::SetDataL
       
   184 // ---------------------------------------------------------
       
   185 //
       
   186 void CImpsFields::SetDataL( CImpsData& aData)
       
   187     {
       
   188     delete iData;
       
   189     iData = NULL;
       
   190     iData = &aData;
       
   191     }
       
   192 #endif
       
   193 
       
   194 // ---------------------------------------------------------
       
   195 // CImpsFields::ResponseStatusL
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 EXPORT_C TInt32 CImpsFields::ResponseStatusL()
       
   199     {
       
   200     TInt code(0);
       
   201     CImpsKey* myKey = CImpsKey::NewLC();    // <<< myKey
       
   202     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
   203 
       
   204     TBool ret = TImpsDataUtils::GetResultStatusL( myKey, myAc, code );
       
   205     CleanupStack::PopAndDestroy(2);     // >>> myKey, myAc
       
   206 
       
   207 #ifdef _FAKE_RESPONSE
       
   208     if( !ret )
       
   209         return KImpsStatusOk;
       
   210     else 
       
   211         return code;
       
   212 #endif
       
   213     if( ret )
       
   214         return code;
       
   215     return 0;
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // CImpsFields::PollL
       
   220 // ---------------------------------------------------------
       
   221 //
       
   222 EXPORT_C TBool CImpsFields::PollL()
       
   223     {
       
   224     CImpsKey* myKey = CImpsKey::NewLC();    // <<< myKey
       
   225     CImpsDataAccessor* myAc = CImpsDataAccessor::NewLC( this );
       
   226 
       
   227     TBool polling(EFalse);
       
   228     TBool ret = TImpsDataUtils::GetPollL( myKey, myAc, polling );
       
   229     CleanupStack::PopAndDestroy(2);     // >>> myKey, myAc
       
   230     if( ret )
       
   231         return polling;
       
   232     return ret;
       
   233     }
       
   234 
       
   235 
       
   236 #ifdef _DEBUG    
       
   237 // ---------------------------------------------------------
       
   238 // CImpsFields::DumpToFile
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 
       
   242 void CImpsFields::DumpToFileL(RFs& aFs, const TDesC& aFilename)
       
   243     {
       
   244     iData->DumpToFileL(aFs, aFilename);
       
   245     }
       
   246 #endif    
       
   247 
       
   248 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   249 
       
   250 //  End of File  
       
   251 
       
   252