2014-02-18 23:14:22 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef NfcService_h
|
|
|
|
#define NfcService_h
|
|
|
|
|
|
|
|
#include "mozilla/ipc/Nfc.h"
|
|
|
|
#include "mozilla/ipc/UnixSocket.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsINfcService.h"
|
|
|
|
#include "NfcMessageHandler.h"
|
|
|
|
|
|
|
|
class nsIThread;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class NfcEventOptions;
|
|
|
|
} // namespace dom
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class NfcService final : public nsINfcService,
|
2015-03-27 11:52:19 -07:00
|
|
|
public mozilla::ipc::NfcSocketListener
|
2014-02-18 23:14:22 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSINFCSERVICE
|
|
|
|
|
|
|
|
static already_AddRefed<NfcService> FactoryCreate();
|
|
|
|
|
|
|
|
void DispatchNfcEvent(const mozilla::dom::NfcEventOptions& aOptions);
|
|
|
|
|
2015-03-09 00:27:00 -07:00
|
|
|
virtual void ReceiveSocketData(
|
2015-03-21 09:28:04 -07:00
|
|
|
nsAutoPtr<mozilla::ipc::UnixSocketRawData>& aData) override;
|
2015-03-09 00:27:00 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void OnConnectSuccess(enum SocketType aSocketType) override;
|
|
|
|
virtual void OnConnectError(enum SocketType aSocketType) override;
|
|
|
|
virtual void OnDisconnect(enum SocketType aSocketType) override;
|
2014-02-18 23:14:22 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIThread> GetThread() {
|
|
|
|
return mThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
NfcService();
|
|
|
|
~NfcService();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIThread> mThread;
|
2014-11-11 19:22:36 -08:00
|
|
|
nsCOMPtr<nsINfcGonkEventListener> mListener;
|
2015-03-11 00:38:00 -07:00
|
|
|
nsRefPtr<mozilla::ipc::NfcListenSocket> mListenSocket;
|
2014-02-18 23:14:22 -08:00
|
|
|
nsRefPtr<mozilla::ipc::NfcConsumer> mConsumer;
|
|
|
|
nsAutoPtr<NfcMessageHandler> mHandler;
|
2015-03-11 00:38:00 -07:00
|
|
|
nsCString mListenSocketName;
|
2014-02-18 23:14:22 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // NfcService_h
|