~ps-jenkins/indicator-transfer/ubuntu-vivid-proposed

« back to all changes in this revision

Viewing changes to include/transfer/transfer.h

  • Committer: Ted Gould
  • Author(s): Charles Kerr
  • Date: 2014-06-18 19:26:56 UTC
  • mfrom: (1.2.20 indicator-transfer)
  • Revision ID: ted@gould.cx-20140618192656-ufycr3k7g5w0en4u
This sets up the code layout, menu, indicator, unit tests, code coverage rules, etc... what you'd expect from an indicator.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors:
 
17
 *   Charles Kerr <charles.kerr@canonical.com>
 
18
 */
 
19
 
 
20
#ifndef INDICATOR_TRANSFER_TRANSFER_H
 
21
#define INDICATOR_TRANSFER_TRANSFER_H
 
22
 
 
23
#include <core/property.h> // parent class
 
24
 
 
25
#include <gio/gio.h> // GIcon
 
26
 
 
27
#include <ctime> // time_t
 
28
#include <memory>
 
29
#include <string>
 
30
#include <vector>
 
31
 
 
32
namespace unity {
 
33
namespace indicator {
 
34
namespace transfer {
 
35
 
 
36
/**
 
37
 * \brief Plain Old Data Structure representing a single Transfer
 
38
 */
 
39
struct Transfer
 
40
{
 
41
  typedef enum { QUEUED, RUNNING, PAUSED, CANCELED,
 
42
                 HASHING, PROCESSING, FINISHED,
 
43
                 ERROR } State;
 
44
  State state = QUEUED;
 
45
  bool can_start() const { return state==QUEUED; }
 
46
  bool can_resume() const { return state==PAUSED || state==CANCELED || state==ERROR; }
 
47
  bool can_pause() const { return state==RUNNING || state==HASHING || state==PROCESSING; }
 
48
  bool can_cancel() const { return state!=FINISHED; }
 
49
  bool can_clear() const { return state==FINISHED; }
 
50
 
 
51
  // -1 == unknown
 
52
  int seconds_left = -1;
 
53
 
 
54
  time_t time_started = 0;
 
55
 
 
56
  // [0...1]
 
57
  float progress = 0.0;
 
58
 
 
59
  uint64_t speed_bps = 0;
 
60
 
 
61
  uint64_t total_size = 0;
 
62
 
 
63
  typedef std::string Id;
 
64
  Id id;
 
65
  std::string title;
 
66
  std::string app_icon;
 
67
 
 
68
  // meaningful iff state is ERROR
 
69
  std::string error_string;
 
70
 
 
71
  // meaningful iff state is FINISHED
 
72
  std::string local_path;
 
73
};
 
74
    
 
75
} // namespace transfer
 
76
} // namespace indicator
 
77
} // namespace unity
 
78
 
 
79
#endif // INDICATOR_TRANSFER_TRANSFER_H