btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp
changeset 47 9e2a905b887f
parent 42 b72428996822
child 57 5ebadcda06cb
equal deleted inserted replaced
45:b0aebde9b1fb 47:9e2a905b887f
    91         delete iResultArray;
    91         delete iResultArray;
    92         }
    92         }
    93     iFs.Close();
    93     iFs.Close();
    94     delete iDialog;
    94     delete iDialog;
    95     delete iProgressDialog;
    95     delete iProgressDialog;
       
    96     delete iRecvDoneDialog;
    96     }
    97     }
    97 
    98 
    98 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
    99 // ErrorIndication()
   100 // ErrorIndication()
   100 // ---------------------------------------------------------
   101 // ---------------------------------------------------------
   117 	}
   118 	}
   118 
   119 
   119 void COPPController::HandleError(TBool aAbort)
   120 void COPPController::HandleError(TBool aAbort)
   120     {
   121     {
   121     TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" )));
   122     TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" )));
       
   123     iReceivingFailed = ETrue;
       
   124     iShowRecvCompleteDialog = EFalse;
   122     if( iObexTransferState == ETransferPut || iObexTransferState == ETransferPutDiskError )
   125     if( iObexTransferState == ETransferPut || iObexTransferState == ETransferPutDiskError )
   123         {        
   126         {        
   124         if(iObexObject)
   127         if(iObexObject)
   125             {
   128             {
   126             iObexObject->Reset();
   129             iObexObject->Reset();
   151 // ---------------------------------------------------------
   154 // ---------------------------------------------------------
   152 //
   155 //
   153 void COPPController::TransportUpIndication()
   156 void COPPController::TransportUpIndication()
   154 	{
   157 	{
   155 	TRACE_FUNC    
   158 	TRACE_FUNC    
       
   159 	iReceivingFailed = EFalse;
   156     iObexTransferState = ETransferIdle;	
   160     iObexTransferState = ETransferIdle;	
   157  
   161  
   158 	if ( !iFs.Handle() )
   162 	if ( !iFs.Handle() )
   159 	    {
   163 	    {
   160 	    TRACE_INFO( (_L( "[oppreceiveservice] TransportUpIndication iFs.Connect()" )) ); 
   164 	    TRACE_INFO( (_L( "[oppreceiveservice] TransportUpIndication iFs.Connect()" )) ); 
   216 // ---------------------------------------------------------
   220 // ---------------------------------------------------------
   217 //
   221 //
   218 void COPPController::TransportDownIndication()
   222 void COPPController::TransportDownIndication()
   219     {
   223     {
   220     TRACE_FUNC
   224     TRACE_FUNC
       
   225     if(!iReceivingFailed && iShowRecvCompleteDialog)
       
   226         {
       
   227         //Launch recevice completed dialog.
       
   228         iRecvDoneDialog = CHbDeviceDialogSymbian::NewL();
       
   229         iRecvDoneDialog->SetObserver(this);
       
   230     
       
   231         CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
       
   232         CleanupStack::PushL(variantMap);
       
   233         
       
   234         TInt dialogIdx = TBluetoothDialogParams::EReceiveDone;
       
   235         CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
       
   236                                                             CHbSymbianVariant::EInt );
       
   237         CleanupStack::PushL(dialogType);
       
   238         TBuf16<6> dialogTypeKey;
       
   239         dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
       
   240         User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
       
   241         CleanupStack::Pop(dialogType);
       
   242         
       
   243         CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
       
   244                                                             CHbSymbianVariant::EDes );
       
   245         CleanupStack::PushL(deviceName);
       
   246         TBuf16<6> deviceNameKey;
       
   247         deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
       
   248         User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
       
   249         CleanupStack::Pop(deviceName);
       
   250         
       
   251         CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
       
   252                                                             CHbSymbianVariant::EDes );
       
   253         CleanupStack::PushL(fileName);
       
   254         TBuf16<6> fileNameKey;
       
   255         fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
       
   256         User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
       
   257         CleanupStack::Pop(fileName);
       
   258         
       
   259         CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
       
   260                                                             CHbSymbianVariant::EInt );
       
   261         CleanupStack::PushL(fileSz);
       
   262         TBuf16<6> fileSzKey;
       
   263         fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
       
   264         User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
       
   265         CleanupStack::Pop(fileSz);
       
   266         
       
   267         CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
       
   268                                                             CHbSymbianVariant::EInt );
       
   269         CleanupStack::PushL(fileCnt);
       
   270         TBuf16<6> fileCntKey;
       
   271         fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
       
   272         User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
       
   273         CleanupStack::Pop(fileCnt);
       
   274         
       
   275         iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this );
       
   276         CleanupStack::PopAndDestroy(variantMap);
       
   277         iShowRecvCompleteDialog = EFalse;
       
   278         }
       
   279     
   221     // Remove receiving buffer and files used during file receiving.
   280     // Remove receiving buffer and files used during file receiving.
   222     //
   281     //
   223     delete iObexObject;
   282     delete iObexObject;
   224     iObexObject = NULL;
   283     iObexObject = NULL;
   225     TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename)); 
   284     TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename)); 
   345         {
   404         {
   346         retVal = HandlePutCompleteIndication();
   405         retVal = HandlePutCompleteIndication();
   347         iObexTransferState = ETransferIdle;
   406         iObexTransferState = ETransferIdle;
   348         CloseReceivingIndicator();
   407         CloseReceivingIndicator();
   349         iFileCount++;
   408         iFileCount++;
       
   409         iShowRecvCompleteDialog = ETrue;
   350         }
   410         }
   351     TRACE_FUNC_EXIT
   411     TRACE_FUNC_EXIT
   352     return retVal;
   412     return retVal;
   353     }
   413     }
   354 
   414 
   967  void COPPController::DataReceived(CHbSymbianVariantMap& aData)
  1027  void COPPController::DataReceived(CHbSymbianVariantMap& aData)
   968      {
  1028      {
   969      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
  1029      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
   970          {
  1030          {
   971          TInt val = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data()));
  1031          TInt val = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data()));
   972          if(!val)
  1032          switch(val)
   973              {
  1033              {
   974              //Cancel has been clicked
  1034              case TBluetoothDialogParams::ECancelReceive:
   975              CancelTransfer();
  1035                  {
   976              }
  1036                  //User choose to cancel receiving.
   977          else
  1037                  CancelTransfer();
   978              {
  1038                  }break;
   979              //Hide has been clicked
  1039                  
   980              CloseReceivingIndicator(EFalse);
  1040              case TBluetoothDialogParams::EHide:
       
  1041                  {
       
  1042                  //Use choose to hide the progress dialog.
       
  1043                  CloseReceivingIndicator(EFalse);
       
  1044                  }break;
       
  1045                  
       
  1046              case TBluetoothDialogParams::EShow:
       
  1047              case TBluetoothDialogParams::ECancelShow:
       
  1048                  {
       
  1049                  //In case of Show, the device dialog will handle the opening of conversation view.
       
  1050                  iRecvDoneDialog->Cancel();
       
  1051                  delete iRecvDoneDialog;
       
  1052                  iRecvDoneDialog = NULL;
       
  1053                  }break;
   981              }
  1054              }
   982          }
  1055          }
   983      }
  1056      }
   984  
  1057  
   985  void COPPController::DeviceDialogClosed(TInt aCompletionCode)
  1058  void COPPController::DeviceDialogClosed(TInt aCompletionCode)