//-------------------------------------------------------------------------------
// <copyright file="ConnectionManagerChannelSettings.h" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
// 	Declaration of ConnectionManagerChannelSettings class, a serializable entity
//  that contains the settings for a ConnectionManagerChannel
// </summary>
//
// <owner>Arash Ushani</owner>
//-------------------------------------------------------------------------------

#ifndef __ConnectionManagerChannelSettings_H__
#define __ConnectionManagerChannelSettings_H__

#include "PPPHostSettings.h"
#include <string>
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>

namespace LiquidRobotics {
namespace ConnectionManager {

class ConnectionManagerChannelSettings
{
public:

	typedef LiquidRobotics::PPPHostLib::PPPHostSettings PPPHostSettings;
	typedef std::string string;

	enum ProtocolRevision
	{	// Use decimal values here as that is what is used in the XML configuration files.
		WIFI = 32,
		CELL = 33,
		BGAN = 34,
		RUDICS = 35
	};

	ConnectionManagerChannelSettings();
	ConnectionManagerChannelSettings(const ConnectionManagerChannelSettings& rhs);

	const int GetProtocolRevision() const;
	void SetProtocolRevision(const int newValue);

	const string& GetPowerOnVerb() const;
	void SetPowerOnVerb(const string& newValue);

	const string& GetPowerOffVerb() const;
	void SetPowerOffVerb(const string& newValue);

	const string& GetSignalStrengthVerb() const;
	void SetSignalStrengthVerb(const string& newValue);

	const string& GetSignalStrengthFilename() const;
	void SetSignalStrengthFilename(const string& newValue);

	const int GetMinimumSignalStrength() const;
	void SetMinimumSignalStrength (const int newValue);

	const int GetQueueCapacity() const;
	void SetQueueCapacity(const int newValue);

	const string& GetModemSerialNumberFilename() const;
	void SetModemSerialNumberFilename(const string& newValue);

	const string& GetModemSimCardFilename() const;
	void SetModemSimCardFilename(const string& newValue);

	const PPPHostSettings& GetPPPSettings() const;
	void SetPPPSettings(const PPPHostSettings& newValue);

	void Load(const string& fileName);
	void Save(const string& fileName) const;

private:

	friend class boost::serialization::access;

	template<class Archive>
	void serialize(Archive & ar, const unsigned int version)
	{
		ar & BOOST_SERIALIZATION_NVP(protocolRevision);

		if (protocolRevision==RUDICS)
		{
			ar & BOOST_SERIALIZATION_NVP(queueCapacity);
			ar & BOOST_SERIALIZATION_NVP(modemSerialNumberFilename);
			ar & BOOST_SERIALIZATION_NVP(modemSimCardFilename);
			ar & BOOST_SERIALIZATION_NVP(pppSettings);
		}
		else
		{
			ar & BOOST_SERIALIZATION_NVP(powerOnVerb);
			ar & BOOST_SERIALIZATION_NVP(powerOffVerb);
			ar & BOOST_SERIALIZATION_NVP(signalStrengthVerb);
			ar & BOOST_SERIALIZATION_NVP(signalStrengthFilename);
//			ar & BOOST_SERIALIZATION_NVP(minimumSignalStrength);
		}
	}

	int protocolRevision;

	// For non-RUDICS Channels
	string powerOnVerb;
	string powerOffVerb;
	string signalStrengthVerb;
	string signalStrengthFilename;
	int    minimumSignalStrength;

	// Only for PPP (Protocol Revision 35/RUDICS)
	int queueCapacity;
	string modemSerialNumberFilename;
	string modemSimCardFilename;
	PPPHostSettings pppSettings;

};


}
}

BOOST_CLASS_VERSION(LiquidRobotics::ConnectionManager::ConnectionManagerChannelSettings, 1)

#endif
