phoneclientserver/aiwdialdata/src/aiwinternaldialdata.cpp
changeset 0 ff3b6d0fd310
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Methods for CAiwInternalDialData class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "aiwinternaldialdata.h"
       
    20 #include "aiwdialdataext.h"
       
    21 
       
    22 // CONSTANTS    
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // 
       
    28 // First phase constructor
       
    29 // 
       
    30 // --------------------------------------------------------------------------- 
       
    31 //
       
    32 EXPORT_C CAiwInternalDialData* CAiwInternalDialData::NewL()
       
    33     {
       
    34     CAiwInternalDialData* self = CAiwInternalDialData::NewLC();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // 
       
    41 // First phase constructor
       
    42 // 
       
    43 // --------------------------------------------------------------------------- 
       
    44 //
       
    45 EXPORT_C CAiwInternalDialData* CAiwInternalDialData::NewLC()
       
    46     {
       
    47     CAiwInternalDialData* self = new( ELeave ) CAiwInternalDialData;
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // 
       
    55 // First phase constructor
       
    56 // Initialises the member data from package.
       
    57 // 
       
    58 // --------------------------------------------------------------------------- 
       
    59 //    
       
    60 EXPORT_C CAiwInternalDialData* CAiwInternalDialData::NewL( 
       
    61     const TDesC8& aPackage )
       
    62     {
       
    63     CAiwInternalDialData* self = CAiwInternalDialData::NewLC( aPackage );
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67     
       
    68 // ---------------------------------------------------------------------------
       
    69 // 
       
    70 // First phase constructor
       
    71 // Initialises the member data from package.
       
    72 // 
       
    73 // --------------------------------------------------------------------------- 
       
    74 //
       
    75 EXPORT_C CAiwInternalDialData* CAiwInternalDialData::NewLC(
       
    76     const TDesC8& aPackage )
       
    77     {
       
    78     CAiwInternalDialData* self = new( ELeave ) CAiwInternalDialData;
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL( aPackage );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // 
       
    86 // Destructor.
       
    87 // 
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CAiwInternalDialData::~CAiwInternalDialData()
       
    91     {
       
    92     delete iPhoneNumber;
       
    93     iPhoneNumber = NULL;
       
    94     delete iName;
       
    95     iName = NULL;
       
    96     delete iContactLink;
       
    97     iContactLink = NULL;
       
    98     delete iSubAddress;
       
    99     iSubAddress = NULL;
       
   100     delete iBearer;
       
   101     iBearer = NULL;
       
   102     delete iUUI;
       
   103     iUUI = NULL;
       
   104     }
       
   105     
       
   106 // ---------------------------------------------------------------------------
       
   107 // Fills the parameter list.
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C void CAiwInternalDialData::FillInParamListL( 
       
   111     CAiwGenericParamList& aInParamList )
       
   112     {
       
   113     HBufC8* package = PackLC();
       
   114     TAiwVariant variant( *package );
       
   115     TAiwGenericParam param( EGenericParamCallDialData, variant );
       
   116     aInParamList.AppendL( param );
       
   117     CleanupStack::PopAndDestroy( package );
       
   118     }
       
   119     
       
   120 // ---------------------------------------------------------------------------
       
   121 // Sets SAT call.
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 EXPORT_C void CAiwInternalDialData::SetSATCall( TBool aIsSATCall ) 
       
   125     {
       
   126     iSATCall = aIsSATCall;
       
   127     }
       
   128    
       
   129 // ---------------------------------------------------------------------------
       
   130 // Sets SubAddress for SAT call.
       
   131 // ---------------------------------------------------------------------------
       
   132 EXPORT_C void CAiwInternalDialData::SetSubAddressL( 
       
   133     const TDesC& aSubAddress )
       
   134     {
       
   135     CheckDescriptorMaxLengthL( aSubAddress.Length(), 
       
   136                                AIWInternalDialData::KAiwSubAddressLength );
       
   137     CopyDescriptorToMemberDescriptorL( aSubAddress, iSubAddress );
       
   138     }
       
   139     
       
   140 // ---------------------------------------------------------------------------
       
   141 // Sets bearer.
       
   142 // ---------------------------------------------------------------------------
       
   143 EXPORT_C void CAiwInternalDialData::SetBearerL(
       
   144     const TDesC8& aBearer )
       
   145     {
       
   146     CheckDescriptorMaxLengthL( aBearer.Length(), 
       
   147                                AIWInternalDialData::KAiwBearerLength );
       
   148     CopyDescriptorToMemberDescriptorL( aBearer, iBearer );
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // Sets end other calls.
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C void CAiwInternalDialData::SetEndOtherCalls( 
       
   156     TBool aEndOtherCalls ) 
       
   157     {
       
   158     iEndOtherCalls = aEndOtherCalls;
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // Sets redial max duation time.
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 EXPORT_C void CAiwInternalDialData::SetRedialMaximumDuration( 
       
   166     const TTimeIntervalSeconds aMaximumRedialDuration ) 
       
   167     {
       
   168     iRedialMaximumDuration = aMaximumRedialDuration;
       
   169     }
       
   170     
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // Sets used service id.
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 EXPORT_C void CAiwInternalDialData::SetServiceId( TUint32 aServiceId )
       
   177     {
       
   178     iServiceId = aServiceId;
       
   179     }
       
   180 
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // Sets user to user information.
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 EXPORT_C void CAiwInternalDialData::SetUUIL( const TDesC& aUUI )
       
   187     {
       
   188     CheckDescriptorMaxLengthL( aUUI.Length(), 
       
   189         AIWInternalDialData::KAiwUUILength );
       
   190     CopyDescriptorToMemberDescriptorL( aUUI, iUUI );
       
   191     }
       
   192     
       
   193 // ---------------------------------------------------------------------------
       
   194 // Sets phone number.
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 EXPORT_C void CAiwInternalDialData::SetPhoneNumberL(
       
   198     const TDesC& aPhoneNumber )
       
   199     {
       
   200     CheckDescriptorMaxLengthL( aPhoneNumber.Length(), 
       
   201                             AIWInternalDialData::KMaximumPhoneNumberLength );
       
   202     CopyDescriptorToMemberDescriptorL( aPhoneNumber, iPhoneNumber );
       
   203     }
       
   204         
       
   205 // ---------------------------------------------------------------------------
       
   206 // Sets call type.
       
   207 // ---------------------------------------------------------------------------
       
   208 //   
       
   209 EXPORT_C void CAiwInternalDialData::SetCallType( 
       
   210     CAiwDialData::TCallType aCallType ) 
       
   211     {
       
   212     iCallType = aCallType;
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // Set initiate call.
       
   217 // ---------------------------------------------------------------------------
       
   218 //    
       
   219 EXPORT_C void CAiwInternalDialData::SetInitiateCall( TBool aInitCall )
       
   220     {
       
   221     iInitCall = aInitCall;
       
   222     }
       
   223    
       
   224 // ---------------------------------------------------------------------------
       
   225 // Set name.
       
   226 // ---------------------------------------------------------------------------
       
   227 //    
       
   228 EXPORT_C void CAiwInternalDialData::SetNameL( const TDesC& aName ) 
       
   229     {
       
   230     CheckDescriptorMaxLengthL( aName.Length(), 
       
   231                                AIWInternalDialData::KMaximumNameLength );
       
   232     CopyDescriptorToMemberDescriptorL( aName, iName );
       
   233     }
       
   234     
       
   235 // ---------------------------------------------------------------------------
       
   236 // Sets window group.
       
   237 // ---------------------------------------------------------------------------
       
   238 //    
       
   239 EXPORT_C void CAiwInternalDialData::SetWindowGroup( TInt aWindowGroup ) 
       
   240     {
       
   241     iWindowGroup = aWindowGroup;
       
   242     }
       
   243    
       
   244 // ---------------------------------------------------------------------------
       
   245 // Sets redial value.
       
   246 // ---------------------------------------------------------------------------
       
   247 //    
       
   248 EXPORT_C void CAiwInternalDialData::SetRedial( TInt aRedial ) 
       
   249     {
       
   250     iRedial = aRedial;
       
   251     }
       
   252     
       
   253 // ---------------------------------------------------------------------------
       
   254 // Set show number.
       
   255 // ---------------------------------------------------------------------------
       
   256 //    
       
   257 EXPORT_C void CAiwInternalDialData::SetShowNumber( TBool aShowNumber ) 
       
   258     {
       
   259     iShowNumber = aShowNumber;
       
   260     }
       
   261     
       
   262 // ---------------------------------------------------------------------------
       
   263 // Sets allow match.
       
   264 // ---------------------------------------------------------------------------
       
   265 //   
       
   266 EXPORT_C void CAiwInternalDialData::SetAllowMatch( TBool aAllowMatch ) 
       
   267     {
       
   268     iAllowMatch = aAllowMatch;
       
   269     }
       
   270     
       
   271 // ---------------------------------------------------------------------------
       
   272 // Sets used contact link.
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C void CAiwInternalDialData::SetContactLinkL( 
       
   276     const TDesC8& aContactLink ) 
       
   277     {
       
   278     CopyDescriptorToMemberDescriptorL( aContactLink, iContactLink );
       
   279     }
       
   280     
       
   281 // ---------------------------------------------------------------------------
       
   282 // Returns SAT call value.
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 EXPORT_C TBool CAiwInternalDialData::SATCall() const
       
   286     {
       
   287     return iSATCall;    
       
   288     }
       
   289 
       
   290 // ---------------------------------------------------------------------------
       
   291 // Returns subaddress.
       
   292 // ---------------------------------------------------------------------------
       
   293 //   
       
   294 EXPORT_C const TDesC& CAiwInternalDialData::SubAddress() const
       
   295     {
       
   296     return *iSubAddress;
       
   297     }
       
   298     
       
   299 // ---------------------------------------------------------------------------
       
   300 // Returns end other calls value.
       
   301 // ---------------------------------------------------------------------------
       
   302 //
       
   303 EXPORT_C TBool CAiwInternalDialData::EndOtherCalls() const
       
   304     {
       
   305     return iEndOtherCalls;
       
   306     }
       
   307     
       
   308 // ---------------------------------------------------------------------------
       
   309 // Returns bearer.
       
   310 // ---------------------------------------------------------------------------
       
   311 //
       
   312 EXPORT_C const TDesC8& CAiwInternalDialData::Bearer() const
       
   313     {
       
   314     return *iBearer;
       
   315     }
       
   316 
       
   317 // ---------------------------------------------------------------------------
       
   318 // Returns redial max duration.
       
   319 // ---------------------------------------------------------------------------
       
   320 //
       
   321 EXPORT_C const TTimeIntervalSeconds 
       
   322     CAiwInternalDialData::RedialMaximumDuration() const
       
   323     {
       
   324     return iRedialMaximumDuration;
       
   325     }
       
   326     
       
   327 
       
   328 // -----------------------------------------------------------------------------
       
   329 // Returns used service id.
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 EXPORT_C TUint32 CAiwInternalDialData::ServiceId() const
       
   333     {
       
   334     return iServiceId;
       
   335     }
       
   336 
       
   337     
       
   338 // ---------------------------------------------------------------------------
       
   339 // Returns name.
       
   340 // ---------------------------------------------------------------------------
       
   341 //
       
   342 EXPORT_C const TDesC& CAiwInternalDialData::Name() const 
       
   343     {
       
   344     return *iName;
       
   345     }      
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // Returns initiate call.
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 EXPORT_C TBool CAiwInternalDialData::InitiateCall() const 
       
   352     {
       
   353     return iInitCall;
       
   354     } 
       
   355         
       
   356 // ---------------------------------------------------------------------------
       
   357 // Returns phone number.
       
   358 // ---------------------------------------------------------------------------
       
   359 //    
       
   360 EXPORT_C const TDesC& CAiwInternalDialData::PhoneNumber() const 
       
   361     {
       
   362     return *iPhoneNumber;    
       
   363     }
       
   364     
       
   365 // ---------------------------------------------------------------------------
       
   366 // Returns call type.
       
   367 // ---------------------------------------------------------------------------
       
   368 //    
       
   369 EXPORT_C CAiwDialData::TCallType CAiwInternalDialData::CallType() const 
       
   370     {
       
   371     return iCallType;
       
   372     }
       
   373         
       
   374 // ---------------------------------------------------------------------------
       
   375 // Return window group.
       
   376 // ---------------------------------------------------------------------------
       
   377 //    
       
   378 EXPORT_C TInt CAiwInternalDialData::WindowGroup() const
       
   379     {
       
   380     return iWindowGroup;
       
   381     }
       
   382 // ---------------------------------------------------------------------------
       
   383 // Return redial value.
       
   384 // ---------------------------------------------------------------------------
       
   385 //    
       
   386 EXPORT_C TInt CAiwInternalDialData::Redial() const 
       
   387     {
       
   388     return iRedial;
       
   389     }
       
   390 // ---------------------------------------------------------------------------
       
   391 // Returns show number.
       
   392 // ---------------------------------------------------------------------------
       
   393 //   
       
   394 EXPORT_C TBool CAiwInternalDialData::ShowNumber() const 
       
   395     {
       
   396     return iShowNumber;
       
   397     }
       
   398     
       
   399 // ---------------------------------------------------------------------------
       
   400 // Return allow match.
       
   401 // ---------------------------------------------------------------------------
       
   402 //   
       
   403 EXPORT_C TBool CAiwInternalDialData::AllowMatch() const 
       
   404     {
       
   405     return iAllowMatch;
       
   406     }
       
   407     
       
   408 // ---------------------------------------------------------------------------
       
   409 // Return contact link.
       
   410 // ---------------------------------------------------------------------------
       
   411 //    
       
   412 EXPORT_C const TDesC8& CAiwInternalDialData::ContactLink() const 
       
   413     {
       
   414     return *iContactLink;
       
   415     }  
       
   416     
       
   417 // ---------------------------------------------------------------------------
       
   418 // Return user to user information
       
   419 // ---------------------------------------------------------------------------
       
   420 //   
       
   421 EXPORT_C const TDesC& CAiwInternalDialData::UUI() const
       
   422     {
       
   423     return *iUUI;
       
   424     }
       
   425     
       
   426 // ---------------------------------------------------------------------------
       
   427 // 
       
   428 // C++ constructor
       
   429 // 
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 CAiwInternalDialData::CAiwInternalDialData() :
       
   433     iShowNumber( ETrue ),
       
   434     iAllowMatch( ETrue ),
       
   435     iServiceId( 0 )
       
   436     {
       
   437     }
       
   438 
       
   439 // ---------------------------------------------------------------------------
       
   440 // 
       
   441 // Symbian OS constructor
       
   442 // 
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 void CAiwInternalDialData::ConstructL()
       
   446     {
       
   447     iPhoneNumber = KNullDesC().AllocL();
       
   448     iName = KNullDesC().AllocL();
       
   449     iContactLink = KNullDesC8().AllocL();
       
   450     iSubAddress = KNullDesC().AllocL();
       
   451     iBearer = KNullDesC8().AllocL();
       
   452     iUUI = KNullDesC().AllocL();
       
   453     iCallType = CAiwDialData::EAIWVoice;
       
   454     iWindowGroup = AIWDialData::KAiwGoToIdle;
       
   455     iInitCall = EFalse;
       
   456     iRedial = AIWDialDataExt::KAIWRedialDefault;
       
   457     iShowNumber = ETrue;
       
   458     iAllowMatch = ETrue;
       
   459     iRedialMaximumDuration = NULL;
       
   460     iSATCall = EFalse;
       
   461     iEndOtherCalls = EFalse;
       
   462     }
       
   463 
       
   464 // ---------------------------------------------------------------------------
       
   465 // 
       
   466 // Symbian OS constructor  
       
   467 // Initialises the member data from package.
       
   468 //
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CAiwInternalDialData::ConstructL(
       
   472     const TDesC8& aPackage ) 
       
   473     {
       
   474     RDesReadStream stream( aPackage );
       
   475     CleanupClosePushL( stream );
       
   476     
       
   477     ReadDescriptorFromStreamL( stream, iPhoneNumber );
       
   478     iCallType = static_cast<CAiwDialData::TCallType>( stream.ReadUint32L() );
       
   479     ReadDescriptorFromStreamL( stream, iName );
       
   480     iWindowGroup = stream.ReadInt32L();
       
   481     iRedial = stream.ReadInt32L();
       
   482     iShowNumber = stream.ReadInt32L();
       
   483     iAllowMatch = stream.ReadInt32L();
       
   484     ReadDescriptorFromStreamL( stream, iContactLink );
       
   485     iSATCall = stream.ReadInt32L();
       
   486     ReadDescriptorFromStreamL( stream, iSubAddress );
       
   487     iEndOtherCalls = stream.ReadInt32L();
       
   488     ReadDescriptorFromStreamL( stream, iBearer );
       
   489     iRedialMaximumDuration = stream.ReadInt32L();
       
   490     iInitCall = stream.ReadInt32L();
       
   491     iServiceId = stream.ReadInt32L();    
       
   492     ReadDescriptorFromStreamL( stream, iUUI );
       
   493     
       
   494     CleanupStack::PopAndDestroy( 1 ); // stream;
       
   495     }
       
   496 
       
   497 // ---------------------------------------------------------------------------
       
   498 // Calculates the size of all member data.
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 TInt CAiwInternalDialData::CalculatePackageSize() const
       
   502     {
       
   503     TInt packageSize = 0;
       
   504     packageSize += CalculateDescriptorSize( *iPhoneNumber );
       
   505     packageSize += sizeof( iCallType );
       
   506     packageSize += CalculateDescriptorSize( *iName );
       
   507     packageSize += sizeof( iWindowGroup );
       
   508     packageSize += sizeof( iRedial );
       
   509     packageSize += sizeof( iShowNumber );
       
   510     packageSize += sizeof( iAllowMatch );
       
   511     packageSize += CalculateDescriptorSize( *iContactLink );
       
   512     packageSize += sizeof( iSATCall );
       
   513     packageSize += CalculateDescriptorSize( *iSubAddress );
       
   514     packageSize += sizeof( iEndOtherCalls );
       
   515     packageSize += CalculateDescriptorSize( *iBearer );
       
   516     packageSize += sizeof( iRedialMaximumDuration );
       
   517     packageSize += sizeof( iInitCall );
       
   518     packageSize += sizeof( iServiceId );
       
   519     packageSize += CalculateDescriptorSize( *iUUI );
       
   520     
       
   521     return packageSize;
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------------------------
       
   525 // Calculates the size of descriptor in package. Note that to retreave 
       
   526 // a descriptor from stream in ConstructL we need to know the size of a
       
   527 // descriptor in order to allocate right size descriptor. This is the reason
       
   528 // for adding sizeof( int ) to descriptor length.
       
   529 // ---------------------------------------------------------------------------
       
   530 // 
       
   531 TInt CAiwInternalDialData::CalculateDescriptorSize( 
       
   532     const TDesC& aDescriptor ) const 
       
   533     {
       
   534     // sizeof( TInt ) is for the length of a descriptor.
       
   535     return sizeof( TInt ) + aDescriptor.Length() * 2; // unicode takes 2 bytes.
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // Calculates the size of descriptor in package. Note that to retreave 
       
   540 // a descriptor from stream in ConstructL we need to know the size of a
       
   541 // descriptor in order to allocate right size descriptor. This is the reason
       
   542 // for adding sizeof( int ) to descriptor length.
       
   543 // ---------------------------------------------------------------------------
       
   544 // 
       
   545 TInt CAiwInternalDialData::CalculateDescriptorSize( 
       
   546     const TDesC8& aDescriptor ) const 
       
   547     {
       
   548     // sizeof( TInt ) is for the length of a descriptor in stream
       
   549     return sizeof( TInt ) + aDescriptor.Length();
       
   550     }    
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // Reads descriptor from stream.
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 void CAiwInternalDialData::ReadDescriptorFromStreamL( 
       
   557     RDesReadStream& aStream,
       
   558     HBufC*& aDescriptor 
       
   559     )
       
   560     {
       
   561     const TInt descLength( aStream.ReadInt32L() );
       
   562     
       
   563     // Not to cleanupstack, aDescriptor will be member variable
       
   564     aDescriptor = HBufC::NewL( descLength ); 
       
   565     TPtr16 ptr = aDescriptor->Des();
       
   566     aStream.ReadL( ptr, descLength );
       
   567     }
       
   568   
       
   569 // ---------------------------------------------------------------------------
       
   570 // Reads descriptor from stream.
       
   571 // ---------------------------------------------------------------------------
       
   572 //  
       
   573 void CAiwInternalDialData::ReadDescriptorFromStreamL( 
       
   574     RDesReadStream& aStream,
       
   575     HBufC8*& aDescriptor 
       
   576     )
       
   577     {
       
   578     const TInt descLength( aStream.ReadInt32L() );
       
   579     
       
   580     // Not to cleanupstack, aDescriptor is member variable
       
   581     aDescriptor = HBufC8::NewL( descLength ); 
       
   582     TPtr8 ptr = aDescriptor->Des();
       
   583     aStream.ReadL( ptr, descLength );
       
   584     }    
       
   585    
       
   586 // ---------------------------------------------------------------------------
       
   587 // Writes descriptor to stream.
       
   588 // ---------------------------------------------------------------------------
       
   589 //  
       
   590 void CAiwInternalDialData::WriteDescriptorToStreamL( 
       
   591     RDesWriteStream& aStream, 
       
   592     const TDesC& aDescriptor ) 
       
   593     {
       
   594     aStream.WriteInt32L( aDescriptor.Length() );
       
   595     aStream.WriteL( aDescriptor );
       
   596     }
       
   597 
       
   598 // ---------------------------------------------------------------------------
       
   599 // Writes descriptor to stream.
       
   600 // ---------------------------------------------------------------------------
       
   601 //  
       
   602 void CAiwInternalDialData::WriteDescriptorToStreamL( 
       
   603     RDesWriteStream& aStream, 
       
   604     const TDesC8& aDescriptor ) 
       
   605     {
       
   606     aStream.WriteInt32L( aDescriptor.Length() );
       
   607     aStream.WriteL( aDescriptor );
       
   608     }
       
   609    
       
   610 // ---------------------------------------------------------------------------
       
   611 // Copies aSource descriptor to aMemberDescriptor. This quarantees that member
       
   612 // descriptor will be valid even if the allocation fails.
       
   613 // ---------------------------------------------------------------------------
       
   614 //   
       
   615 void CAiwInternalDialData::CopyDescriptorToMemberDescriptorL( 
       
   616     const TDesC& aSource, 
       
   617     HBufC*& aMemberDescriptor )
       
   618     {
       
   619     HBufC* temp = aSource.AllocL();
       
   620     delete aMemberDescriptor;
       
   621     aMemberDescriptor = temp;
       
   622     }
       
   623 
       
   624 // ---------------------------------------------------------------------------
       
   625 // Copies aSource descriptor to aMemberDescriptor. This quarantees that member
       
   626 // descriptor will be valid even if the allocation fails.
       
   627 // ---------------------------------------------------------------------------
       
   628 //       
       
   629 void CAiwInternalDialData::CopyDescriptorToMemberDescriptorL( 
       
   630     const TDesC8& aSource, 
       
   631     HBufC8*& aMemberDescriptor )
       
   632     {
       
   633     HBufC8* temp = aSource.AllocL();
       
   634     delete aMemberDescriptor;
       
   635     aMemberDescriptor = temp;
       
   636     }
       
   637 
       
   638 // ---------------------------------------------------------------------------
       
   639 // Checks that descriptorLength is not longer than maximum allowed descriptor
       
   640 // length.
       
   641 // ---------------------------------------------------------------------------
       
   642 //   
       
   643 void CAiwInternalDialData::CheckDescriptorMaxLengthL( 
       
   644     TInt aDescriptorLength, TInt aMaxAllowedDescriptorLength ) const
       
   645     {
       
   646     if( aDescriptorLength > aMaxAllowedDescriptorLength )
       
   647         {
       
   648         User::Leave( KErrArgument );
       
   649         }
       
   650     }
       
   651 
       
   652 // ---------------------------------------------------------------------------
       
   653 // Packs the member data to descriptor. Ownershipd of returned descriptor
       
   654 // is given for caller.
       
   655 // ---------------------------------------------------------------------------
       
   656 //  
       
   657 HBufC8* CAiwInternalDialData::PackLC() 
       
   658     {
       
   659     HBufC8* package = HBufC8::NewLC( CalculatePackageSize() );
       
   660     
       
   661     TPtr8 des = package->Des();
       
   662     RDesWriteStream stream( des );
       
   663     CleanupClosePushL( stream );
       
   664     
       
   665     WriteDescriptorToStreamL( stream, *iPhoneNumber );
       
   666     stream.WriteInt32L( iCallType );
       
   667     WriteDescriptorToStreamL( stream, *iName );
       
   668     stream.WriteInt32L( iWindowGroup );
       
   669     stream.WriteInt32L( iRedial );
       
   670     stream.WriteInt32L( iShowNumber );
       
   671     stream.WriteInt32L( iAllowMatch );
       
   672     WriteDescriptorToStreamL( stream, *iContactLink );
       
   673     stream.WriteInt32L( iSATCall );
       
   674     WriteDescriptorToStreamL( stream, *iSubAddress );
       
   675     stream.WriteInt32L( iEndOtherCalls );
       
   676     WriteDescriptorToStreamL( stream, *iBearer );
       
   677     stream.WriteInt32L( iRedialMaximumDuration.Int() );
       
   678     stream.WriteInt32L( iInitCall );
       
   679     stream.WriteUint32L( iServiceId );
       
   680     WriteDescriptorToStreamL( stream, *iUUI );
       
   681         
       
   682     stream.CommitL();
       
   683     
       
   684     CleanupStack::PopAndDestroy( 1 ); // stream
       
   685     
       
   686     return package;
       
   687     }
       
   688 
       
   689 //  End of File