~ubuntu-branches/ubuntu/utopic/indicator-transfer/utopic

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright 2014 Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3, as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
 *
 * Authors:
 *   Charles Kerr <charles.kerr@canonical.com>
 */

#ifndef INDICATOR_TRANSFER_TRANSFER_H
#define INDICATOR_TRANSFER_TRANSFER_H

#include <core/property.h> // parent class

#include <gio/gio.h> // GIcon

#include <ctime> // time_t
#include <memory>
#include <string>
#include <vector>

namespace unity {
namespace indicator {
namespace transfer {

/**
 * \brief A simple struct representing a single Transfer
 */
struct Transfer
{
  typedef enum { QUEUED, RUNNING, PAUSED, CANCELED,
                 HASHING, PROCESSING, FINISHED,
                 ERROR } State;
  State state = QUEUED;
  bool can_start() const;
  bool can_resume() const;
  bool can_pause() const;
  bool can_cancel() const;
  bool can_clear() const;

  // -1 == unknown
  int seconds_left = -1;

  time_t time_started = 0;

  // [0...1]
  float progress = 0.0;

  uint64_t speed_bps = 0;

  uint64_t total_size = 0;

  typedef std::string Id;
  Id id;
  std::string title;
  std::string app_icon;

  // meaningful iff state is ERROR
  std::string error_string;

  // meaningful iff state is FINISHED
  std::string local_path;

protected:
  static std::string next_unique_id();
};
    
} // namespace transfer
} // namespace indicator
} // namespace unity

#endif // INDICATOR_TRANSFER_TRANSFER_H