mobilemessaging/smum/src/SMSUCDMA.CPP
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     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 *     Sms Ui Mtm.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <bldvariant.hrh>
       
    23 
       
    24 // Specific includes
       
    25 #include <msvids.h>
       
    26 #include <smutset.h>
       
    27 #include <smuthdr.h>
       
    28 #include <tia637.h>
       
    29 #include <smsMessageSettings.h>
       
    30 #include <smsmessagewrappers.h>
       
    31 #include <csmsaccount.h>
       
    32 #include <MsvOffPeakTime.h>
       
    33 using namespace tia637;
       
    34 
       
    35 #include <smum.rsg>                       // resource ids
       
    36 #include <smutcmds.hrh>
       
    37 // Standard includes
       
    38 #include <txtrich.h>                     // CRichText
       
    39 // Comms includes
       
    40 #include <AknInputBlock.h>				 // CAknInputBlock
       
    41 #include <muiumsginfo.h>                 // CMsgInfoMessageInfoDialog
       
    42 // other includes
       
    43 #include <StringLoader.h>                // StringLoader
       
    44 #include <AknPhoneNumberGrouping.h>      //CAknPhoneNumberGrouping
       
    45 #include <msgbiouids.h>                  // KMsgBioUidPictureMsg
       
    46 #include <MsvScheduleSettings.h>         //
       
    47 // locals
       
    48 #include "SmumSettingsDialogCDMA.h"      // CSmumMainSettingsDialogCDMA
       
    49 #include "smsu.hrh"                      // for KMtmUiFunctionSimDialog
       
    50 #include "smsucdma.h"                    // CSmsMtmUiCDMA
       
    51 #include "smsui.pan"                     // panics
       
    52 #include <MsvSysAgentAction.h>           // for CMsvSysAgentActions
       
    53 
       
    54 #include <E32Property.h>                 // RProperty
       
    55 #include <PsVariables.h>                 // RProperty
       
    56 #include <SaCls.h>
       
    57 
       
    58 #include <CentralRepository.h>
       
    59 #include <MessagingInternalCRKeys.h>
       
    60 
       
    61 //  LOCAL CONSTANTS AND MACROS
       
    62 const TInt KMaxSubjectLength = 30;
       
    63 const TInt KSmumAdditionalCharsStringLength = 6;
       
    64 const TUint KSmumLRMarker = 0x200E;
       
    65 const TInt KDefMaxRetries = 1;
       
    66 const TInt KMsgQError = -31003;
       
    67 const TInt KPendingTimeout = 4320;
       
    68 _LIT( KSmumCharLeftAddressIterator, "<" );
       
    69 _LIT( KSmumCharRightAddressIterator, ">" );
       
    70 _LIT( KSmumCharCommaAndSpace, ", " );
       
    71 _LIT( KSmumSmsService, "Sms Service" );
       
    72 
       
    73 // Callback Number
       
    74 _LIT(KDefCallbackNumber, "");
       
    75 
       
    76 // Default values, if central repository data reading fails
       
    77 const TInt KDefDeliveryReport = 1;
       
    78 
       
    79 // Use for reading the callback number 
       
    80 const TInt KMaxPhoneNumberLength = 64;
       
    81 
       
    82 
       
    83 //  MEMBER FUNCTIONS
       
    84 
       
    85 // Factory constructor function
       
    86 CSmsMtmUiCDMA* CSmsMtmUiCDMA::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll )
       
    87     {
       
    88     CSmsMtmUiCDMA* smsmtmui=new ( ELeave ) CSmsMtmUiCDMA( aBaseMtm, aRegisteredMtmDll );
       
    89     CleanupStack::PushL( smsmtmui );
       
    90     smsmtmui->ConstructL();
       
    91     CleanupStack::Pop();
       
    92     return smsmtmui;
       
    93     }
       
    94 
       
    95 // C++ constructor can NOT contain any code, that
       
    96 // might leave.
       
    97 CSmsMtmUiCDMA::CSmsMtmUiCDMA( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ):
       
    98     CSmsMtmUi( aBaseMtm, aRegisteredMtmDll ),
       
    99     iMsgQueueTimeout( KPendingTimeout )
       
   100     {
       
   101     }
       
   102 
       
   103 // Symbian OS default constructor can leave.
       
   104 void CSmsMtmUiCDMA::ConstructL()
       
   105     {
       
   106     CSmsMtmUi::ConstructL();
       
   107     
       
   108     iNoCallbackNumber = StringLoader::LoadL( R_QTN_SMS_DETAIL_CALLBACK_NONE, iCoeEnv );
       
   109     }
       
   110 
       
   111 // Destructor
       
   112 CSmsMtmUiCDMA::~CSmsMtmUiCDMA()
       
   113     {
       
   114     delete iNoCallbackNumber;
       
   115     // iCenRepSession, iEditorFilename, iViewerFilename, iErrorResolver will be deallocated by its parent
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CSmsMtmUiCDMA::OpenL
       
   120 //
       
   121 // ---------------------------------------------------------
       
   122 CMsvOperation* CSmsMtmUiCDMA::OpenL(TRequestStatus& aStatus)
       
   123     {
       
   124 
       
   125     __ASSERT_DEBUG( 
       
   126         BaseMtm().Entry().Entry().iMtm == Type(), Panic( ESmsuWrongMtmType ));
       
   127     __ASSERT_DEBUG( BaseMtm().Entry().Entry().iType != 
       
   128         KUidMsvFolderEntry, Panic( ESmsuFoldersNotSupported ));
       
   129     __ASSERT_DEBUG( BaseMtm().Entry().Entry().iType != KUidMsvAttachmentEntry, 
       
   130         Panic( ESmsuAttachmentsNotSupported ));
       
   131 
       
   132     const TMsvEntry myEntry = BaseMtm().Entry().Entry();
       
   133     if( myEntry.iType == KUidMsvFolderEntry || myEntry.iType == KUidMsvAttachmentEntry )
       
   134         {
       
   135         User::Leave(KErrNotSupported);
       
   136         }
       
   137     else if ( myEntry.iType == KUidMsvMessageEntry )
       
   138         {
       
   139         CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue );
       
   140         }
       
   141     // read-only messages and messages in the sent folder will be shown using the
       
   142     // viewer.
       
   143     if (myEntry.ReadOnly() || myEntry.Parent() == KMsvSentEntryId)
       
   144         {
       
   145         return ViewL(aStatus);
       
   146         }
       
   147 
       
   148     return EditL(aStatus);
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------
       
   152 // CSmsMtmUiCDMA::InvokeSyncFunctionL
       
   153 //
       
   154 // ---------------------------------------------------------
       
   155 void CSmsMtmUiCDMA::InvokeSyncFunctionL(
       
   156     TInt aFunctionId, 
       
   157     const CMsvEntrySelection& aSelection, 
       
   158     TDes8& aParameter )
       
   159     {
       
   160     switch ( aFunctionId )
       
   161         {
       
   162 
       
   163         case KMtmUiFunctionSimDialog:
       
   164             break;
       
   165 
       
   166         case KMtmUiMessagingInitialisation:
       
   167         case KMtmUiFunctionRestoreFactorySettings: //deliberate fall through
       
   168             {
       
   169             TMsvId serviceEntryId = KMsvNullIndexEntryId;
       
   170             serviceEntryId = CreateSmsServiceL( EFalse );
       
   171             // Creates service settings and sets up default
       
   172             //
       
   173             CreateDefaultSettingsL( serviceEntryId );            
       
   174             break;
       
   175             }
       
   176         case KMtmUiFunctionSmumRemoveSMSC:
       
   177             break;
       
   178             
       
   179         default:
       
   180             CSmsMtmUi::InvokeSyncFunctionL( aFunctionId, aSelection, aParameter );
       
   181             return;
       
   182         }
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------
       
   186 // CSmsMtmUiCDMA::LaunchSettingsDialogL
       
   187 //
       
   188 // ---------------------------------------------------------
       
   189 CMsvOperation* CSmsMtmUiCDMA::LaunchSettingsDialogL( TRequestStatus& aStatus )
       
   190     {
       
   191     __ASSERT_DEBUG(
       
   192         BaseMtm().Entry().Entry().iMtm == Type(), Panic( ESmsuWrongMtmType ));
       
   193     __ASSERT_DEBUG(
       
   194         BaseMtm().Entry().Entry().iType.iUid == 
       
   195         KUidMsvServiceEntryValue, Panic( ESmsuNotAServiceEntry ));
       
   196 	
       
   197 	TInt err = KErrNone;
       
   198 	 
       
   199     // Load settings
       
   200     //
       
   201     CSmsAccount* smsAccount = CSmsAccount::NewLC();
       
   202     CSmsSettings* smsSettings = CSmsSettings::NewL();
       
   203     CleanupStack::PushL( smsSettings );
       
   204     smsAccount->LoadSettingsL( *smsSettings );
       
   205     	
       
   206     // Launch the service settings dialog on the current entry
       
   207     //
       
   208     TInt exitCode = ESmumSmsSettingsInitialvalue;
       
   209     TInt notUsed( 0 );
       
   210     CSmumMainSettingsDialog* mainSettingsDialog = CSmumMainSettingsDialog::NewL(
       
   211                                                   *smsSettings, ESmumMainSmsSettings, exitCode, notUsed );                                 
       
   212     mainSettingsDialog->ExecuteLD( R_MAIN_SETTINGS_DIALOG );
       
   213 
       
   214     // Save Settings
       
   215     // @todo what to do for conditional scheduling???
       
   216     //
       
   217     smsAccount->SaveSettingsL( *smsSettings );	
       
   218     CleanupStack::PopAndDestroy( 2, smsAccount ); // smsSettings, smsAccount
       
   219 	
       
   220     // Check if user wants to exit to idle = ESmumSmsSettingsMenuExit
       
   221     //
       
   222     if ( exitCode == ESmumSmsSettingsMenuExit )
       
   223     	{ // Exiting...
       
   224         err = EEikCmdExit;
       
   225         }
       
   226 
       
   227     return CMsvCompletedOperation::NewL(
       
   228         Session(), 
       
   229         Type(), 
       
   230         KNullDesC8, 
       
   231         KMsvLocalServiceIndexEntryId, 
       
   232         aStatus, 
       
   233         err);
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------
       
   237 // CSmsMtmUi::CreateSmsServiceL
       
   238 // Function should be deprecated now that we have Messaging_V2
       
   239 // ---------------------------------------------------------
       
   240 TMsvId CSmsMtmUiCDMA::CreateSmsServiceL( TBool aNoServiceNoCheckNeeded )
       
   241     {
       
   242     // Check for service if needed
       
   243     TMsvId serviceEntryId = KMsvNullIndexEntryId;
       
   244     TInt err = KErrNone;
       
   245     if ( !aNoServiceNoCheckNeeded )
       
   246         {
       
   247         TRAP( err, serviceEntryId = ServiceIdL());
       
   248         }
       
   249 
       
   250     // If no service, create one
       
   251     if ( err == KErrNotFound || aNoServiceNoCheckNeeded )
       
   252         {
       
   253         TMsvEntry entry;
       
   254         entry.iMtm = KUidMsgTypeSMS;
       
   255         entry.iType = KUidMsvServiceEntry;
       
   256         entry.SetReadOnly( EFalse );
       
   257         entry.SetVisible( EFalse );
       
   258         entry.iDate.HomeTime();
       
   259         entry.iDetails.Set( KSmumSmsService );
       
   260         CMsvEntry* root = Session().GetEntryL( KMsvRootIndexEntryId );
       
   261         CleanupStack::PushL( root );
       
   262         // In case no root store, create one...
       
   263         if ( !root->HasStoreL() )
       
   264             {
       
   265             // --- The entry does not have a store. EditStoreL() will create one ---
       
   266             CMsvStore* store = root->EditStoreL();
       
   267             CleanupStack::PushL( store );
       
   268             store->CommitL();
       
   269             CleanupStack::PopAndDestroy(); // store
       
   270             store = NULL; // destroyed
       
   271             }
       
   272         root->CreateL( entry );
       
   273         CleanupStack::PopAndDestroy(); // root
       
   274         BaseMtm().SwitchCurrentEntryL( entry.Id());
       
   275         serviceEntryId = entry.Id();
       
   276         iNewSmsSettings = ETrue;
       
   277         }
       
   278     else
       
   279         {
       
   280         User::LeaveIfError( err );
       
   281         }
       
   282 
       
   283     return serviceEntryId;
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------
       
   287 // CSmsMtmUiCDMA::ReadDefaultSettingsFromSharedDataL
       
   288 //
       
   289 // ---------------------------------------------------------
       
   290 void CSmsMtmUiCDMA::ReadDefaultSettingsFromSharedDataL( CSmsSettings* aServiceSettings )
       
   291     {
       
   292     if ( iCenRepSession )
       
   293     	{
       
   294         TInt readSetting;
       
   295         TBuf<KMaxPhoneNumberLength> readSettingStr;
       
   296 
       
   297         // Priority
       
   298         if ( iCenRepSession->Get( KSmumMsgPriority, readSetting ) != KErrNone )
       
   299             {
       
   300             readSetting = tia637::KBdNormal;
       
   301             }
       
   302         aServiceSettings->MessageSettings().Cdma().SetPriority(readSetting);//FYI:KBdUrgent=0x02;
       
   303             
       
   304         // Callback Number
       
   305         if ( iCenRepSession->Get( KSmumCallbackNumber, readSettingStr ) != KErrNone )
       
   306             {
       
   307             readSettingStr.Copy(KDefCallbackNumber);
       
   308             }
       
   309         aServiceSettings->MessageSettings().Cdma().SetCallBackNumberL(readSettingStr);
       
   310 
       
   311         // Default delivery report setting
       
   312         TBool isDeliveryReportSupported = EFalse;
       
   313         TBool isDeliveryReportEnabled = EFalse;
       
   314         // Transport ACK enabled
       
   315         // delivery/user/read ACK disabled
       
   316         TSmsReplyOptions reply(ETrue, EFalse, EFalse, EFalse);
       
   317 
       
   318         if ( iCenRepSession->Get( KSmumDefDelReport, isDeliveryReportSupported ) != KErrNone )
       
   319             {
       
   320             isDeliveryReportSupported = EFalse;
       
   321             }
       
   322         
       
   323         if ( isDeliveryReportSupported ) 
       
   324             {
       
   325             // @note Currently we are not supporting the Delivery Report (note) functionality
       
   326             if ( iCenRepSession->Get( KSmumDeliveryReport, isDeliveryReportEnabled ) != KErrNone )
       
   327                 {
       
   328                 isDeliveryReportEnabled = EFalse;
       
   329                 }
       
   330             reply.SetDeliveryAck(isDeliveryReportEnabled);
       
   331             aServiceSettings->SetDeliveryReport(isDeliveryReportEnabled);
       
   332             aServiceSettings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxInvisibleAndMatch);
       
   333             }
       
   334         else
       
   335             {
       
   336             aServiceSettings->SetStatusReportHandling(CSmsSettings::EDiscardReport);
       
   337             }        
       
   338         aServiceSettings->MessageSettings().SetReplyOptions(reply);
       
   339 
       
   340         // Message Queue On/Off
       
   341         if ( iCenRepSession->Get( KSmumMsgQueue, readSetting ) != KErrNone )
       
   342             {
       
   343             readSetting = EFalse;
       
   344             }
       
   345         iMsgQueueEnabled = readSetting;
       
   346 
       
   347         // Message Queue Timeout
       
   348         if ( iCenRepSession->Get( KSmumMsgQueueTimeout, readSetting ) != KErrNone )
       
   349             {
       
   350             readSetting = 0;
       
   351             }
       
   352         iMsgQueueTimeout = readSetting;
       
   353         }
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------
       
   357 // CSmsMtmUiCDMA::CreateDefaultSettingsL
       
   358 //
       
   359 // ---------------------------------------------------------
       
   360 void CSmsMtmUiCDMA::CreateDefaultSettingsL( TMsvId aServiceId )
       
   361     {
       
   362     // P&S account
       
   363     //
       
   364     CSmsAccount* smsAccount = CSmsAccount::NewLC();
       
   365 
       
   366     CSmsSettings* serviceSettings = CSmsSettings::NewL();
       
   367     CleanupStack::PushL(serviceSettings);
       
   368     	
       
   369     // Init Default Settings
       
   370     smsAccount->InitialiseDefaultSettingsL( *serviceSettings );  // Creates service entry
       
   371 
       
   372     // Enable specific bearer subparameters
       
   373     //
       
   374     serviceSettings->MessageSettings().Cdma().ActivateMessageSetting(tia637::KTUserData,ETrue);
       
   375     serviceSettings->MessageSettings().Cdma().ActivateMessageSetting(tia637::KTPriorityIndicator, ETrue);
       
   376     serviceSettings->MessageSettings().Cdma().ActivateMessageSetting(tia637::KTCallBackNumber, ETrue);
       
   377     serviceSettings->MessageSettings().Cdma().ActivateMessageSetting(tia637::KTReplyOption, ETrue);
       
   378     serviceSettings->MessageSettings().Cdma().ActivateMessageSetting(tia637::KTLanguageIndicator, ETrue);
       
   379 
       
   380     // Read the RFS related settings from Central Repository data/P&S
       
   381     ReadDefaultSettingsFromSharedDataL( serviceSettings );
       
   382 
       
   383     // Voice mail notification handling
       
   384     // Now handled in the Bio Watchers, keep sake only for now.
       
   385     //serviceSettings->SetVMNReportHandling(CSmsSettings::EMoveReportToInboxInvisible);
       
   386 
       
   387     serviceSettings->MessageSettings().SetEncoding( TSmsDataCodingScheme::ESmsAlphabet7Bit );
       
   388     serviceSettings->MessageSettings().Cdma().SetLanguage( tia637::KLanguageEnglish );
       
   389     //aServiceSettings->SetSmsAckRequest(ETrue) Transport ACK on by default... no need to set?
       
   390 
       
   391     // Setup Message Queuing Parameters
       
   392     //
       
   393     CMsvOffPeakTimes* peakTimes = new (ELeave) CMsvOffPeakTimes();
       
   394     CleanupStack::PushL(peakTimes);
       
   395     CMsvSendErrorActions* sendErrActions = CMsvSendErrorActions::NewLC();
       
   396     CMsvSysAgentActions* actions = new (ELeave) CMsvSysAgentActions();
       
   397     CleanupStack::PushL(actions);
       
   398     CMsvScheduleSettings* schSettings = CMsvScheduleSettings::NewL();
       
   399     CleanupStack::PushL(schSettings);
       
   400 
       
   401     // Get default settings from SMS Account
       
   402     //
       
   403     smsAccount->LoadSettingsL( *schSettings, *peakTimes, *sendErrActions, *actions );
       
   404     actions->Reset();
       
   405 
       
   406     // Message queuing condition to meet in order to send the message
       
   407     // Must have network coverage, if we do not have network coverage, we fail with -31003
       
   408     // Max retry of 3 days (3430minutes) and maximum of 1 retry
       
   409     //
       
   410     if ( iMsgQueueEnabled ) 
       
   411         {
       
   412         TMsvSysAgentConditionAction action;
       
   413         action.iUseDefaultSysAgentAction = EFalse;
       
   414         action.iErrorAction.iAction = ESendActionRetryConditionMet;
       
   415         action.iErrorAction.iRetries = ESendRetriesFixed;
       
   416         action.iErrorAction.iRetrySpacing = ESendRetrySpacingStatic;
       
   417         action.iErrorAction.iError  = KMsgQError;
       
   418         action.iErrorAction.SetMaxRetries(KDefMaxRetries);
       
   419 
       
   420         action.iCondition.iVariable = KUidNetworkStatus; //KUidNetworkStatus;
       
   421         action.iCondition.iState = ESANetworkAvailable;    //ESANetworkAvailable
       
   422         action.iCondition.iType = TMsvCondition::EMsvSchSendEquals;
       
   423         actions->AppendL(action);
       
   424         }
       
   425 
       
   426     // Set schedule time outs
       
   427     //
       
   428     schSettings->SetPendingConditionsTimeout( iMsgQueueTimeout );
       
   429 
       
   430     // Save Settings
       
   431     //
       
   432     smsAccount->SaveSettingsL( *serviceSettings );
       
   433 
       
   434     // Create the message store
       
   435     //
       
   436     CMsvEntry* service = Session().GetEntryL( aServiceId );
       
   437     CleanupStack::PushL( service );
       
   438     CMsvStore* msvstore = service->EditStoreL();
       
   439     CleanupStack::PushL( msvstore );
       
   440     msvstore->CommitL();    
       
   441     CleanupStack::PopAndDestroy( 2 ); // msvstore, service
       
   442 
       
   443     // Cleanup Pushed items
       
   444     //
       
   445     CleanupStack::PopAndDestroy( 5, serviceSettings ); //  serviceSettings,schSettings,
       
   446                                                        //  peaktimes,actions,sendErrActions
       
   447     CleanupStack::PopAndDestroy( smsAccount );
       
   448     }
       
   449 
       
   450 // ---------------------------------------------------------
       
   451 // CSmsMtmUi::ConstructAndShowInfoDialogL
       
   452 //
       
   453 // ---------------------------------------------------------
       
   454 void CSmsMtmUiCDMA::ConstructAndShowInfoDialogL() const
       
   455     {
       
   456     // Load the message
       
   457     //
       
   458     CSmsClientMtm& smsClientMtm = SmsClientMtm();
       
   459     smsClientMtm.LoadMessageL();
       
   460     
       
   461     // Message Header and SMS Settings
       
   462     //
       
   463     CSmsHeader& smsHeader = smsClientMtm.SmsHeader();
       
   464     TMsvMessageCdma& msg = smsHeader.CdmaMessage();
       
   465     
       
   466     // Structure to hold data for Message Info
       
   467     //
       
   468     TMsgInfoMessageInfoData infoData;
       
   469 
       
   470     const TMsvEntry tentry = smsClientMtm.Entry().Entry();
       
   471 
       
   472     // Temporary HBufs
       
   473     //
       
   474     HBufC* callback = NULL;
       
   475     HBufC* priority = NULL;
       
   476     HBufC* subject = NULL;
       
   477     HBufC* status = NULL;
       
   478 
       
   479     // Status
       
   480     //
       
   481     status = StatusTextL(tentry);
       
   482     if (status)
       
   483         {
       
   484         CleanupStack::PushL(status);
       
   485         }
       
   486 
       
   487     infoData.iStatus.Set(*status);
       
   488 
       
   489     // Subject
       
   490     // If this was a Picture Bio Message, show subject
       
   491     // Else, if it was a SMS message show subject field
       
   492     // For others, no subject field
       
   493     //
       
   494     if ( tentry.iBioType == KMsgBioUidPictureMsg.iUid )
       
   495         {           
       
   496         subject = ExtractTitleFromGMSBodyL( smsClientMtm.Body(), KMaxSubjectLength );
       
   497         CleanupStack::PushL( subject );          
       
   498         infoData.iSubject.Set( *subject );           
       
   499         }
       
   500     else if ( !tentry.iBioType )
       
   501         { //normal sms          
       
   502         //sms subject field (dialog truncates text to fit screen width and adds '...' so we don't need to do it here)
       
   503         TBuf<KMaxSubjectLength> subjText;
       
   504         subjText = smsClientMtm.Body().Read( 0, KMaxSubjectLength );
       
   505         subjText.TrimAll();
       
   506         subject = subjText.AllocLC();
       
   507         infoData.iSubject.Set( *subject );
       
   508         }
       
   509 
       
   510     // Callback Number
       
   511     //
       
   512     callback = msg.GetCallbackNumberL();
       
   513     if( callback != NULL )
       
   514         {
       
   515         CleanupStack::PushL(callback);
       
   516     	if ( callback->Length() >0 )
       
   517             {
       
   518             infoData.iCallback.Set(*callback); 
       
   519             }
       
   520         else 
       
   521             {
       
   522             infoData.iCallback.Set(*iNoCallbackNumber);
       
   523             }
       
   524         }
       
   525     else 
       
   526         {
       
   527         infoData.iCallback.Set(*iNoCallbackNumber);
       
   528         }
       
   529         
       
   530     // Priority
       
   531     //
       
   532     TPriorityIndicator priIndicator;
       
   533     msg.GetPriorityIndicatorL( priIndicator );
       
   534     switch( priIndicator )
       
   535     	{
       
   536         case tia637::KBdNormal :
       
   537             priority  = StringLoader::LoadLC( R_QTN_SMS_DET_PRIORITY_NOM, iCoeEnv );
       
   538             break;
       
   539         case tia637::KBdUrgent:
       
   540             priority  = StringLoader::LoadLC( R_QTN_SMS_DET_PRIORITY_URG, iCoeEnv );
       
   541             break;
       
   542         default:
       
   543             priority  = StringLoader::LoadLC( R_QTN_SMS_DET_PRIORITY_NOM, iCoeEnv );
       
   544             break;
       
   545         }
       
   546     infoData.iPriority.Set( *priority);
       
   547 
       
   548 
       
   549     // Sms type
       
   550     //
       
   551     HBufC* messageType = NULL; // Holds the message info text for sms
       
   552     if( tentry.iBioType )
       
   553         { 
       
   554 
       
   555         TInt resourceId( KErrNotFound );
       
   556 
       
   557         if ( tentry.iBioType == KMsgBioUidVCard.iUid )
       
   558             {
       
   559             resourceId = R_QTN_SM_INFO_BUSINESS_CARD;
       
   560             }
       
   561         else if ( tentry.iBioType == KMsgBioUidVCalendar.iUid )
       
   562             {
       
   563             resourceId = R_QTN_SM_INFO_CALENDAR;
       
   564             }
       
   565         else if ( tentry.iBioType == KMsgBioUidWmlBrSettings.iUid )
       
   566             {
       
   567             resourceId = R_QTN_SM_TITLE_CONFIGURATION;
       
   568             }
       
   569         else if ( tentry.iBioType == KMsgBioUidPictureMsg.iUid )
       
   570             {
       
   571             resourceId = R_QTN_SM_INFO_GMS;
       
   572             }
       
   573         else
       
   574             {
       
   575             // Don't change the resourceId
       
   576             }
       
   577 
       
   578         if ( resourceId != KErrNotFound )
       
   579             {
       
   580             messageType = iEikonEnv->AllocReadResourceLC( resourceId );
       
   581             infoData.iType.Set( *messageType );
       
   582             }
       
   583         else
       
   584             {
       
   585             infoData.iType.Set(tentry.iDescription);
       
   586             }
       
   587         }
       
   588     else
       
   589         {
       
   590         //sms type
       
   591         messageType = StringLoader::LoadLC( R_QTN_SMS_MINFO_TYPE_SMS, iCoeEnv );
       
   592         infoData.iType.Set( *messageType );
       
   593         }
       
   594 
       
   595     // Sms date and time
       
   596     //
       
   597     TMsvEntry entry = smsClientMtm.Entry().Entry();
       
   598     infoData.iDateTime = entry.iDate;   
       
   599     
       
   600     // Recipient info check if we are MO or MT
       
   601     // 
       
   602     if ( smsHeader.MessageType() == KSmsTypeDeliver )
       
   603         { 
       
   604         // Want to show 'viewer' type fields
       
   605         // Sms 'from' field
       
   606         //
       
   607         HBufC* senderNumber = smsHeader.FromAddress().AllocLC();
       
   608         HBufC* fromText = HBufC::NewLC( entry.iDetails.Length() + senderNumber->Length() + KSmumAdditionalCharsStringLength ); // for the chars: '<' '>' 2 x KSmumLRMarker
       
   609         
       
   610         // Do we have alias?
       
   611         if ( senderNumber->Compare( entry.iDetails ))
       
   612             { // yes
       
   613             TPtr fromTextPtr = fromText->Des();
       
   614             fromTextPtr.Append( entry.iDetails );
       
   615             fromTextPtr.Append( KSmumLRMarker );
       
   616             fromTextPtr.Append( KSmumCharLeftAddressIterator );
       
   617 
       
   618             // Before we append a number, we have to number group it
       
   619             HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( *senderNumber );
       
   620             CleanupStack::PushL(groupedNumber);
       
   621             fromTextPtr.Append( groupedNumber->Des() );
       
   622             CleanupStack::PopAndDestroy(groupedNumber);
       
   623 
       
   624             fromTextPtr.Append( KSmumCharRightAddressIterator );
       
   625             fromTextPtr.Append( KSmumLRMarker );
       
   626             infoData.iFrom.Set( *fromText );
       
   627             }
       
   628         else
       
   629             { // no
       
   630             infoData.iFrom.Set( *senderNumber );
       
   631             }
       
   632         
       
   633         CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL();
       
   634         infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::ESmsViewer );
       
   635 
       
   636         if ( fromText )
       
   637             {
       
   638             CleanupStack::PopAndDestroy( fromText );
       
   639             }
       
   640         if ( senderNumber )
       
   641             {
       
   642             CleanupStack::PopAndDestroy( senderNumber );
       
   643             }
       
   644         }
       
   645     else
       
   646         { 
       
   647         // EditType is ETrue, want to show 'editor' type fields
       
   648         // Sms 'to:' list
       
   649         //
       
   650         HBufC* toList = TurnRecipientsArrayIntoStringLC( smsHeader.Recipients());
       
   651         infoData.iTo.Set( *toList );
       
   652 
       
   653         CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL();
       
   654         if( tentry.iBioType )
       
   655             {
       
   656             infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::EBiosEditor );
       
   657             }
       
   658         else
       
   659             {
       
   660             infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::ESmsEditor );
       
   661             }
       
   662 
       
   663         CleanupStack::PopAndDestroy(toList);
       
   664         }
       
   665 
       
   666 	
       
   667     // Cleanup 
       
   668     //
       
   669     if ( messageType )
       
   670         {
       
   671         CleanupStack::PopAndDestroy( messageType );
       
   672         }
       
   673 
       
   674     if ( priority )
       
   675         {
       
   676         CleanupStack::PopAndDestroy( priority );
       
   677         }
       
   678 
       
   679     if ( callback )
       
   680         {
       
   681         CleanupStack::PopAndDestroy( callback );
       
   682         }
       
   683 
       
   684     if ( subject )
       
   685         {
       
   686         CleanupStack::PopAndDestroy( subject );
       
   687         }
       
   688 
       
   689     if ( status)
       
   690         {
       
   691         CleanupStack::PopAndDestroy( status);
       
   692         }
       
   693         
       
   694     }
       
   695 
       
   696 // ---------------------------------------------------------
       
   697 // CSmsMtmUiCDMA::CheckAndEnsureSmsServiceOkL
       
   698 //
       
   699 // ---------------------------------------------------------
       
   700 TInt CSmsMtmUiCDMA::CheckAndEnsureSmsServiceOkL( TBool aCreateService, TBool aCreateStore, TBool /*aFetchSMSCs*/ )
       
   701     {
       
   702     TInt recreation = ESmsReCreatedNone;
       
   703     TMsvId currContext = iBaseMtm.Entry().Entry().Id(); // take current context to safe
       
   704     TMsvId serviceEntryId = KMsvNullIndexEntryId;
       
   705     
       
   706     // Check first do we have service entry...
       
   707     TRAPD( err, serviceEntryId = ServiceIdL());
       
   708     if ( err == KErrNotFound && aCreateService )
       
   709         { // ...no, let's create one
       
   710         iNewSmsSettings = EFalse;
       
   711         CreateDefaultSettingsL( serviceEntryId );
       
   712         recreation = ESmsReCreatedService;
       
   713         iBaseMtm.SwitchCurrentEntryL( currContext );
       
   714         }
       
   715     else if ( err == KErrNone ) 
       
   716         {
       
   717         // If service ok, then check do we have msg store for it...
       
   718         iBaseMtm.SwitchCurrentEntryL( serviceEntryId );
       
   719         if ( !iBaseMtm.Entry().HasStoreL() && aCreateStore )
       
   720             { // ...no, let's create one
       
   721             iNewSmsSettings = EFalse;
       
   722             CreateDefaultSettingsL( serviceEntryId );
       
   723             recreation = recreation ? ESmsReCreatedBoth : ESmsReCreatedServicesStore;
       
   724             }
       
   725         iBaseMtm.SwitchCurrentEntryL( currContext );
       
   726         }
       
   727 
       
   728     return recreation;
       
   729     }
       
   730 
       
   731 // ---------------------------------------------------------
       
   732 // CSmsMtmUi::TurnRecipientsArrayIntoStringLC
       
   733 //
       
   734 // ---------------------------------------------------------
       
   735 HBufC* CSmsMtmUiCDMA::TurnRecipientsArrayIntoStringLC( 
       
   736     const CArrayPtrFlat<CSmsNumber>& aRecip, 
       
   737     const TBool /*aEmailMessage*/ ) const
       
   738     {
       
   739     //calc length of string needed
       
   740     TInt stringLength = 0;
       
   741     TInt index;
       
   742     TInt count = aRecip.Count();
       
   743 
       
   744     // Do north american number grouping first, the length is no longer the same!
       
   745     for( index = 0; index < count; index++ )
       
   746         {
       
   747         stringLength += aRecip[index]->Name().Length();
       
   748         HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( aRecip[index]->Address() );
       
   749         stringLength += groupedNumber->Length();
       
   750         delete groupedNumber;
       
   751         stringLength += KSmumAdditionalCharsStringLength; // for the 6 chars: '<' '>' ', ' 2 x KSmumLRMarker
       
   752         }
       
   753     //construct string
       
   754     HBufC* toList = HBufC::NewLC( stringLength );
       
   755     for( index=0; index < count; index++ )
       
   756         {
       
   757         TPtrC name = aRecip[index]->Name();
       
   758         TPtrC number = aRecip[index]->Address();
       
   759         TPtr toListPtr = toList->Des();
       
   760         if( name.Length())
       
   761             {
       
   762             toListPtr.Append( name );
       
   763             toListPtr.Append( KSmumLRMarker );
       
   764             toListPtr.Append( KSmumCharLeftAddressIterator );
       
   765 
       
   766             // Before we append a number, we have to number group it
       
   767             HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( number );
       
   768             CleanupStack::PushL(groupedNumber);
       
   769             toListPtr.Append( groupedNumber->Des() );
       
   770             CleanupStack::PopAndDestroy(groupedNumber);
       
   771 
       
   772             toListPtr.Append( KSmumCharRightAddressIterator );
       
   773             toListPtr.Append( KSmumLRMarker );
       
   774             }
       
   775         else
       
   776             {
       
   777             HBufC* groupedNumber = CAknPhoneNumberGrouping::CreateGroupedPhoneNumberL( number );
       
   778             CleanupStack::PushL(groupedNumber);
       
   779             toListPtr.Append( groupedNumber->Des() );
       
   780             CleanupStack::PopAndDestroy(groupedNumber);
       
   781             }
       
   782         
       
   783         if ( index < ( count - 1 )) // comma needed?
       
   784             {
       
   785             toListPtr.Append( KSmumCharCommaAndSpace );
       
   786             }
       
   787         }
       
   788 
       
   789     return toList;
       
   790     }       
       
   791 
       
   792 
       
   793 // ---------------------------------------------------------
       
   794 // CSmsMtmUiCDMA::StatusTextL
       
   795 //
       
   796 // ---------------------------------------------------------
       
   797 HBufC* CSmsMtmUiCDMA::StatusTextL( const TMsvEntry& aContext ) const
       
   798     {
       
   799     TInt res = 0;
       
   800     TUint sendingState = aContext.SendingState();
       
   801     switch( sendingState )
       
   802         {
       
   803         case KMsvSendStateFailed:
       
   804             res = R_QTN_MCE_OUTBOX_STATUS_FAILED;
       
   805             break;
       
   806 
       
   807         case KMsvSendStateUponRequest: // Mapped to be the same
       
   808         case KMsvSendStateSuspended:
       
   809             res = R_QTN_MCE_OUTBOX_STATUS_SUSPENDED;
       
   810             break;
       
   811         
       
   812         case KMsvSendStateScheduled: // Mapped to be the same
       
   813         case KMsvSendStateWaiting:
       
   814             res = R_QTN_MCE_OUTBOX_STATUS_WAITING;
       
   815             break;
       
   816             
       
   817         case KMsvSendStateResend:
       
   818             res = R_QTN_MCE_OUTBOX_STATUS_RETRY_AT;
       
   819             break;
       
   820             
       
   821         case KMsvSendStateSending:
       
   822             res = R_QTN_MCE_OUTBOX_STATUS_SENDING;
       
   823             break;
       
   824         
       
   825         case KMsvSendStateSent:
       
   826             res = R_QTN_MCE_OUTBOX_STATUS_SENT;
       
   827             break;
       
   828         case KMsvSendStateNotApplicable:
       
   829             res = 0;
       
   830             break;
       
   831         default:
       
   832             User::Leave( KErrNotSupported );
       
   833             break;
       
   834         }
       
   835     
       
   836         if (!res)
       
   837             {
       
   838             return HBufC::NewL(0);
       
   839             }
       
   840       
       
   841         if ( sendingState == KMsvSendStateResend )
       
   842             {
       
   843             TBuf<KTBuf80Length> bufTimeFormat;
       
   844             TBuf<KTBuf80Length> bufTimeFormatted;
       
   845             StringLoader::Load( 
       
   846                 bufTimeFormat, R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv );
       
   847             aContext.iDate.FormatL( bufTimeFormatted, bufTimeFormat );
       
   848             return StringLoader::LoadL( 
       
   849                 R_QTN_MCE_OUTBOX_STATUS_RETRY_AT, bufTimeFormatted, iCoeEnv );
       
   850             }
       
   851         else
       
   852             {
       
   853             return StringLoader::LoadL( res, iCoeEnv );
       
   854             }
       
   855     }
       
   856 
       
   857 //  End of File