messagingfw/deprecate/senduiservices/src_old/SendUiImpl.cpp
branchRCL_3
changeset 22 d2c4c66342f3
equal deleted inserted replaced
21:e5b3a2155e1a 22:d2c4c66342f3
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   Can be used to show "Send" list query and to create and send
       
    15 *                messages via available sending services. Created messages are
       
    16 *                sent directly or message editor is opened for editing,
       
    17 *                depending on the type of the selected service.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #include <coemain.h>
       
    23 #include <Sendnorm.rsg>
       
    24 #include <AknListQueryDialog.h>
       
    25 #include <eikmenup.h>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 #include <DRMHelper.h>
       
    28 #include <centralrepository.h>
       
    29 #include <e32cmn.h> // Uid
       
    30 #include <e32property.h>
       
    31 #include <barsread.h>
       
    32 #include <akninputblock.h>
       
    33 #include <centralrepository.h>
       
    34 #include <miutset.h>
       
    35 #include <MessagingDomainCRKeys.h>
       
    36 
       
    37 // Features
       
    38 #include <FeatMgr.h>    
       
    39 #include <bldvariant.hrh>
       
    40 #include <msgmimetypes.h>
       
    41 #include <CSendingServiceInfo.h>
       
    42 #include <CSendingService.h>
       
    43 #include <CMessageData.h>
       
    44 #include <SendUiConsts.h>
       
    45 #include <senduisingleton.h>
       
    46 
       
    47 #include "SendUiImpl.h"
       
    48 #include "senduiserviceclient.h"
       
    49 #include "SendUiCapabilityCheck.h"
       
    50 #include "SendUiUtils.h"
       
    51 #include "senduiserviceslog.h"              // Logging
       
    52 #include "SendUiPrivateCRKeys.h"
       
    53 #include "senduiproperty.h"
       
    54 #include "propertyobserver.h"
       
    55 #include "senduilauncher.h"
       
    56 #include "SendUiInternalConsts.h"
       
    57 
       
    58 
       
    59 const TInt KArrayGranularity = 2;
       
    60 const TInt KSendUiServiceOrderArrayGranularity = 6;
       
    61 const TInt KTitleBufLength = 64;
       
    62 
       
    63 
       
    64 _LIT( KSendUiResourceFileName,"sendnorm.rsc" );
       
    65 
       
    66 // ======== MEMBER FUNCTIONS ========
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSendUiImpl::NewL
       
    69 // Two-phased constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CSendUiImpl* CSendUiImpl::NewL()
       
    73     {
       
    74     CSendUiImpl* self = new( ELeave ) CSendUiImpl;
       
    75     
       
    76     CleanupStack::PushL( self );
       
    77     self->ConstructL();
       
    78     CleanupStack::Pop( self );
       
    79 
       
    80     return self;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // Destructor
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CSendUiImpl::~CSendUiImpl()
       
    88     {
       
    89     iResourceLoader.Close();
       
    90     TInt count = iSendingServices.Count();
       
    91     while ( count )
       
    92         {
       
    93         delete iSendingServices[--count];
       
    94         }
       
    95     iSendingServices.Close();
       
    96     delete iSendUiServicesOrderArray;
       
    97     delete iServicesToDim;
       
    98     delete iPropertyObserver;
       
    99     delete iSingleton;
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // AddTypedMenuItemL
       
   104 //
       
   105 // No menu item is added, if services are not found. This can happen if asyncronous
       
   106 // sending service update is not yet finished.
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 void CSendUiImpl::AddTypedMenuItemL(
       
   110     CSendUi::TSendUiMenuType    aMenuType,
       
   111     CEikMenuPane&               aMenuPane,
       
   112     TInt                        aIndex,
       
   113     TInt                        aCommandId,
       
   114     TSendingCapabilities        aRequiredCapabilities )
       
   115     {
       
   116     TInt i(0);
       
   117     TBool menuItemAdded = EFalse;
       
   118     TBuf<KTitleBufLength> menuItemName;
       
   119     
       
   120      // Read the resources
       
   121     aMenuType == CSendUi::ESendMenu ? 
       
   122         i = R_SENDUI_MENUITEM_SEND : 
       
   123         i = R_SENDUI_MENUITEM_WRITE; // CSendUi::EWriteMenu
       
   124         
       
   125     iCoeEnv->ReadResourceL( menuItemName, i );
       
   126   
       
   127     for ( i = 0; i < iSendingServices.Count(); i++ )
       
   128     {
       
   129     TUid serviceUid = iSendingServices[i]->ServiceId();
       
   130     if ( QueryCapabilities( i, aRequiredCapabilities ) )
       
   131         {
       
   132         CEikMenuPaneItem::SData data;
       
   133         data.iCascadeId = NULL;
       
   134         data.iText = menuItemName;
       
   135         data.iCommandId = aCommandId;
       
   136 
       
   137         if ( aIndex == aMenuPane.NumberOfItemsInPane() )
       
   138             {
       
   139             aMenuPane.AddMenuItemL( data );
       
   140             }
       
   141         else
       
   142             {
       
   143             aMenuPane.InsertMenuItemL( data, aIndex );
       
   144             }
       
   145             
       
   146         menuItemAdded = ETrue;
       
   147         break;
       
   148         }
       
   149     }
       
   150 
       
   151     // Hide menu item if sending is already in progress.
       
   152     if ( menuItemAdded )
       
   153         {
       
   154         aMenuPane.SetItemDimmed( aCommandId, iIsSending);
       
   155         }        
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // ShowTypedQueryAndSendL
       
   160 // First shows list query and then creates the message.
       
   161 // Editor is launched for editing the message or the message is sent
       
   162 // directly without opening the editor. Functionality depends on the
       
   163 // type of selected sending service.
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CSendUiImpl::ShowTypedQueryAndSendL(
       
   167     CSendUi::TSendUiMenuType    aMenuType,
       
   168     const CMessageData*         aMessageData,
       
   169     TSendingCapabilities        aRequiredCapabilities,
       
   170     CArrayFix<TUid>*            aServicesToDim,
       
   171     TBool                       aLaunchEditorEmbedded,
       
   172     const TDesC&                aTitleText )
       
   173     {
       
   174     TUid serviceId = ShowTypedQueryL(
       
   175         aMenuType,
       
   176         aMessageData,
       
   177         aRequiredCapabilities,
       
   178         aServicesToDim,
       
   179         aTitleText );
       
   180 
       
   181     if ( serviceId != KNullUid )
       
   182         {
       
   183         // Process user selection.
       
   184         CreateAndSendMessageL(
       
   185             serviceId,
       
   186             aMessageData,
       
   187             aLaunchEditorEmbedded);
       
   188         }
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // ShowTypedQueryL
       
   193 // Shows list query and returns the user selection.
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 TUid CSendUiImpl::ShowTypedQueryL(
       
   197     CSendUi::TSendUiMenuType    aMenuType,
       
   198     const CMessageData*         aMessageData,
       
   199     TSendingCapabilities        aRequiredCapabilities,
       
   200     CArrayFix<TUid>*            aServicesToDim,
       
   201     const TDesC&                aTitleText )
       
   202     {
       
   203     // Implemented for CR # 401-1806 >>    
       
   204     // This section to enable/disable features (supported by feature manager) at run time, is to be revised,
       
   205     // once an observer class is available from feature manager side to intimate about feature state
       
   206 		
       
   207     CRepository* repository = CRepository::NewLC( KCRUidSendUi );
       
   208     TInt oldFeatures(0);   
       
   209     TInt newFeatures(0); 
       
   210     TBool updateNeeded( EFalse );   
       
   211     
       
   212     if ( repository->Get( KKeySendUiFeatureManagerServices, oldFeatures ) != KErrNone )
       
   213     	{
       
   214     	updateNeeded = ETrue;
       
   215     	}
       
   216     FeatureManager::InitializeLibL();
       
   217     FeatureStatus( KFeatureIdMmsPostcard, newFeatures, KSendUiPostcard );
       
   218     FeatureStatus( KFeatureIdAudioMessaging, newFeatures, KSendUiAudioMessage );
       
   219     FeatureStatus( KFeatureIdSenduiMmsUpload, newFeatures, KSendUiMmsUpload );
       
   220     FeatureManager::UnInitializeLib();
       
   221     if ( newFeatures != oldFeatures )
       
   222         {
       
   223         repository->Set( KKeySendUiFeatureManagerServices, newFeatures );
       
   224         updateNeeded = ETrue;
       
   225         }
       
   226 
       
   227     CleanupStack::PopAndDestroy( repository );
       
   228     
       
   229     RProperty propertyUpdateOperation;
       
   230     TRequestStatus status;
       
   231     if ( updateNeeded )
       
   232         {
       
   233         RProperty::Set( 
       
   234             KPSUidSendUiProperty, 
       
   235             KSendUiUpdateRequest, 
       
   236             KSendUiUpdateRequested );
       
   237         User::LeaveIfError( propertyUpdateOperation.Attach( KPSUidSendUiProperty, KSendUiUpdateRequest ));
       
   238         propertyUpdateOperation.Subscribe( status );	
       
   239         User::WaitForRequest(status);
       
   240         TInt value = KErrNone;
       
   241         if(propertyUpdateOperation.Get( value ) !=KErrNotFound && value == KSendUiUpdated )
       
   242             {
       
   243             TRAPD( err, GetServicesL() );
       
   244             if ( err )
       
   245                 {
       
   246 #ifdef _DEBUG
       
   247                 TBuf<256> buf;
       
   248                 buf.Format(_L("SendUi err"));
       
   249                 User::InfoPrint(buf);
       
   250 #endif
       
   251                 TUid serviceId( KNullUid );
       
   252                 return serviceId;
       
   253                 }
       
   254             }
       
   255         propertyUpdateOperation.Close();
       
   256         }
       
   257     // Implemented for CR # 401-1806 <<    
       
   258     // List items for list query.
       
   259     CDesCArrayFlat* listItems = new (ELeave) CDesCArrayFlat( KArrayGranularity );
       
   260     CleanupStack::PushL( listItems);
       
   261 
       
   262     // This array is used to map user selection to correct service.
       
   263     CArrayFix<TUid>* listItemUids = 
       
   264         new ( ELeave ) CArrayFixFlat<TUid>( KArrayGranularity );
       
   265     CleanupStack::PushL( listItemUids );
       
   266 
       
   267     iServicesToDim->Reset();
       
   268 
       
   269     TInt i = 0;
       
   270     if ( aServicesToDim )
       
   271         {
       
   272         for ( i = 0; i < aServicesToDim->Count(); i++  )
       
   273             {
       
   274             iServicesToDim->AppendL( (*aServicesToDim)[i] );
       
   275             }
       
   276         }
       
   277   
       
   278     // Get and filter ECom based services.
       
   279     FilterServicesL(
       
   280         *listItems,
       
   281         *listItemUids,
       
   282         aRequiredCapabilities,
       
   283         aMessageData,
       
   284         aMenuType );
       
   285 
       
   286     TUid serviceId( KNullUid );
       
   287     if ( listItems->Count() > 0 )
       
   288         {
       
   289         // Show list query.
       
   290         SortListL( *listItems, *listItemUids );
       
   291 
       
   292         serviceId = ShowListQueryL(
       
   293             listItems,
       
   294             *listItemUids,
       
   295             aTitleText,
       
   296             aMenuType );
       
   297         }
       
   298 
       
   299     CleanupStack::PopAndDestroy( 2, listItems );  // listItemUids, listItems
       
   300 
       
   301     return serviceId;
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // SendMessageL
       
   306 // -----------------------------------------------------------------------------
       
   307 TInt CSendUiImpl::SendMessageL(    
       
   308     TUid                    aServiceUid,
       
   309     const CMessageData*     aMessageData,
       
   310     TBool                   aLaunchEditorEmbedded)
       
   311     { 
       
   312     if ( iIsSending || aServiceUid == KNullUid )
       
   313         {
       
   314         return KErrNone;
       
   315         }
       
   316         
       
   317         CAknInputBlock* absorber = CAknInputBlock::NewLC( ); 
       
   318         // Ensures proper sending state if leave happens.
       
   319         iIsSending = ETrue;
       
   320         TInt success( KErrNone );
       
   321         CleanupStack::PushL( TCleanupItem( ResetIsSending, (TAny*)&iIsSending ) );
       
   322 
       
   323         // Create the requested ECom service.
       
   324         TInt i( ResolveServiceIndex( aServiceUid ));
       
   325         if ( i != KErrNotFound )
       
   326             {
       
   327             TRAP( success, 
       
   328                 CSendingService* sendingService = CSendingService::NewL( 
       
   329                     iSendingServices[i]->ServiceProviderId(), *iCoeEnv, *iSingleton );
       
   330                 CleanupStack::PushL( sendingService );  
       
   331                 
       
   332                 sendingService->CreateAndSendMessageL( aServiceUid, aMessageData, aLaunchEditorEmbedded );
       
   333                 CleanupStack::PopAndDestroy( sendingService );
       
   334                     );
       
   335                 
       
   336             }
       
   337         else
       
   338             {
       
   339             iIsSending = EFalse;
       
   340             }
       
   341     CleanupStack::PopAndDestroy( 2, absorber); // TCleanupItem, absorber
       
   342     return success;
       
   343     }
       
   344 
       
   345 // -----------------------------------------------------------------------------
       
   346 // SendMessageViaServer
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 void CSendUiImpl::SendMessageViaServerL( 
       
   350     TUid                    aServiceUid,
       
   351     const CMessageData*     aMessageData,
       
   352     TBool                   aLaunchEditorEmbedded )
       
   353     {
       
   354     TInt index( ResolveServiceIndex( aServiceUid ));
       
   355     TBool capabilitiesOk = ETrue;
       
   356     if ( index == KErrNotFound )
       
   357     	{
       
   358     	return;
       
   359     	}
       
   360     if ( iSendingServices[index]->ServiceFeatures() & CSendingServiceInfo::EServiceCanSendDirectly )
       
   361     	{
       
   362 	    // Check sending rights
       
   363 	    RProcess process;
       
   364 	    TSecurityInfo securityInfo( process );
       
   365 	    CSendUiCapabilityCheck* capabilityCheck = CSendUiCapabilityCheck::NewLC();
       
   366 
       
   367 		capabilitiesOk = capabilityCheck->CheckCapabilitiesL( 
       
   368 		    securityInfo, 
       
   369 		    iSingleton->MsvSessionL(), 
       
   370 		    KSenduiMtmMmsUid, 
       
   371 		    iSendingServices[index]->ServiceName() );
       
   372 		    
       
   373 		CleanupStack::PopAndDestroy( capabilityCheck );
       
   374 	    }
       
   375     
       
   376     if ( capabilitiesOk )
       
   377     	{
       
   378         TUid providerUid = iSendingServices[index]->ServiceProviderId();	
       
   379 	    RSendUiServiceClient sendUiClient;
       
   380 	    CleanupClosePushL( sendUiClient );
       
   381 	    sendUiClient.ConnectChainedAppL( KSendUiLauncherAppUid );
       
   382 	    // LaunchSendUiL is syncronous operation
       
   383 	    sendUiClient.LaunchSendUiL( 
       
   384 	        aServiceUid,
       
   385 	        providerUid,
       
   386 	        aLaunchEditorEmbedded, 
       
   387 	        aMessageData ); 
       
   388 	    CleanupStack::PopAndDestroy( &sendUiClient);
       
   389     	}
       
   390 	    
       
   391     }
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CreateAndSendMessageL
       
   395 // Creates the message and launches the editor for editing the message
       
   396 // or sends the message directly without opening the editor. 
       
   397 // Functionality depends on the type of selected sending service.
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 void CSendUiImpl::CreateAndSendMessageL(
       
   401     TUid                    aServiceUid,
       
   402     const CMessageData*     aMessageData,
       
   403     TBool                   aLaunchEditorEmbedded )
       
   404     {
       
   405     LOGTEXT(_L("CSendUiImpl::CreateAndSendMessageL >>"));
       
   406     TInt err(0); // initializing this to 0 helps debugging SendMessageViaServerL
       
   407     err = SendMessageL( aServiceUid, aMessageData, aLaunchEditorEmbedded );
       
   408     if ( !iServerAppLaunch && ( err == KErrPermissionDenied || err == KErrAccessDenied ) )
       
   409         {
       
   410         SendMessageViaServerL( aServiceUid, aMessageData, aLaunchEditorEmbedded );
       
   411         }
       
   412     else
       
   413        	{
       
   414         User::LeaveIfError( err );
       
   415        	}
       
   416     LOGTEXT(_L("CSendUiImpl::CreateAndSendMessageL <<"));
       
   417    }
       
   418 
       
   419 // -----------------------------------------------------------------------------
       
   420 // ServiceCapabilitiesL
       
   421 // Returns sending capabilities of the sending service.
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 TInt CSendUiImpl::ServiceCapabilities(
       
   425     TUid                    aServiceUid,
       
   426     TSendingCapabilities&   aServiceCapabilities )
       
   427     {
       
   428     TInt i( ResolveServiceIndex( aServiceUid ));
       
   429     
       
   430     if ( i != KErrNotFound )
       
   431         {
       
   432         aServiceCapabilities = 
       
   433             iSendingServices[i]->ServiceCapabilities();
       
   434         i = KErrNone;        
       
   435         }
       
   436     return i;
       
   437     }
       
   438 
       
   439 // -----------------------------------------------------------------------------
       
   440 // AvailableServicesL
       
   441 // Populates given list with the information about services
       
   442 // provided by specified ECom service provider.
       
   443 // (other items were commented in a header).
       
   444 // -----------------------------------------------------------------------------
       
   445 //
       
   446 
       
   447 void CSendUiImpl::AvailableServicesL(
       
   448     RPointerArray<CSendingServiceInfo>& aServiceList,
       
   449     TUid aServiceProvider)
       
   450     {
       
   451     for ( TInt i(0); i < iSendingServices.Count(); i++ )
       
   452         {
       
   453         if ( iSendingServices[i]->ServiceProviderId() == aServiceProvider 
       
   454             || aServiceProvider == KNullUid )
       
   455             {
       
   456             CSendingServiceInfo* serviceInfo = iSendingServices[i]->CopyLC();
       
   457             aServiceList.AppendL( serviceInfo );
       
   458             CleanupStack::Pop( serviceInfo ); // serviceInfo
       
   459             }
       
   460         }
       
   461     }
       
   462 // -----------------------------------------------------------------------------
       
   463 // TechnologyType
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 TUid CSendUiImpl::TechnologyType( TUid aServiceUid )
       
   467     {
       
   468     TInt i = ResolveServiceIndex( aServiceUid );
       
   469     if ( i != KErrNotFound )
       
   470         {
       
   471         return iSendingServices[i]->TechnologyTypeId(); 
       
   472         }
       
   473     else
       
   474         {        
       
   475         return TUid::Null();
       
   476         }
       
   477     }
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 TInt CSendUiImpl::ResolveServiceIndex( TUid aServiceUid )
       
   484     {
       
   485     TInt index( iSendingServices.Count() );
       
   486     
       
   487     while( --index >= 0)
       
   488         {
       
   489         if ( iSendingServices[index]->ServiceId() == aServiceUid )
       
   490             {
       
   491             return index;           
       
   492             }
       
   493         }
       
   494     return KErrNotFound;
       
   495     }
       
   496 
       
   497 // -----------------------------------------------------------------------------
       
   498 // QueryCapabilities
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 TBool CSendUiImpl::QueryCapabilities( 
       
   502     TInt index, 
       
   503     TSendingCapabilities aRequiredCapabilities )
       
   504     {
       
   505     if ( index == KErrNotFound )
       
   506     	{
       
   507     	return EFalse;
       
   508     	}
       
   509 
       
   510      if ( aRequiredCapabilities.iFlags == TSendingCapabilities::EAllServices )
       
   511         { 
       
   512         // No capabilities required from service
       
   513         return ETrue;
       
   514         }
       
   515     TSendingCapabilities serviceCap = iSendingServices[ index ]->ServiceCapabilities();
       
   516     
       
   517     if ( !(serviceCap.iMessageSize == 0 // no size limit set for the service
       
   518     || aRequiredCapabilities.iMessageSize == 0 ) // no size limit asked from the client
       
   519     && aRequiredCapabilities.iMessageSize > serviceCap.iMessageSize )
       
   520         {
       
   521         return EFalse;
       
   522         }
       
   523     
       
   524     // Check if support for attachments are required.
       
   525     if ( aRequiredCapabilities.iFlags & TSendingCapabilities::ESupportsAttachments
       
   526         && serviceCap.iFlags & TSendingCapabilities::ESupportsAttachments )
       
   527         {
       
   528         return ETrue;
       
   529         }
       
   530 
       
   531     // Check if support for body text is required.
       
   532     if ( aRequiredCapabilities.iFlags & TSendingCapabilities::ESupportsBodyText )
       
   533         {
       
   534         if ( serviceCap.iFlags & TSendingCapabilities::ESupportsBodyText )
       
   535             {
       
   536             if ( serviceCap.iBodySize > 0 && aRequiredCapabilities.iBodySize > serviceCap.iBodySize )
       
   537                 {
       
   538                 return EFalse; // size limit defined and it is enough
       
   539                 }
       
   540             // no size limit in service for bodytext or required size below max size.
       
   541             return ETrue;
       
   542             }
       
   543         }
       
   544         
       
   545     
       
   546     // Check if support for BIO sending is required.
       
   547         if ( aRequiredCapabilities.iFlags & TSendingCapabilities::ESupportsBioSending 
       
   548              && serviceCap.iFlags & TSendingCapabilities::ESupportsBioSending )
       
   549             {
       
   550             return ETrue;
       
   551             }
       
   552 
       
   553     // Check if support for editor is required.
       
   554         if ( aRequiredCapabilities.iFlags & TSendingCapabilities::ESupportsEditor
       
   555              && serviceCap.iFlags & TSendingCapabilities::ESupportsEditor )
       
   556             {
       
   557             return ETrue;
       
   558             }
       
   559     return EFalse;
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // CSendUiImpl::GetServicesL
       
   564 // 
       
   565 // (other items were commented in a header).
       
   566 // -----------------------------------------------------------------------------
       
   567 //
       
   568 
       
   569 void CSendUiImpl::GetServicesL( )
       
   570 {
       
   571     TInt value(0);
       
   572     TInt serviceCount;
       
   573     TInt cleanupItems(0);
       
   574     
       
   575     CRepository* rep = CRepository::NewLC( KCRUidSendUi );
       
   576     cleanupItems++;
       
   577     TInt err = rep->Get( KKeySendUiServiceCount, serviceCount );
       
   578     
       
   579     if ( err )
       
   580         {
       
   581         LOGTEXT(_L("SendUiImpl->GetServicesL: Cenrep init file missing"));
       
   582         CleanupStack::PopAndDestroy( rep );
       
   583         return;
       
   584         }
       
   585     else
       
   586         {
       
   587         if ( serviceCount == KSendUiNotInitialized )
       
   588             {
       
   589             // Services has not been initialized, launch service resolver in the bacground.
       
   590             CleanupStack::PopAndDestroy( rep);
       
   591             // iSendingServices are updated, when update is done.
       
   592             RProperty::Set( 
       
   593                 KPSUidSendUiProperty, 
       
   594                 KSendUiUpdateRequest, 
       
   595                 KSendUiUpdateRequested); 
       
   596 
       
   597             return;            
       
   598             }
       
   599         }
       
   600     
       
   601     while ( iSendingServices.Count() )
       
   602         {
       
   603         delete iSendingServices[0];
       
   604         iSendingServices.Remove(0);
       
   605         }
       
   606         
       
   607     HBufC* text = HBufC::NewLC( KSendUiServiceMaxNameLength );
       
   608     cleanupItems++;
       
   609     TPtr ptr = text->Des();
       
   610     TInt key;
       
   611     for( TInt i(0); i < serviceCount; i++ )
       
   612         {
       
   613         key = KSendUiServiceIndex * i;
       
   614         CSendingServiceInfo* info = CSendingServiceInfo::NewLC();
       
   615     
       
   616         err = rep->Get( key | KSendUiServiceId, value );
       
   617         if (!err )
       
   618             {
       
   619             info->SetServiceId( TUid::Uid( value  ));
       
   620             }
       
   621 
       
   622         err = rep->Get( key | KSendUiServiceProviderId, value );
       
   623         if (!err )
       
   624             {
       
   625             info->SetServiceProviderId( TUid::Uid( value  ));
       
   626             }
       
   627 
       
   628        err = rep->Get( key | KSendUiServiceName, ptr );
       
   629         if (!err)
       
   630             {
       
   631             __ASSERT_DEBUG( ptr.Length() <= KSendUiServiceMaxNameLength, User::Invariant() );
       
   632             info->SetServiceNameL( ptr );
       
   633             }
       
   634         
       
   635         err = rep->Get( key | KSendUiServiceMenuName, ptr );
       
   636         if (!err)
       
   637             {
       
   638             __ASSERT_DEBUG( ptr.Length() <= KSendUiServiceMaxNameLength, User::Invariant() );
       
   639             info->SetServiceMenuNameL( ptr );
       
   640             }
       
   641         
       
   642         err = rep->Get( key | KSendUiServiceAddress, ptr );
       
   643         if (!err)
       
   644             {
       
   645             __ASSERT_DEBUG( ptr.Length() <= KSendUiServiceMaxNameLength, User::Invariant() );
       
   646             info->SetServiceAddressL( ptr );
       
   647             }
       
   648         
       
   649         TSendingCapabilities cap;
       
   650             
       
   651         err = rep->Get( key | KSendUiServiceFlags, value );
       
   652         if (!err)
       
   653             {
       
   654             cap.iFlags = value;
       
   655             }
       
   656         
       
   657         err = rep->Get( key | KSendUiServiceBodySize, value );
       
   658         if (!err)
       
   659             {
       
   660             cap.iBodySize = value;
       
   661             }
       
   662         
       
   663         err = rep->Get( key | KSendUiServiceMessageSize, value );
       
   664         if (!err)
       
   665             {
       
   666             cap.iMessageSize = value;
       
   667             }
       
   668     
       
   669     
       
   670         err = rep->Get( key | KSendUiServiceTechnologyType, value );
       
   671         if (!err )
       
   672             {
       
   673             info->SetTechnologyTypeId( TUid::Uid( value  ));
       
   674             }
       
   675         
       
   676         err = rep->Get( key | KSendUiServiceFeatures, value );
       
   677         if (!err)
       
   678             {
       
   679             info->SetServiceFeatures( value );
       
   680             }
       
   681     
       
   682         if (!err)
       
   683             {
       
   684             info->SetServiceCapabilities( cap );            
       
   685             iSendingServices.Append( info );
       
   686             CleanupStack::Pop( info);
       
   687             }
       
   688 
       
   689         }
       
   690     
       
   691     CleanupStack::PopAndDestroy( cleanupItems, rep); // text, rep
       
   692     
       
   693 }
       
   694 
       
   695 // ---------------------------------------------------------
       
   696 // ShowListQueryL(
       
   697 // Displays list query.
       
   698 // (other items were commented in a header).
       
   699 // ---------------------------------------------------------
       
   700 // 
       
   701 TUid CSendUiImpl::ShowListQueryL(
       
   702     MDesCArray*                 aListItems,
       
   703     const CArrayFix<TUid>&      aListItemUids,
       
   704     const TDesC&                aTitleText,
       
   705     CSendUi::TSendUiMenuType    aMenuType )
       
   706     {
       
   707     // Show list query.
       
   708     TInt choice = KErrNotFound;
       
   709     CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &choice );
       
   710     TInt ret = 0;
       
   711     TRAPD( err, 
       
   712     dlg->PrepareLC( R_SENDUI_LIST_QUERY );
       
   713     dlg->SetItemTextArray( aListItems );
       
   714     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   715 
       
   716     // Set title
       
   717     CAknPopupHeadingPane* heading = dlg->Heading();
       
   718 
       
   719     if ( aTitleText != KNullDesC )
       
   720         {
       
   721         heading->SetTextL( aTitleText );
       
   722         }
       
   723     else 
       
   724         {
       
   725         HBufC* title;
       
   726         TInt titleId(0);
       
   727         if (aMenuType == CSendUi::ESendMenu )
       
   728             {
       
   729             titleId = R_SENDUI_LIST_QUERY_TITLE ;
       
   730             }
       
   731         else if ( aMenuType == CSendUi::EWriteMenu )
       
   732             {
       
   733             titleId = R_SENDUI_LIST_QUERY_TITLE_WRITE;
       
   734             }
       
   735         
       
   736         if ( titleId )
       
   737             {
       
   738             title = iCoeEnv->AllocReadResourceLC( titleId );
       
   739             heading->SetTextL( *title );
       
   740             CleanupStack::PopAndDestroy( title );
       
   741             }
       
   742         }
       
   743     
       
   744     ret = dlg->RunLD();
       
   745     ); //end of TRAPD
       
   746     
       
   747     if( err == KLeaveExit )
       
   748         {
       
   749         delete dlg;
       
   750         dlg = NULL;
       
   751         }
       
   752     
       
   753     if ( !ret )
       
   754         {
       
   755         return KNullUid;
       
   756         }
       
   757     return aListItemUids.At( choice );
       
   758     }
       
   759 
       
   760 
       
   761 // -----------------------------------------------------------------------------
       
   762 // CanSendContentL
       
   763 // -----------------------------------------------------------------------------
       
   764 //
       
   765 TBool CSendUiImpl::CanSendContentL(
       
   766     TUid                    aServiceUid,
       
   767     TUid                    aServiceProviderId,
       
   768     const CMessageData*     aMessageData,
       
   769     TDataType*              aMimeType )
       
   770     {
       
   771     // Other ecoms are filtered by their base provider, but versitile MTMs under 
       
   772     // GenericMtmPlugin have filtering by their serviceUid    
       
   773     if ( aServiceProviderId != KGenericMtmPlugin )
       
   774     {
       
   775         aServiceUid = aServiceProviderId;
       
   776     }
       
   777     // Content based filtering is done only for some selected services.
       
   778     // Cannot filter with no data, certain services and audio message (if no audiomessage support)
       
   779     if ( !aMessageData ||
       
   780          !( aServiceUid == KDrmLinkSender || 
       
   781             aServiceUid == KSenduiMtmPostcardUid ||
       
   782             aServiceUid == KMmsDirectUpload ||
       
   783             aServiceUid == KMmsIndirectUpload ||
       
   784             aServiceUid == KSenduiMtmAudioMessageUid ||
       
   785             aServiceUid == KSenduiMtmSmsUid ) )                            
       
   786         {
       
   787         return ETrue;
       
   788         }
       
   789 
       
   790 
       
   791     const CDesCArray& attachmentPaths = aMessageData->AttachmentArray();
       
   792     const RArray<RFile>& attachments = aMessageData->AttachmentHandleArray();
       
   793 
       
   794     TInt attachmentCount = attachmentPaths.Count() + attachments.Count();
       
   795 
       
   796     if ( attachmentCount == 0 )
       
   797         { // No content to send
       
   798         
       
   799         if ( aServiceUid == KDrmLinkSender )
       
   800             {
       
   801             return EFalse;
       
   802             }
       
   803         TInt bodyTextLength = aMessageData->BodyText()->DocumentLength();
       
   804         // Dim MMS Upload services, if there is no bodytext
       
   805         if ( ( aServiceUid == KMmsDirectUpload 
       
   806             || aServiceUid == KMmsIndirectUpload ) 
       
   807             && bodyTextLength == 0 )
       
   808             {
       
   809             return EFalse; // bodytext will be converted into attachment
       
   810             }
       
   811         // Dim Audio message, if there is bodytext    
       
   812         if ( aServiceUid == KSenduiMtmAudioMessageUid 
       
   813             && bodyTextLength > 0 )
       
   814             {
       
   815             return EFalse;
       
   816             }
       
   817         return ETrue;
       
   818         }
       
   819     else if ( attachmentCount == 1  )
       
   820         {
       
   821         TBool result = ETrue;
       
   822         
       
   823         switch ( aServiceUid.iUid )
       
   824             {
       
   825             case KSenduiMtmSmsUidValue: 
       
   826                 {
       
   827                 if ( aMimeType->Des8().CompareF( KMsgMimeVCard ) != 0 &&
       
   828                      aMimeType->Des8().CompareF( KMsgMimeVCal ) != 0 )
       
   829                     {
       
   830                     result = EFalse;
       
   831                     }
       
   832                 break;
       
   833                 }
       
   834             case KSenduiMtmPostcardUidValue:
       
   835                 {
       
   836                 if( aMimeType->Des8().CompareF( KMsgMimeImageJpeg ) != 0 &&
       
   837                     aMimeType->Des8().CompareF( KMsgMimeImageGif ) != 0 &&
       
   838                     aMimeType->Des8().CompareF( KMsgMimeImagePng ) != 0 &&
       
   839                     aMimeType->Des8().CompareF( KMsgMimeTextPlain ) != 0 )
       
   840                     {
       
   841                     // Supported types: jpeg, png, gif, plain text
       
   842                     result = EFalse;
       
   843                     }
       
   844                 }
       
   845                 break;   
       
   846             case KSenduiMtmAudioMessageUidValue:
       
   847                 {
       
   848                 if( aMimeType->Des8().CompareF( KMsgMimeAudioAmr ) != 0 ||
       
   849                     aMessageData->BodyText()->DocumentLength() > 0 )
       
   850                     {
       
   851                     // Does not allow other than amr attachment and empty bodytext
       
   852                     result = EFalse;
       
   853                     }
       
   854                 }    
       
   855                 break;    
       
   856             case KDrmLinkSenderValue:
       
   857                 {
       
   858                 // Check OMA DRM level
       
   859 
       
   860                 TInt drmMethod = 0;
       
   861                 CDRMHelper::TDRMHelperOMALevel omaDRMLevel;
       
   862                 CDRMHelper* drmHelper = NULL;
       
   863                 TRAPD( error, drmHelper = CDRMHelper::NewL( iFs ) );
       
   864                 if ( error != KErrNone )
       
   865                     {
       
   866                     return error;
       
   867                     }
       
   868                 error = drmHelper->SupportedDRMMethods2( drmMethod, omaDRMLevel );
       
   869                 if ( !(omaDRMLevel & CDRMHelper::EOMA_2_0 ))
       
   870                      {
       
   871                      result = EFalse;
       
   872                      break;
       
   873                      }
       
   874                 delete drmHelper;
       
   875 
       
   876 
       
   877                 if ( attachmentPaths.Count() )
       
   878                     {
       
   879                     RFile handle = SendUiUtils::OpenFileHandleL( attachmentPaths.MdcaPoint(0), iFs );
       
   880                     CleanupClosePushL( handle );
       
   881                     result = SendUiUtils::HasContentUrlL( handle );
       
   882                     CleanupStack::PopAndDestroy( &handle );
       
   883                     }
       
   884                 else
       
   885                     {
       
   886                     result = SendUiUtils::HasContentUrlL( const_cast<RFile&>( attachments[0] ) );
       
   887                     }
       
   888                 }
       
   889                 break;
       
   890             default:
       
   891                 // Should never end up here
       
   892                 break;
       
   893             }
       
   894      
       
   895         return result;        
       
   896         }
       
   897     else if ( attachmentCount > 1  )
       
   898         {
       
   899         if ( aServiceUid == KDrmLinkSender ||
       
   900              aServiceUid == KSenduiMtmPostcardUid ||
       
   901              aServiceUid == KSenduiMtmAudioMessageUid ||
       
   902              aServiceUid == KSenduiMtmSmsUid )
       
   903             {
       
   904             // Currently supports sending of one file only
       
   905             // or no files (SMS)
       
   906             return EFalse;
       
   907             }
       
   908         return ETrue;
       
   909         }
       
   910    
       
   911    // Should never end up here
       
   912    return ETrue;
       
   913    }
       
   914 
       
   915 // -----------------------------------------------------------------------------
       
   916 // CSendUiImpl::FilterServicesL
       
   917 // 
       
   918 // (other items were commented in a header).
       
   919 // -----------------------------------------------------------------------------
       
   920 //
       
   921 void CSendUiImpl::FilterServicesL(
       
   922     CDesCArrayFlat&         aListItems,
       
   923     CArrayFix<TUid>&        aListItemUids,
       
   924     TSendingCapabilities    aRequiredCapabilities,
       
   925     const CMessageData*     aMessageData,
       
   926     CSendUi::TSendUiMenuType    aMenuType  )
       
   927     {
       
   928     TInt i = 0;
       
   929     TInt cc = 0;
       
   930     TBool dimService = EFalse;
       
   931 	TDataType* mimeType = NULL;
       
   932 	TInt cleanupItems(0);
       
   933     // Filter some services away if there is no content to be send.
       
   934     if ( !aMessageData )
       
   935         {
       
   936         iServicesToDim->AppendL( KDrmLinkSender );
       
   937         iServicesToDim->AppendL( KMmsDirectUpload );
       
   938         iServicesToDim->AppendL( KMmsIndirectUpload );
       
   939         iServicesToDim->AppendL( KShareOnline );
       
   940         }
       
   941     else if ( aMessageData->AttachmentArray().Count() == 1
       
   942             || aMessageData->AttachmentHandleArray().Count() == 1 )
       
   943     	{
       
   944     	// CanSendContent can recycle these in mime type resolving
       
   945     	// for all services that have attachments
       
   946 		mimeType = new (ELeave) TDataType();
       
   947 		CleanupStack::PushL( mimeType );
       
   948 		cleanupItems++;
       
   949 				
       
   950 	    if ( aMessageData->AttachmentArray().Count() )
       
   951             {
       
   952             RFile handle = SendUiUtils::OpenFileHandleL(
       
   953                 aMessageData->AttachmentArray().MdcaPoint( 0 ), iFs );
       
   954             CleanupClosePushL( handle );
       
   955             SendUiUtils::ResolveMimeTypeL( handle, *mimeType );
       
   956             CleanupStack::PopAndDestroy( &handle );
       
   957             }
       
   958         else
       
   959             {
       
   960             SendUiUtils::ResolveMimeTypeL( aMessageData->AttachmentHandleArray()[0], *mimeType );
       
   961             }
       
   962     	}
       
   963     TBool addMailService = EFalse;
       
   964     TUid integratedEmailClientMtmUid;
       
   965 		
       
   966     if ( iEmailClientIntegration )
       
   967     	{
       
   968     	CRepository* repository = NULL;
       
   969     	TInt mtmPluginID = 0;
       
   970     	TRAPD( ret, repository = CRepository::NewL( KCRUidSelectableDefaultEmailSettings ) );
       
   971     	
       
   972     	if(ret == KErrNone)
       
   973     	    {
       
   974     	    //Get Email application mtm plugin ID
       
   975     	    repository->Get( KIntegratedEmailAppMtmPluginId, mtmPluginID ); 
       
   976     	    }
       
   977 
       
   978     	delete repository;
       
   979     	integratedEmailClientMtmUid = TUid::Uid(mtmPluginID);
       
   980     	for( i = 0 ; i < iSendingServices.Count(); i++ )
       
   981     		{
       
   982     		TUid serviceUid = iSendingServices[i]->ServiceId();
       
   983     		// Check if it is found in sendingServices and it's valid, then hide
       
   984     		if ( integratedEmailClientMtmUid == iSendingServices[i]->ServiceId() && 
       
   985     				CheckServiceCapabilities( serviceUid, aRequiredCapabilities ) &&
       
   986     				CanSendContentL( serviceUid, 
       
   987     							     iSendingServices[i]->ServiceProviderId(), 
       
   988     							     aMessageData, mimeType ) )
       
   989     			{
       
   990     			addMailService = ETrue;
       
   991     			}
       
   992     		}
       
   993     	
       
   994     	}
       
   995 
       
   996     // Filter available ECom services and add to list item array.
       
   997     // Capability based filtering: CheckServiceCapabilities
       
   998     // Content based filtering: CanSendContentL
       
   999     // "dimmable array" filtering: done here
       
  1000     TInt serviceFeatures;
       
  1001     for( i = 0 ; i < iSendingServices.Count(); i++ )
       
  1002         {
       
  1003         dimService = EFalse;
       
  1004         TUid serviceUid = iSendingServices[i]->ServiceId();
       
  1005         TUid serviceProviderUid = iSendingServices[i]->ServiceProviderId();
       
  1006         
       
  1007         if ( iSendingServices[i]->ServiceMenuName() == KNullDesC )
       
  1008             {
       
  1009             dimService = ETrue;
       
  1010             }
       
  1011         
       
  1012         TUid serviceTechnologyType = iSendingServices[i]->TechnologyTypeId();
       
  1013         TUid dimServiceUid;
       
  1014         for ( cc = 0; cc < iServicesToDim->Count(); cc++ )
       
  1015             {
       
  1016 			dimServiceUid = (*iServicesToDim)[cc];
       
  1017             if ( dimServiceUid == serviceUid 
       
  1018             || dimServiceUid == serviceProviderUid
       
  1019             || dimServiceUid == serviceTechnologyType 
       
  1020             )
       
  1021                 {
       
  1022                 dimService = ETrue;
       
  1023                 break;
       
  1024                 }
       
  1025             }
       
  1026         if ( iEmailClientIntegration )
       
  1027             {
       
  1028             //Hide Email application (not the platform email) from "send" menu
       
  1029             if( integratedEmailClientMtmUid == iSendingServices[i]->ServiceId() )
       
  1030                 {
       
  1031                 dimService = ETrue;
       
  1032                 }  
       
  1033             }
       
  1034 		serviceFeatures = iSendingServices[i]->ServiceFeatures();
       
  1035         if ( iEmailClientIntegration )
       
  1036         	{
       
  1037         	//If there is a mailbox created by integrated mail client then 
       
  1038         	//put SMTP MTM ("Email") in the "send" menu, by changing the 
       
  1039         	//serviceFeature    
       
  1040         	if ( addMailService && 
       
  1041         		 ( iSendingServices[i]->ServiceId() == KUidMsgTypeSMTP ) )
       
  1042         		{
       
  1043         		serviceFeatures = 0;
       
  1044         		addMailService = EFalse; //MailService must be added only once
       
  1045         		}
       
  1046         	}       
       
  1047         if ( !dimService &&
       
  1048              !( serviceFeatures & CSendingServiceInfo::EServiceInValid ) &&
       
  1049              !( serviceFeatures & CSendingServiceInfo::EServiceHidden )
       
  1050              &&  CheckServiceCapabilities( serviceUid, aRequiredCapabilities ) &&
       
  1051              CanSendContentL( serviceUid, serviceProviderUid, aMessageData, mimeType ) )
       
  1052             {
       
  1053             if ( aMenuType == CSendUi::ESendMenu )
       
  1054                 {
       
  1055                 aListItems.AppendL(iSendingServices[i]->ServiceMenuName() );
       
  1056                 }
       
  1057             else if ( aMenuType == CSendUi::EWriteMenu )
       
  1058                 {
       
  1059                 aListItems.AppendL(iSendingServices[i]->ServiceName() );
       
  1060                 }
       
  1061 
       
  1062             aListItemUids.AppendL( serviceUid );
       
  1063             }
       
  1064         }
       
  1065     CleanupStack::PopAndDestroy( cleanupItems );
       
  1066     }
       
  1067 
       
  1068 // -----------------------------------------------------------------------------
       
  1069 // SortListL
       
  1070 // Sets ECom services to correct positions in "Send"-list query.
       
  1071 // -----------------------------------------------------------------------------
       
  1072 //
       
  1073 void CSendUiImpl::SortListL(
       
  1074     CDesCArrayFlat&     aListItems,
       
  1075     CArrayFix<TUid>&    aListItemUids )
       
  1076     {
       
  1077     TInt insertIndex(0);
       
  1078     TUid positionUid;   
       
  1079     TInt j;
       
  1080     // set the services into correct order. The order is predefined in the resources.
       
  1081     for ( TInt i = 0; i < iSendUiServicesOrderArray->Count() ; i++ )
       
  1082         {
       
  1083         positionUid = TUid::Uid( (*iSendUiServicesOrderArray)[i] );
       
  1084         for (j = insertIndex; j < aListItems.Count(); j++ )
       
  1085             {
       
  1086             TUid tmp = aListItemUids[j];
       
  1087             if ( positionUid == aListItemUids[j] ) 
       
  1088                 {
       
  1089                 if ( j >= insertIndex )
       
  1090                     {
       
  1091                     HBufC* serviceName = aListItems[j].AllocL();
       
  1092                     CleanupStack::PushL( serviceName );
       
  1093 
       
  1094                     aListItemUids.Delete( j );
       
  1095                     aListItems.Delete( j );
       
  1096 
       
  1097                     aListItemUids.InsertL( insertIndex, positionUid );
       
  1098                     aListItems.InsertL( insertIndex, *serviceName );
       
  1099                     CleanupStack::PopAndDestroy( serviceName );
       
  1100                     insertIndex++;      
       
  1101                     }
       
  1102                 else
       
  1103                     {
       
  1104                     // service already on the right place. Next.
       
  1105                     insertIndex++;  
       
  1106                     }
       
  1107                     
       
  1108                 }
       
  1109             }
       
  1110         }
       
  1111     }
       
  1112 
       
  1113 
       
  1114 // ---------------------------------------------------------
       
  1115 // ResetIsSending
       
  1116 // Resets sending state flag.
       
  1117 // ---------------------------------------------------------
       
  1118 //    
       
  1119 void CSendUiImpl::ResetIsSending( TAny* aAny )
       
  1120     {
       
  1121     *( (TBool*)aAny ) = EFalse;
       
  1122     }
       
  1123 
       
  1124 // -----------------------------------------------------------------------------
       
  1125 // CheckServiceCapabilities
       
  1126 // Compares ECom service sending capabilities to required capabilities.
       
  1127 // (other items were commented in a header).
       
  1128 // -----------------------------------------------------------------------------
       
  1129 //
       
  1130 TBool CSendUiImpl::CheckServiceCapabilities(
       
  1131     TUid                    aServiceUid,
       
  1132     TSendingCapabilities    aRequiredCapabilities )
       
  1133     {
       
  1134     TInt i = 0;
       
  1135     TSendingCapabilities serviceCapabilities;
       
  1136 
       
  1137     // No capabilities defined, uses content-based filtering
       
  1138     // or no capabilities required from service
       
  1139     if ( aServiceUid == KDrmLinkSender 
       
  1140          || aRequiredCapabilities.iFlags == TSendingCapabilities::EAllServices )
       
  1141         { 
       
  1142         return ETrue;
       
  1143         }
       
  1144 
       
  1145     i = ResolveServiceIndex( aServiceUid );
       
  1146 
       
  1147     if ( i != KErrNotFound )
       
  1148         {
       
  1149         return QueryCapabilities( i, aRequiredCapabilities );  
       
  1150         }
       
  1151     else
       
  1152         {
       
  1153         return EFalse;          
       
  1154         }
       
  1155     }
       
  1156 
       
  1157 // -----------------------------------------------------------------------------
       
  1158 // CSendUiImpl
       
  1159 // C++ default constructor can NOT contain any code, that
       
  1160 // might leave.
       
  1161 // -----------------------------------------------------------------------------
       
  1162 //
       
  1163 CSendUiImpl::CSendUiImpl()
       
  1164     :  iCoeEnv( CCoeEnv::Static() ),
       
  1165         iFs( iCoeEnv->FsSession() ),
       
  1166         iResourceLoader( *iCoeEnv )
       
  1167         
       
  1168     {
       
  1169     }
       
  1170 
       
  1171 // -----------------------------------------------------------------------------
       
  1172 // CSendUiImpl::FeatureStatus
       
  1173 // -----------------------------------------------------------------------------
       
  1174 //
       
  1175 void CSendUiImpl::FeatureStatus( TInt aFeature, TInt &aNewFeatures, TInt aFeatureFlag )
       
  1176     {
       
  1177     if ( FeatureManager::FeatureSupported( aFeature ) )
       
  1178         {
       
  1179         // If Postcard only is supported,     aFeatureFlag is 0x00000001 ==> aNewFeatures == 0x00000001
       
  1180         // If Audio message is also supported aFeatureFlag is 0x00000002 ==> aNewFeatures == 0x00000003
       
  1181         // If MMSUpload is also supported,    aFeatureFlag is 0x00000004 ==> aNewFeatures == 0x00000007
       
  1182         aNewFeatures |= aFeatureFlag;
       
  1183         }
       
  1184     }
       
  1185 // ConstructL
       
  1186 // Symbian 2nd phase constructor can leave.
       
  1187 // -----------------------------------------------------------------------------
       
  1188 //
       
  1189 void CSendUiImpl::ConstructL()
       
  1190     {
       
  1191     iSingleton = CSendUiSingleton::NewL();
       
  1192     //User::LeaveIfError( iFs.Connect() );
       
  1193     iFs.ShareProtected();
       
  1194 
       
  1195     TParse* fp = new(ELeave) TParse(); 
       
  1196     fp->Set( KSendUiResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
  1197     iResourceFileName = fp->FullName();
       
  1198     delete fp;
       
  1199     fp = NULL;
       
  1200     
       
  1201     iResourceLoader.OpenL( iResourceFileName );
       
  1202 
       
  1203     // Check for server launch
       
  1204     RProcess process;
       
  1205     TUid hostId = process.SecureId();
       
  1206     if ( hostId == KSendUiLauncherAppUid ) 
       
  1207         {
       
  1208         iServerAppLaunch = ETrue;
       
  1209         }
       
  1210    else
       
  1211         {
       
  1212         iServerAppLaunch = EFalse;
       
  1213         iSendUiServicesOrderArray = 
       
  1214             new ( ELeave ) CArrayFixFlat<TInt32>( KSendUiServiceOrderArrayGranularity );
       
  1215 
       
  1216         TResourceReader reader;
       
  1217         iCoeEnv->CreateResourceReaderLC( reader, R_SENDUISERVICEORDER_ARRAY );
       
  1218         const TInt count = reader.ReadInt16();
       
  1219         for ( TInt loop = 0; loop < count; loop++ )
       
  1220             {
       
  1221             iSendUiServicesOrderArray->AppendL( reader.ReadInt32() );
       
  1222             }
       
  1223         CleanupStack::PopAndDestroy( ); // reader 
       
  1224         }
       
  1225 
       
  1226     iPropertyObserver = CPropertyObserver::NewL( this );
       
  1227     TRAPD( err, GetServicesL() );
       
  1228     
       
  1229     if ( err )
       
  1230         {
       
  1231 #ifdef _DEBUG
       
  1232         TBuf<256> buf;
       
  1233         buf.Format(_L("SendUi err"));
       
  1234         User::InfoPrint(buf);
       
  1235         LOGTEXT2(_L("Error %d while loading CenRep"), err );
       
  1236 #endif
       
  1237         return;
       
  1238         }
       
  1239     iServicesToDim = new (ELeave) CArrayFixFlat<TUid>( KArrayGranularity );
       
  1240     FeatureManager::InitializeLibL();
       
  1241     
       
  1242     if ( FeatureManager::FeatureSupported( KFeatureIdEmailMceIntegration ) )
       
  1243     	{
       
  1244 
       
  1245     	iEmailClientIntegration = ETrue;
       
  1246     	}
       
  1247     else
       
  1248     	{
       
  1249 
       
  1250     	iEmailClientIntegration = EFalse;
       
  1251     	}   
       
  1252     FeatureManager::UnInitializeLib();
       
  1253     }
       
  1254 
       
  1255 // end of file
       
  1256