messagingappbase/msgavkon/muiu_domain/messageinfo/src/muiumsginfo.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 *     Encapsulates the data which populates the fields in the message 
       
    16 *     info dialogs (email, sms, bios, mms), also holds the text for the 
       
    17 *     labels and fields in the message info dialog and displays a message 
       
    18 *     info dialog for particular message types
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include <AknPhoneNumberGrouping.h>      // CAknPhoneNumberGrouping
       
    26 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
       
    27 #include <aknmessagequerydialog.h>       // CaknMessageQueryDialog
       
    28 #include <eikenv.h>                      // CEikonEnv
       
    29 #include <muiu.rsg>
       
    30 #include "Muiumsginfo.h"
       
    31 #include "Muiumsginfo.hrh"
       
    32 
       
    33 
       
    34 // CONSTANTS
       
    35 const TInt KExtraSpaceForLabelString = 2;  // Length of KLabelExtraString(":" + line feed)
       
    36 const TInt KExtraSpaceForLineFeed = 1;     // Length of line feed
       
    37 const TInt KNumberOfLineFeeds = 2;         // How many line feeds one item need
       
    38 const TInt KNumOfReplaceChars = 3; 	// for subject field whitebox removal
       
    39 const TInt KLineFeed = 0x0000000a; 	// unicode representation for linefeed.
       
    40 const TInt KDateSize = 30;          // Size of Date and Time strings in Message info
       
    41  
       
    42 _LIT( KDirAndMuiuResFileName,"muiu.rsc" );
       
    43 _LIT( KNullString, "" );
       
    44 _LIT( KLabelExtraString, ":\n" );
       
    45 _LIT( Ks1, "<" );
       
    46 _LIT( Ks2, ">" );
       
    47 
       
    48 
       
    49 // ============================ MEMBER FUNCTIONS ===============================
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CMsgInfoMessageInfoDialog::~CMsgInfoMessageInfoDialog
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 CMsgInfoMessageInfoDialog::~CMsgInfoMessageInfoDialog()
       
    57     {
       
    58     iResources.Close();
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CMsgInfoMessageInfoDialog::CMsgInfoMessageInfoDialog
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 CMsgInfoMessageInfoDialog::CMsgInfoMessageInfoDialog() : iResources( *CEikonEnv::Static() )
       
    67     {}
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CMsgInfoMessageInfoDialog::ConstructL
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 void CMsgInfoMessageInfoDialog::ConstructL()
       
    75     {
       
    76     TParse parse;
       
    77     parse.Set( KDirAndMuiuResFileName, &KDC_RESOURCE_FILES_DIR, NULL ); 
       
    78     TFileName fileName( parse.FullName() );
       
    79     iResources.OpenL( fileName );
       
    80     }
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------
       
    84 // CMsgInfoMessageInfoDialog::NewL
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 EXPORT_C CMsgInfoMessageInfoDialog* CMsgInfoMessageInfoDialog::NewL()
       
    88     {
       
    89     CMsgInfoMessageInfoDialog* self = new( ELeave ) CMsgInfoMessageInfoDialog;
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self ); //self
       
    93     return self;
       
    94     }
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CMsgInfoMessageInfoDialog::ExecuteLD
       
    99 // Show the message info dialog.
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 EXPORT_C void CMsgInfoMessageInfoDialog::ExecuteLD( TMsgInfoMessageInfoData& aFieldData, 
       
   103                                                     TMessageInfoType aMessageType)
       
   104     {
       
   105     TInt popCount = 0;
       
   106     TMsgInfoMessageInfoData convertedFieldData;
       
   107     CleanupStack::PushL( this );
       
   108     iMessageType = aMessageType;
       
   109 
       
   110 
       
   111     // Note: Lanquage specific number conversion done here.
       
   112     // This way dialog seem to open faster. (Number conversion and memory allocation take time)
       
   113 
       
   114     //From ----------------------------------------------------------------------
       
   115     HBufC* tmpFromString = GroupPhoneNumberAndDoLangSpecificNumberConversionL( aFieldData.iFrom );
       
   116     CleanupStack::PushL( tmpFromString );
       
   117     popCount++;
       
   118     SetStringToPointerDescriptor( tmpFromString, convertedFieldData.iFrom );
       
   119 
       
   120     //Subject ----------------------------------------------------------------------
       
   121     HBufC* tmpSubjectString = aFieldData.iSubject.AllocLC();
       
   122     popCount++;
       
   123     TPtr tmpSubjecPtr = tmpSubjectString->Des();
       
   124     TBuf<KNumOfReplaceChars> replaceChars;
       
   125     replaceChars.Zero();
       
   126     replaceChars.Append( CEditableText::EParagraphDelimiter );
       
   127     replaceChars.Append( CEditableText::ETabCharacter );
       
   128     replaceChars.Append( KLineFeed );
       
   129     AknTextUtils::ReplaceCharacters(
       
   130         tmpSubjecPtr, 
       
   131         replaceChars, 
       
   132         CEditableText::ESpace );
       
   133     if ( tmpSubjecPtr.Length() > 0 )
       
   134         {
       
   135         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tmpSubjecPtr );
       
   136         }
       
   137     convertedFieldData.iSubject.Set( tmpSubjecPtr );
       
   138 
       
   139     //Type ----------------------------------------------------------------------
       
   140     HBufC* tmpTypeString = aFieldData.iType.AllocLC();
       
   141     popCount++;
       
   142     DoNumberConversion( tmpTypeString, convertedFieldData.iType );
       
   143 
       
   144     //Size ----------------------------------------------------------------------
       
   145     HBufC* tmpSizeString = aFieldData.iSize.AllocLC();
       
   146     popCount++;
       
   147     DoNumberConversion( tmpSizeString, convertedFieldData.iSize );
       
   148 
       
   149     //Priority ------------------------------------------------------------------
       
   150     HBufC* tmpPriorityString = aFieldData.iPriority.AllocLC();
       
   151     popCount++;
       
   152     DoNumberConversion( tmpPriorityString, convertedFieldData.iPriority );
       
   153 
       
   154     //To----------------------------------------------------------------------
       
   155     HBufC* tmpToString = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( aFieldData.iTo );
       
   156     TPtr tmpToPtr = tmpToString->Des();
       
   157     AknTextUtils::ReplaceCharacters( tmpToPtr, replaceChars, CEditableText::ESpace );
       
   158     CleanupStack::PushL( tmpToString );
       
   159     popCount++;
       
   160     DoNumberConversion( tmpToString, convertedFieldData.iTo );
       
   161 
       
   162     //CC----------------------------------------------------------------------
       
   163     HBufC* tmpCCString = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( aFieldData.iCC );
       
   164     TPtr tmpCCPtr = tmpCCString->Des();
       
   165     AknTextUtils::ReplaceCharacters( tmpCCPtr, replaceChars, CEditableText::ESpace );
       
   166     CleanupStack::PushL( tmpCCString );
       
   167     popCount++;
       
   168     DoNumberConversion( tmpCCString, convertedFieldData.iCC );
       
   169 
       
   170     //BCC----------------------------------------------------------------------
       
   171     HBufC* tmpBCCString = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( aFieldData.iBCC );
       
   172     CleanupStack::PushL( tmpBCCString );
       
   173     popCount++;
       
   174     DoNumberConversion( tmpBCCString, convertedFieldData.iBCC );
       
   175 
       
   176 
       
   177     convertedFieldData.iDateTime = aFieldData.iDateTime;
       
   178     SetInfoArrayL( convertedFieldData );
       
   179     CleanupStack::PopAndDestroy( popCount, tmpFromString ); //tmpFromString, tmpSubjectString
       
   180     // tmpTypeString, tmpSizeString, tmpPriorityString, tmpToString, tmpCCString, tmpBCCString
       
   181     CleanupStack::Pop( this ); //this
       
   182     delete this;
       
   183     }
       
   184 
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // CMsgInfoMessageInfoDialog::SetInfoArrayL
       
   188 // 
       
   189 // ---------------------------------------------------------
       
   190 //
       
   191 void CMsgInfoMessageInfoDialog::SetInfoArrayL( TMsgInfoMessageInfoData& aFieldData ) const
       
   192     {
       
   193     
       
   194     TInt neededHBufSpace(0);
       
   195     TInt cleanupStackIndex(0);
       
   196 
       
   197     CEikonEnv* env = CEikonEnv::Static();
       
   198     if ( !env )
       
   199         {
       
   200         User::Leave( KErrGeneral );
       
   201         }
       
   202     
       
   203     //Construct label strings and calculate how much space whole message info string need
       
   204     //From -----------------------------------------------------------
       
   205     HBufC* labelTextFrom;
       
   206     labelTextFrom = NULL;
       
   207     TBool fromAdded( EFalse );
       
   208     if( aFieldData.iFrom.Length() )
       
   209         {
       
   210         labelTextFrom = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   211                         R_MESSAGE_INFO_FROM_LABEL, 
       
   212                         aFieldData.iFrom, neededHBufSpace, env );
       
   213         fromAdded = ETrue;
       
   214         cleanupStackIndex++;
       
   215         }    
       
   216 
       
   217     //Subject --------------------------------------------------
       
   218     HBufC* labelTextSubject;
       
   219     labelTextSubject = NULL;
       
   220     TBool subjectAdded( EFalse );   
       
   221     if( aFieldData.iSubject.Length() )
       
   222         {
       
   223         labelTextSubject = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   224             R_MESSAGE_INFO_SUBJECT_LABEL, 
       
   225             aFieldData.iSubject, neededHBufSpace, env );
       
   226         subjectAdded = ETrue;
       
   227         cleanupStackIndex++;
       
   228         }
       
   229     
       
   230     
       
   231     //Date and Time -------------------------------------------------------------
       
   232     TBuf<KDateSize> dateString;
       
   233     TBuf<KDateSize> timeString;
       
   234     TPtrC dateStr;
       
   235     TPtrC timeStr;
       
   236     GetFormattedTimeAndDateStringsL( aFieldData.iDateTime, dateString, timeString, env );
       
   237     HBufC* tmpDateString = dateString.AllocLC();
       
   238     cleanupStackIndex++;
       
   239     DoNumberConversion( tmpDateString, dateStr );
       
   240     HBufC* tmpTimeString = timeString.AllocLC();
       
   241     cleanupStackIndex++;
       
   242     DoNumberConversion( tmpTimeString, timeStr );
       
   243     
       
   244     //Date ------------------------------------------------------------------
       
   245     HBufC* labelTextDate;
       
   246     labelTextDate = NULL;
       
   247     TBool dateAdded( EFalse );
       
   248     if( dateStr.Length() )
       
   249         {
       
   250         labelTextDate = ConstructLabelStrAndCalculateNeededSpaceLC( R_MESSAGE_INFO_DATE_LABEL, 
       
   251             dateStr, neededHBufSpace, env );
       
   252         dateAdded = ETrue;
       
   253         cleanupStackIndex++;
       
   254         }
       
   255     
       
   256     //Time ------------------------------------------------------------------
       
   257     HBufC* labelTextTime;
       
   258     labelTextTime = NULL;
       
   259     TBool timeAdded( EFalse );
       
   260     if( timeStr.Length() )
       
   261         {
       
   262         labelTextTime = ConstructLabelStrAndCalculateNeededSpaceLC( R_MESSAGE_INFO_TIME_LABEL, 
       
   263             timeStr, neededHBufSpace, env );
       
   264         timeAdded = ETrue;
       
   265         cleanupStackIndex++;
       
   266         }
       
   267     
       
   268     //Type ----------------------------------------------------------------------
       
   269     HBufC* labelTextType;
       
   270     labelTextType = NULL;
       
   271     TBool typeAdded( EFalse );
       
   272     if( aFieldData.iType.Length() )
       
   273         {
       
   274         labelTextType = ConstructLabelStrAndCalculateNeededSpaceLC( R_MESSAGE_INFO_TYPE_LABEL, 
       
   275             aFieldData.iType, neededHBufSpace, env );
       
   276         typeAdded = ETrue;
       
   277         cleanupStackIndex++;
       
   278         }
       
   279     
       
   280     
       
   281     //Size ----------------------------------------------------------------------
       
   282     HBufC* labelTextSize;
       
   283     labelTextSize = NULL;
       
   284     TBool sizeAdded( EFalse );
       
   285     if( aFieldData.iSize.Length() )
       
   286         {
       
   287         labelTextSize = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   288                     R_MESSAGE_INFO_SIZE_LABEL, 
       
   289                     aFieldData.iSize, neededHBufSpace, env );
       
   290         sizeAdded = ETrue;
       
   291         cleanupStackIndex++;
       
   292         }
       
   293     
       
   294     //Priority ------------------------------------------------------------------
       
   295     HBufC* labelTextPriority;
       
   296     labelTextPriority = NULL;
       
   297     TBool priorityAdded( EFalse );
       
   298     if( aFieldData.iPriority.Length() )
       
   299         {
       
   300         labelTextPriority = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   301                     R_MMS_INFO_PRIORITY_LABEL, 
       
   302                     aFieldData.iPriority, neededHBufSpace, env );
       
   303         priorityAdded = ETrue;
       
   304         cleanupStackIndex++;
       
   305         }
       
   306 
       
   307     
       
   308     //To ----------------------------------------------------------------------
       
   309     HBufC* labelTextTo;
       
   310     labelTextTo = NULL;
       
   311     TBool toAdded( EFalse );
       
   312     if( aFieldData.iTo.Length() )
       
   313         {
       
   314         labelTextTo = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   315                     R_MESSAGE_INFO_TO_LABEL, 
       
   316                     aFieldData.iTo, neededHBufSpace, env );
       
   317         toAdded = ETrue;
       
   318         cleanupStackIndex++;
       
   319         }
       
   320         
       
   321     
       
   322     //Cc ----------------------------------------------------------------------
       
   323     HBufC* labelTextCc;
       
   324     labelTextCc = NULL;
       
   325     TBool ccAdded( EFalse );
       
   326     if( aFieldData.iCC.Length() )
       
   327         {
       
   328         labelTextCc = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   329                     R_MESSAGE_INFO_CC_LABEL, 
       
   330                     aFieldData.iCC, neededHBufSpace, env );
       
   331         ccAdded = ETrue;
       
   332         cleanupStackIndex++;
       
   333         }
       
   334 
       
   335     
       
   336     //Bcc ----------------------------------------------------------------------
       
   337     HBufC* labelTextBcc;
       
   338     labelTextBcc = NULL;
       
   339     TBool bccAdded( EFalse );
       
   340     if( aFieldData.iBCC.Length() )
       
   341         {
       
   342         labelTextBcc = ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   343                     R_MESSAGE_INFO_BCC_LABEL, 
       
   344                     aFieldData.iBCC, neededHBufSpace, env );
       
   345         bccAdded = ETrue;
       
   346         cleanupStackIndex++;
       
   347         }
       
   348     
       
   349     
       
   350     // Add all message info strings to queryDialogBuf and 
       
   351     // show queryDialogBuf in CAknMessageQueryDialog
       
   352     HBufC* queryDialogBuf;
       
   353     queryDialogBuf = NULL;
       
   354     
       
   355     queryDialogBuf = HBufC::NewLC( neededHBufSpace );
       
   356     cleanupStackIndex++;
       
   357     TBool firstItem(ETrue);
       
   358     //From -----------------------------------------------------------
       
   359     if( fromAdded && labelTextFrom )
       
   360         {
       
   361         AddToqueryDialogBuf( queryDialogBuf, *labelTextFrom, aFieldData.iFrom, firstItem );
       
   362         firstItem = EFalse;
       
   363         }
       
   364     //Subject --------------------------------------------------------
       
   365     if( subjectAdded && labelTextSubject )
       
   366         {
       
   367         AddToqueryDialogBuf( queryDialogBuf, *labelTextSubject, aFieldData.iSubject, firstItem );
       
   368         firstItem = EFalse;
       
   369         }
       
   370     
       
   371     //Date -----------------------------------------------------------
       
   372     if( dateAdded && labelTextDate )
       
   373         {
       
   374         AddToqueryDialogBuf( queryDialogBuf, *labelTextDate, dateStr, firstItem );
       
   375         firstItem = EFalse;
       
   376         }
       
   377     
       
   378     //Time -----------------------------------------------------------
       
   379     if( timeAdded && labelTextTime )
       
   380         {
       
   381         AddToqueryDialogBuf( queryDialogBuf, *labelTextTime, timeStr, firstItem  );
       
   382         firstItem = EFalse;
       
   383         }
       
   384     
       
   385     //Type -----------------------------------------------------------
       
   386     if( typeAdded && labelTextType )
       
   387         {
       
   388         AddToqueryDialogBuf( queryDialogBuf, *labelTextType, aFieldData.iType, firstItem );
       
   389         firstItem = EFalse;
       
   390         }
       
   391     
       
   392     //Size -----------------------------------------------------------
       
   393     if( sizeAdded && labelTextSize )
       
   394         {
       
   395         AddToqueryDialogBuf( queryDialogBuf, *labelTextSize, aFieldData.iSize, firstItem );
       
   396         firstItem = EFalse;
       
   397         }
       
   398     
       
   399     
       
   400     //Priority -------------------------------------------------------
       
   401     if( priorityAdded && labelTextPriority )
       
   402         {
       
   403         AddToqueryDialogBuf( queryDialogBuf, 
       
   404                              *labelTextPriority, aFieldData.iPriority, firstItem );
       
   405         firstItem = EFalse;
       
   406         }
       
   407     
       
   408     
       
   409     //To -------------------------------------------------------------
       
   410     if( toAdded && labelTextTo )
       
   411         {
       
   412         AddToqueryDialogBuf( queryDialogBuf, *labelTextTo, aFieldData.iTo, firstItem );
       
   413         firstItem = EFalse;
       
   414         }
       
   415     
       
   416     //Cc -------------------------------------------------------------
       
   417     if( ccAdded && labelTextCc )
       
   418         {
       
   419         AddToqueryDialogBuf( queryDialogBuf, *labelTextCc, aFieldData.iCC, firstItem );
       
   420         firstItem = EFalse;
       
   421         }
       
   422     
       
   423     //Bcc ------------------------------------------------------------
       
   424     if( bccAdded && labelTextBcc )
       
   425         {
       
   426         AddToqueryDialogBuf( queryDialogBuf, *labelTextBcc, aFieldData.iBCC, firstItem );
       
   427         firstItem = EFalse;
       
   428         }
       
   429     
       
   430     CAknMessageQueryDialog* dialog = CAknMessageQueryDialog::NewL( *queryDialogBuf );
       
   431     dialog->PrepareLC( R_MUIU_MESSAGE_QUERY );
       
   432     dialog->RunLD();
       
   433     CleanupStack::PopAndDestroy( cleanupStackIndex );
       
   434     }
       
   435 
       
   436 
       
   437 // ---------------------------------------------------------
       
   438 // Convert between arabic-indic digits and european digits based on existing language setting.
       
   439 // So it'll convert any digit from the string
       
   440 // to use either european digits or arabic-indic digits based on current settings.
       
   441 // @param aFieldString: Data buffer used in conversion.
       
   442 // @param aFieldData: Return converted data in this parameter.
       
   443 // ---------------------------------------------------------
       
   444 //
       
   445 void CMsgInfoMessageInfoDialog::DoNumberConversion( HBufC* aFieldString, 
       
   446                                                     TPtrC& aFieldData ) const
       
   447     {
       
   448     if( aFieldString )
       
   449         {
       
   450     	TPtr tmpPtr = aFieldString->Des();
       
   451     	if ( tmpPtr.Length() > 0 )
       
   452             {
       
   453             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tmpPtr );
       
   454             }
       
   455         aFieldData.Set( tmpPtr );
       
   456         }
       
   457     else
       
   458         {
       
   459         aFieldData.Set(KNullString);
       
   460         }
       
   461     }
       
   462 
       
   463 
       
   464 // ---------------------------------------------------------
       
   465 // Creates formatted date and time strings and return these strings in parameters
       
   466 // aDateBuf and aTimeBuf. Function get UTC time in parameter aUTCtime and
       
   467 // constructs date and time strings with this UTC time value.
       
   468 // @param aUTCtime: UTC time used in time conversion.
       
   469 // @param aDateBuf: Return date string after time conversion.
       
   470 // @param aTimeBuf: Return time string after time conversion. 
       
   471 //
       
   472 // ---------------------------------------------------------
       
   473 //
       
   474 void CMsgInfoMessageInfoDialog::GetFormattedTimeAndDateStringsL( TTime& aUTCtime, 
       
   475                                                                 TDes& aDateBuf, 
       
   476                                                                 TDes& aTimeBuf, 
       
   477                                                                 const CEikonEnv* aEikonEnv ) const
       
   478     {
       
   479     TLocale locale;
       
   480     
       
   481     // Get Universal time offset
       
   482     TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
       
   483     
       
   484     // Add locale's universal time offset to universal time to get the local time
       
   485     aUTCtime+=universalTimeOffset;
       
   486     
       
   487     // If home daylight saving in effect, add one hour offset. 
       
   488     if ( locale.QueryHomeHasDaylightSavingOn() )
       
   489         {
       
   490         TTimeIntervalHours daylightSaving( 1 );
       
   491         aUTCtime+=daylightSaving;
       
   492         }
       
   493     
       
   494     if( aEikonEnv )
       
   495         {
       
   496         //Set date and time
       
   497         HBufC* dateFormat = aEikonEnv->AllocReadResourceLC( R_QTN_DATE_USUAL_WITH_ZERO );
       
   498         aUTCtime.FormatL( aDateBuf, *dateFormat );
       
   499         CleanupStack::PopAndDestroy( dateFormat );//dateFormat
       
   500         
       
   501         HBufC* timeFormat = aEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
       
   502         aUTCtime.FormatL( aTimeBuf, *timeFormat );
       
   503         CleanupStack::PopAndDestroy( timeFormat );//timeFormat
       
   504         }
       
   505     else
       
   506         {
       
   507         // Does nothing
       
   508         }
       
   509     }
       
   510 
       
   511 
       
   512 // ---------------------------------------------------------
       
   513 // CMsgInfoMessageInfoDialog::ConstructLabelStrAndCalculateNeededSpaceLC
       
   514 //
       
   515 //
       
   516 // ---------------------------------------------------------
       
   517 //
       
   518 HBufC* CMsgInfoMessageInfoDialog::ConstructLabelStrAndCalculateNeededSpaceLC( 
       
   519                                                               TInt aLabelResourceId,
       
   520                                                               const TPtrC& aFieldText,
       
   521                                                               TInt& aNeededSpace, 
       
   522                                                               const CEikonEnv* aEikonEnv ) const
       
   523     {
       
   524     if( aEikonEnv )
       
   525         {
       
   526         TInt spaceFieldNeed;
       
   527         HBufC* labelTextStr = aEikonEnv->AllocReadResourceLC( aLabelResourceId );
       
   528         spaceFieldNeed = labelTextStr->Des().Length() + KExtraSpaceForLabelString;
       
   529         spaceFieldNeed = spaceFieldNeed + 
       
   530             aFieldText.Length() + KNumberOfLineFeeds * KExtraSpaceForLineFeed;
       
   531         aNeededSpace = aNeededSpace + spaceFieldNeed;
       
   532         return labelTextStr;
       
   533         }
       
   534     else
       
   535         {
       
   536         return NULL;
       
   537         }
       
   538     }
       
   539 
       
   540 
       
   541 
       
   542 // ---------------------------------------------------------
       
   543 // CMsgInfoMessageInfoDialog::AddToqueryDialogBuf
       
   544 //
       
   545 //
       
   546 // ---------------------------------------------------------
       
   547 //
       
   548 void CMsgInfoMessageInfoDialog::AddToqueryDialogBuf( HBufC* aQueryDialogBuf,
       
   549                                                      const TDesC& aLabelText,
       
   550                                                      const TDesC& aFieldText,
       
   551                                                      TBool aFirstItem ) const
       
   552     {
       
   553     if( aQueryDialogBuf )
       
   554         {
       
   555         if ( aFirstItem )
       
   556             {
       
   557             aQueryDialogBuf->Des().Append( aLabelText );
       
   558             aQueryDialogBuf->Des().Append( KLabelExtraString );
       
   559             aQueryDialogBuf->Des().Append( aFieldText );	
       
   560             }
       
   561         else
       
   562             {
       
   563             aQueryDialogBuf->Des().Append( KLineFeed );
       
   564             aQueryDialogBuf->Des().Append( KLineFeed );
       
   565             aQueryDialogBuf->Des().Append( aLabelText );
       
   566             aQueryDialogBuf->Des().Append( KLabelExtraString );
       
   567             aQueryDialogBuf->Des().Append( aFieldText );	
       
   568             }
       
   569         }
       
   570     }
       
   571 
       
   572 
       
   573 // ---------------------------------------------------------
       
   574 // CMsgInfoMessageInfoDialog::GroupPhoneNumberAndDoLangSpecificNumberConversion
       
   575 //
       
   576 //
       
   577 // ---------------------------------------------------------
       
   578 // 
       
   579 HBufC* CMsgInfoMessageInfoDialog::GroupPhoneNumberAndDoLangSpecificNumberConversionL( const TDesC& aFieldString )
       
   580     {
       
   581     HBufC* newString(NULL);
       
   582     if(aFieldString.Length())
       
   583         {	
       
   584         TPtrC16 name;
       
   585         TPtrC16 rightPartOfName;
       
   586         TPtrC16 number;
       
   587         TInt currentLength;
       
   588         TInt point1;
       
   589         TInt point2;
       
   590         TBool isEnd( EFalse );
       
   591 		
       
   592         point1 = aFieldString.Find( Ks1 );
       
   593 		
       
   594         if( point1 > KErrNotFound )
       
   595             {
       
   596             //There is phone number part so there is "<" )
       
   597             //For example string "Aa44 Bb55 <050 5899560>"
       
   598             currentLength = point1;
       
   599             name.Set( aFieldString.Left( currentLength ) );
       
   600             rightPartOfName.Set( aFieldString.Mid( currentLength ) );
       
   601             newString = HBufC::NewL( currentLength );
       
   602             TPtr newStringPtr = newString->Des();
       
   603             newStringPtr.Copy( name );
       
   604             }
       
   605         else
       
   606             {
       
   607             // There is no "<" char so there is only name part or 
       
   608             // phone number without "<" and ">" chars
       
   609             // For example "0505899560"
       
   610             HBufC* groupedNumberStr = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( aFieldString );
       
   611             TPtr groupedNumberPtr = groupedNumberStr->Des();
       
   612             currentLength = groupedNumberPtr.Length();
       
   613             newString = HBufC::NewL( currentLength );
       
   614             TPtr ptr = newString->Des();
       
   615             ptr.Copy( groupedNumberPtr );
       
   616             delete groupedNumberStr;
       
   617             groupedNumberStr = NULL;
       
   618             }
       
   619 		
       
   620 		
       
   621         while ( ( !isEnd ) && ( point1 > KErrNotFound ) )
       
   622             {
       
   623             point2 = rightPartOfName.Find( Ks2 );
       
   624             if( point2 > KErrNotFound )
       
   625                 {
       
   626                 number.Set( rightPartOfName.Left( point2 ) ); 
       
   627                 rightPartOfName.Set( rightPartOfName.Mid( point2 ) );
       
   628                 if ( number.Length() > 0 )
       
   629                     {
       
   630                     CleanupStack::PushL( newString );
       
   631                     HBufC* numberStr = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( number );
       
   632                     CleanupStack::Pop( newString );
       
   633                     TPtr numberPtr = numberStr->Des();
       
   634                     currentLength = currentLength + numberPtr.Length();
       
   635                     newString = newString->ReAlloc( currentLength );
       
   636                     TPtr ptr = newString->Des();
       
   637                     ptr.Append( numberPtr );
       
   638                     delete numberStr;
       
   639                     numberStr = NULL;
       
   640                     }
       
   641                 else
       
   642                     {
       
   643                     currentLength = currentLength + rightPartOfName.Length();
       
   644                     newString = newString->ReAlloc( currentLength );
       
   645                     TPtr ptr = newString->Des();
       
   646                     ptr.Append( rightPartOfName );
       
   647                     }
       
   648                 }
       
   649             else
       
   650                 {
       
   651                 isEnd = ETrue;
       
   652                 currentLength = currentLength + rightPartOfName.Length();
       
   653                 newString = newString->ReAlloc( currentLength );
       
   654                 TPtr ptr = newString->Des();
       
   655                 ptr.Append( rightPartOfName );
       
   656                 }
       
   657 			
       
   658             if( !isEnd )
       
   659 			          {
       
   660                 point1 = rightPartOfName.Find( Ks1 );
       
   661                 if( point1 > KErrNotFound )
       
   662                     {
       
   663                     name.Set( rightPartOfName.Left( point1 ) );
       
   664                     rightPartOfName.Set( rightPartOfName.Mid( point1 ) );
       
   665                     currentLength = currentLength + point1;
       
   666                     newString = newString->ReAlloc( currentLength );
       
   667                     TPtr ptr = newString->Des();
       
   668                     ptr.Append( name );	
       
   669                     }
       
   670                 else
       
   671                     {
       
   672                     currentLength = currentLength + rightPartOfName.Length();
       
   673                     newString = newString->ReAlloc( currentLength );
       
   674                     TPtr ptr = newString->Des();
       
   675                     ptr.Append( rightPartOfName );
       
   676                     }
       
   677 			          }
       
   678             }; //While
       
   679         return newString;
       
   680         }
       
   681     else
       
   682         {
       
   683         return newString;	
       
   684         }
       
   685     }
       
   686     
       
   687     
       
   688     
       
   689 // ---------------------------------------------------------
       
   690 // Set HBufC string to pointer descriptor.
       
   691 // 
       
   692 // 
       
   693 // ---------------------------------------------------------
       
   694 //
       
   695 void CMsgInfoMessageInfoDialog::SetStringToPointerDescriptor( HBufC* aFieldString, 
       
   696                                                         TPtrC& aFieldData ) const
       
   697     {
       
   698     if( aFieldString )
       
   699         {
       
   700     	  TPtr tmpPtr = aFieldString->Des();
       
   701         aFieldData.Set( tmpPtr );
       
   702         }
       
   703     else
       
   704         {
       
   705         aFieldData.Set( KNullString );
       
   706         }
       
   707     }
       
   708 
       
   709 
       
   710 // End of file