btobexprofiles/obexsendservices/obexservicesendutils/src/BTSBIPController.cpp
changeset 32 19bd632b5100
child 40 997690c3397a
equal deleted inserted replaced
31:a0ea99b6fa53 32:19bd632b5100
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Image push implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "BTSBIPController.h"
       
    22 #include "BTSUDebug.h"
       
    23 #include "BTSUImageConverter.h"
       
    24 #include "BTSUXmlParser.h"
       
    25 #include <Obexutils.rsg>
       
    26 
       
    27 
       
    28 
       
    29 // CONSTANTS
       
    30 // image push target header
       
    31 _LIT8( KBIPImagePushID, "\xE3\x3D\x95\x45\x83\x74\x4A\xD7\x9E\xC5\xC1\x6B\xE3\x1E\xDE\x8E" );
       
    32 
       
    33 // type headers
       
    34 _LIT8( KBTSBIPCapabilities, "x-bt/img-capabilities\0");
       
    35 _LIT8( KBTSBIPImageType,    "x-bt/img-img\0");
       
    36 _LIT8( KBTSBIPThmType,      "x-bt/img-thm\0");
       
    37 
       
    38 // imageBTS descriptor
       
    39 _LIT8( KBTSBIPDescriptorStart,     "<image-descriptor version=\"1.0\">\r" );
       
    40 _LIT8( KBTSBIPDescriptorEncoding,  "<image encoding=\"" );
       
    41 _LIT8( KBTSBIPDescriptorPixel,     "\" pixel=\"" );
       
    42 _LIT8( KBTSBIPDescriptorSize,      "\" size=\"" );
       
    43 _LIT8( KBTSBIPDescriptorEnd,       "\"/>\r</image-descriptor>" );
       
    44 
       
    45 // temp file path for capabilities object
       
    46 
       
    47 //temp file path drive letter
       
    48 _LIT(KBTSBIPTempPathDrive,"c:");
       
    49 const TInt KBTSUMaxPathLenght=256;
       
    50 const TInt KBTSUMaxPrivatePathLenght=20;
       
    51 
       
    52 
       
    53 
       
    54 // ============================ MEMBER FUNCTIONS ===============================
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CBTSBIPController::CBTSBIPController
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CBTSBIPController::CBTSBIPController( MBTServiceObserver* aObserver, 
       
    63                                       CBTServiceParameterList* aList ) :
       
    64                                       iListPtr( aList ),
       
    65                                       iObserverPtr( aObserver )
       
    66 									  
       
    67     {
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CBTSBIPController::ConstructL
       
    72 // Symbian 2nd phase constructor can leave.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CBTSBIPController::ConstructL( const TUint aRemotePort, 
       
    76                                     const TBTDevAddr& aRemoteDeviceAddr )
       
    77     {
       
    78     FLOG(_L("[BTSU]\t CBTSBIPController::ConstructL()"));
       
    79     
       
    80     // Add image push target header
       
    81     //
       
    82     CObexHeader* header = CObexHeader::NewL();
       
    83     CleanupStack::PushL( header );
       
    84     header->SetByteSeqL( KBTSUTargetHeader, KBIPImagePushID );
       
    85 
       
    86     RArray<CObexHeader*> headerList;
       
    87     CleanupClosePushL( headerList );
       
    88     headerList.Append( header );
       
    89     
       
    90     CreateClientL ( this, aRemoteDeviceAddr, aRemotePort, headerList );    
       
    91 
       
    92     CleanupStack::Pop( 2 ); //header, headerlist
       
    93     headerList.Close();
       
    94 
       
    95     FLOG(_L("[BTSU]\t CBTSBIPController::ConstructL() completed"));
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CBTSBIPController::NewL
       
   100 // Two-phased constructor.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CBTSBIPController* CBTSBIPController::NewL( MBTServiceObserver* aObserver,
       
   104                                            const TUint aRemotePort,
       
   105                                            const TBTDevAddr& aRemoteDeviceAddr,
       
   106                                            CBTServiceParameterList* aList )
       
   107     {
       
   108     CBTSBIPController* self = 
       
   109         new( ELeave ) CBTSBIPController( aObserver, aList );
       
   110     CleanupStack::PushL( self );
       
   111     self->ConstructL( aRemotePort, aRemoteDeviceAddr );
       
   112     CleanupStack::Pop(self);
       
   113     return self;
       
   114     }
       
   115 
       
   116 // Destructor
       
   117 CBTSBIPController::~CBTSBIPController()
       
   118     {
       
   119     DeleteTempFile( iThumbnailFileName );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CBTSBIPController::ConnectCompleted
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CBTSBIPController::ConnectCompleted( TInt aStatus )
       
   127     {
       
   128     FLOG(_L("[BTSU]\t CBTSBIPController::ConnectCompleted()"));
       
   129 
       
   130     if ( aStatus == KErrNone )
       
   131         {
       
   132         iFileIndex = 0;
       
   133         // get remote device capabilities
       
   134         //
       
   135         TRAPD( error, GetL() );
       
   136         if ( error != KErrNone )
       
   137             {
       
   138             iObserverPtr->ControllerComplete( EBTSGettingFailed );
       
   139             }
       
   140         }
       
   141     else
       
   142         {
       
   143         //Error on Obex level
       
   144         //
       
   145         iObserverPtr->ControllerComplete( EBTSConnectingFailed );
       
   146         }
       
   147 
       
   148     FLOG(_L("[BTSU]\t CBTSBIPController::ConnectCompleted() completed"));
       
   149     }
       
   150 // -----------------------------------------------------------------------------
       
   151 // CBTSBIPController::ClientConnectionClosed
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CBTSBIPController::ClientConnectionClosed()
       
   155     {
       
   156     FLOG(_L("[BTSU]\t CBTSBIPController::ClientConnectionClosed()"));
       
   157 
       
   158     // Everything ready, stop service
       
   159     //    
       
   160     iObserverPtr->ControllerComplete( EBTSNoError );	
       
   161     FLOG(_L("[BTSU]\t CBTSBIPController::ClientConnectionClosed() completed"));
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CBTSBIPController::PutCompleted
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CBTSBIPController::PutCompleted( TInt aStatus, 
       
   169                                       const CObexHeaderSet* aPutResponse )
       
   170     {
       
   171     FLOG(_L("[BTSU]\t CBTSBIPController::PutCompleted()"));
       
   172 
       
   173     // Remove temporary thumbnail file
       
   174     //
       
   175     DeleteTempFile( iThumbnailFileName );
       
   176     if ( aStatus == KErrNone )
       
   177         {              
       
   178         iFileIndex++;
       
   179         // Send was ok. Start sending next image
       
   180         //
       
   181         TRAPD( error, SendL() );
       
   182         if ( error )
       
   183             {
       
   184             FTRACE(FPrint(_L("[BTSU]\t CBTSBPPController::Send leaved with %d"), error ));
       
   185             iObserverPtr->ControllerComplete( EBTSPuttingFailed);
       
   186             }                
       
   187         }
       
   188     else if ( aStatus == KErrIrObexRespPartialContent )
       
   189         {
       
   190         // Remote device has requested a thumbnail image
       
   191         //
       
   192         TRAPD( error, SendThumbnailL(aPutResponse ) );
       
   193         if ( error )
       
   194             {
       
   195             FTRACE(FPrint(_L("[BTSU]\t CBTSBPPController::Send thumbnail leaved with %d"), error ));
       
   196             iObserverPtr->ControllerComplete( EBTSPuttingFailed );
       
   197             }
       
   198         }
       
   199     else
       
   200         {
       
   201         // Some error on Obex level
       
   202         //
       
   203         iObserverPtr->ControllerComplete( EBTSPuttingFailed);
       
   204         }
       
   205 
       
   206     FLOG(_L("[BTSU]\t CBTSBIPController::PutCompleted() done"));
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CBTSBIPController::GetCompleted
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 void CBTSBIPController::GetCompleted( TInt aStatus, 
       
   214                                       CObexBufObject* aGetResponse )
       
   215     {
       
   216     FLOG(_L("[BTSU]\t CBTSBIPController::GetCompleted()"));	
       
   217 
       
   218     if ( aStatus == KErrAbort )
       
   219         {
       
   220         // Connection is cancelled
       
   221         //
       
   222         iObserverPtr->ControllerComplete( EBTSGettingFailed );
       
   223         }
       
   224     
       
   225     else if ( aStatus == KErrNone )
       
   226         {
       
   227         TRAPD( error, HandleGetCompleteIndicationL( aGetResponse ) );
       
   228         if ( error != KErrNone )
       
   229             {
       
   230             DeleteTempFile( iTempFileName );
       
   231             // Error on capability handling
       
   232             //
       
   233             iObserverPtr->ControllerComplete( EBTSGettingFailed );
       
   234             }
       
   235         }
       
   236     else if( aStatus != KErrAbort && aGetResponse->BytesReceived()==0 )
       
   237         {
       
   238         TRAPD( error,iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize(),iListPtr->ImageCount() ) );
       
   239         error=KErrNone;
       
   240         TRAP(error, SendL() );    	 
       
   241         if ( error != KErrNone )
       
   242             {            
       
   243             iObserverPtr->ControllerComplete( EBTSPuttingFailed );
       
   244             }    	      
       
   245         } 	
       
   246     else if ( aStatus != KErrNone && aGetResponse->BytesReceived()>0 )
       
   247         {
       
   248         // Error on Obex level
       
   249         //
       
   250         iObserverPtr->ControllerComplete( EBTSGettingFailed );
       
   251         }
       
   252     
       
   253 
       
   254     FLOG(_L("[BTSU]\t CBTSBIPController::GetCompleted() done"));
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CBTSBIPController::SendL
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 void CBTSBIPController::SendL()
       
   262     {
       
   263     FLOG(_L("[BTSU]\t CBTSBIPController::SendL()"));
       
   264 
       
   265     
       
   266     if ( iListPtr->ImageCount() > 0 && iFileIndex < iListPtr->ImageCount())
       
   267         {        
       
   268         
       
   269         RArray<CObexHeader*> headerList;
       
   270         CleanupClosePushL( headerList );
       
   271 
       
   272         // Add Type header
       
   273         //
       
   274         CObexHeader* typeHeader = CObexHeader::NewL();
       
   275         CleanupStack::PushL( typeHeader );
       
   276         typeHeader->SetByteSeqL( KBTSUTypeHeader, KBTSBIPImageType );
       
   277         headerList.Append( typeHeader );
       
   278 
       
   279         // Add image descriptor
       
   280         //
       
   281         HBufC8* imagedescriptor = CreateImageDescriptorL( );
       
   282         CleanupStack::PushL( imagedescriptor );
       
   283   
       
   284         CObexHeader* imageDescriptorHeader = CObexHeader::NewL();
       
   285         CleanupStack::PushL( imageDescriptorHeader );
       
   286         imageDescriptorHeader->SetByteSeqL( KBTSUImgDescriptorHeader, imagedescriptor->Des() );
       
   287         headerList.Append( imageDescriptorHeader );
       
   288 
       
   289         // Send image
       
   290         //
       
   291         
       
   292         TBTSUImageParam imageparam = iListPtr->ImageAtL( iFileIndex );        
       
   293         RBuf filename;
       
   294         filename.CreateL(256);
       
   295         CleanupClosePushL(filename);
       
   296         imageparam.iFile.Name(filename);
       
   297         
       
   298         iObserverPtr->UpdateProgressNoteL(imageparam.iFileSize,iFileIndex,filename);
       
   299         CleanupStack::PopAndDestroy(&filename);
       
   300         
       
   301         iListPtr->MarkAsSendL(iFileIndex);
       
   302         
       
   303         
       
   304         iClient->PutObjectL( headerList, imageparam.iFile );
       
   305         
       
   306           
       
   307         CleanupStack::Pop(4); // headerList, imageDescriptorHeader, typeHeader, imagedescriptor
       
   308         delete imagedescriptor;
       
   309         headerList.Close();
       
   310         }
       
   311     else
       
   312         {
       
   313         FLOG(_L("[BTSU]\t CBTSBIPController::SendL() all images sent, closing connection"));
       
   314 
       
   315         // All images sent, close client connection.
       
   316         //
       
   317         iClient->CloseClientConnection();
       
   318         }
       
   319 
       
   320     FLOG(_L("[BTSU]\t CBTSBIPController::SendL() completed"));
       
   321     }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CBTSBIPController::GetL
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 void CBTSBIPController::GetL()
       
   328     {
       
   329     FLOG(_L("[BTSU]\t CBTSBIPController::GetL()"));
       
   330 
       
   331     RArray<CObexHeader*> headerList;
       
   332     CleanupClosePushL(headerList);
       
   333     
       
   334     // Add capabilities type header
       
   335     //
       
   336     CObexHeader* typeHeader = CObexHeader::NewL();
       
   337     CleanupStack::PushL( typeHeader );
       
   338     typeHeader->SetByteSeqL( KBTSUTypeHeader, KBTSBIPCapabilities );
       
   339     headerList.Append( typeHeader );
       
   340 
       
   341     // Get capabilities object from remote device
       
   342     //
       
   343     iClient->GetObjectL( headerList );
       
   344 
       
   345     CleanupStack::Pop(2); // headerList, typeHeader
       
   346     headerList.Close();
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // CBTSBIPController::SendThumbnailL
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 void CBTSBIPController::SendThumbnailL( const CObexHeaderSet *aPutResponse )
       
   354     {
       
   355     FLOG(_L("[BTSU]\t CBTSBIPController::SendThumbnail()"));
       
   356 
       
   357     // Create thumbnail for sending
       
   358     // Delete the created thumbnail on PutComplete
       
   359     //
       
   360 
       
   361     // Fill header array
       
   362     //
       
   363 	
       
   364     RArray<CObexHeader*> headerList;
       
   365     CleanupClosePushL(headerList);
       
   366 
       
   367     // Add ImageHandle header
       
   368     //
       
   369     CObexHeader* imageHandleHeader = CObexHeader::NewL();
       
   370     CleanupStack::PushL( imageHandleHeader );
       
   371 
       
   372     aPutResponse->First();
       
   373 	User::LeaveIfError(aPutResponse->Find(KBTSUImageHandleHeader,
       
   374 			 *imageHandleHeader ) );
       
   375 	headerList.Append( imageHandleHeader );
       
   376 	
       
   377     // Add Type header
       
   378     //
       
   379     CObexHeader* typeHeader = CObexHeader::NewL();
       
   380     CleanupStack::PushL( typeHeader );
       
   381     typeHeader->SetByteSeqL( KBTSUTypeHeader, KBTSBIPThmType );
       
   382     headerList.Append( typeHeader );
       
   383 	
       
   384 	
       
   385     CreateTempFileL( iThumbnailFileName );
       
   386     CBTSUImageConverter* imageConverter = CBTSUImageConverter::NewL();
       
   387     CleanupStack::PushL( imageConverter );
       
   388     
       
   389     TBTSUImageParam imgparam = iListPtr->ImageAtL( iFileIndex );
       
   390     imageConverter->CreateThumbnailL(imgparam.iFile, iThumbnailFileName );
       
   391     
       
   392     CleanupStack::PopAndDestroy(imageConverter);    
       
   393 
       
   394 	// Add Name header
       
   395     //
       
   396     TParse parse;
       
   397     User::LeaveIfError( parse.Set( iThumbnailFileName, NULL, NULL ) );
       
   398     CObexHeader* nameHeader = CObexHeader::NewL();
       
   399     CleanupStack::PushL( nameHeader );
       
   400     nameHeader->SetUnicodeL( KBTSUNameHeader, parse.NameAndExt() );
       
   401     headerList.Append( nameHeader );
       
   402 
       
   403     // send thumbnail
       
   404     //
       
   405     iClient->PutObjectL( headerList, iThumbnailFileName );
       
   406     
       
   407     // Cleanup
       
   408     //
       
   409     CleanupStack::Pop(4); // headerList, imageHandleHeader, typeHeader, nameHeader
       
   410     headerList.Close();
       
   411     }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CBTSBIPController::CreateTempFileL
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CBTSBIPController::CreateTempFileL( TFileName& aFileName )
       
   418     {
       
   419     FLOG(_L("[BTSU]\t CBTSBIPController::CreateTempFileL()"));
       
   420 
       
   421     RFs fileSession;
       
   422     RFile file;    
       
   423     
       
   424     TBuf<KBTSUMaxPrivatePathLenght> privatepath;     
       
   425     TBuf<KBTSUMaxPathLenght> tempPath;     
       
   426     
       
   427     User::LeaveIfError( fileSession.Connect() );
       
   428     CleanupClosePushL( fileSession );    
       
   429     
       
   430     User::LeaveIfError(fileSession.CreatePrivatePath(EDriveC));
       
   431     User::LeaveIfError(fileSession.PrivatePath(privatepath));
       
   432     tempPath.Append(KBTSBIPTempPathDrive());
       
   433     tempPath.Append(privatepath);    
       
   434     User::LeaveIfError( file.Temp( fileSession, privatepath, 
       
   435                             aFileName, EFileWrite ) );
       
   436     
       
   437     file.Flush();
       
   438     file.Close();
       
   439     CleanupStack::Pop();    // Close fileSession
       
   440     fileSession.Close();
       
   441     }
       
   442 
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CBTSBIPController::GenerateTempFileNameL
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 void CBTSBIPController::GenerateTempFileNameL( TFileName& aFileName )
       
   449     {
       
   450     FLOG(_L("[BTSU]\t CBTSBIPController::GenerateTempFileNameL()"));
       
   451 
       
   452     RFs fileSession;
       
   453     RFile file;  
       
   454     
       
   455     TBuf<KBTSUMaxPrivatePathLenght> privatepath;     
       
   456     TBuf<KBTSUMaxPathLenght> tempPath;     
       
   457     
       
   458     User::LeaveIfError( fileSession.Connect() );
       
   459     CleanupClosePushL( fileSession );
       
   460     
       
   461     User::LeaveIfError(fileSession.CreatePrivatePath(EDriveC));
       
   462     User::LeaveIfError(fileSession.PrivatePath(privatepath ));
       
   463     tempPath.Append(KBTSBIPTempPathDrive());
       
   464     tempPath.Append(privatepath);
       
   465     User::LeaveIfError(file.Temp( fileSession, tempPath, 
       
   466                             aFileName, EFileWrite ) );                            
       
   467     
       
   468     file.Flush();
       
   469     file.Close();
       
   470     // Delete the file so that only a unique name is created
       
   471     fileSession.Delete( aFileName );
       
   472     CleanupStack::Pop();    // Close fileSession
       
   473     fileSession.Close();
       
   474     }    
       
   475 
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CBTSBIPController::DeleteTempFileL
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 void CBTSBIPController::DeleteTempFile( TFileName& aFileName )
       
   482     {
       
   483     FLOG(_L("[BTSU]\t CBTSBIPController::DeleteTempFile()"));
       
   484 
       
   485     if ( &aFileName != NULL )
       
   486         {
       
   487         if ( aFileName.Length() > 0 )
       
   488             {
       
   489             RFs fileSession;
       
   490             TInt retVal = fileSession.Connect();
       
   491             if (retVal == KErrNone)
       
   492                 {
       
   493                 fileSession.Delete( aFileName );
       
   494                 }
       
   495             fileSession.Close();
       
   496             }
       
   497         }
       
   498 
       
   499     FLOG(_L("[BTSU]\t CBTSBIPController::DeleteTempFile() complete"));
       
   500     }
       
   501 
       
   502 // -----------------------------------------------------------------------------
       
   503 // CBTSBIPController::CreateImageDescriptorL
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 HBufC8*  CBTSBIPController::CreateImageDescriptorL()
       
   507     {
       
   508     FLOG(_L("[BTSU]\t CBTSBIPController::CreateImageDescriptorL()"));
       
   509 
       
   510     //   Example image descriptor of an small jpeg picture
       
   511     //   with size 160*120 pixels and a size of 5000 bytes.
       
   512     //
       
   513     //  <image-descriptor version=\"1.0\">
       
   514     //  <image encoding=\"JPEG\" pixel=\"160*120\" size=\"5000\"/>
       
   515     //  </image-descriptor>
       
   516     TBTSUImageParam param = iListPtr->ImageAtL( iFileIndex );
       
   517     
       
   518     // Add start of image description
       
   519     //
       
   520     TBuf8<KBTSUMaxStringLength> string( KBTSBIPDescriptorStart );
       
   521 
       
   522     // Add image encoding
       
   523     //
       
   524     string.Append( KBTSBIPDescriptorEncoding );
       
   525     string.Append( *param.iDisplayName );
       
   526 
       
   527     // Add image pixel size
       
   528     //
       
   529     string.Append( KBTSBIPDescriptorPixel );
       
   530     string.AppendNum( param.iPixelSize.iWidth );
       
   531     string.Append( '*' );
       
   532     string.AppendNum( param.iPixelSize.iHeight );
       
   533 
       
   534     // Add image size
       
   535     //
       
   536     string.Append( KBTSBIPDescriptorSize );
       
   537     string.AppendNum( param.iFileSize );
       
   538 
       
   539     // Add end of image description
       
   540     //
       
   541     string.Append( KBTSBIPDescriptorEnd );
       
   542 
       
   543     FLOG(_L("[BTSU]\t CBTSBIPController::CreateImageDescriptorL() completed"));
       
   544     
       
   545     return string.AllocL();
       
   546     }
       
   547 
       
   548 
       
   549 // -----------------------------------------------------------------------------
       
   550 // CBTSBIPController::HandleGetCompleteIndicationL
       
   551 // -----------------------------------------------------------------------------
       
   552 //
       
   553 void CBTSBIPController::HandleGetCompleteIndicationL( CObexBufObject* aGetResponse )
       
   554     {
       
   555     FLOG(_L("[BTSU]\t CBTSBIPController::HandleGetCompleteIndicationL()"));
       
   556 
       
   557     TBool found;
       
   558     TBool allSupported;
       
   559     TInt picindex,capindex;
       
   560     TInt confirm=0;
       
   561     CBTSUXmlParser* xmlParser = CBTSUXmlParser::NewL();
       
   562     CleanupStack::PushL( xmlParser );
       
   563     GenerateTempFileNameL( iTempFileName );
       
   564     aGetResponse->WriteToFile( iTempFileName );
       
   565     aGetResponse->Reset();
       
   566     
       
   567     // Parse capability object and create a list of supported image encodings
       
   568     //
       
   569     RArray<TBTSUImageCap>* remoteCapabilityList = 
       
   570         xmlParser->GetImgCapabilityListL( iTempFileName );
       
   571     
       
   572     // Delete the temp file since we dont need it anymore
       
   573     //
       
   574     DeleteTempFile( iTempFileName );
       
   575 
       
   576     // Go through all the images on our sending list and check 
       
   577     // if remote device is capable of receiving those.
       
   578     // 
       
   579     allSupported= ETrue;   
       
   580     for (picindex=0; picindex< iListPtr->ImageCount(); picindex++ )
       
   581     	{
       
   582     	found=EFalse;
       
   583     	for (capindex=0; capindex < remoteCapabilityList->Count(); capindex++)
       
   584     		{
       
   585     		//Find first is encoding suported			
       
   586     		if((iListPtr->ImageAtL( picindex ).iDisplayName->Compare(*(*remoteCapabilityList)[capindex].iEncoding))==0)		
       
   587     			{
       
   588     			found=ETrue;    			
       
   589     			//Check pixel size
       
   590     			if((*remoteCapabilityList)[capindex].iMinPixelSize.iHeight>=0)
       
   591     				{
       
   592     				if(((*remoteCapabilityList)[capindex].iMaxPixelSize.iWidth < iListPtr->ImageAtL( picindex ).iPixelSize.iWidth)  ||
       
   593     				   ((*remoteCapabilityList)[capindex].iMaxPixelSize.iHeight < iListPtr->ImageAtL( picindex ).iPixelSize.iHeight)|| 
       
   594     				   ((*remoteCapabilityList)[capindex].iMinPixelSize.iHeight > iListPtr->ImageAtL( picindex ).iPixelSize.iHeight)||
       
   595     				   ((*remoteCapabilityList)[capindex].iMinPixelSize.iWidth > iListPtr->ImageAtL( picindex ).iPixelSize.iWidth)
       
   596     				   )
       
   597     					{
       
   598     					found=EFalse;
       
   599     					}
       
   600     				}
       
   601     		
       
   602     			//Check byte size
       
   603     			if((*remoteCapabilityList)[capindex].iMaxByteSize>=0)
       
   604     				{    				
       
   605     				if((*remoteCapabilityList)[capindex].iMaxByteSize<iListPtr->ImageAtL( picindex ).iFileSize)
       
   606     					{
       
   607     					found=EFalse;
       
   608     					}
       
   609     				}    	
       
   610     			// If file is supported, stop the loop.
       
   611     			//
       
   612     			if ( found )
       
   613     			    break;
       
   614     			}
       
   615      		}
       
   616     	allSupported = found & allSupported;
       
   617     	}
       
   618     	
       
   619 	for (TInt index=0; index < remoteCapabilityList->Count(); index++)
       
   620 		{
       
   621 		if((*remoteCapabilityList)[index].iEncoding)
       
   622 			{
       
   623 			delete ((*remoteCapabilityList)[index].iEncoding);
       
   624 			}
       
   625 
       
   626 		}
       
   627 		
       
   628 	remoteCapabilityList->Close();
       
   629 	delete remoteCapabilityList;
       
   630     CleanupStack::PopAndDestroy( xmlParser ); 
       
   631     
       
   632     if(!allSupported  && iListPtr->ImageCount() > 1)
       
   633     	{      	
       
   634     	
       
   635     	confirm=iObserverPtr->LaunchConfirmationQuery(R_BT_NOT_SEND_ALL_QUERY_MIXED);    	
       
   636     		
       
   637     	if(confirm==EAknSoftkeyYes)
       
   638     		{
       
   639     		// Everything went ok. Start sending images
       
   640     		//
       
   641     		iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize(),iListPtr->ImageCount() );
       
   642     
       
   643 		    // Start sending images
       
   644     		//
       
   645    			SendL();
       
   646     		}
       
   647     	
       
   648     		
       
   649     	}
       
   650     else if ( !allSupported  &&  iListPtr->ImageCount() == 1)
       
   651         {
       
   652         // We allow user to choose wheather to send the image file which is not supported on target device
       
   653         // Original codeline: iObserverPtr->ControllerComplete( EBTSBIPOneNotSend ); 
       
   654         confirm=iObserverPtr->LaunchConfirmationQuery(R_BT_NOT_SEND_ALL_QUERY_SINGLE);       
       
   655                     
       
   656         if(confirm==EAknSoftkeyYes)
       
   657             {
       
   658             // Everything went ok. Start sending the images
       
   659             //
       
   660             iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize(),iListPtr->ImageCount() );
       
   661             
       
   662             // Start sending images
       
   663             //
       
   664             SendL();
       
   665             }
       
   666         } 	
       
   667     else if( allSupported )  	
       
   668         {
       
   669     	iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize() + iListPtr->ObjectListSizeL(),iListPtr->ImageCount() + iListPtr->ObjectCount());
       
   670     
       
   671 	    // Start sending images
       
   672     	//   	
       
   673    		SendL();   		
       
   674     	}
       
   675     	
       
   676     
       
   677     FLOG(_L("[BTSU]\t CBTSBIPController::HandleGetCompleteIndicationL() #3"));
       
   678     }
       
   679     
       
   680 
       
   681 //-----------------------------------------------------------------------------
       
   682 // void CBTSBIPController::ConnectTimedOut()
       
   683 // -----------------------------------------------------------------------------
       
   684 //        
       
   685 void CBTSBIPController::ConnectTimedOut()    
       
   686     {
       
   687     iObserverPtr->ConnectTimedOut();    
       
   688     }
       
   689 
       
   690 
       
   691 //  End of File