logsui/AppSrc/CLogsEventListAdapter.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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 *     Adapter to EventList copies data from model listbox
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <logfilterandeventconstants.hrh>
       
    23 #endif
       
    24 #include <eiklabel.h>   // ceiklabel
       
    25 #include <AknUtils.h>   // akntextutils
       
    26 #include <eikclb.h>     // ceikcolumnlistbox
       
    27 
       
    28 #include <Logs.rsg>
       
    29 
       
    30 #include "CLogsEventListAdapter.h"
       
    31 #include "CLogsEventListControlContainer.h"
       
    32 #include "CLogsEventListView.h"
       
    33 #include "MLogsSharedData.h"
       
    34 #include "MLogsModel.h"
       
    35 #include "MLogsEventGetter.h"
       
    36 #include "CPhoneNumberFormat.h"
       
    37 
       
    38 #include "LogsConstants.hrh"
       
    39 #include <LogsApiConsts.h>  //additional event uids
       
    40 #include "LogsConsts.h"
       
    41 
       
    42 
       
    43 //[FIXME: Remove the following after mmsEventType is defined in Symbian include file]
       
    44 #include "LogsEngConsts.h"  //klogsengmmseventtype
       
    45 
       
    46 // EXTERNAL DATA STRUCTURES
       
    47 
       
    48 // EXTERNAL FUNCTION PROTOTYPES  
       
    49 
       
    50 // CONSTANTS
       
    51 const TInt KEventListSubCellId = 2;
       
    52 // MACROS
       
    53 
       
    54 // LOCAL CONSTANTS AND MACROS
       
    55 
       
    56 // MODULE DATA STRUCTURES
       
    57 
       
    58 // LOCAL FUNCTION PROTOTYPES
       
    59 
       
    60 
       
    61 // ================= MEMBER FUNCTIONS =======================
       
    62 
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // CLogsEventListAdapter::NewL
       
    66 //
       
    67 // Two-phased constructor.
       
    68 // ----------------------------------------------------------------------------
       
    69 //
       
    70 CLogsEventListAdapter* CLogsEventListAdapter::NewL( CLogsEventListControlContainer* aContainer )
       
    71     {
       
    72     CLogsEventListAdapter* self = new( ELeave ) CLogsEventListAdapter( aContainer );
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop(self);
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CLogsEventListAdapter::CLogsEventListAdapter
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CLogsEventListAdapter::CLogsEventListAdapter( CLogsEventListControlContainer* aContainer ) : 
       
    84     iEngine( aContainer->View()->Engine() ),
       
    85     iModel( aContainer->View()->Engine()->Model( ELogsMainModel )),
       
    86     //FIXME: this can be removed as Phone takes care of leavin csd numbers unlogged if preferred                                         
       
    87     // iShowCsd( aContainer->View()->Engine()->SharedDataL()->ShowCsdNumber() ),
       
    88     iListBox( aContainer->ListBox() )
       
    89     {
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CLogsEventListAdapter::ConstructL
       
    94 // ----------------------------------------------------------------------------
       
    95 //
       
    96 void CLogsEventListAdapter::ConstructL()
       
    97     {
       
    98     CEikonEnv* env = CEikonEnv::Static();
       
    99 
       
   100     iBuffer = HBufC::NewL( KLogsBuff128 );
       
   101     iCallText = env->AllocReadResourceL( R_LOGS_ET_CALL_TEXT );
       
   102     iDataText = env->AllocReadResourceL( R_LOGS_ET_DATA_TEXT );
       
   103     iSMSText = env->AllocReadResourceL( R_LOGS_ET_SMS_TEXT );
       
   104     iMMSText = env->AllocReadResourceL( R_LOGS_ET_MMS_TEXT );
       
   105     iPacketText = env->AllocReadResourceL( R_LOGS_ET_PACKET_TEXT );
       
   106     iWLANText = env->AllocReadResourceL( R_LOGS_ET_WLAN_TEXT );
       
   107     iFaxText = env->AllocReadResourceL( R_LOGS_ET_FAX_TEXT);
       
   108     iVideoText = env->AllocReadResourceL( R_LOGS_ET_VIDEO_TEXT );
       
   109     iPoCText = env->AllocReadResourceL( R_LOGS_ET_POC_TEXT );
       
   110     iPoCTextInfo = env->AllocReadResourceL( R_LOGS_ET_POC_INFO_TEXT );    
       
   111 
       
   112     iVoIPText = env->AllocReadResourceL( R_LOGS_ET_VOIP_TEXT);
       
   113 
       
   114     iPrivateNumber = env->AllocReadResourceL( R_LOGS_CON_PRIVATE_NUM );
       
   115     iUnknownNumber = env->AllocReadResourceL( R_LOGS_CON_UNKNOWN_NUM ); 
       
   116     iPayphoneNumber = env->AllocReadResourceL( R_LOGS_CON_PAYPHONE_NUM );	 
       
   117     
       
   118     iSATNumber = env->AllocReadResourceL( R_LOGS_CON_OPER_SERV );
       
   119     iGroupCall = env->AllocReadResourceL( R_LOGS_CON_GROUP_CALL );
       
   120     iEmergencyCall = env->AllocReadResourceL( R_LOGS_EMERG_CALL );
       
   121     iCsdNumber = env->AllocReadResourceL( R_LOGS_DETAILS_CSD_NUMBER );
       
   122 
       
   123     iLabel = new (ELeave) CEikLabel();
       
   124 
       
   125     iPhoneNumber = CPhoneNumberFormat::NewL();
       
   126     }
       
   127     
       
   128 // Destructor
       
   129 // ----------------------------------------------------------------------------
       
   130 // CLogsEventListAdapter::~CLogsEventListAdapter
       
   131 // ----------------------------------------------------------------------------
       
   132 //
       
   133 CLogsEventListAdapter::~CLogsEventListAdapter()
       
   134     {
       
   135     delete iBuffer;
       
   136     delete iCallText;
       
   137     delete iDataText;
       
   138     delete iSMSText;
       
   139     delete iMMSText;
       
   140     delete iPacketText;
       
   141     delete iWLANText;
       
   142     delete iFaxText;
       
   143     delete iVideoText;
       
   144     delete iPoCText;
       
   145     delete iPoCTextInfo;    
       
   146     delete iVoIPText;
       
   147 
       
   148     delete iPrivateNumber;
       
   149     delete iUnknownNumber;
       
   150     delete iPayphoneNumber;    
       
   151     
       
   152     delete iSATNumber;
       
   153     delete iGroupCall; 
       
   154     delete iEmergencyCall;
       
   155     delete iCsdNumber;
       
   156     delete iLabel;
       
   157 
       
   158     delete iPhoneNumber;
       
   159     }
       
   160 
       
   161 
       
   162 // ----------------------------------------------------------------------------
       
   163 // CLogsEventListAdapter::MdcaCount
       
   164 //
       
   165 // from MDesCArray
       
   166 // ----------------------------------------------------------------------------
       
   167 //
       
   168 TInt  CLogsEventListAdapter::MdcaCount () const 
       
   169     {
       
   170     return iModel->Count();   
       
   171     }
       
   172     
       
   173 // ----------------------------------------------------------------------------
       
   174 // CLogsEventListAdapter::MdcaPoint
       
   175 //
       
   176 // from MDesCArray
       
   177 // ----------------------------------------------------------------------------
       
   178 //
       
   179 TPtrC16  CLogsEventListAdapter::MdcaPoint( TInt aIndex ) const
       
   180     {
       
   181     TPtr des( iBuffer->Des() );
       
   182     // Single Graphics Style "0\tHead\tText"
       
   183     // or single graphic heading style "0\tHead\tLabel\t1\t2"
       
   184         
       
   185     const MLogsEventGetter* event = iModel->At( aIndex );
       
   186 
       
   187     TLogsDirection dir = event->Direction();    
       
   188     
       
   189     des.Num( static_cast<TInt>( dir ) );
       
   190     des.Append( KTab );
       
   191 
       
   192     TUid uid;
       
   193     uid.iUid = event->EventUid().iUid;
       
   194 
       
   195     switch( uid.iUid )
       
   196         {
       
   197         case KLogCallEventType:
       
   198 
       
   199             //Currently Voice, VT, PoC and VoIP are shown as mutually exclusive. This may change in the future, e.g.
       
   200             //VoIP and VT types may beboth in the same event 
       
   201             if( event->LogsEventData()->VT() )
       
   202                 {
       
   203                 des.Append( iVideoText->Des() );
       
   204                 }
       
   205             else if( event->LogsEventData()->PoC() )
       
   206                 {
       
   207                 des.Append( iPoCText->Des() );
       
   208                 }
       
   209             else if( event->LogsEventData()->VoIP() )
       
   210                 {
       
   211                 des.Append( iVoIPText->Des() );
       
   212                 }
       
   213             else
       
   214                 {
       
   215                 des.Append( iCallText->Des() );
       
   216                 }
       
   217             break;
       
   218             
       
   219         case KLogsEngPocInfoEventType:            
       
   220             des.Append( iPoCTextInfo->Des() );
       
   221             break;
       
   222             
       
   223         case KLogDataEventType:   
       
   224             des.Append( iDataText->Des() );
       
   225             break;
       
   226             
       
   227         case KLogShortMessageEventType:   
       
   228             des.Append( iSMSText->Des() );
       
   229             break;
       
   230             
       
   231         case KLogsEngMmsEventType:   
       
   232             des.Append( iMMSText->Des() );
       
   233             break;
       
   234             
       
   235         case KLogPacketDataEventType:   
       
   236             des.Append( iPacketText->Des() );
       
   237             break;
       
   238             
       
   239         case KLogsEngWlanEventType:   
       
   240             des.Append( iWLANText->Des() );
       
   241             break;
       
   242             
       
   243         case KLogFaxEventType:   
       
   244             des.Append( iFaxText->Des() );
       
   245             break;
       
   246             
       
   247         default:
       
   248             break;
       
   249         } // switch
       
   250 
       
   251     des.Append( KTab );
       
   252     
       
   253     //if( ! iShowCsd && //FIXME: this can be removed as Phone takes care of leavin csd numbers unlogged if preferred
       
   254     if( !event->Number() && !event->RemoteParty() &&
       
   255         uid.iUid == KLogDataEventType &&
       
   256         ( dir == EDirOutAlt || dir == EDirOut ) )
       
   257         {
       
   258         // hide csd numbers if required
       
   259         des.Append( *iCsdNumber );
       
   260         }
       
   261     else
       
   262         {
       
   263         switch ( event->EventType() )
       
   264             {
       
   265             case ETypeUsual:
       
   266                 if( event->RemoteParty() )
       
   267                     {
       
   268                     // Lets strip control chars like tabulator marks which would break 
       
   269                     // the listbox descriptor, see OJON-7CA9SU
       
   270                     TPtr remoteParty = event->RemoteParty()->Des();
       
   271                     AknTextUtils::StripCharacters(remoteParty, KAknStripListControlChars);
       
   272                     des.Append( remoteParty );  
       
   273                     }
       
   274                 else if( event->Number() )
       
   275                     //We prefer showing phone number over sip uri although for making calls uri is preferred (if both
       
   276                     //available, Poc has made a "best guess" for corresponding msisdn for subsequent cs calls).
       
   277                     {
       
   278                     TBuf<KLogsPhoneNumberMaxLen> tmp;
       
   279                     TBuf<KLogsPhoneNumberMaxLen> clippedNumber;
       
   280                     
       
   281                     CPhoneNumberFormat::DTMFStrip( *(event->Number()), tmp );
       
   282 
       
   283                     iPhoneNumber->PhoneNumberFormat
       
   284                                     (   tmp
       
   285                                     ,   clippedNumber
       
   286                                     ,   AknTextUtils::EClipFromBeginning
       
   287                                     ,   iListBox
       
   288                                     ,   aIndex
       
   289                                     ,   KEventListSubCellId
       
   290                                     );
       
   291 
       
   292                     des.Append( clippedNumber );
       
   293                     }
       
   294                 else if( event->LogsEventData()->Url().Length() > 0 ) 
       
   295                     {
       
   296                     TBuf<KLogsSipUriMaxLen> buf; 
       
   297                     
       
   298                     if ( iEngine->ConvertToUnicode( event->LogsEventData()->Url(), buf ) )
       
   299                         {
       
   300                         buf.Zero(); //Converting failed
       
   301                         }
       
   302                     else
       
   303                         {
       
   304                         AknTextUtils::StripCharacters(buf, KAknStripListControlChars);
       
   305                         des.Append( buf );                      
       
   306                         }
       
   307                     }
       
   308                 break;
       
   309 
       
   310             case ETypePoCGroupCall:                
       
   311                 if( event->RemoteParty() )
       
   312                     {
       
   313                     // Lets strip control chars like tabulator marks which would break 
       
   314                     // the listbox descriptor, see OJON-7CA9SU
       
   315                     TPtr remoteParty = event->RemoteParty()->Des();
       
   316                     AknTextUtils::StripCharacters(remoteParty, KAknStripListControlChars);
       
   317                     des.Append( remoteParty );  
       
   318                     }
       
   319                 else                                //if no remote party data available, show
       
   320                     {                               //localised text "group call"
       
   321                     des.Append( *iGroupCall );  
       
   322                     }
       
   323                 break;                
       
   324                        
       
   325             case ETypePrivate:
       
   326                 des.Append( *iPrivateNumber );
       
   327                 break;
       
   328 
       
   329             case ETypeUnknown:
       
   330                 des.Append( *iUnknownNumber );
       
   331                 break;
       
   332                 
       
   333             case ETypePayphone:
       
   334                 des.Append( *iPayphoneNumber );
       
   335                 break;
       
   336 
       
   337             case ETypeSAT:
       
   338                 if( event->RemoteParty()) 
       
   339                     { 
       
   340                     // sat event with contact
       
   341                     // Lets strip control chars like tabulator marks which would break 
       
   342                     // the listbox descriptor, see OJON-7CA9SU
       
   343                     TPtr remoteParty = event->RemoteParty()->Des();
       
   344                     AknTextUtils::StripCharacters(remoteParty, KAknStripListControlChars);
       
   345                     des.Append( remoteParty ); 
       
   346                     }
       
   347                 else 
       
   348                     {
       
   349                     des.Append( *iSATNumber );
       
   350                     }
       
   351                 break;
       
   352 
       
   353             case ETypeEmerg:
       
   354                 des.Append( *iEmergencyCall ); 
       
   355                 break;
       
   356 
       
   357             default:
       
   358                 break;
       
   359             }
       
   360         }
       
   361      
       
   362     // Finally, lets replace paragraph delimiters with single white space, fix for EBWG-6ZPCMZ 
       
   363     TBuf<1> charsToRemove;
       
   364     charsToRemove.Append(TChar(TInt(CEditableText::EParagraphDelimiter)));
       
   365     AknTextUtils::ReplaceCharacters(des, charsToRemove, TChar(TInt(CEditableText::ESpace)));
       
   366     
       
   367     return *iBuffer;
       
   368     }
       
   369 
       
   370 //  End of File