phoneengine/loghandling/src/cpelogevent.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  This module contains the implementation of CPELogEvent class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include "cpelogevent.h"
       
    21 #include "cpeloginfo.h"
       
    22 #include "cpeloghandling.h"
       
    23 #include "cpeloghandlingcommand.h"
       
    24 #include <PbkFields.hrh>
       
    25 #include <talogger.h>
       
    26 #include <logcli.h>
       
    27 #include <LogsApiConsts.h>
       
    28 
       
    29 
       
    30 // EXTERNAL DATA STRUCTURES
       
    31 //None
       
    32 
       
    33 // EXTERNAL FUNCTION PROTOTYPES  
       
    34 //None
       
    35 
       
    36 // CONSTANTS
       
    37 const TInt KPhonebookTypeIdLength = 11;
       
    38 
       
    39 // Defined in \s60\app\contacts\logsui\EngineIncLogsEngConsts.h as KLogEventALS
       
    40 const TLogFlags KPELogEventALS = 0x4;
       
    41 
       
    42 const TInt KOneChar = 1;
       
    43 
       
    44 // MACROS
       
    45 //None
       
    46 
       
    47 // LOCAL CONSTANTS AND MACROS
       
    48 //None
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51 //None
       
    52 
       
    53 // LOCAL FUNCTION PROTOTYPES
       
    54 //None
       
    55 
       
    56 // FORWARD DECLARATIONS
       
    57 //None
       
    58 
       
    59 
       
    60 // ==================== LOCAL FUNCTIONS =====================================
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CPELogEvent::NewL
       
    64 // Two-phased constructor.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CPELogEvent* CPELogEvent::NewL
       
    68         ( 
       
    69         CPELogHandling& aOwner,  // Owner of the object
       
    70         CPELogHandlingCommand& aLogHandlingCommand
       
    71         )
       
    72     {
       
    73     TEFLOGSTRING(KTAOBJECT, "LOG CPELogEvent::NewL start.");
       
    74     CPELogEvent* self = new ( ELeave ) CPELogEvent( aOwner, aLogHandlingCommand );
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop( self );
       
    78     TEFLOGSTRING(KTAOBJECT, "LOG CPELogEvent::NewL complete.");
       
    79     return self;
       
    80     }
       
    81   
       
    82 // Destructor
       
    83 /*****************************************************
       
    84 *    Series 60 Customer / LOGENG
       
    85 *    Series 60  LOGENG API
       
    86 *****************************************************/
       
    87 CPELogEvent::~CPELogEvent
       
    88         (
       
    89         // None
       
    90         )
       
    91     {
       
    92     TEFLOGSTRING( KTAOBJECT, "LOG CPELogEvent::~CPELogEvent()" );
       
    93     delete iEvent;
       
    94     delete iLogInfo;
       
    95     }
       
    96 
       
    97 
       
    98 // ================= MEMBER FUNCTIONS =======================================
       
    99 // -----------------------------------------------------------------------------
       
   100 // CPELogEvent::CPELogEvent
       
   101 // C++ default constructor can NOT contain any code, that
       
   102 // might leave.
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 CPELogEvent::CPELogEvent
       
   106         ( 
       
   107         CPELogHandling& aOwner,
       
   108         CPELogHandlingCommand& aLogHandlingCommand
       
   109         ) : iOwner( aOwner ),
       
   110             iLogHandlingCommand( aLogHandlingCommand ),
       
   111             iCompleted( EFalse ),
       
   112             iAdded( EFalse ),
       
   113             iSaveLeave( EFalse )
       
   114     {
       
   115     }
       
   116 // -----------------------------------------------------------------------------
       
   117 // CPELogEvent::ConstructL
       
   118 // Symbian 2nd phase constructor can leave.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 /*****************************************************
       
   122 *    Series 60 Customer / LOGENG
       
   123 *    Series 60  LOGENG API
       
   124 *****************************************************/
       
   125 void CPELogEvent::ConstructL
       
   126         (
       
   127         // None
       
   128         )
       
   129     {
       
   130     iEvent = CLogEvent::NewL();
       
   131     ResetEvent( );
       
   132     iLogInfo = CPELogInfo::NewL();
       
   133     }
       
   134     
       
   135 // -----------------------------------------------------------------------------
       
   136 // CPELogEvent::Save
       
   137 // Saves the event to the log.
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CPELogEvent::SaveL()
       
   141     {
       
   142     iSaveLeave = ETrue;
       
   143     // iCopleted flag must be set before the function leave as it is used 
       
   144     // in log subsytem recovery procedure in case of leave.
       
   145     if ( EPEStateIdle == iLogInfo->CallState() || iLogInfo->ForcedCompletion() )
       
   146         {
       
   147         iCompleted = ETrue;
       
   148         }
       
   149         
       
   150     if ( !iAdded )
       
   151         {
       
   152         TEFLOGSTRING2( KTAINT, "LOG CPELogEvent::SaveL() > CPELogHandlingCommand::AddEvent(), callId=%d", iLogInfo->CallId() );  
       
   153         SetPhoneNumberId();
       
   154         SetEventTypeL();
       
   155         SetLogEvent();
       
   156         SetDuration();
       
   157         SetServiceIdL();
       
   158         
       
   159         if ( &iLogInfo->ContactLink() )
       
   160             {
       
   161             SetContactLinkL();
       
   162             }
       
   163         // event under processing will always be of index 0 in the queued array
       
   164         User::LeaveIfError( iLogHandlingCommand.AddEvent( *iEvent ) );
       
   165         }
       
   166     else
       
   167         { 
       
   168         TEFLOGSTRING2( KTAINT, "LOG CPELogEvent::SaveL() > CPELogHandlingCommand::ChangeEvent(), callId=%d", iLogInfo->CallId() );            
       
   169         SetLogEvent();
       
   170         SetDuration();
       
   171         User::LeaveIfError( iLogHandlingCommand.ChangeEvent( *iEvent ) );
       
   172         }
       
   173     // indicates no leave happened in Save function
       
   174     iSaveLeave = EFalse;
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CPELogEvent::UpdateLogInfo
       
   179 // Update log database entry.
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CPELogEvent::UpdateLogInfoL
       
   183         ( 
       
   184         const CPELogInfo& aLogInfo // Call information
       
   185         ) 
       
   186     {
       
   187     // CPELogHandling generic loginfo must be replicated to this event
       
   188     iLogInfo->CopyL( aLogInfo );
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CPELogEvent::ResetLogInfo
       
   193 // Reset log info.
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 void CPELogEvent::ResetLogInfo() 
       
   197     {
       
   198     TEFLOGSTRING( KTAINT, "LOG CPELogEvent::ResetLogInfo: start" );  
       
   199     iLogInfo->Reset();
       
   200     TEFLOGSTRING( KTAINT, "LOG CPELogEvent::ResetLogInfo: complete" ); 
       
   201     }
       
   202     
       
   203 // -----------------------------------------------------------------------------
       
   204 // CPELogEvent::ResetEvent
       
   205 // Reset event on the idle state.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 /*****************************************************
       
   209 *    Series 60 Customer / LOGENG
       
   210 *    Series 60  LOGENG API
       
   211 *****************************************************/
       
   212 void CPELogEvent::ResetEvent()
       
   213     {
       
   214     iAdded = EFalse;
       
   215     iCompleted = EFalse;
       
   216     iSaveLeave = EFalse;
       
   217 
       
   218     // CLogEvent -variables
       
   219     iEvent->SetId( KLogNullId );
       
   220     iEvent->SetEventType( KNullUid );
       
   221     iEvent->SetRemoteParty( KNullDesC );
       
   222     iEvent->SetDirection( KNullDesC );
       
   223     iEvent->SetTime( Time::NullTTime() );
       
   224     iEvent->SetDurationType( KLogNullDurationType );
       
   225     iEvent->SetDuration( KLogNullDuration );
       
   226     iEvent->SetStatus( KNullDesC );
       
   227     iEvent->SetSubject( KNullDesC );
       
   228     iEvent->SetNumber( KNullDesC );
       
   229     iEvent->SetContact( KNullContactId );
       
   230     iEvent->SetLink( KLogNullLink );
       
   231     iEvent->SetDescription( KNullDesC );
       
   232     iEvent->ClearFlags( KLogFlagsMask );
       
   233     TRAPD( error, iEvent->SetDataL( KNullDesC8 ) );
       
   234     if ( error != KErrNone )
       
   235         {
       
   236         // SetDataL leave should not cause log subsystem to fail. Just log the error.
       
   237         TEFLOGSTRING2( KTAERROR, "LOG CPELogEvent::Save()>CPELogHandlingCommand::ResetEvent(), error=%d", error );  
       
   238         }
       
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CPELogEvent::CallId
       
   243 // Get call id of the event.
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 TInt CPELogEvent::CallId
       
   247         (
       
   248         // None
       
   249         )
       
   250     {
       
   251     return iLogInfo->CallId();
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CPELogEvent::IsCompleted
       
   256 // Returns flag if the entry has been completed, ie. no further updates are expected
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 TBool CPELogEvent::IsCompleted
       
   260         (
       
   261         // None
       
   262         )
       
   263     {       
       
   264     return iCompleted;
       
   265     }
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // CPELogEvent::Added
       
   269 // iAdded flag is set to ETrue
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 void CPELogEvent::SetAdded
       
   273         (
       
   274         // None
       
   275         )
       
   276     {       
       
   277     iAdded = ETrue;
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CPELogEvent::SaveLeave
       
   282 // Return value of save leave flag
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 TBool CPELogEvent::SaveLeave
       
   286         (
       
   287         // None
       
   288         )
       
   289     {       
       
   290     return iSaveLeave;
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CPELogEvent::SetPhoneNumberId
       
   295 // Set event subject.
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 /*****************************************************
       
   299 *    Series 60 Customer / LOGENG
       
   300 *    Series 60  LOGENG API
       
   301 *****************************************************/
       
   302 void CPELogEvent::SetPhoneNumberId()
       
   303     {
       
   304     TBuf<KPhonebookTypeIdLength> subject;
       
   305     subject.Zero();
       
   306 
       
   307     switch ( iLogInfo->PhoneNumberId() )
       
   308         {
       
   309         case EPEMobileNumber:
       
   310             subject.AppendNum( EPbkFieldIdPhoneNumberMobile );
       
   311             break;
       
   312         case EPETelephoneNumber:
       
   313             subject.AppendNum( EPbkFieldIdPhoneNumberGeneral );
       
   314             break;
       
   315         case EPEPager:
       
   316             subject.AppendNum( EPbkFieldIdPagerNumber );
       
   317             break;
       
   318         case EPEFaxNumber:
       
   319             subject.AppendNum( EPbkFieldIdFaxNumber );
       
   320             break; 
       
   321         case EPEAssistantNumber:
       
   322             subject.AppendNum( EPbkFieldIdAssistantNumber);
       
   323             break;
       
   324         case EPECarNumber:
       
   325             subject.AppendNum( EPbkFieldIdCarNumber);
       
   326             break;
       
   327         default:
       
   328             subject.AppendNum( EPbkFieldIdNone );
       
   329             break;
       
   330         }
       
   331 
       
   332     if ( subject.Length() > 0 )
       
   333         {
       
   334         iEvent->SetSubject( subject );
       
   335         }
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CPEGsmLogsEntry::SetEventType
       
   340 // Set event type.
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 /*****************************************************
       
   344 *    Series 60 Customer / LOGENG
       
   345 *    Series 60  LOGENG API
       
   346 *****************************************************/
       
   347 void CPELogEvent::SetEventTypeL()
       
   348     {
       
   349     switch ( iLogInfo->EventType() )
       
   350         {
       
   351         case CPELogInfo::EPEVoiceEvent:
       
   352             
       
   353             {
       
   354             iEvent->SetEventType( KLogCallEventTypeUid );
       
   355             }
       
   356             break;
       
   357         case CPELogInfo::EPEVideoCallEvent:
       
   358             {           
       
   359             iEvent->SetEventType( KLogCallEventTypeUid );
       
   360             iEvent->SetDataL( KLogsDataFldTag_VT );
       
   361             TEFLOGSTRING( KTAINT, "LOG CPELogEvent::SetEventTypeL() video" );                
       
   362             }
       
   363             break;
       
   364         case CPELogInfo::EPEEmergecyEvent:
       
   365             {           
       
   366             iEvent->SetEventType( KLogCallEventTypeUid );
       
   367             iEvent->SetDataL( KLogsDataFldTag_Emergency );
       
   368             TEFLOGSTRING( KTAINT, "LOG CPELogEvent::SetEventTypeK() Emergecy" );                
       
   369             }
       
   370             break;
       
   371         case CPELogInfo::EPEVoIPEvent:
       
   372             {
       
   373             iEvent->SetEventType( KLogCallEventTypeUid );
       
   374             iEvent->SetDataL( KLogsDataFldTag_IP );
       
   375             TEFLOGSTRING( KTAINT, "LOG CPELogEvent::SetEventTypeL() VoIP" );                
       
   376             }
       
   377             break;
       
   378         case CPELogInfo::EPEUnknownEvent:
       
   379         default:
       
   380             {
       
   381             iEvent->SetEventType( KLogCallEventTypeUid );
       
   382             }
       
   383             break;
       
   384         }
       
   385     }
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // CPELogEvent::SetLogEvent
       
   389 // Set the rest of event information.
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 /*****************************************************
       
   393 *    Series 60 Customer / LOGENG
       
   394 *    Series 60  LOGENG API
       
   395 *****************************************************/
       
   396 void CPELogEvent::SetLogEvent()
       
   397     {
       
   398     if( CCCECallParameters::ECCELineTypeAux == iLogInfo->CurrentLine() )
       
   399         {
       
   400         iEvent->SetFlags( KPELogEventALS );             
       
   401         }
       
   402     if ( RMobileCall::EMobileOriginated == iLogInfo->CallDirection() )
       
   403         {     
       
   404         if ( CCCECallParameters::ECCELineTypeAux == iLogInfo->CurrentLine() )
       
   405             {
       
   406             iEvent->SetDirection( iOwner.LogStringOutAlt( ) );
       
   407             }
       
   408         else
       
   409             {
       
   410             iEvent->SetDirection( iOwner.LogStringOut( ) );    
       
   411             }
       
   412         }
       
   413     else if ( RMobileCall::EMobileTerminated == iLogInfo->CallDirection() )
       
   414         {
       
   415         if ( iLogInfo->MissedCall() && EPEStateIdle == iLogInfo->CallState() )
       
   416             {
       
   417             iEvent->SetDirection( iOwner.LogStringMissed( ) );
       
   418             }
       
   419         else
       
   420             //Logging on states Connected and Idle
       
   421             {
       
   422             if ( CCCECallParameters::ECCELineTypeAux == iLogInfo->CurrentLine() )
       
   423                 {
       
   424                 iEvent->SetDirection( iOwner.LogStringInAlt( ) );
       
   425                 }
       
   426             else
       
   427                 {
       
   428                 iEvent->SetDirection( iOwner.LogStringIn( ) );
       
   429                 }
       
   430             }
       
   431         }
       
   432 
       
   433     SetRemoteParty( *iEvent, *iLogInfo );
       
   434     iEvent->SetStatus( iOwner.LogStringDelivery( ) );
       
   435     
       
   436     SetRemoteContact( *iEvent, *iLogInfo );
       
   437     
       
   438     if ( KNullDesC() != iLogInfo->MyAddress() )
       
   439         {
       
   440         TRAPD( error, SetDataFieldL( KLogsDataFldTag_MA, iLogInfo->MyAddress() ) );
       
   441         if ( error )
       
   442             {
       
   443             TEFLOGSTRING2( KTAERROR, 
       
   444                 "LOG CPELogEvent::SetLogEvent()>SetDataFieldL(), error=%d", 
       
   445                     error )
       
   446             }
       
   447         }
       
   448     }
       
   449 
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CPELogEvent::SetDuration
       
   453 // Set the event duration
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 /*****************************************************
       
   457 *    Series 60 Customer / LOGENG
       
   458 *    Series 60  LOGENG API
       
   459 *****************************************************/
       
   460 void CPELogEvent::SetDuration()
       
   461     {
       
   462     iEvent->SetDurationType( KLogDurationValid );
       
   463     iEvent->SetDuration( static_cast <TLogDuration> ( iLogInfo->Duration().Int() ) );
       
   464 
       
   465 #ifdef _DEBUG
       
   466     if ( EPEStateIdle == iLogInfo->CallState() )
       
   467         {
       
   468         // debug logging of the event start time.
       
   469         TBuf<KPEESDWFormattedTimeLength> formattedTime;
       
   470         formattedTime.Zero();
       
   471         TRAPD( error, iEvent->Time().FormatL( formattedTime, KPEESDWTimeFormat ) );    
       
   472         if( error == KErrNone )
       
   473             {
       
   474             TEFLOGSTRING2( KTAINT, "LOG CPELogEvent::SetDuration() Idle state > formattedTime: %S", &formattedTime );
       
   475             }
       
   476         else
       
   477             {
       
   478             TEFLOGSTRING( KTAERROR, "LOG CPELogEvent::SetDuration() Idle state > time conversion failed!");
       
   479             }        
       
   480         }
       
   481 #endif // _DEBUG
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
       
   485 // CPELogEvent::SetServiceIdL
       
   486 // Set callers service id to log event.
       
   487 // -----------------------------------------------------------------------------
       
   488 //
       
   489 void CPELogEvent::SetServiceIdL()
       
   490     {
       
   491     HBufC8* eventData = NULL; 
       
   492     if ( iEvent->Data().Length() )
       
   493         {
       
   494         // There are existing data logged.
       
   495         eventData = HBufC8::NewLC( iEvent->Data().Length() 
       
   496                    + KLogsDataFldNameDelimiter().Length() // separator
       
   497                    + KLogsDataFldTag_ServiceId().Length()
       
   498                    + KLogsDataFldValueDelimiter().Length()
       
   499                    + KTUintCharLength );    
       
   500                    
       
   501         // Copy existing data to temp buffer.
       
   502         eventData->Des().Copy( iEvent->Data() );
       
   503    
       
   504         // Append tag separator.
       
   505         eventData->Des().Append( KLogsDataFldNameDelimiter );    
       
   506         }
       
   507     else
       
   508         {
       
   509         // No existing data logged. 
       
   510         eventData = HBufC8::NewLC( 
       
   511             KLogsDataFldTag_ServiceId().Length()
       
   512             + KLogsDataFldValueDelimiter().Length()
       
   513             + KTUintCharLength ); 
       
   514         }
       
   515     
       
   516     // Append service id
       
   517     eventData->Des().Append( KLogsDataFldTag_ServiceId );
       
   518     eventData->Des().Append( KLogsDataFldValueDelimiter );
       
   519     eventData->Des().AppendNum( (TInt)iLogInfo->ServiceId() );
       
   520     
       
   521     iEvent->SetDataL( *eventData );
       
   522     TEFLOGSTRING( KTAINT, "LOG CPELogEvent::SetServiceIdL() Service id set ok" );  
       
   523     CleanupStack::PopAndDestroy( eventData );
       
   524     }
       
   525 
       
   526 // -----------------------------------------------------------------------------
       
   527 // Sets callers contact link to log event.
       
   528 // Contact link data might accidentally contain "\t"(KLogsDataFldNameDelimiter),
       
   529 // because of this, those "accidents" are stuffed with another "\t". They are
       
   530 // removed in logs handling side when data is read in.
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 void CPELogEvent::SetContactLinkL()
       
   534     {
       
   535     HBufC8* eventData = NULL;
       
   536     
       
   537     TPtrC8 pDelimiter( iLogInfo->ContactLink() );
       
   538     TInt delimiterCount = 0;
       
   539     // Check how many "delimiters" data contains so that we can
       
   540     // reserve space for data duplication
       
   541     while ( KErrNotFound != pDelimiter.Find( KLogsDataFldNameDelimiter ) )
       
   542         {
       
   543         // Skip first \t to see if there exists another one after that 
       
   544         pDelimiter.Set( pDelimiter.Mid( pDelimiter.Find( KLogsDataFldNameDelimiter ) + KOneChar ) );
       
   545         ++delimiterCount;
       
   546         }
       
   547     if ( iEvent->Data().Length() )
       
   548         {
       
   549         // There is previous data logged
       
   550         eventData = HBufC8::NewLC( 
       
   551             iEvent->Data().Length() 
       
   552             + KLogsDataFldNameDelimiter().Length() // separator
       
   553             + KLogsDataFldTag_ContactLink().Length() 
       
   554             + KLogsDataFldValueDelimiter().Length()
       
   555             + iLogInfo->ContactLink().Length() 
       
   556             + delimiterCount );
       
   557                    
       
   558         // Copy previous data to temp buffer
       
   559         eventData->Des().Copy( iEvent->Data() );
       
   560    
       
   561         // Append tag separator
       
   562         eventData->Des().Append( KLogsDataFldNameDelimiter );    
       
   563         }
       
   564     else
       
   565         {
       
   566         // No previous data logged. 
       
   567         eventData = HBufC8::NewLC( 
       
   568                 KLogsDataFldTag_ContactLink().Length() 
       
   569             + KLogsDataFldValueDelimiter().Length()
       
   570             + iLogInfo->ContactLink().Length() 
       
   571             + delimiterCount ); 
       
   572         }
       
   573     
       
   574     TPtr8 eventDataPtr( eventData->Des() );
       
   575     eventDataPtr.Append( KLogsDataFldTag_ContactLink );
       
   576     eventDataPtr.Append( KLogsDataFldValueDelimiter );
       
   577     
       
   578     if ( delimiterCount )
       
   579         {
       
   580         // Link data contained unintended \t chars
       
   581         TPtrC8 linkPtr( iLogInfo->ContactLink() );
       
   582         TInt dataLength = 0;
       
   583         // Copy link data between \t chars
       
   584         for ( TInt i = 0; i < delimiterCount; i++ )
       
   585             {
       
   586             // Plus one because we need length, not offset
       
   587             dataLength = linkPtr.Find( KLogsDataFldNameDelimiter ) + KOneChar;
       
   588             // Append from beginning of data, including \t
       
   589             eventDataPtr.Append( linkPtr.Left( dataLength ) );
       
   590             // Add another \t
       
   591             eventDataPtr.Append( KLogsDataFldNameDelimiter );
       
   592             linkPtr.Set( linkPtr.Mid( dataLength ) );
       
   593             }
       
   594         // Copy rest of link data
       
   595         eventDataPtr.Append( linkPtr );
       
   596         }
       
   597     else
       
   598         {
       
   599         // Link data didn't contain \t, so normal copy is possible
       
   600         eventDataPtr.Append( iLogInfo->ContactLink() );
       
   601         }
       
   602     
       
   603     iEvent->SetDataL( *eventData );
       
   604     TEFLOGSTRING( KTAINT, "LOG CPELogEvent::ContactLinkL() Contact link set ok" );
       
   605     CleanupStack::PopAndDestroy( eventData );
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // CPELogEvent::SetDataFieldL
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 void CPELogEvent::SetDataFieldL( const TDesC8& aTag, const TDesC& aFieldData )
       
   613     {
       
   614     __ASSERT_ALWAYS( aTag.Length() != 0 && aFieldData.Length() != 0 ,
       
   615         User::Leave( KErrArgument ) );
       
   616     
       
   617     if ( KErrNotFound == iEvent->Data().Find( aTag ) )
       
   618         {
       
   619         HBufC8* eventData = NULL;
       
   620         const TInt fieldLength = aTag.Length() 
       
   621             + KLogsDataFldValueDelimiter().Length()
       
   622             + aFieldData.Length();
       
   623         const TInt oldDataFieldLength = iEvent->Data().Length();
       
   624         
       
   625         if ( oldDataFieldLength != 0 )
       
   626             {
       
   627             const TInt newDataFieldLength = oldDataFieldLength 
       
   628                 + KLogsDataFldNameDelimiter().Length()
       
   629                 + fieldLength;
       
   630             
       
   631             eventData = HBufC8::NewLC( newDataFieldLength );
       
   632             
       
   633             // Copy previous data
       
   634             eventData->Des().Copy( iEvent->Data() );
       
   635             eventData->Des().Append( KLogsDataFldNameDelimiter );
       
   636             }
       
   637         else
       
   638             {
       
   639             eventData = HBufC8::NewLC( fieldLength );
       
   640             }
       
   641         
       
   642         // Add a new data field.
       
   643         eventData->Des().Append( aTag );
       
   644         eventData->Des().Append( KLogsDataFldValueDelimiter );
       
   645         eventData->Des().Append( aFieldData );     
       
   646         iEvent->SetDataL( *eventData );
       
   647         
       
   648         CleanupStack::PopAndDestroy( eventData );
       
   649         }
       
   650     }
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // CPELogEvent::SetRemoteParty
       
   654 // -----------------------------------------------------------------------------
       
   655 //
       
   656 void CPELogEvent::SetRemoteParty( CLogEvent& aEvent, 
       
   657         const CPELogInfo& aLogInfo )
       
   658     {
       
   659     if ( KNullDesC() != aLogInfo.Name() )
       
   660         {
       
   661         aEvent.SetRemoteParty( aLogInfo.Name() );
       
   662         }
       
   663     }
       
   664 
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // CPELogEvent::SetRemoteContact
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 void CPELogEvent::SetRemoteContact( CLogEvent& aEvent, 
       
   671         const CPELogInfo& aLogInfo )
       
   672     {
       
   673     if ( KNullDesC() != aLogInfo.PhoneNumber() )
       
   674         {
       
   675         aEvent.SetNumber( aLogInfo.PhoneNumber() );
       
   676         }
       
   677     
       
   678     if ( KNullDesC() != aLogInfo.VoipAddress() )
       
   679         {
       
   680         TRAPD( error, SetDataFieldL( KLogsDataFldTag_URL, aLogInfo.VoipAddress() ) );
       
   681         if ( error )
       
   682             {
       
   683             TEFLOGSTRING2( KTAERROR, 
       
   684                 "LOG CPELogEvent::SetLogEvent()>SetDataFieldL(), error=%d", error )
       
   685             }
       
   686         }
       
   687     }
       
   688 
       
   689 
       
   690 // ================= OTHER EXPORTED FUNCTIONS ===============================
       
   691 
       
   692 //  End of File 
       
   693