btobexprofiles/obexreceiveservices/bip/src/BIPController.cpp
changeset 47 9e2a905b887f
parent 42 b72428996822
child 57 5ebadcda06cb
equal deleted inserted replaced
45:b0aebde9b1fb 47:9e2a905b887f
   108         delete iResultArray;
   108         delete iResultArray;
   109         }
   109         }
   110     iFs.Close();
   110     iFs.Close();
   111     delete iDialog;
   111     delete iDialog;
   112     delete iProgressDialog;
   112     delete iProgressDialog;
       
   113     delete iRecvDoneDialog;
   113     TRACE_FUNC_EXIT    
   114     TRACE_FUNC_EXIT    
   114     }
   115     }
   115 
   116 
   116 // ---------------------------------------------------------
   117 // ---------------------------------------------------------
   117 // ErrorIndication()
   118 // ErrorIndication()
   137     }
   138     }
   138 
   139 
   139 void CBIPController::HandleError(TBool aAbort)
   140 void CBIPController::HandleError(TBool aAbort)
   140     {
   141     {
   141     TRACE_FUNC_ENTRY
   142     TRACE_FUNC_ENTRY
   142     
   143     iReceivingFailed = ETrue;
       
   144     iShowRecvCompleteDialog = EFalse;
   143     if( iBTTransferState == ETransferPut || (!aAbort && iBTTransferState == ETransferPutDiskError) )
   145     if( iBTTransferState == ETransferPut || (!aAbort && iBTTransferState == ETransferPutDiskError) )
   144         {
   146         {
   145         if(iBTObject)
   147         if(iBTObject)
   146             {
   148             {
   147             iBTObject->Reset();
   149             iBTObject->Reset();
   186 // ---------------------------------------------------------
   188 // ---------------------------------------------------------
   187 //
   189 //
   188 void CBIPController::TransportUpIndication()
   190 void CBIPController::TransportUpIndication()
   189     {
   191     {
   190     TRACE_FUNC
   192     TRACE_FUNC
       
   193     iReceivingFailed = EFalse;
   191     if (!iFs.Handle())
   194     if (!iFs.Handle())
   192         {
   195         {
   193         TRACE_INFO( (_L( "[bipreceiveservice] TransportUpIndication iFs.Connect()" )) ); 
   196         TRACE_INFO( (_L( "[bipreceiveservice] TransportUpIndication iFs.Connect()" )) ); 
   194         if (iFs.Connect())   // error value not checked, iFs.Handle() checked one more time before first useage
   197         if (iFs.Connect())   // error value not checked, iFs.Handle() checked one more time before first useage
   195             {
   198             {
   245 // TransportDownIndication()
   248 // TransportDownIndication()
   246 // ---------------------------------------------------------
   249 // ---------------------------------------------------------
   247 //
   250 //
   248 void CBIPController::TransportDownIndication()
   251 void CBIPController::TransportDownIndication()
   249     {
   252     {
   250     TRACE_FUNC   
   253     TRACE_FUNC  
       
   254     if(!iReceivingFailed && iShowRecvCompleteDialog)
       
   255         {
       
   256         //Launch recevice completed dialog.
       
   257         iRecvDoneDialog = CHbDeviceDialogSymbian::NewL();
       
   258         iRecvDoneDialog->SetObserver(this);
       
   259     
       
   260         CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
       
   261         CleanupStack::PushL(variantMap);
       
   262         
       
   263         TInt dialogIdx = TBluetoothDialogParams::EReceiveDone;
       
   264         CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
       
   265                                                             CHbSymbianVariant::EInt );
       
   266         CleanupStack::PushL(dialogType);
       
   267         TBuf16<6> dialogTypeKey;
       
   268         dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
       
   269         User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
       
   270         CleanupStack::Pop(dialogType);
       
   271         
       
   272         CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
       
   273                                                             CHbSymbianVariant::EDes );
       
   274         CleanupStack::PushL(deviceName);
       
   275         TBuf16<6> deviceNameKey;
       
   276         deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
       
   277         User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
       
   278         CleanupStack::Pop(deviceName);
       
   279         
       
   280         CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
       
   281                                                             CHbSymbianVariant::EDes );
       
   282         CleanupStack::PushL(fileName);
       
   283         TBuf16<6> fileNameKey;
       
   284         fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
       
   285         User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
       
   286         CleanupStack::Pop(fileName);
       
   287         
       
   288         CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
       
   289                                                             CHbSymbianVariant::EInt );
       
   290         CleanupStack::PushL(fileSz);
       
   291         TBuf16<6> fileSzKey;
       
   292         fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
       
   293         User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
       
   294         CleanupStack::Pop(fileSz);
       
   295         
       
   296         CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
       
   297                                                             CHbSymbianVariant::EInt );
       
   298         CleanupStack::PushL(fileCnt);
       
   299         TBuf16<6> fileCntKey;
       
   300         fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
       
   301         User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
       
   302         CleanupStack::Pop(fileCnt);
       
   303         
       
   304         iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this );
       
   305         CleanupStack::PopAndDestroy(variantMap);
       
   306         
       
   307         iShowRecvCompleteDialog = EFalse;
       
   308         }
       
   309     
   251     // Remove receiving buffer and files used during file receiving.
   310     // Remove receiving buffer and files used during file receiving.
   252     //
   311     //
   253     delete iBTObject;
   312     delete iBTObject;
   254     iBTObject = NULL;
   313     iBTObject = NULL;
   255     TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename));  
   314     TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename));  
   379         {
   438         {
   380         retVal = HandlePutCompleteIndication();
   439         retVal = HandlePutCompleteIndication();
   381         iBTTransferState = ETransferIdle;
   440         iBTTransferState = ETransferIdle;
   382         CloseReceivingIndicator();
   441         CloseReceivingIndicator();
   383         iFileCount++;
   442         iFileCount++;
       
   443         iShowRecvCompleteDialog = ETrue;
   384         }
   444         }
   385     TRACE_FUNC_EXIT
   445     TRACE_FUNC_EXIT
   386     return retVal;
   446     return retVal;
   387     }
   447     }
   388 
   448 
  1002  void CBIPController::DataReceived(CHbSymbianVariantMap& aData)
  1062  void CBIPController::DataReceived(CHbSymbianVariantMap& aData)
  1003      {
  1063      {
  1004      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
  1064      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
  1005          {
  1065          {
  1006          TInt val = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data()));
  1066          TInt val = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data()));
  1007          if(!val)
  1067          switch(val)
  1008              {
  1068              {
  1009              //Cancel has been clicked
  1069              case TBluetoothDialogParams::ECancelReceive:
  1010              CancelTransfer();
  1070                  {
  1011              }
  1071                  //User choose to cancel receiving.
  1012          else
  1072                  CancelTransfer();
  1013              {
  1073                  }break;
  1014              //Hide has been clicked
  1074                  
  1015              CloseReceivingIndicator(EFalse);
  1075              case TBluetoothDialogParams::EHide:
       
  1076                  {
       
  1077                  //Use choose to hide the progress dialog.
       
  1078                  CloseReceivingIndicator(EFalse);
       
  1079                  }break;
       
  1080                  
       
  1081              case TBluetoothDialogParams::EShow:
       
  1082              case TBluetoothDialogParams::ECancelShow:
       
  1083                  {
       
  1084                  //In case of Show, the device dialog will handle the opening of conversation view.
       
  1085                  iRecvDoneDialog->Cancel();
       
  1086                  delete iRecvDoneDialog;
       
  1087                  iRecvDoneDialog = NULL;
       
  1088                  }break;
  1016              }
  1089              }
  1017          }
  1090          }
  1018      }
  1091      }
  1019  
  1092  
  1020  void CBIPController::DeviceDialogClosed(TInt aCompletionCode)
  1093  void CBIPController::DeviceDialogClosed(TInt aCompletionCode)