/*!
 * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 *
 * @Author:  NADAL Jean-Baptiste
 * @Date: 23/06/2017
 */

#ifndef _WEB_CONNECTION_H
#define _WEB_CONNECTION_H

/*------------------------------- INCLUDES ----------------------------------*/

#include <string>

/*----------------------------- Dependencies --------------------------------*/

struct client;
struct uhttpd_ops;
struct ubus_context;

/*----------------------------- Dependencies --------------------------------*/

#define kEvent_status_entry "status"
#define kEvent_version_entry "version"
#define kEvent_content_entry "content"

/*--------------------------------- CLASS ----------------------------------*/

class WebConnection
{
  public:
	WebConnection(struct uhttpd_ops *an_ops, struct client *a_client);
	virtual ~WebConnection(void);

	int add_data(const char *a_data, int a_len);
	struct client *get_client(void);

	virtual void invoke(struct ubus_context *a_ctx);

	bool should_be_removed(void);

  protected:
	struct uhttpd_ops *m_ops;
	struct client *m_client;
	std::string m_connection_data;
	bool m_should_be_removed;
};

#endif /* _WEB_CONNECTION_H */
