summaryrefslogtreecommitdiff
path: root/src/DeviceSettings.hpp
blob: 22b0a90423979c4637f7a0e3b871ceac6802e8c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix -*-
// ***** BEGIN LICENSE BLOCK *****
//////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011-2014 RALOVICH, Kristóf                            //
//                                                                      //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 3 of the License, or    //
// (at your option) any later version.                                  //
//                                                                      //
// This program 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.                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////
// ***** END LICENSE BLOCK *****


#include <ctime>
#include <string>

namespace antpm {

class DeviceSettings
{
public:
  DeviceSettings(const char* devId);

  void loadDefaultValues();
  const std::string getConfigFileName() const;
  const std::string getFolder() const;
  bool saveToFile(const char* fname);
  bool saveToFile(const std::string& fname) { return saveToFile(fname.c_str()); }
  bool loadFromFile(const char* fname);
  bool loadFromFile(const std::string& fname) { return loadFromFile(fname.c_str()); }
  void mergeLastUserProfileTime(const std::time_t gmt);
  void mergeLastTransferredTime(const std::time_t gmt);

  static std::time_t str2time(const char* from);
  static const std::string time2str(const std::time_t t);

  unsigned int MaxFileDownloads;
  std::time_t  LastUserProfileTime; // date of the latest activity successfully downloaded fromt the device, represented as GMT/UTC
  std::time_t  LastTransferredTime; // last timepoint, communication happened with the device, represented as GMT/UTC
  size_t       SerialWriteDelayMs;
private:
  std::string mDevId;
};

}