I use CObexClient class to send file via Bluetooth. It is similar to example "BTObjectExchange", however I have added user dialogs, in particular Connection and Sending Progress which user can terminate by Cancel rightkey. So the Connecting dialog looks like in SDK "Notepad/Send/Bluetooth".
When Connection process started, remote device displays the "Receive message via Bluetooth from paired device ___ ?" dialog. If I press Cancel in Notepad, remote device dialog disappeares immediatelly - my device sends any "termination" command, and socket is in "safe" state after that.
But in my case (class CObexClient) - how can I do the same, when remote device user didn't press Yes or No, but I press Cancel? I have to:
1) modify status of ActiveObject which uses CObexClient. I do it via CObexClient::Error(kErrCancel) method. Control returns OK to RunL of my AO, but however I'm not 100% sure I can use that callback method for this safely;
2) notify remote device to terminate "connecting" process, and delete my CObexClient object to use it later when called from "Send/Bluetooth" menu... Both Abort() or Disconnect() methods (because IsConnected() is FALSE) do NOT force remote device to dismiss the dialog (probably my device sends nothing), and when I finally call "delete CObexClient", this is BLOCKING operation, until I press Yes or No on remote device.
So how can I force remote device to stop "connecting" process, as well as put local CObexClient into "safe" state? Probably use any methods of its RSocket member (whic is however protected)?
Is there any solution, or Notepad uses other socket classes?
Any advices, docs, links are welcome!
RE: CObexClient: how to Cancel
I have to investigate this. I cannot yet find anything to solve this.
However, I also encourage to use a high level API, 'Send As' functionality, instead of implementing an own OBEX service, if possible. 'Send As' simply adds an option into the menu of an application that enables you to send files over e.g. Bluetooth.
Im having the same problem. In emulator with 2.1 sdk the connection can be cancelled as it would expect to do. But when i try to run in on device (ngage), connection attempt cannot be cancelled until remote device answers.
I had the same problem - CObexClient client from some reason hasn't any method for canceling pending request, when user on receiving side doesn not decide to press anything or if sender simply wants to cancel the operation. Why? I don't know - but maybe there're some good "architecutre" reasons. Anyway Mika Raento presented a way (with switching off BT connectins) how to "hack" it with use of bteng.lib from SendoX SDK. Maybe it's ot legal, but it's working solution - just check Google...