phonebookui/Phonebook2/CommandsExtension/src/CPbk2SendContactCmd.cpp
branchRCL_3
changeset 85 38bb213f60ba
parent 68 9da50d567e3c
equal deleted inserted replaced
74:6b5524b4f673 85:38bb213f60ba
    20 
    20 
    21 // Phonebook 2
    21 // Phonebook 2
    22 #include "Pbk2SendCmdUtils.h"
    22 #include "Pbk2SendCmdUtils.h"
    23 #include "CPbk2vCardConverter.h"
    23 #include "CPbk2vCardConverter.h"
    24 #include <MPbk2CommandObserver.h>
    24 #include <MPbk2CommandObserver.h>
    25 #include <pbk2commands.rsg>
    25 #include <Pbk2Commands.rsg>
    26 #include <pbk2cmdextres.rsg>
    26 #include <Pbk2CmdExtRes.rsg>
    27 #include <Pbk2ProcessDecoratorFactory.h>
    27 #include <Pbk2ProcessDecoratorFactory.h>
    28 #include <MPbk2ProcessDecorator.h>
    28 #include <MPbk2ProcessDecorator.h>
    29 #include <MPbk2ContactLinkIterator.h>
    29 #include <MPbk2ContactLinkIterator.h>
    30 #include <CPbk2AttachmentFile.h>
    30 #include <CPbk2AttachmentFile.h>
    31 #include <CPbk2DriveSpaceCheck.h>
    31 #include <CPbk2DriveSpaceCheck.h>
    40 #include <MPbk2ContactUiControl.h>
    40 #include <MPbk2ContactUiControl.h>
    41 #include <MVPbkStoreContactFieldCollection.h>
    41 #include <MVPbkStoreContactFieldCollection.h>
    42 #include <MVPbkStoreContact.h>
    42 #include <MVPbkStoreContact.h>
    43 #include <MVPbkFieldType.h>
    43 #include <MVPbkFieldType.h>
    44 #include <TVPbkFieldTypeMapping.h>
    44 #include <TVPbkFieldTypeMapping.h>
    45 #include <vpbkeng.rsg>
    45 #include <VPbkEng.rsg>
    46 
    46 
    47 // System includes
    47 // System includes
    48 #include <txtrich.h>
    48 #include <txtrich.h>
    49 #include <barsread.h>
    49 #include <barsread.h>
    50 #include <AknWaitDialog.h>
    50 #include <AknWaitDialog.h>
   367     if( iUiControl )
   367     if( iUiControl )
   368         {
   368         {
   369         iUiControl->RegisterCommand( NULL );
   369         iUiControl->RegisterCommand( NULL );
   370         }
   370         }
   371 
   371 
   372     delete iWaiter;
       
   373     delete iSelectedContacts;
   372     delete iSelectedContacts;
   374     delete iConverter;
   373     delete iConverter;
   375     delete iVCardSender;
   374     delete iVCardSender;
   376     delete iVCardEngine;
   375     delete iVCardEngine;
   377     iStoreContacts.ResetAndDestroy();
   376     iStoreContacts.ResetAndDestroy();
   545         case ECancelling:
   544         case ECancelling:
   546             {
   545             {
   547             ProcessDone( KErrCancel );
   546             ProcessDone( KErrCancel );
   548             break;
   547             break;
   549             }
   548             }
   550         case EReleaseResource:
       
   551             {
       
   552             CPbk2AttachmentFileArray& fileArray = iConverter->AttachmentFileArray();
       
   553             TInt count = fileArray.Count();
       
   554             TInt deleteIndex = count -1;
       
   555             CPbk2AttachmentFile * file = fileArray.At(deleteIndex);
       
   556             fileArray.Delete(deleteIndex);
       
   557             delete file;
       
   558             
       
   559             if ( count > 1) 
       
   560             {
       
   561               IssueRequest();
       
   562             }
       
   563             else
       
   564             {
       
   565               iWaiter->AsyncStop();
       
   566             }
       
   567             break;
       
   568             }
       
   569         }
   549         }
   570     }
   550     }
   571 
   551 
   572 // --------------------------------------------------------------------------
   552 // --------------------------------------------------------------------------
   573 // CPbk2SendContactCmd::RunError
   553 // CPbk2SendContactCmd::RunError
   574 // --------------------------------------------------------------------------
   554 // --------------------------------------------------------------------------
   575 //
   555 //
   576 TInt CPbk2SendContactCmd::RunError(TInt aError)
   556 TInt CPbk2SendContactCmd::RunError(TInt aError)
   577     {
   557     {
   578     if( iWaiter && iWaiter->IsStarted() )
       
   579         iWaiter->AsyncStop();
       
   580     
       
   581     return FilterErrors(aError);
   558     return FilterErrors(aError);
   582     }
   559     }
   583 
   560 
   584 // --------------------------------------------------------------------------
   561 // --------------------------------------------------------------------------
   585 // CPbk2SendContactCmd::DoCancel
   562 // CPbk2SendContactCmd::DoCancel
   586 // --------------------------------------------------------------------------
   563 // --------------------------------------------------------------------------
   587 //
   564 //
   588 void CPbk2SendContactCmd::DoCancel()
   565 void CPbk2SendContactCmd::DoCancel()
   589     {
   566     {
   590     if( iWaiter && iWaiter->IsStarted() )
       
   591         iWaiter->AsyncStop();
       
   592     
       
   593     delete iRetrieveOperation;
   567     delete iRetrieveOperation;
   594     iRetrieveOperation = NULL;
   568     iRetrieveOperation = NULL;
   595     }
   569     }
   596 
   570 
   597 // --------------------------------------------------------------------------
   571 // --------------------------------------------------------------------------
  1283         result = ETrue;
  1257         result = ETrue;
  1284         }
  1258         }
  1285     return result;
  1259     return result;
  1286     }
  1260     }
  1287 
  1261 
  1288 // --------------------------------------------------------------------------
       
  1289 // CPbk2SendContactCmd::CommandExtension
       
  1290 // --------------------------------------------------------------------------
       
  1291 //
       
  1292 TAny* CPbk2SendContactCmd::CommandExtension(TUid aExtensionUid )
       
  1293     {
       
  1294      if( aExtensionUid == TUid::Uid(MPbk2ResourceReleaseUID) )
       
  1295         {
       
  1296         return static_cast<MPbk2ResourceRelease *>(this);
       
  1297         }
       
  1298      else
       
  1299         {
       
  1300         return NULL;
       
  1301         }
       
  1302     }
       
  1303 
       
  1304 // --------------------------------------------------------------------------
       
  1305 // CPbk2SendContactCmd::ReleaseResource
       
  1306 // --------------------------------------------------------------------------
       
  1307 //
       
  1308 void CPbk2SendContactCmd::ReleaseResource()
       
  1309     {
       
  1310     Cancel();
       
  1311     if (iConverter)
       
  1312         {
       
  1313         iConverter->Cancel();
       
  1314         CPbk2AttachmentFileArray& fileArray = iConverter->AttachmentFileArray();        
       
  1315         if (fileArray.Count() > 0)
       
  1316             {
       
  1317             if ( !iWaiter )
       
  1318                 {
       
  1319                 TInt err( KErrNone );
       
  1320                 TRAP( err,iWaiter = new (ELeave) CActiveSchedulerWait());
       
  1321                 if ( err != KErrNone )
       
  1322                     {
       
  1323                     fileArray.ResetAndDestroy();
       
  1324                     return;
       
  1325                     }
       
  1326                  }
       
  1327             
       
  1328               iState = EReleaseResource;
       
  1329               IssueRequest();         
       
  1330               iWaiter->Start();
       
  1331             }
       
  1332        }
       
  1333     }
       
  1334 
       
  1335 // End of File
  1262 // End of File