deskflow/src/lib/shared/SerialKey.h

55 lines
1.6 KiB
C
Raw Normal View History

2015-10-21 23:00:23 +00:00
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Ltd.
*
2015-10-21 23:00:23 +00:00
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
2015-10-21 23:00:23 +00:00
* This package 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "SerialKeyData.h"
2020-10-02 07:19:13 +00:00
#include "SerialKeyEdition.h"
#include <ctime>
#include <string>
2015-10-21 23:00:23 +00:00
class SerialKey {
friend bool operator==(SerialKey const &, SerialKey const &);
public:
explicit SerialKey(Edition edition = kUnregistered);
explicit SerialKey(const std::string &serial);
bool isExpiring(time_t currentTime) const;
bool isExpired(time_t currentTime) const;
bool isTrial() const;
bool isTemporary() const;
bool isMaintenance() const;
bool isValid() const;
time_t daysLeft(time_t currentTime) const;
time_t getExpiration() const;
int getSpanLeft(time_t time = ::time(0)) const;
Edition edition() const;
const std::string &toString() const;
private:
SerialKeyData m_data;
2015-10-21 23:00:23 +00:00
};
inline bool operator==(SerialKey const &lhs, SerialKey const &rhs) {
return (lhs.m_data == rhs.m_data);
}
inline bool operator!=(SerialKey const &lhs, SerialKey const &rhs) {
return !(lhs == rhs);
}