wvuing/wvuiave/AppSrc/CCAUiMessageUtils.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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:  UI utils for message handling
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CCAUiMessageUtils.h"
       
    22 #include    "IMDialogUtils.h"
       
    23 #include    "ChatDebugPrint.h"
       
    24 #include    "ChatDefinitions.h"
       
    25 #include    "CAArrayUtils.h"
       
    26 #include    "imutils.h"
       
    27 
       
    28 #include    "MCAConversationMessage.h"
       
    29 #include    "mcablockchecker.h"
       
    30 
       
    31 
       
    32 #include    <NewFileServiceClient.h>
       
    33 #include    <AiwGenericParam.h>
       
    34 #include    <chatNG.rsg>
       
    35 #include    <MGFetch.h>
       
    36 #include    <MMGFetchVerifier.h>
       
    37 #include    <documenthandler.h>
       
    38 
       
    39 #include    <eikenv.h>
       
    40 #include    <imageconversion.h>
       
    41 
       
    42 #include    "impsbuilddefinitions.h"
       
    43 #include    "chatdebugassert.h"
       
    44 
       
    45 #include	"MCAConversationPC.h"
       
    46 #include	"IMMessageUtilsPC.h"
       
    47 #include	<aknnavi.h>
       
    48 #include	<aknappui.h>
       
    49 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    50 // so the enums for keys and central repository header is added here
       
    51 #include 	"VariantKeys.h"
       
    52 
       
    53 #ifdef  RD_IMAGEPREVIEW
       
    54 #include    <imagepreview.h>
       
    55 
       
    56 
       
    57 #endif  // RD_IMAGEPREVIEW
       
    58 
       
    59 // CONSTANTS
       
    60 
       
    61 _LIT8( KMimeTypeJpeg, "image/jpeg" );
       
    62 _LIT8( KMimeTypeGif,  "image/gif" );
       
    63 _LIT8( KMimeTypeEmpty, "" );
       
    64 // From ICL documentation:
       
    65 // "all decoder plugins also support thumbnail decodes with ratios of 1:2, 1:4 and 1:8."
       
    66 const TInt KDecodeScaleRatioMin = 2;
       
    67 const TInt KDecodeScaleRatioMax = 8;
       
    68 
       
    69 
       
    70 // ============================ MEMBER FUNCTIONS ===============================
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CCAUiMessageUtils::CCAUiMessageUtils
       
    74 // C++ default constructor can NOT contain any code, that
       
    75 // might leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CCAUiMessageUtils::CCAUiMessageUtils( MCABlockChecker* aBlockChecker )
       
    79         : CActive( CActive::EPriorityLow ), iBlockChecker( aBlockChecker )
       
    80     {
       
    81     CActiveScheduler::Add( this );
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCAUiMessageUtils::ConstructL
       
    86 // Symbian 2nd phase constructor can leave.
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CCAUiMessageUtils::ConstructL()
       
    90     {
       
    91     User::LeaveIfError( iApaSession.Connect() );
       
    92 
       
    93     // create dochandler
       
    94     iDocHandler = CDocumentHandler::NewL();
       
    95     iDocHandler->SetExitObserver( this );
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CCAUiMessageUtils::NewL
       
   100 // Two-phased constructor.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CCAUiMessageUtils* CCAUiMessageUtils::NewLC( MCABlockChecker* aBlockChecker /*= NULL*/ )
       
   104     {
       
   105     CCAUiMessageUtils* self = new( ELeave ) CCAUiMessageUtils( aBlockChecker );
       
   106 
       
   107     CleanupStack::PushL( self );
       
   108     self->ConstructL();
       
   109 
       
   110     return self;
       
   111     }
       
   112 
       
   113 
       
   114 // Destructor
       
   115 CCAUiMessageUtils::~CCAUiMessageUtils()
       
   116     {
       
   117     Cancel();
       
   118 
       
   119     delete iDecoder;
       
   120     delete iSelectedNames;
       
   121 
       
   122     delete iDocHandler;
       
   123     iApaSession.Close();
       
   124     if ( iWait.IsStarted() )
       
   125         {
       
   126         iWait.AsyncStop();
       
   127         }
       
   128     }
       
   129 
       
   130 //-----------------------------------------------------------------------------
       
   131 // CCAUiMessageUtils::RunL
       
   132 // ( Other items commented in header )
       
   133 //-----------------------------------------------------------------------------
       
   134 void CCAUiMessageUtils::RunL()
       
   135     {
       
   136     if ( iWait.IsStarted() )
       
   137         {
       
   138         iWait.AsyncStop();
       
   139         }
       
   140     }
       
   141 
       
   142 //-----------------------------------------------------------------------------
       
   143 // CCAUiMessageUtils::DoCancel
       
   144 // ( Other items commented in header )
       
   145 //-----------------------------------------------------------------------------
       
   146 void CCAUiMessageUtils::DoCancel()
       
   147     {
       
   148     iDecoder->Cancel();
       
   149     }
       
   150 
       
   151 //-----------------------------------------------------------------------------
       
   152 // CCAUiMessageUtils::RunError
       
   153 // ( Other items commented in header )
       
   154 //-----------------------------------------------------------------------------
       
   155 TInt CCAUiMessageUtils::RunError( TInt aError )
       
   156     {
       
   157     if ( IsActive() )
       
   158         {
       
   159         iStatus = aError;
       
   160         Cancel();
       
   161         }
       
   162 
       
   163     if ( aError == KErrNoMemory )
       
   164         {
       
   165         CActiveScheduler::Current()->Error( KErrNoMemory );
       
   166         }
       
   167 
       
   168     return KErrNone;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CCAUiMessageUtils::SendNewFileL
       
   173 // (other items were commented in a header).
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CCAUiMessageUtils::SendNewFileL( TNewServiceFileType aFileType,
       
   177                                       MCAConversationPC& aMessageRWInterfacePC,
       
   178                                       const TDesC& aSender /*= KNullDesC*/,
       
   179                                       const MDesCArray* aScreenNames /*= NULL*/,
       
   180                                       TBool aIsWhisperAllowed /*= ETrue*/ )
       
   181     {
       
   182     // show the list of recipients first
       
   183     if ( ! SelectRecipientsL( aScreenNames, aIsWhisperAllowed ) )
       
   184         {
       
   185         // cancelled
       
   186         return;
       
   187         }
       
   188 
       
   189     // only one file will be created
       
   190     CDesCArray* fileNames = new( ELeave )CDesCArrayFlat( 1 );
       
   191     CleanupStack::PushL( fileNames );
       
   192     CNewFileServiceClient* newFile = NewFileServiceFactory::NewClientL();
       
   193     CleanupStack::PushL( newFile );
       
   194 
       
   195     CAiwGenericParamList* params = CAiwGenericParamList::NewLC();
       
   196 
       
   197 //    CEikonEnv::Static()->SetSystem( ETrue );
       
   198 
       
   199     CHAT_DP_TXT( "Starting new file service.." );
       
   200     TBool okToSend = EFalse;
       
   201     TRAPD( err, okToSend =
       
   202                newFile->NewFileL( *fileNames, params, aFileType, EFalse ) );
       
   203     if ( err )
       
   204         {
       
   205 //        // restore state
       
   206 //        CEikonEnv::Static()->SetSystem( EFalse );
       
   207         User::LeaveIfError( err );
       
   208         }
       
   209 
       
   210     if ( okToSend )
       
   211         {
       
   212         // we got new file, let's send it
       
   213         CHAT_DP_TXT( "..got new file, sending it" );
       
   214 
       
   215         DoSendFileL( *fileNames, aMessageRWInterfacePC, aSender );
       
   216 
       
   217         }
       
   218 
       
   219     CleanupStack::PopAndDestroy( 3, fileNames ); // params, newFile, fileNames
       
   220     CHAT_DP_TXT( "Send new file done.." );
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CCAUiMessageUtils::SendImageL
       
   225 // (other items were commented in a header).
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void CCAUiMessageUtils::SendImageL(
       
   229     MCAConversationPC& aMessageRWInterfacePC,
       
   230     const TDesC& aSender /* = KNullDesC */,
       
   231     const MDesCArray* aScreenNames /* = NULL */,
       
   232     TBool aIsWhisperAllowed /*= ETrue*/ )
       
   233     {
       
   234     TBool ok( EFalse );
       
   235     // show the list of recipients first
       
   236     if ( ! SelectRecipientsL( aScreenNames, aIsWhisperAllowed ) )
       
   237         {
       
   238         // cancelled
       
   239         return;
       
   240         }
       
   241     while ( !ok )
       
   242         {
       
   243         // only one image can be selected at the moment
       
   244         CDesCArray* files = new( ELeave )CDesCArrayFlat( 1 );
       
   245         CleanupStack::PushL( files );
       
   246 
       
   247         HBufC* softkey = CCoeEnv::Static()->AllocReadResourceLC(
       
   248                              R_TEXT_SOFTKEY_SELECT );
       
   249 
       
   250         iBeginVerifySelection = EFalse;
       
   251 
       
   252         // This rd flag is for testing purposes only.
       
   253 #ifndef RD_SEND_NOT_SUPPORTED_CONTENT
       
   254         // only one image can be selected (EFalse)
       
   255         if ( MGFetch::RunL( *files, EImageFile    , EFalse, *softkey, KNullDesC, this ) )
       
   256 #else
       
   257         if ( MGFetch::RunL( *files, EAnyMediaFile, EFalse, *softkey, KNullDesC, this ) )
       
   258 #endif //RD_SEND_NOT_SUPPORTED_CONTENT
       
   259             {
       
   260             // verify the selected image
       
   261             iBeginVerifySelection = ETrue;
       
   262             TBool verify = VerifySelectionL( files );
       
   263 
       
   264             if ( !verify )
       
   265                 {
       
   266                 CleanupStack::PopAndDestroy( softkey ); // softkey
       
   267                 CleanupStack::PopAndDestroy( files );   // files
       
   268                 continue;
       
   269                 }
       
   270 
       
   271 #ifdef RD_IMAGEPREVIEW
       
   272             //
       
   273             // Open image preview
       
   274             //
       
   275             if ( files->MdcaCount() == 1 ) // We can only open 1 image
       
   276                 {
       
   277                 HBufC* skSelect = CCoeEnv::Static()->AllocReadResourceLC(
       
   278                                       R_TEXT_SOFTKEY_SELECT );
       
   279                 HBufC* skBack = CCoeEnv::Static()->AllocReadResourceLC(
       
   280                                     R_TEXT_SOFTKEY_BACK );
       
   281 
       
   282                 this->SetNavigationPaneDimmed( ETrue );
       
   283 
       
   284                 TInt res = ImagePreview::ShowImageL( files->MdcaPoint( 0 ),
       
   285                                                      *skSelect, *skBack );
       
   286 
       
   287                 this->SetNavigationPaneDimmed( EFalse );
       
   288                 CleanupStack::PopAndDestroy( 2 ); // skSelect, skBack
       
   289                 ( res == EAknSoftkeyCancel ) ? ( ok = EFalse ) : ( ok = ETrue );
       
   290                 }
       
   291             else
       
   292                 {
       
   293                 // Invalid number of images
       
   294                 __CHAT_ASSERT_DEBUG( EFalse );
       
   295                 }
       
   296 #endif //RD_IMAGEPREVIEW
       
   297 
       
   298             if ( ok )
       
   299                 {
       
   300                 // send files
       
   301                 DoSendFileL( *files, aMessageRWInterfacePC, aSender );
       
   302 
       
   303                 }
       
   304             CleanupStack::PopAndDestroy( 2 ); // files, softkey
       
   305 
       
   306             }
       
   307         else
       
   308             {
       
   309             // user canceled
       
   310             CleanupStack::PopAndDestroy( 2 ); // files, softkey
       
   311             ok = ETrue;
       
   312             }
       
   313         } //end of while
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------
       
   317 // CCAUiMessageUtils::SendFileL
       
   318 // (other items were commented in a header).
       
   319 // ---------------------------------------------------------
       
   320 //
       
   321 void CCAUiMessageUtils::SendFileL(
       
   322     const MDesCArray& aFileNames,
       
   323     MCAConversationPC& aMessageRWInterfacePC,
       
   324     const TDesC& aSender /*= KNullDesC*/,
       
   325     const MDesCArray* aScreenNames /*= NULL*/ )
       
   326     {
       
   327     // show the list of recipients first
       
   328     if ( ! SelectRecipientsL( aScreenNames ) )
       
   329         {
       
   330         // cancelled
       
   331         return;
       
   332         }
       
   333 
       
   334     DoSendFileL( aFileNames, aMessageRWInterfacePC, aSender );
       
   335 
       
   336     }
       
   337 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CCAUiMessageUtils::SendNewFileL
       
   341 // (other items were commented in a header).
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CCAUiMessageUtils::SendNewFileL( TNewServiceFileType aFileType,
       
   345                                       MCAGroupPC& aMessageRWInterfacePC,
       
   346                                       const TDesC& aSender /*= KNullDesC*/,
       
   347                                       const MDesCArray* aScreenNames /*= NULL*/,
       
   348                                       TBool aIsWhisperAllowed /*= ETrue*/ )
       
   349     {
       
   350     // show the list of recipients first
       
   351     if ( ! SelectRecipientsL( aScreenNames, aIsWhisperAllowed ) )
       
   352         {
       
   353         // cancelled
       
   354         return;
       
   355         }
       
   356 
       
   357     // only one file will be created
       
   358     CDesCArray* fileNames = new( ELeave )CDesCArrayFlat( 1 );
       
   359     CleanupStack::PushL( fileNames );
       
   360     CNewFileServiceClient* newFile = NewFileServiceFactory::NewClientL();
       
   361     CleanupStack::PushL( newFile );
       
   362 
       
   363     CAiwGenericParamList* params = CAiwGenericParamList::NewLC();
       
   364 
       
   365     CHAT_DP_TXT( "Starting new file service.." );
       
   366     if ( newFile->NewFileL( *fileNames, params, aFileType, EFalse ) )
       
   367         {
       
   368 
       
   369         // we got new file, let's send it
       
   370         CHAT_DP_TXT( "..got new file, sending it" );
       
   371 
       
   372         DoSendFileL( *fileNames, aMessageRWInterfacePC, aSender );
       
   373 
       
   374         }
       
   375 
       
   376     CleanupStack::PopAndDestroy( 3, fileNames ); // params, newFile, fileNames
       
   377     CHAT_DP_TXT( "Send new file done.." );
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CCAUiMessageUtils::SendImageL
       
   382 // (other items were commented in a header).
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 void CCAUiMessageUtils::SendImageL(
       
   386     MCAGroupPC& aMessageRWInterfacePC,
       
   387     const TDesC& aSender /* = KNullDesC */,
       
   388     const MDesCArray* aScreenNames /* = NULL */,
       
   389     TBool aIsWhisperAllowed /*= ETrue*/ )
       
   390     {
       
   391     TBool ok( EFalse );
       
   392     // show the list of recipients first
       
   393     if ( ! SelectRecipientsL( aScreenNames, aIsWhisperAllowed ) )
       
   394         {
       
   395         // cancelled
       
   396         return;
       
   397         }
       
   398 
       
   399     while ( !ok )
       
   400         {
       
   401         // only one image can be selected at the moment
       
   402         CDesCArray* files = new( ELeave )CDesCArrayFlat( 1 );
       
   403         CleanupStack::PushL( files );
       
   404 
       
   405         HBufC* softkey = CCoeEnv::Static()->AllocReadResourceLC(
       
   406                              R_TEXT_SOFTKEY_SELECT );
       
   407 
       
   408         iBeginVerifySelection = EFalse;
       
   409 
       
   410         // This rd flag is for testing purposes only.
       
   411 #ifndef RD_SEND_NOT_SUPPORTED_CONTENT
       
   412         // only one image can be selected (EFalse)
       
   413         if ( MGFetch::RunL( *files, EImageFile, EFalse, *softkey, KNullDesC, this ) )
       
   414 #else
       
   415         if ( MGFetch::RunL( *files, EAnyMediaFile, EFalse, *softkey, KNullDesC, this ) )
       
   416 #endif //RD_SEND_NOT_SUPPORTED_CONTENT
       
   417             {
       
   418             // verify the selected image
       
   419             iBeginVerifySelection = ETrue;
       
   420             TBool verify = VerifySelectionL( files );
       
   421 
       
   422             if ( !verify )
       
   423                 {
       
   424                 CleanupStack::PopAndDestroy( softkey ); // softkey
       
   425                 CleanupStack::PopAndDestroy( files );   // files
       
   426                 continue;
       
   427                 }
       
   428 
       
   429 #ifdef RD_IMAGEPREVIEW
       
   430             //
       
   431             // Open image preview
       
   432             //
       
   433             if ( files->MdcaCount() == 1 ) // We can only open 1 image
       
   434                 {
       
   435                 HBufC* skSelect = CCoeEnv::Static()->AllocReadResourceLC(
       
   436                                       R_TEXT_SOFTKEY_SELECT );
       
   437                 HBufC* skBack = CCoeEnv::Static()->AllocReadResourceLC(
       
   438                                     R_TEXT_SOFTKEY_BACK );
       
   439 
       
   440                 this->SetNavigationPaneDimmed( ETrue );
       
   441 
       
   442                 TInt res = ImagePreview::ShowImageL( files->MdcaPoint( 0 ),
       
   443                                                      *skSelect, *skBack );
       
   444 
       
   445                 this->SetNavigationPaneDimmed( EFalse );
       
   446 
       
   447                 CleanupStack::PopAndDestroy( 2 ); // skSelect, skBack
       
   448                 ( res == EAknSoftkeyCancel ) ? ( ok = EFalse ) : ( ok = ETrue );
       
   449                 }
       
   450             else
       
   451                 {
       
   452                 // Invalid number of images
       
   453                 __CHAT_ASSERT_DEBUG( EFalse );
       
   454                 }
       
   455 #endif //RD_IMAGEPREVIEW
       
   456 
       
   457             if ( ok )
       
   458                 {
       
   459                 // send files
       
   460                 DoSendFileL( *files, aMessageRWInterfacePC, aSender );
       
   461 
       
   462                 }
       
   463             CleanupStack::PopAndDestroy( 2 ); // files, softkey
       
   464 
       
   465             }
       
   466         else
       
   467             {
       
   468             // user canceled
       
   469             CleanupStack::PopAndDestroy( 2 ); // files, softkey
       
   470             ok = ETrue;
       
   471             }
       
   472         } //end of while
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CCAUiMessageUtils::SendFileL
       
   477 // (other items were commented in a header).
       
   478 // ---------------------------------------------------------
       
   479 //
       
   480 void CCAUiMessageUtils::SendFileL(
       
   481     const MDesCArray& aFileNames,
       
   482     MCAGroupPC& aMessageRWInterfacePC,
       
   483     const TDesC& aSender /*= KNullDesC*/,
       
   484     const MDesCArray* aScreenNames /*= NULL*/ )
       
   485     {
       
   486     // show the list of recipients first
       
   487     if ( ! SelectRecipientsL( aScreenNames ) )
       
   488         {
       
   489         // cancelled
       
   490         return;
       
   491         }
       
   492 
       
   493     DoSendFileL( aFileNames, aMessageRWInterfacePC, aSender );
       
   494 
       
   495     }
       
   496 
       
   497 
       
   498 // ---------------------------------------------------------
       
   499 // CCAUiMessageUtils::SelectRecipientsL
       
   500 // (other items were commented in a header).
       
   501 // ---------------------------------------------------------
       
   502 //
       
   503 TBool CCAUiMessageUtils::SelectRecipientsL( const MDesCArray* aScreenNames,
       
   504                                             TBool aIsWhisperAllowed /*= ETrue*/ )
       
   505     {
       
   506     delete iSelectedNames;
       
   507     iSelectedNames = NULL;
       
   508 
       
   509     // check if we're sending a group message and whispering is allowed.
       
   510     // in that case, group members are in aScreenNames array
       
   511 
       
   512     const MDesCArray* screenNames = aScreenNames;
       
   513 
       
   514     if ( screenNames && aIsWhisperAllowed )
       
   515         {
       
   516         TInt count( screenNames->MdcaCount() );
       
   517         if ( count > 0 )
       
   518             {
       
   519             // insert "All" to top of the list
       
   520             HBufC* all = CCoeEnv::Static()->AllocReadResourceLC(
       
   521                              R_QTN_CHAT_SEND_FILE_TO_ALL );
       
   522             HBufC* title = CCoeEnv::Static()->AllocReadResourceLC(
       
   523                                R_QTN_CHAT_SEND_FILE_TO );
       
   524 
       
   525             // we have some screennames..
       
   526             CDesCArray* lst = CAArrayUtils::CloneArrayLC( *screenNames );
       
   527             lst->Sort();
       
   528             lst->InsertL( 0, *all );
       
   529 
       
   530             // show query
       
   531             iSelectedNames =
       
   532                 IMDialogUtils::MultiselectionListQueryDialogL( *lst, *title );
       
   533 
       
   534             CleanupStack::PopAndDestroy( 2, title ); // lst, title
       
   535             if ( ! iSelectedNames )
       
   536                 {
       
   537                 // cancel
       
   538                 CleanupStack::PopAndDestroy( all );
       
   539                 return EFalse; // not accepted
       
   540                 }
       
   541 
       
   542             if ( iSelectedNames->Count() > 0 )
       
   543                 {
       
   544                 TInt pos;
       
   545                 if ( iSelectedNames->Find( *all, pos ) == 0 )
       
   546                     {
       
   547                     // "All" selected, send message with
       
   548                     // empty array of screennames
       
   549                     iSelectedNames->Reset();
       
   550                     }
       
   551                 }
       
   552             CleanupStack::PopAndDestroy( all );
       
   553             }
       
   554         else
       
   555             {
       
   556             // possibly the user is in group by himself
       
   557             // => send to all.
       
   558             delete iSelectedNames;
       
   559             iSelectedNames = NULL;
       
   560             iSelectedNames = new( ELeave ) CDesCArrayFlat( 1 );
       
   561             iSelectedNames->Reset();
       
   562             }
       
   563         }
       
   564     else if ( !aIsWhisperAllowed )
       
   565         {
       
   566         // Whispering not allowed
       
   567         // Send message with empty array of screennames
       
   568         if ( !iSelectedNames )
       
   569             {
       
   570             iSelectedNames = new( ELeave ) CDesCArrayFlat( 1 );
       
   571             }
       
   572         iSelectedNames->Reset();
       
   573         }
       
   574 
       
   575     return ETrue; // was accepted
       
   576     }
       
   577 
       
   578 // ---------------------------------------------------------
       
   579 // CCAUiMessageUtils::OpenObjectL
       
   580 // (other items were commented in a header).
       
   581 // ---------------------------------------------------------
       
   582 //
       
   583 void CCAUiMessageUtils::OpenObjectL( MCAConversationMessage& aMsg )
       
   584     {
       
   585     CHAT_DP( D_CHAT_LIT( "*OpenObject: opening.." ) );
       
   586     TEnumsPC::TContentProcessState state = aMsg.ContentProcessState();
       
   587 
       
   588     switch ( state )
       
   589         {
       
   590         case TEnumsPC::EThumbnailReady:
       
   591             {
       
   592             if ( aMsg.MessagerType() != TEnumsPC::EMessageSent )
       
   593                 {
       
   594 
       
   595                 if ( aMsg.ContentData().Length() == 0 )
       
   596                     {
       
   597                     //In case there is only a thumbnail available in the buffer, because the real
       
   598                     //image file is deleted because of lack of memory
       
   599                     IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEM_LOW_IMAGE_OPEN );
       
   600                     return;
       
   601                     }
       
   602                 else
       
   603                     {
       
   604                     if ( aMsg.IsImageSaved() )
       
   605                         {
       
   606                         //In case there is only a thumbnail available in the buffer, because user
       
   607                         //has saved the image
       
   608                         IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEM_LOW_IMAGE_OPEN_SAVED );
       
   609                         return;
       
   610                         }
       
   611                     }
       
   612                 }
       
   613             else
       
   614                 {
       
   615                 //In case there is only a thumbnail available in the buffer, because user
       
   616                 //sent it by himself
       
   617                 IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEM_LOW_IMAGE_OPEN_SAVED );
       
   618                 return;
       
   619                 }
       
   620 
       
   621             break;
       
   622             }
       
   623 
       
   624         case TEnumsPC::EContentCorrupted:
       
   625             {
       
   626             // => corrupted
       
   627             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_CORRUPTED );
       
   628             return;
       
   629             }
       
   630 
       
   631         case TEnumsPC::EContentNotSupported:
       
   632         case TEnumsPC::EContentNotSupportedDrm:
       
   633             {
       
   634             // => unsupported
       
   635             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_UNSUPPORTED );
       
   636             return;
       
   637             }
       
   638 
       
   639         default:
       
   640             {
       
   641             break;
       
   642             }
       
   643         }
       
   644 
       
   645 
       
   646     // save to a temporary file
       
   647     HBufC* tempFileName = HBufC::NewMaxLC( KMaxPath );
       
   648     TPtr tempFileNamePtr( tempFileName->Des() );
       
   649 
       
   650     HBufC* fileName = NULL;
       
   651 
       
   652     // Check if there is filename defined in message
       
   653     const TDesC& origName = aMsg.Text();
       
   654     if ( origName.Length() > 0 )
       
   655         {
       
   656         TParse parser;
       
   657         User::LeaveIfError( parser.Set( origName, NULL, NULL ) );
       
   658         TPtrC ptr = parser.Name();
       
   659         fileName = ptr.AllocLC();
       
   660         tempFileNamePtr.SetLength( 0 );
       
   661         tempFileNamePtr.Insert( 0, *fileName );
       
   662         }
       
   663     else
       
   664         {
       
   665         fileName = CCoeEnv::Static()->AllocReadResourceLC(
       
   666                        R_QTN_CHAT_UNNAMED_FILE );
       
   667         }
       
   668 
       
   669     TPtr fileNamePtr( fileName->Des() );
       
   670 
       
   671     TDataType type( aMsg.MimeType() );
       
   672     RFile tempFile;
       
   673     CleanupClosePushL( tempFile );
       
   674 
       
   675     CHAT_DP( D_CHAT_LIT( "*OpenObject: creating temporary file %S" ),
       
   676              &fileNamePtr );
       
   677     iDocHandler->SaveTempFileL( aMsg.ContentData(), type, fileNamePtr,
       
   678                                 tempFile );
       
   679     iDocHandler->GetPath( tempFileNamePtr );
       
   680     CHAT_DP( D_CHAT_LIT( "*OpenObject: created temporary file to %S" ),
       
   681              &tempFileNamePtr );
       
   682 
       
   683     // check rights
       
   684     if ( !IMUtils::FileProtectedL( tempFileNamePtr ) )
       
   685         {
       
   686         // Create parameters to allow IV do saving
       
   687         CAiwGenericParamList* params = CAiwGenericParamList::NewL();
       
   688         CleanupStack::PushL( params );
       
   689         TAiwGenericParam saveParam( EGenericParamAllowSave );
       
   690         params->AppendL( saveParam );
       
   691         // start the document
       
   692         TRAPD( err, iDocHandler->OpenFileEmbeddedL( tempFile, type, *params ) );
       
   693         if ( err == KErrNone )
       
   694             {
       
   695             // and wait for exit
       
   696             CHAT_DP( D_CHAT_LIT( "*OpenObject: launched OpenFileEmbeddedL,\
       
   697                         waiting for complete.. " ) );
       
   698 
       
   699             if ( ! iWait.IsStarted() )
       
   700                 {
       
   701                 iWait.Start();  // CSI: 10 # iWait is not an active object
       
   702                 }
       
   703             }
       
   704         else
       
   705             {
       
   706             CHAT_DP( D_CHAT_LIT( "*OpenObject: OpenFileEmbeddedL left with %d " ),
       
   707                      err );
       
   708             CActiveScheduler::Current()->Error( err );
       
   709             }
       
   710         CleanupStack::PopAndDestroy( params );
       
   711         }
       
   712     else
       
   713         {
       
   714         // content is protected
       
   715         IMDialogUtils::DisplayInformationNoteL(
       
   716             R_QTN_DRM_NOT_ALLOWED );
       
   717         }
       
   718 
       
   719     // delete temporary file
       
   720     CleanupStack::PopAndDestroy( 2, fileName ); // tempFile.Close(), fileName
       
   721     CHAT_DP( D_CHAT_LIT( "*OpenObject: deleting %S" ), &tempFileNamePtr );
       
   722     RFs& fs = CCoeEnv::Static()->FsSession();
       
   723     fs.Delete( *tempFileName );
       
   724 
       
   725     CleanupStack::PopAndDestroy( tempFileName );
       
   726     CHAT_DP( D_CHAT_LIT( "*OpenObject: done" ) );
       
   727     }
       
   728 
       
   729 // ---------------------------------------------------------
       
   730 // CCAUiMessageUtils::SaveObjectL
       
   731 // (other items were commented in a header).
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 TInt CCAUiMessageUtils::SaveObjectL( MCAConversationMessage& aMsg )
       
   735     {
       
   736     CHAT_DP( D_CHAT_LIT( "*SaveObject: saving.." ) );
       
   737     if ( aMsg.ContentData().Length() == 0 )
       
   738         {
       
   739         // No content
       
   740         return KErrGeneral;
       
   741         }
       
   742 
       
   743     // Check if there is filename defined in message
       
   744     HBufC* fileName = NULL;
       
   745     const TDesC& origName = aMsg.Text();
       
   746 
       
   747     if ( origName.Length() > 0 )
       
   748         {
       
   749         TParse parser;
       
   750         User::LeaveIfError( parser.Set( origName, NULL, NULL ) );
       
   751         TPtrC ptr = parser.Name();
       
   752         fileName = parser.Name().AllocLC();
       
   753         }
       
   754     else
       
   755         {
       
   756         fileName = HBufC::NewLC( 0 );
       
   757         }
       
   758 
       
   759     TDataType type( aMsg.MimeType() );
       
   760     RFile tempFile;
       
   761     CleanupClosePushL( tempFile );
       
   762 
       
   763     // First save to temp file
       
   764     iDocHandler->SaveTempFileL( aMsg.ContentData(), type, *fileName, tempFile );
       
   765     TFileName tempFileName;
       
   766     TInt err = KErrNone;
       
   767     tempFile.Name( tempFileName );
       
   768     iDocHandler->GetPath( tempFileName );
       
   769 
       
   770     // Copy temp file, asks user drive for copying and leaves if free space
       
   771     // on requested drive is below or will fall below critical level
       
   772     if ( origName.Length() > 0 )
       
   773         {
       
   774         err = iDocHandler->CopyL( tempFile, *fileName, type, KEntryAttNormal );
       
   775         }
       
   776     else
       
   777         {
       
   778         err = iDocHandler->CopyL( tempFile, KNullDesC, type, KEntryAttNormal );
       
   779         }
       
   780 
       
   781     //fix - refer Ui Spec Approved Version 1.0
       
   782     //(Instant Messaging NG 001 151006.pdf)
       
   783     //Section 10.2.10 Pg 131 -
       
   784     //"In case user has saved the image already or sent it
       
   785     //by himself, this option(save) is not available."
       
   786     if ( err == KErrNone )
       
   787         {
       
   788         aMsg.SetImageAsSaved( ETrue );
       
   789         }
       
   790     CleanupStack::PopAndDestroy( 2, fileName );  // tempFile.Close(), fileName
       
   791 
       
   792     // Delete temp file
       
   793     RFs& fs = CCoeEnv::Static()->FsSession();
       
   794     fs.Delete( tempFileName );
       
   795 
       
   796     return err;
       
   797     }
       
   798 
       
   799 // ---------------------------------------------------------
       
   800 // CCAUiMessageUtils::HandleServerAppExit
       
   801 // (other items were commented in a header).
       
   802 // ---------------------------------------------------------
       
   803 //
       
   804 void CCAUiMessageUtils::HandleServerAppExit( TInt aReason )
       
   805     {
       
   806     iServerAppExitReason = aReason;
       
   807     if ( iWait.IsStarted() )
       
   808         {
       
   809         iWait.AsyncStop();
       
   810         }
       
   811     }
       
   812 
       
   813 // ---------------------------------------------------------
       
   814 // CCAUiMessageUtils::VerifySelectionL
       
   815 // (other items were commented in a header).
       
   816 // ---------------------------------------------------------
       
   817 //
       
   818 TBool CCAUiMessageUtils::VerifySelectionL( const MDesCArray* aSelectedFiles )
       
   819     {
       
   820     if ( !iBeginVerifySelection )
       
   821         {
       
   822         return ETrue;
       
   823         }
       
   824 
       
   825     TBool ok( EFalse );
       
   826     TBool protectedCount( 0 );
       
   827     TBool corruptedImage( EFalse );
       
   828 
       
   829 #ifndef RD_SEND_NOT_SUPPORTED_CONTENT
       
   830     if ( aSelectedFiles )
       
   831         {
       
   832         TInt count( aSelectedFiles->MdcaCount() );
       
   833         for ( TInt i( 0 ); i < count; ++i )
       
   834             {
       
   835             TUid dummyUid( KNullUid );
       
   836             TDataType dataType;
       
   837             TPtrC filename( aSelectedFiles->MdcaPoint( i ) );
       
   838             User::LeaveIfError( iApaSession.AppForDocument(
       
   839                                     filename,
       
   840                                     dummyUid, dataType ) );
       
   841 
       
   842             //Mime type is empty for non image files (e.g book marks)
       
   843             // so retrun false
       
   844             if ( dataType.Des8().CompareF( KMimeTypeEmpty ) == 0 )
       
   845                 {
       
   846                 return EFalse;
       
   847                 }
       
   848 
       
   849             if ( dataType.Des8().CompareF( KMimeTypeJpeg ) == 0 ||
       
   850                  dataType.Des8().CompareF( KMimeTypeGif ) == 0 )
       
   851                 {
       
   852                 // selected object is gif or jpeg
       
   853                 if ( !IMUtils::FileProtectedL( filename ) )
       
   854                     {
       
   855                     // if not protected => image is ok
       
   856                     ok = ETrue;
       
   857                     }
       
   858                 else
       
   859                     {
       
   860                     ++protectedCount;
       
   861                     }
       
   862                 }
       
   863 
       
   864             // try to open and decode picture to make sure it's
       
   865             // not corrupted.
       
   866 
       
   867             delete iDecoder;
       
   868             iDecoder = NULL;
       
   869 
       
   870             TInt params( CImageDecoder::EOptionNone
       
   871 #ifndef RD_30_COMPATIBILITY_MODE
       
   872                          | CImageDecoder::EPreferFastDecode
       
   873 #endif
       
   874                        );
       
   875 
       
   876             TRAPD( err, iDecoder = CImageDecoder::FileNewL(
       
   877                                        CEikonEnv::Static()->FsSession(), filename,
       
   878                                        static_cast<CImageDecoder::TOptions>( params ) ) );
       
   879 
       
   880             if ( err == KErrNone )
       
   881                 {
       
   882                 // file seems ok, try to decode image
       
   883                 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap();
       
   884                 CleanupStack::PushL( bitmap );
       
   885 
       
   886                 TFrameInfo frame =  iDecoder->FrameInfo();
       
   887                 TSize decodeSize( DecodeSize( frame.iOverallSizeInPixels ) );
       
   888 
       
   889                 TInt bitmaperr =
       
   890                     bitmap->Create( decodeSize, frame.iFrameDisplayMode );
       
   891 
       
   892                 if ( bitmaperr )
       
   893                     {
       
   894                     CHAT_DP( D_CHAT_LIT( "CCAUiMessageUtils::VerifySelectionL:\
       
   895                             Unable to create bitmap (%d)" ), bitmaperr );
       
   896                     CActiveScheduler::Current()->Error( bitmaperr );
       
   897                     CleanupStack::PopAndDestroy( bitmap );
       
   898                     return EFalse;
       
   899                     }
       
   900                 // start converting
       
   901                 iDecoder->Convert( &iStatus, *bitmap );
       
   902                 if ( !IsActive() )
       
   903                     {
       
   904                     SetActive();
       
   905                     }
       
   906 
       
   907                 // and wait until it's finished
       
   908                 if ( !iWait.IsStarted() )
       
   909                     {
       
   910                     iWait.Start();  // CSI: 10 # iWait is not an active object
       
   911                     }
       
   912 
       
   913                 TInt statuscode = iStatus.Int();
       
   914                 CleanupStack::PopAndDestroy( bitmap );
       
   915 
       
   916                 if ( statuscode == KErrCorrupt )
       
   917                     {
       
   918                     CHAT_DP_TXT( "CCAUiMessageUtils::VerifySelectionL\
       
   919                             corrupted: decode failed" );
       
   920                     corruptedImage = ETrue;
       
   921                     }
       
   922 
       
   923                 delete iDecoder;
       
   924                 iDecoder = NULL;
       
   925                 }
       
   926             else
       
   927                 {
       
   928                 // something wrong with opening file
       
   929                 // -> assume corrupt
       
   930                 corruptedImage = ETrue;
       
   931                 }
       
   932             }
       
   933         }
       
   934     else
       
   935         {
       
   936         return ok;
       
   937         }
       
   938 #else
       
   939     ok = ETrue;
       
   940 #endif //RD_SEND_NOT_SUPPORTED_CONTENT
       
   941 
       
   942     if ( protectedCount > 0 )
       
   943         {
       
   944         // some of the files were protected
       
   945         IMDialogUtils::DisplayQueryDialogL(
       
   946             protectedCount == 1 ?
       
   947             R_QTN_DRM_INFO_SEND_FORBID_ONE :
       
   948             R_QTN_DRM_INFO_SEND_FORBID_SOME );
       
   949         }
       
   950     else if ( corruptedImage )
       
   951         {
       
   952         IMDialogUtils::DisplayQueryDialogL( R_QTN_MMS_UPLOAD_INFO_CORRUPTED );
       
   953         ok = EFalse; // don't allow selection of this image
       
   954         }
       
   955     else if ( !ok && aSelectedFiles->MdcaCount() != 0 )
       
   956         {
       
   957         // not ok, show note
       
   958         IMDialogUtils::DisplayQueryDialogL( R_QTN_MMS_INFO_OBJ_NOT_SUPP_SEND );
       
   959         }
       
   960     return ok;
       
   961     }
       
   962 
       
   963 
       
   964 // ---------------------------------------------------------
       
   965 // CCAUiMessageUtils::DecodeSize
       
   966 // (other items were commented in a header).
       
   967 // ---------------------------------------------------------
       
   968 //
       
   969 TSize CCAUiMessageUtils::DecodeSize( const TSize& aSize )
       
   970     {
       
   971     // 1:1 is always valid ratio for decode scaling
       
   972     TInt lastValidRatio( 1 );
       
   973     for ( TInt ratio( KDecodeScaleRatioMin ); ratio <= KDecodeScaleRatioMax; ratio <<= 1 )
       
   974         {
       
   975         if ( aSize.iWidth % ratio + aSize.iHeight % ratio == 0 )
       
   976             {
       
   977             // this ratio is valid
       
   978             lastValidRatio = ratio;
       
   979             }
       
   980         }
       
   981 
       
   982     // return the size scaled with correct ratio
       
   983     return TSize( aSize.iWidth / lastValidRatio,
       
   984                   aSize.iHeight / lastValidRatio );
       
   985     }
       
   986 
       
   987 // ---------------------------------------------------------
       
   988 // CCAUiMessageUtils::ForwardContentMessageL
       
   989 // (other items were commented in a header).
       
   990 // ---------------------------------------------------------
       
   991 //
       
   992 TBool CCAUiMessageUtils::ForwardContentMessageL(
       
   993     const MCAConversationMessage& aMessage,
       
   994     const TDesC& aRecipient,
       
   995     const MDesCArray* aScreenNames,
       
   996     MCAConversationPC& aMessageRWInterfacePC,
       
   997     TBool aIsWhisperingAllowed,
       
   998     const TDesC& aSender /*= KNullDesC*/ )
       
   999     {
       
  1000     // picture was forwarded
       
  1001     if ( aMessage.ContentType() == TEnumsPC::EContentPicture )
       
  1002         {
       
  1003         // Check image state and DRM.
       
  1004         // We should not get corrupted or DRM files at this point,
       
  1005         // but it's better to make sure of it.
       
  1006         TBool isProtected( IMUtils::ContentProtectedL( aMessage.ContentData() ) );
       
  1007 
       
  1008         TEnumsPC::TContentProcessState state =
       
  1009             aMessage.ContentProcessState();
       
  1010         if ( state == TEnumsPC::EContentCorrupted )
       
  1011             {
       
  1012             // => corrupted
       
  1013             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_CORRUPTED );
       
  1014             // Message was handled as best as we could
       
  1015             return ETrue;
       
  1016             }
       
  1017         else if ( state == TEnumsPC::EContentNotSupported ||
       
  1018                   state == TEnumsPC::EContentNotSupportedDrm ||
       
  1019                   isProtected )
       
  1020             {
       
  1021             // => unsupported
       
  1022             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_UNSUPPORTED );
       
  1023             // Message was handled as best as we could
       
  1024             return ETrue;
       
  1025             }
       
  1026 
       
  1027         // Image seems to be ok, so let's continue forwarding.
       
  1028 
       
  1029         // show the list of recipients first
       
  1030         if ( aScreenNames )
       
  1031             {
       
  1032             if ( !SelectRecipientsL( aScreenNames, aIsWhisperingAllowed ) )
       
  1033                 {
       
  1034                 // cancelled. Return true because it needs to seem that
       
  1035                 // we handled the message.
       
  1036                 return ETrue;
       
  1037                 }
       
  1038             }
       
  1039         else
       
  1040             {
       
  1041             // this has to be Null when sending a PtoP message.
       
  1042             delete iSelectedNames;
       
  1043             iSelectedNames = NULL;
       
  1044             }
       
  1045 
       
  1046         IMMessageUtilsPC::SendMessageL(
       
  1047             aMessage,
       
  1048             aRecipient,
       
  1049             aMessageRWInterfacePC,
       
  1050             iSelectedNames,
       
  1051             aSender ) ;
       
  1052 
       
  1053         // message handled succesfully
       
  1054         return ETrue;
       
  1055         }
       
  1056 
       
  1057     // We handle only pictures here, so message was not handled.
       
  1058     return EFalse;
       
  1059     }
       
  1060 
       
  1061 // ---------------------------------------------------------
       
  1062 // CCAUiMessageUtils::ForwardContentMessageL
       
  1063 // (other items were commented in a header).
       
  1064 // ---------------------------------------------------------
       
  1065 //
       
  1066 TBool CCAUiMessageUtils::ForwardContentMessageL(
       
  1067     const MCAConversationMessage& aMessage,
       
  1068     const TDesC& aRecipient,
       
  1069     const MDesCArray* aScreenNames,
       
  1070     MCAGroupPC& aMessageRWInterfacePC,
       
  1071     TBool aIsWhisperingAllowed,
       
  1072     const TDesC& aSender /*= KNullDesC*/ )
       
  1073     {
       
  1074     // picture was forwarded
       
  1075     if ( aMessage.ContentType() == TEnumsPC::EContentPicture )
       
  1076         {
       
  1077         // Check image state and DRM.
       
  1078         // We should not get corrupted or DRM files at this point,
       
  1079         // but it's better to make sure of it.
       
  1080         TBool isProtected( IMUtils::ContentProtectedL( aMessage.ContentData() ) );
       
  1081 
       
  1082         TEnumsPC::TContentProcessState state =
       
  1083             aMessage.ContentProcessState();
       
  1084         if ( state == TEnumsPC::EContentCorrupted )
       
  1085             {
       
  1086             // => corrupted
       
  1087             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_CORRUPTED );
       
  1088             // Message was handled as best as we could
       
  1089             return ETrue;
       
  1090             }
       
  1091         else if ( state == TEnumsPC::EContentNotSupported ||
       
  1092                   state == TEnumsPC::EContentNotSupportedDrm ||
       
  1093                   isProtected )
       
  1094             {
       
  1095             // => unsupported
       
  1096             IMDialogUtils::DisplayInformationNoteL( R_QTN_CHAT_MEDIA_UNSUPPORTED );
       
  1097             // Message was handled as best as we could
       
  1098             return ETrue;
       
  1099             }
       
  1100 
       
  1101         // Image seems to be ok, so let's continue forwarding.
       
  1102 
       
  1103         // show the list of recipients first
       
  1104         if ( aScreenNames )
       
  1105             {
       
  1106             if ( !SelectRecipientsL( aScreenNames, aIsWhisperingAllowed ) )
       
  1107                 {
       
  1108                 // cancelled. Return true because it needs to seem that
       
  1109                 // we handled the message.
       
  1110                 return ETrue;
       
  1111                 }
       
  1112             }
       
  1113         else
       
  1114             {
       
  1115             // this has to be Null when sending a PtoP message.
       
  1116             delete iSelectedNames;
       
  1117             iSelectedNames = NULL;
       
  1118             }
       
  1119 
       
  1120         IMMessageUtilsPC::SendMessageL(
       
  1121             aMessage,
       
  1122             aRecipient,
       
  1123             aMessageRWInterfacePC,
       
  1124             iSelectedNames,
       
  1125             aSender ) ;
       
  1126 
       
  1127         // message handled succesfully
       
  1128         return ETrue;
       
  1129         }
       
  1130 
       
  1131     // We handle only pictures here, so message was not handled.
       
  1132     return EFalse;
       
  1133     }
       
  1134 
       
  1135 // ---------------------------------------------------------
       
  1136 // CCAUiMessageUtils::DoSendFileL
       
  1137 // (other items were commented in a header).
       
  1138 // ---------------------------------------------------------
       
  1139 //
       
  1140 void CCAUiMessageUtils::DoSendFileL(
       
  1141     const MDesCArray& aFileNames,
       
  1142     MCAConversationPC& aMsgRWInterface,
       
  1143     const TDesC& aSender /*= KNullDesC*/ )
       
  1144     {
       
  1145 
       
  1146     TDataType dataType;
       
  1147     TPtrC8 mimeType;
       
  1148     TBool sendOption;
       
  1149 
       
  1150     // check file before it will be sent.
       
  1151     if ( CheckFileL( aFileNames, dataType, mimeType, sendOption ) )
       
  1152         {
       
  1153         TPtrC fileName( aFileNames.MdcaPoint( 0 ) );
       
  1154         IMMessageUtilsPC::SendFileL( aMsgRWInterface,
       
  1155                                      iSelectedNames,
       
  1156                                      sendOption,
       
  1157                                      fileName,
       
  1158                                      mimeType,
       
  1159                                      KNullDesC8,
       
  1160                                      aSender );
       
  1161         }
       
  1162     }
       
  1163 
       
  1164 // ---------------------------------------------------------
       
  1165 // CCAUiMessageUtils::DoSendFileL
       
  1166 // (other items were commented in a header).
       
  1167 // ---------------------------------------------------------
       
  1168 //
       
  1169 void CCAUiMessageUtils::DoSendFileL(
       
  1170     const MDesCArray& aFileNames,
       
  1171     MCAGroupPC& aMsgRWInterface,
       
  1172     const TDesC& aSender /*= KNullDesC*/ )
       
  1173     {
       
  1174     TDataType dataType;
       
  1175     TPtrC8 mimeType;
       
  1176     TBool sendOption;
       
  1177 
       
  1178     // check file before it will be sent.
       
  1179     if ( CheckFileL( aFileNames, dataType, mimeType, sendOption ) )
       
  1180         {
       
  1181         TPtrC fileName( aFileNames.MdcaPoint( 0 ) );
       
  1182         IMMessageUtilsPC::SendFileL( aMsgRWInterface,
       
  1183                                      iSelectedNames,
       
  1184                                      sendOption,
       
  1185                                      fileName,
       
  1186                                      mimeType,
       
  1187                                      KNullDesC8,
       
  1188                                      aSender );
       
  1189         }
       
  1190     }
       
  1191 
       
  1192 // ---------------------------------------------------------
       
  1193 // CCAUiMessageUtils::CheckFileL
       
  1194 // (other items were commented in a header).
       
  1195 // ---------------------------------------------------------
       
  1196 //
       
  1197 TBool CCAUiMessageUtils::CheckFileL( const MDesCArray& aFileNames, TDataType& aDataType, TPtrC8& aMimeType, TBool& aSendOption )
       
  1198     {
       
  1199     if ( aFileNames.MdcaCount() == 0 )
       
  1200         return EFalse;
       
  1201 
       
  1202     // Check if recipient is blocked
       
  1203     if ( iBlockChecker )
       
  1204         {
       
  1205         iBlockChecker->CheckBlockedL();
       
  1206         }
       
  1207 
       
  1208     TPtrC fileName( aFileNames.MdcaPoint( 0 ) );
       
  1209     TUid dummyUid( KNullUid );
       
  1210 
       
  1211 #ifndef RD_SEND_NOT_SUPPORTED_CONTENT
       
  1212 
       
  1213     if ( IMUtils::FileProtectedL( fileName ) )
       
  1214         return EFalse;
       
  1215 
       
  1216     // not drm-protected
       
  1217     User::LeaveIfError( iApaSession.AppForDocument( fileName,
       
  1218                                                     dummyUid,
       
  1219                                                     aDataType ) );
       
  1220     aMimeType.Set( aDataType.Des8() );
       
  1221     aSendOption = EFalse;
       
  1222 
       
  1223     return ETrue;
       
  1224 #else
       
  1225 
       
  1226     TInt err( iApaSession.AppForDocument( fileName, dummyUid, aDataType ) );
       
  1227     if ( err == KErrNone )
       
  1228         aMimeType.Set( aDataType.Des8() );
       
  1229     else
       
  1230         aMimeType.Set( KMimeTypeJpeg );
       
  1231 
       
  1232     if ( !IMUtils::FileProtectedL( fileName ) )
       
  1233         aSendOption = EFalse;
       
  1234     else
       
  1235         aSendOption = ETrue;
       
  1236 
       
  1237     return ETrue;
       
  1238 #endif //RD_SEND_NOT_SUPPORTED_CONTENT
       
  1239     }
       
  1240 
       
  1241 // ---------------------------------------------------------
       
  1242 // CCAUiMessageUtils::SetNaviPaneDimmed
       
  1243 // (other items were commented in a header).
       
  1244 // ---------------------------------------------------------
       
  1245 //
       
  1246 void CCAUiMessageUtils::SetNavigationPaneDimmed( TBool aDimmed )
       
  1247     {
       
  1248     CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
  1249     CCoeControl* control = statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
       
  1250     CAknNavigationControlContainer* navipane = static_cast<CAknNavigationControlContainer*>( control );
       
  1251     statusPane->SetDimmed( aDimmed );
       
  1252     }
       
  1253 
       
  1254 //  End of File