2013-06-17 22:33:48 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2013-11-01 09:45:46 +00:00
|
|
|
/* Copyright © 2013, Deutsche Telekom, Inc. */
|
|
|
|
|
2013-06-17 22:33:48 +00:00
|
|
|
#ifndef mozilla_ipc_Nfc_h
|
|
|
|
#define mozilla_ipc_Nfc_h 1
|
|
|
|
|
2015-03-11 07:34:00 +00:00
|
|
|
#include <mozilla/ipc/ListenSocket.h>
|
2015-01-21 09:59:21 +00:00
|
|
|
#include <mozilla/ipc/StreamSocket.h>
|
2013-06-17 22:33:48 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
2014-02-19 07:14:22 +00:00
|
|
|
class NfcSocketListener
|
|
|
|
{
|
|
|
|
public:
|
2015-03-09 07:27:00 +00:00
|
|
|
enum SocketType {
|
2015-03-11 07:34:00 +00:00
|
|
|
LISTEN_SOCKET,
|
2015-03-09 07:27:00 +00:00
|
|
|
STREAM_SOCKET
|
|
|
|
};
|
|
|
|
|
2015-04-23 11:48:48 +00:00
|
|
|
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aData) = 0;
|
2015-03-09 07:27:00 +00:00
|
|
|
|
|
|
|
virtual void OnConnectSuccess(enum SocketType aSocketType) = 0;
|
|
|
|
virtual void OnConnectError(enum SocketType aSocketType) = 0;
|
|
|
|
virtual void OnDisconnect(enum SocketType aSocketType) = 0;
|
2014-02-19 07:14:22 +00:00
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class NfcListenSocket final : public mozilla::ipc::ListenSocket
|
2015-03-11 07:34:00 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NfcListenSocket(NfcSocketListener* aListener);
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
void OnConnectSuccess() override;
|
|
|
|
void OnConnectError() override;
|
|
|
|
void OnDisconnect() override;
|
2015-03-11 07:34:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
NfcSocketListener* mListener;
|
|
|
|
};
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class NfcConsumer final : public mozilla::ipc::StreamSocket
|
2013-06-17 22:33:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-02-19 07:14:22 +00:00
|
|
|
NfcConsumer(NfcSocketListener* aListener);
|
2013-11-01 09:45:46 +00:00
|
|
|
|
2014-02-19 07:14:22 +00:00
|
|
|
void Shutdown();
|
|
|
|
bool PostToNfcDaemon(const uint8_t* aData, size_t aSize);
|
2013-11-01 09:45:46 +00:00
|
|
|
|
2013-06-17 22:33:48 +00:00
|
|
|
private:
|
2015-04-23 11:48:48 +00:00
|
|
|
void ReceiveSocketData(nsAutoPtr<UnixSocketBuffer>& aBuffer) override;
|
2013-06-17 22:33:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
void OnConnectSuccess() override;
|
|
|
|
void OnConnectError() override;
|
|
|
|
void OnDisconnect() override;
|
2013-06-17 22:33:48 +00:00
|
|
|
|
|
|
|
private:
|
2014-02-19 07:14:22 +00:00
|
|
|
NfcSocketListener* mListener;
|
2013-06-17 22:33:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
} // namepsace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ipc_Nfc_h
|