logsui/AppSrc/CLogsDetailAdapter.h
changeset 0 e686773b3f54
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 *     Adapts data from logsmodel to logs ui component (listbox) format
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CLogsDetailAdapter_H
       
    21 #define CLogsDetailAdapter_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <bamdesca.h>  // MDesCArray
       
    25 #include <e32base.h>
       
    26 #include <logwrap.h>
       
    27 
       
    28 // CONSTANTS
       
    29 // Adaptor buffer length
       
    30 const TInt KLogsDetailsListAdaptorArrayLen = 100;
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CEikLabel;
       
    34 class MLogsEventGetter;
       
    35 class MLogsGetEvent;
       
    36 class CFont;
       
    37 class CLogEvent;
       
    38 class CPhoneNumberFormat;
       
    39 class CLogsEngine;
       
    40 class CAknSingleHeadingStyleListBox;
       
    41 class CLogsDetailView;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 
       
    46 /**
       
    47 *  Adapts data from logsmodel to logs ui component (listbox) format.
       
    48 */
       
    49 class CLogsDetailAdapter : public CBase, public MDesCArray
       
    50     {  
       
    51     private:
       
    52 
       
    53         enum TRowNumber
       
    54             {
       
    55             EFirstRow,
       
    56             ESecondRow
       
    57             };
       
    58 
       
    59     public:  // Constructors and destructor
       
    60                 
       
    61        /**
       
    62         * Two-phased constructor.
       
    63         * @param aListBox pointer to listbox
       
    64         * @param aView pointer to view
       
    65         * @return new created object
       
    66         */
       
    67         static CLogsDetailAdapter* NewL( 
       
    68             CAknSingleHeadingStyleListBox* aListBox,
       
    69             CLogsDetailView* aView );
       
    70 
       
    71        /**
       
    72         * Destructor.
       
    73         */
       
    74         virtual ~CLogsDetailAdapter();
       
    75 
       
    76     private:
       
    77         
       
    78        /**
       
    79         * C++ default constructor.
       
    80         * @param aEngine pointer to Logs engine
       
    81         */
       
    82         CLogsDetailAdapter( CAknSingleHeadingStyleListBox* aListBox, CLogsDetailView* aView ); 
       
    83 
       
    84 
       
    85         /**
       
    86         * By default Symbian OS constructor is private.
       
    87         */
       
    88         void ConstructL();
       
    89 
       
    90 
       
    91     public: // Functions from MDesCArray
       
    92 
       
    93         /**
       
    94          *  Returns number of entries in details window
       
    95          *
       
    96          *  @return TInt number of lines in listbox
       
    97          */
       
    98         TInt MdcaCount() const;
       
    99     
       
   100         /**
       
   101          *  Returns a TPtrC related with the position given by aIndex
       
   102          *
       
   103          *  @param  TInt    aIndex
       
   104          *  @return TPtrC16 listbox line descriptor
       
   105          */
       
   106         TPtrC16 MdcaPoint( TInt aIndex ) const;        
       
   107 
       
   108     public: 
       
   109         /**
       
   110          *  Sets the maximum width in pixels for the detail line. This needs to be called from controller's
       
   111          *  SizeChanged() method.
       
   112          *
       
   113          *  @param  TInt    aTextWidth maximum width in pixels
       
   114          */
       
   115         void SetLineWidth(TInt aTextWidth);
       
   116         
       
   117         /**
       
   118          *  Updates the display content.
       
   119          */
       
   120         void UpdateL();
       
   121 
       
   122     private: 
       
   123         
       
   124         /**
       
   125          * Direction Row, returns true
       
   126          * @param aEvent event for formatting
       
   127          * @return ETrue if direction can be shown for current event, 
       
   128          *         otherwise EFalse
       
   129          */
       
   130         TBool DirectionRow( const MLogsEventGetter* aEvent ) const;
       
   131 
       
   132         /**
       
   133          * Type Row, returns true
       
   134          * @param aEvent event for formatting
       
   135          * @return ETrue if type can be shown for current event, 
       
   136          *         otherwise EFalse
       
   137          */
       
   138         TBool TypeRow( const MLogsEventGetter* aEvent ) const;
       
   139 
       
   140         /**
       
   141          * Status Row, if not shown return False, else true. 
       
   142          * @param aEvent event for formatting
       
   143          * @return ETrue if status can be shown for current event, 
       
   144          *         otherwise EFalse
       
   145          */
       
   146         TBool StatusRow( const CLogEvent* aCLogEvent,
       
   147                          const MLogsEventGetter* aEvent ) const;
       
   148 
       
   149 
       
   150         /**
       
   151          * Duration Row, if not shown return False, else true. 
       
   152          * @param aEvent event for formatting 
       
   153          * @return ETrue if duration can be shown for current event, 
       
   154          *         otherwise EFalse
       
   155          */
       
   156         TBool DurationRow( const CLogEvent* aEvent ) const;
       
   157 
       
   158         /**
       
   159          * Amount Row, if not shown return False, else true. 
       
   160          * @param aEvent event for formatting 
       
   161          * @return ETrue if amount can be shown for current event, 
       
   162          *         otherwise EFalse
       
   163          */
       
   164         TBool AmountRow( const MLogsEventGetter* aEvent ) const;
       
   165 
       
   166         /**
       
   167          * Sent Amount Row, if not shown return EFalse, else ETrue. 
       
   168          * @param aEvent event for formatting 
       
   169          * @return ETrue if sent amount can be shown for current event, 
       
   170          *         otherwise EFalse
       
   171          */
       
   172         TBool SentAmountRow( const MLogsEventGetter* aEvent ) const;
       
   173 
       
   174         /**
       
   175          * Received Amount Row, if not shown return EFalse, else ETrue. 
       
   176          * @param aEvent event for formatting 
       
   177          * @return ETrue if received amount can be shown for current event, 
       
   178          *         otherwise EFalse
       
   179          */
       
   180         TBool ReceivedAmountRow( const MLogsEventGetter* aEvent ) const;
       
   181 
       
   182         /**
       
   183          * Tel Row, if not shown return False, else true. 
       
   184          * @param aLogsEvent event for formatting (CLogsEvent!)
       
   185          * @param aRowNumber row number if splitted
       
   186          * @return ETrue if tel number can be shown for current event, 
       
   187          *         otherwise EFalse
       
   188          */
       
   189         TBool TelRow( const MLogsEventGetter* aEvent, 
       
   190                         TRowNumber aRowNumber = EFirstRow ) const;
       
   191 
       
   192         /*
       
   193         * TimeL, wrapper for leavable functions in time formatting 
       
   194         * @param aTime to format
       
   195         */
       
   196         void TimeFormattingL( TTime& aTime ) const;
       
   197 
       
   198         /**
       
   199          * Split string or phone number into 2 lines if needed.
       
   200          * @param aEvent log event to get a number from
       
   201          * @param aFont used font
       
   202          * @param aMaxWidthInPixels max with of column in pixels
       
   203          * @param aPreferUri Use uri instead of phonenumber
       
   204          * @return ETrue if splitted, otherwise EFalse
       
   205          */
       
   206         TBool SplitNumber( const MLogsEventGetter* aEvent, 
       
   207                            const CFont& aFont, 
       
   208                            TInt aMaxWidthInPixels, 
       
   209                            TBool aPreferUri = EFalse ) const;
       
   210 
       
   211         //
       
   212         void ProcessPocAndVoipRows( TDes& aDes, 
       
   213                                TInt aIndex, 
       
   214                                const MLogsEventGetter* aEvent, 
       
   215                                const CLogEvent* aLogEvent ) const;
       
   216         void ProcessCallAndFaxRows( TDes& aDes, 
       
   217                                TInt aIndex, 
       
   218                                const MLogsEventGetter* aEvent, 
       
   219                                const CLogEvent* aLogEvent ) const;
       
   220 
       
   221         const CFont* LineFont();
       
   222         
       
   223         void Reverse(TDes& aText ) const;        
       
   224 
       
   225     private:    // Data
       
   226 
       
   227         // Ref: Pointer to CLogEngine
       
   228         CLogsEngine* iEngine;
       
   229 
       
   230         /// Ref: event getter
       
   231         MLogsGetEvent* iGetter;
       
   232         /// Own: Conversion buffer 
       
   233         TBuf<KLogsDetailsListAdaptorArrayLen> iBuffer;
       
   234 
       
   235         /// Own: Direction text
       
   236         HBufC* iDirection;
       
   237         /// Own: Type text
       
   238         HBufC* iType;
       
   239         /// Own: Status text
       
   240         HBufC* iStatus;
       
   241         /// Own: Duration text
       
   242         HBufC* iDuration;
       
   243         /// Own: Amounttext
       
   244         HBufC* iAmount;
       
   245         /// Own: Amount in kb's text
       
   246         HBufC* iAmountKB; 
       
   247         /// Own: phone nbr text
       
   248         HBufC* iNbr;
       
   249 
       
   250         /// Own: Private, unknown, payphone number text
       
   251         //HBufC* iPrivateNumber;
       
   252         HBufC* iUnknownNumber;
       
   253         //HBufC* iPayphoneNumber;        
       
   254 
       
   255         /// Own: Direction in
       
   256         HBufC* iDirectionIn;
       
   257         HBufC* iDirectionOut;
       
   258         HBufC* iDirectionMissed;
       
   259 
       
   260         /// Own: Event type
       
   261         HBufC* iEventTypeVoice;
       
   262         HBufC* iEventTypeSMS;
       
   263         HBufC* iEventTypeMMS;
       
   264         HBufC* iEventTypeGPRS;
       
   265         HBufC* iEventTypeData;
       
   266         HBufC* iEventTypeWLAN;
       
   267         HBufC* iEventTypeFax;
       
   268         HBufC* iEventTypeVideo;
       
   269 
       
   270         HBufC* iEventTypePoC;
       
   271         HBufC* iEventTypePoCInfo;        
       
   272         HBufC* iEventTypeVoIP;
       
   273         HBufC* iPoCAddr;
       
   274         HBufC* iVoIPCallFrom;
       
   275         HBufC* iVoIPCallTo;
       
   276 
       
   277         /// Own: Print status messages, shown in box
       
   278         HBufC* iEventStatusDelivered;
       
   279         HBufC* iEventStatusPending;
       
   280         HBufC* iEventStatusFailed;
       
   281         HBufC* iEventStatusSent;
       
   282 
       
   283         /// Own: Duration field format
       
   284         HBufC* iDurationFormat;
       
   285         
       
   286         /// Own: Label for clipping
       
   287         //CEikLabel* iLabel;
       
   288 
       
   289         /// Own: Event status 
       
   290         TLogString iEventStatusPendingTxt;
       
   291         TLogString iEventStatusSentTxt;
       
   292         TLogString iEventStatusFailedTxt;
       
   293         TLogString iEventStatusNoDeliveryTxt;
       
   294         TLogString iEventStatusDeliveredTxt;
       
   295         TLogString iEventStatusNotSentTxt;
       
   296 
       
   297         HBufC* iNumberFirstRow;
       
   298         HBufC* iNumberSecondRow;  
       
   299         __MUTABLE TBool  iNumberSplitted;    
       
   300 
       
   301         /// Own: Sent text
       
   302         HBufC* iSentAmount;
       
   303         /// Own: Received text
       
   304         HBufC* iReceivedAmount;
       
   305 
       
   306         /// Own: object with groupping, clipping and A&H functionality
       
   307         CPhoneNumberFormat* iPhoneNbrFormatter;
       
   308 
       
   309         //Maximum text width in pixels that fit in one row
       
   310         TInt iTextWidth;
       
   311         /// Ref: 
       
   312         const CFont* iListboxFont;  // not owned
       
   313 
       
   314         /// Ref: reference to the list box owned by the control container
       
   315         CAknSingleHeadingStyleListBox* iListBox;
       
   316         CLogsDetailView* iView;
       
   317         
       
   318         /// Own:
       
   319         CDesCArrayFlat* iDisplayRows;
       
   320         TInt iDisplayRowNumber;
       
   321 
       
   322 
       
   323     };
       
   324 
       
   325 #endif      // CLogsDetailsAdapter_H
       
   326             
       
   327 // End of File