localconnectivityservice/obexsendservices/obexservicesendutils/src/BTSBIPController.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     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() ) );
       
   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         
       
   294         
       
   295         iListPtr->MarkAsSendL(iFileIndex);
       
   296         
       
   297         
       
   298         iClient->PutObjectL( headerList, imageparam.iFile );
       
   299         
       
   300 
       
   301         CleanupStack::Pop(4); // headerList, imageDescriptorHeader, typeHeader, imagedescriptor
       
   302         delete imagedescriptor;
       
   303         headerList.Close();
       
   304         }
       
   305     else
       
   306         {
       
   307         FLOG(_L("[BTSU]\t CBTSBIPController::SendL() all images sent, closing connection"));
       
   308 
       
   309         // All images sent, close client connection.
       
   310         //
       
   311         iClient->CloseClientConnection();
       
   312         }
       
   313 
       
   314     FLOG(_L("[BTSU]\t CBTSBIPController::SendL() completed"));
       
   315     }
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // CBTSBIPController::GetL
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void CBTSBIPController::GetL()
       
   322     {
       
   323     FLOG(_L("[BTSU]\t CBTSBIPController::GetL()"));
       
   324 
       
   325     RArray<CObexHeader*> headerList;
       
   326     CleanupClosePushL(headerList);
       
   327     
       
   328     // Add capabilities type header
       
   329     //
       
   330     CObexHeader* typeHeader = CObexHeader::NewL();
       
   331     CleanupStack::PushL( typeHeader );
       
   332     typeHeader->SetByteSeqL( KBTSUTypeHeader, KBTSBIPCapabilities );
       
   333     headerList.Append( typeHeader );
       
   334 
       
   335     // Get capabilities object from remote device
       
   336     //
       
   337     iClient->GetObjectL( headerList );
       
   338 
       
   339     CleanupStack::Pop(2); // headerList, typeHeader
       
   340     headerList.Close();
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CBTSBIPController::SendThumbnailL
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 void CBTSBIPController::SendThumbnailL( const CObexHeaderSet *aPutResponse )
       
   348     {
       
   349     FLOG(_L("[BTSU]\t CBTSBIPController::SendThumbnail()"));
       
   350 
       
   351     // Create thumbnail for sending
       
   352     // Delete the created thumbnail on PutComplete
       
   353     //
       
   354 
       
   355     // Fill header array
       
   356     //
       
   357 	
       
   358     RArray<CObexHeader*> headerList;
       
   359     CleanupClosePushL(headerList);
       
   360 
       
   361     // Add ImageHandle header
       
   362     //
       
   363     CObexHeader* imageHandleHeader = CObexHeader::NewL();
       
   364     CleanupStack::PushL( imageHandleHeader );
       
   365 
       
   366     aPutResponse->First();
       
   367 	User::LeaveIfError(aPutResponse->Find(KBTSUImageHandleHeader,
       
   368 			 *imageHandleHeader ) );
       
   369 	headerList.Append( imageHandleHeader );
       
   370 	
       
   371     // Add Type header
       
   372     //
       
   373     CObexHeader* typeHeader = CObexHeader::NewL();
       
   374     CleanupStack::PushL( typeHeader );
       
   375     typeHeader->SetByteSeqL( KBTSUTypeHeader, KBTSBIPThmType );
       
   376     headerList.Append( typeHeader );
       
   377 	
       
   378 	
       
   379     CreateTempFileL( iThumbnailFileName );
       
   380     CBTSUImageConverter* imageConverter = CBTSUImageConverter::NewL();
       
   381     CleanupStack::PushL( imageConverter );
       
   382     
       
   383     TBTSUImageParam imgparam = iListPtr->ImageAtL( iFileIndex );
       
   384     imageConverter->CreateThumbnailL(imgparam.iFile, iThumbnailFileName );
       
   385     
       
   386     CleanupStack::PopAndDestroy(imageConverter);    
       
   387 
       
   388 	// Add Name header
       
   389     //
       
   390     TParse parse;
       
   391     User::LeaveIfError( parse.Set( iThumbnailFileName, NULL, NULL ) );
       
   392     CObexHeader* nameHeader = CObexHeader::NewL();
       
   393     CleanupStack::PushL( nameHeader );
       
   394     nameHeader->SetUnicodeL( KBTSUNameHeader, parse.NameAndExt() );
       
   395     headerList.Append( nameHeader );
       
   396 
       
   397     // send thumbnail
       
   398     //
       
   399     iClient->PutObjectL( headerList, iThumbnailFileName );
       
   400     
       
   401     // Cleanup
       
   402     //
       
   403     CleanupStack::Pop(4); // headerList, imageHandleHeader, typeHeader, nameHeader
       
   404     headerList.Close();
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CBTSBIPController::CreateTempFileL
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void CBTSBIPController::CreateTempFileL( TFileName& aFileName )
       
   412     {
       
   413     FLOG(_L("[BTSU]\t CBTSBIPController::CreateTempFileL()"));
       
   414 
       
   415     RFs fileSession;
       
   416     RFile file;    
       
   417     
       
   418     TBuf<KBTSUMaxPrivatePathLenght> privatepath;     
       
   419     TBuf<KBTSUMaxPathLenght> tempPath;     
       
   420     
       
   421     User::LeaveIfError( fileSession.Connect() );
       
   422     CleanupClosePushL( fileSession );    
       
   423     
       
   424     User::LeaveIfError(fileSession.CreatePrivatePath(EDriveC));
       
   425     User::LeaveIfError(fileSession.PrivatePath(privatepath));
       
   426     tempPath.Append(KBTSBIPTempPathDrive());
       
   427     tempPath.Append(privatepath);    
       
   428     User::LeaveIfError( file.Temp( fileSession, privatepath, 
       
   429                             aFileName, EFileWrite ) );
       
   430     
       
   431     file.Flush();
       
   432     file.Close();
       
   433     CleanupStack::Pop();    // Close fileSession
       
   434     fileSession.Close();
       
   435     }
       
   436 
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CBTSBIPController::GenerateTempFileNameL
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CBTSBIPController::GenerateTempFileNameL( TFileName& aFileName )
       
   443     {
       
   444     FLOG(_L("[BTSU]\t CBTSBIPController::GenerateTempFileNameL()"));
       
   445 
       
   446     RFs fileSession;
       
   447     RFile file;  
       
   448     
       
   449     TBuf<KBTSUMaxPrivatePathLenght> privatepath;     
       
   450     TBuf<KBTSUMaxPathLenght> tempPath;     
       
   451     
       
   452     User::LeaveIfError( fileSession.Connect() );
       
   453     CleanupClosePushL( fileSession );
       
   454     
       
   455     User::LeaveIfError(fileSession.CreatePrivatePath(EDriveC));
       
   456     User::LeaveIfError(fileSession.PrivatePath(privatepath ));
       
   457     tempPath.Append(KBTSBIPTempPathDrive());
       
   458     tempPath.Append(privatepath);
       
   459     User::LeaveIfError(file.Temp( fileSession, tempPath, 
       
   460                             aFileName, EFileWrite ) );                            
       
   461     
       
   462     file.Flush();
       
   463     file.Close();
       
   464     // Delete the file so that only a unique name is created
       
   465     fileSession.Delete( aFileName );
       
   466     CleanupStack::Pop();    // Close fileSession
       
   467     fileSession.Close();
       
   468     }    
       
   469 
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // CBTSBIPController::DeleteTempFileL
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 void CBTSBIPController::DeleteTempFile( TFileName& aFileName )
       
   476     {
       
   477     FLOG(_L("[BTSU]\t CBTSBIPController::DeleteTempFile()"));
       
   478 
       
   479     if ( &aFileName != NULL )
       
   480         {
       
   481         if ( aFileName.Length() > 0 )
       
   482             {
       
   483             RFs fileSession;
       
   484             TInt retVal = fileSession.Connect();
       
   485             if (retVal == KErrNone)
       
   486                 {
       
   487                 fileSession.Delete( aFileName );
       
   488                 }
       
   489             fileSession.Close();
       
   490             }
       
   491         }
       
   492 
       
   493     FLOG(_L("[BTSU]\t CBTSBIPController::DeleteTempFile() complete"));
       
   494     }
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CBTSBIPController::CreateImageDescriptorL
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 HBufC8*  CBTSBIPController::CreateImageDescriptorL()
       
   501     {
       
   502     FLOG(_L("[BTSU]\t CBTSBIPController::CreateImageDescriptorL()"));
       
   503 
       
   504     //   Example image descriptor of an small jpeg picture
       
   505     //   with size 160*120 pixels and a size of 5000 bytes.
       
   506     //
       
   507     //  <image-descriptor version=\"1.0\">
       
   508     //  <image encoding=\"JPEG\" pixel=\"160*120\" size=\"5000\"/>
       
   509     //  </image-descriptor>
       
   510     TBTSUImageParam param = iListPtr->ImageAtL( iFileIndex );
       
   511     
       
   512     // Add start of image description
       
   513     //
       
   514     TBuf8<KBTSUMaxStringLength> string( KBTSBIPDescriptorStart );
       
   515 
       
   516     // Add image encoding
       
   517     //
       
   518     string.Append( KBTSBIPDescriptorEncoding );
       
   519     string.Append( *param.iDisplayName );
       
   520 
       
   521     // Add image pixel size
       
   522     //
       
   523     string.Append( KBTSBIPDescriptorPixel );
       
   524     string.AppendNum( param.iPixelSize.iWidth );
       
   525     string.Append( '*' );
       
   526     string.AppendNum( param.iPixelSize.iHeight );
       
   527 
       
   528     // Add image size
       
   529     //
       
   530     string.Append( KBTSBIPDescriptorSize );
       
   531     string.AppendNum( param.iFileSize );
       
   532 
       
   533     // Add end of image description
       
   534     //
       
   535     string.Append( KBTSBIPDescriptorEnd );
       
   536 
       
   537     FLOG(_L("[BTSU]\t CBTSBIPController::CreateImageDescriptorL() completed"));
       
   538     
       
   539     return string.AllocL();
       
   540     }
       
   541 
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // CBTSBIPController::HandleGetCompleteIndicationL
       
   545 // -----------------------------------------------------------------------------
       
   546 //
       
   547 void CBTSBIPController::HandleGetCompleteIndicationL( CObexBufObject* aGetResponse )
       
   548     {
       
   549     FLOG(_L("[BTSU]\t CBTSBIPController::HandleGetCompleteIndicationL()"));
       
   550 
       
   551     TBool found;
       
   552     TBool allSupported;
       
   553     TInt picindex,capindex;
       
   554     TInt confirm=0;
       
   555     CBTSUXmlParser* xmlParser = CBTSUXmlParser::NewL();
       
   556     CleanupStack::PushL( xmlParser );
       
   557     GenerateTempFileNameL( iTempFileName );
       
   558     aGetResponse->WriteToFile( iTempFileName );
       
   559     aGetResponse->Reset();
       
   560     
       
   561     // Parse capability object and create a list of supported image encodings
       
   562     //
       
   563     RArray<TBTSUImageCap>* remoteCapabilityList = 
       
   564         xmlParser->GetImgCapabilityListL( iTempFileName );
       
   565     
       
   566     // Delete the temp file since we dont need it anymore
       
   567     //
       
   568     DeleteTempFile( iTempFileName );
       
   569 
       
   570     // Go through all the images on our sending list and check 
       
   571     // if remote device is capable of receiving those.
       
   572     // 
       
   573     allSupported= ETrue;   
       
   574     for (picindex=0; picindex< iListPtr->ImageCount(); picindex++ )
       
   575     	{
       
   576     	found=EFalse;
       
   577     	for (capindex=0; capindex < remoteCapabilityList->Count(); capindex++)
       
   578     		{
       
   579     		//Find first is encoding suported			
       
   580     		if((iListPtr->ImageAtL( picindex ).iDisplayName->Compare(*(*remoteCapabilityList)[capindex].iEncoding))==0)		
       
   581     			{
       
   582     			found=ETrue;    			
       
   583     			//Check pixel size
       
   584     			if((*remoteCapabilityList)[capindex].iMinPixelSize.iHeight>=0)
       
   585     				{
       
   586     				if(((*remoteCapabilityList)[capindex].iMaxPixelSize.iWidth < iListPtr->ImageAtL( picindex ).iPixelSize.iWidth)  ||
       
   587     				   ((*remoteCapabilityList)[capindex].iMaxPixelSize.iHeight < iListPtr->ImageAtL( picindex ).iPixelSize.iHeight)|| 
       
   588     				   ((*remoteCapabilityList)[capindex].iMinPixelSize.iHeight > iListPtr->ImageAtL( picindex ).iPixelSize.iHeight)||
       
   589     				   ((*remoteCapabilityList)[capindex].iMinPixelSize.iWidth > iListPtr->ImageAtL( picindex ).iPixelSize.iWidth)
       
   590     				   )
       
   591     					{
       
   592     					found=EFalse;
       
   593     					}
       
   594     				}
       
   595     		
       
   596     			//Check byte size
       
   597     			if((*remoteCapabilityList)[capindex].iMaxByteSize>=0)
       
   598     				{    				
       
   599     				if((*remoteCapabilityList)[capindex].iMaxByteSize<iListPtr->ImageAtL( picindex ).iFileSize)
       
   600     					{
       
   601     					found=EFalse;
       
   602     					}
       
   603     				}    	
       
   604     			// If file is supported, stop the loop.
       
   605     			//
       
   606     			if ( found )
       
   607     			    break;
       
   608     			}
       
   609      		}
       
   610     	allSupported = found & allSupported;
       
   611     	}
       
   612     	
       
   613 	for (TInt index=0; index < remoteCapabilityList->Count(); index++)
       
   614 		{
       
   615 		if((*remoteCapabilityList)[index].iEncoding)
       
   616 			{
       
   617 			delete ((*remoteCapabilityList)[index].iEncoding);
       
   618 			}
       
   619 
       
   620 		}
       
   621 		
       
   622 	remoteCapabilityList->Close();
       
   623 	delete remoteCapabilityList;
       
   624     CleanupStack::PopAndDestroy( xmlParser ); 
       
   625     
       
   626     if(!allSupported  && iListPtr->ImageCount() > 1)
       
   627     	{      	
       
   628     	
       
   629     	confirm=iObserverPtr->LaunchConfirmationQuery(R_BT_NOT_SEND_ALL_QUERY_MIXED);    	
       
   630     		
       
   631     	if(confirm==EAknSoftkeyYes)
       
   632     		{
       
   633     		// Everything went ok. Start sending images
       
   634     		//
       
   635     		iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize() );
       
   636     
       
   637 		    // Start sending images
       
   638     		//
       
   639    			SendL();
       
   640     		}
       
   641     	
       
   642     		
       
   643     	}
       
   644     else if ( !allSupported  &&  iListPtr->ImageCount() == 1)
       
   645         {
       
   646         // We allow user to choose wheather to send the image file which is not supported on target device
       
   647         // Original codeline: iObserverPtr->ControllerComplete( EBTSBIPOneNotSend ); 
       
   648         confirm=iObserverPtr->LaunchConfirmationQuery(R_BT_NOT_SEND_ALL_QUERY_SINGLE);       
       
   649                     
       
   650         if(confirm==EAknSoftkeyYes)
       
   651             {
       
   652             // Everything went ok. Start sending the images
       
   653             //
       
   654             iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize() );
       
   655             
       
   656             // Start sending images
       
   657             //
       
   658             SendL();
       
   659             }
       
   660         } 	
       
   661     else if( allSupported )  	
       
   662         {
       
   663     	iObserverPtr->LaunchProgressNoteL( iClient, iListPtr->ImageListSize() + iListPtr->ObjectListSizeL());
       
   664     
       
   665 	    // Start sending images
       
   666     	//
       
   667    		SendL();   		
       
   668     	}
       
   669     	
       
   670     
       
   671     FLOG(_L("[BTSU]\t CBTSBIPController::HandleGetCompleteIndicationL() #3"));
       
   672     }
       
   673     
       
   674 
       
   675 //-----------------------------------------------------------------------------
       
   676 // void CBTSBIPController::ConnectTimedOut()
       
   677 // -----------------------------------------------------------------------------
       
   678 //        
       
   679 void CBTSBIPController::ConnectTimedOut()    
       
   680     {
       
   681     iObserverPtr->ConnectTimedOut();    
       
   682     }
       
   683 
       
   684 
       
   685 //  End of File