gwenhywfar
4.8.0beta
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
gui
progressdata.c
Go to the documentation of this file.
1
/***************************************************************************
2
begin : Tue Feb 16 2010
3
copyright : (C) 2010 by Martin Preuss
4
email : martin@libchipcard.de
5
6
***************************************************************************
7
* Please see toplevel file COPYING for license details *
8
***************************************************************************/
9
10
11
#ifdef HAVE_CONFIG_H
12
# include <config.h>
13
#endif
14
15
#define DISABLE_DEBUGLOG
16
17
18
#include "progressdata_p.h"
19
20
#include <gwenhywfar/misc.h>
21
#include <gwenhywfar/debug.h>
22
23
24
25
26
GWEN_TREE_FUNCTIONS
(
GWEN_PROGRESS_DATA
, GWEN_ProgressData)
27
28
29
30
31
GWEN_PROGRESS_DATA
*
GWEN_ProgressData_new
(
GWEN_GUI
*gui,
32
uint32_t
id
,
33
uint32_t progressFlags,
34
const
char
*title,
35
const
char
*text,
36
uint64_t total) {
37
GWEN_PROGRESS_DATA
*pd;
38
39
GWEN_NEW_OBJECT
(
GWEN_PROGRESS_DATA
, pd);
40
GWEN_TREE_INIT
(
GWEN_PROGRESS_DATA
, pd);
41
42
pd->gui=gui;
43
pd->id=id;
44
pd->flags=progressFlags;
45
if
(title)
46
pd->title=strdup(title);
47
if
(text)
48
pd->text=strdup(text);
49
pd->total=total;
50
51
pd->logBuf=
GWEN_Buffer_new
(0, 1024, 0, 1);
52
pd->startTime=time(0);
53
54
return
pd;
55
}
56
57
58
59
void
GWEN_ProgressData_free
(
GWEN_PROGRESS_DATA
*pd) {
60
if
(pd) {
61
GWEN_TREE_FINI
(
GWEN_PROGRESS_DATA
, pd);
62
free(pd->title);
63
free(pd->text);
64
GWEN_Buffer_free
(pd->logBuf);
65
GWEN_FREE_OBJECT
(pd);
66
}
67
}
68
69
70
71
GWEN_GUI
*
GWEN_ProgressData_GetGui
(
const
GWEN_PROGRESS_DATA
*pd) {
72
assert(pd);
73
return
pd->gui;
74
}
75
76
77
78
uint32_t
GWEN_ProgressData_GetId
(
const
GWEN_PROGRESS_DATA
*pd) {
79
assert(pd);
80
return
pd->id;
81
}
82
83
84
85
uint32_t
GWEN_ProgressData_GetPreviousId
(
const
GWEN_PROGRESS_DATA
*pd) {
86
assert(pd);
87
return
pd->previousId;
88
}
89
90
91
92
void
GWEN_ProgressData_SetPreviousId
(
GWEN_PROGRESS_DATA
*pd, uint32_t i) {
93
assert(pd);
94
pd->previousId=i;
95
}
96
97
98
99
uint32_t
GWEN_ProgressData_GetFlags
(
const
GWEN_PROGRESS_DATA
*pd) {
100
assert(pd);
101
return
pd->flags;
102
}
103
104
105
106
void
GWEN_ProgressData_AddFlags
(
GWEN_PROGRESS_DATA
*pd, uint32_t fl) {
107
assert(pd);
108
pd->flags|=fl;
109
}
110
111
112
113
void
GWEN_ProgressData_SubFlags
(
GWEN_PROGRESS_DATA
*pd, uint32_t fl) {
114
assert(pd);
115
pd->flags&=~fl;
116
}
117
118
119
120
const
char
*
GWEN_ProgressData_GetTitle
(
const
GWEN_PROGRESS_DATA
*pd) {
121
assert(pd);
122
return
pd->title;
123
}
124
125
126
127
const
char
*
GWEN_ProgressData_GetText
(
const
GWEN_PROGRESS_DATA
*pd) {
128
assert(pd);
129
return
pd->text;
130
}
131
132
133
134
uint64_t
GWEN_ProgressData_GetTotal
(
const
GWEN_PROGRESS_DATA
*pd) {
135
assert(pd);
136
return
pd->total;
137
}
138
139
140
141
uint64_t
GWEN_ProgressData_GetCurrent
(
const
GWEN_PROGRESS_DATA
*pd) {
142
assert(pd);
143
return
pd->current;
144
}
145
146
147
148
void
GWEN_ProgressData_SetCurrent
(
GWEN_PROGRESS_DATA
*pd, uint64_t i) {
149
assert(pd);
150
pd->current=i;
151
}
152
153
154
155
void
GWEN_ProgressData_SetTotal
(
GWEN_PROGRESS_DATA
*pd, uint64_t i) {
156
assert(pd);
157
pd->total=i;
158
}
159
160
161
162
GWEN_BUFFER
*
GWEN_ProgressData_GetLogBuf
(
const
GWEN_PROGRESS_DATA
*pd) {
163
assert(pd);
164
return
pd->logBuf;
165
}
166
167
168
169
const
char
*
GWEN_ProgressData_GetLogText
(
const
GWEN_PROGRESS_DATA
*pd) {
170
assert(pd);
171
return
GWEN_Buffer_GetStart
(pd->logBuf);
172
}
173
174
175
176
void
GWEN_ProgressData_ClearLogText
(
GWEN_PROGRESS_DATA
*pd) {
177
assert(pd);
178
GWEN_Buffer_Reset
(pd->logBuf);
179
}
180
181
182
183
void
GWEN_ProgressData_AddLogText
(
GWEN_PROGRESS_DATA
*pd,
184
GWEN_LOGGER_LEVEL
level,
185
const
char
*s) {
186
assert(pd);
187
GWEN_Buffer_AppendString
(pd->logBuf, s);
188
}
189
190
191
192
int
GWEN_ProgressData_GetAborted
(
const
GWEN_PROGRESS_DATA
*pd) {
193
assert(pd);
194
return
pd->aborted;
195
}
196
197
198
199
void
GWEN_ProgressData_SetAborted
(
GWEN_PROGRESS_DATA
*pd,
int
i) {
200
assert(pd);
201
pd->aborted=i;
202
}
203
204
205
206
int
GWEN_ProgressData_GetShown
(
const
GWEN_PROGRESS_DATA
*pd) {
207
assert(pd);
208
return
pd->shown;
209
}
210
211
212
213
void
GWEN_ProgressData_SetShown
(
GWEN_PROGRESS_DATA
*pd,
int
i) {
214
assert(pd);
215
pd->shown=i;
216
}
217
218
219
220
time_t
GWEN_ProgressData_GetStartTime
(
const
GWEN_PROGRESS_DATA
*pd) {
221
assert(pd);
222
return
pd->startTime;
223
}
224
225
226
227
void
GWEN_ProgressData_SetStartTime
(
GWEN_PROGRESS_DATA
*pd, time_t t) {
228
assert(pd);
229
pd->startTime=t;
230
}
231
232
233
234
time_t
GWEN_ProgressData_GetCheckTime
(
const
GWEN_PROGRESS_DATA
*pd) {
235
assert(pd);
236
return
pd->checkTime;
237
}
238
239
240
241
void
GWEN_ProgressData_SetCheckTime
(
GWEN_PROGRESS_DATA
*pd, time_t t) {
242
assert(pd);
243
pd->checkTime=t;
244
}
245
246
247
248
GWEN_DIALOG
*
GWEN_ProgressData_GetDialog
(
const
GWEN_PROGRESS_DATA
*pd) {
249
assert(pd);
250
return
pd->dialog;
251
}
252
253
254
255
void
GWEN_ProgressData_SetDialog
(
GWEN_PROGRESS_DATA
*pd,
GWEN_DIALOG
*dlg) {
256
assert(pd);
257
pd->dialog=dlg;
258
}
259
260
261
262
GWEN_PROGRESS_DATA
*
GWEN_ProgressData_Tree_FindProgressById
(GWEN_PROGRESS_DATA_TREE *pt, uint32_t
id
) {
263
GWEN_PROGRESS_DATA
*pd;
264
265
pd=GWEN_ProgressData_Tree_GetFirst(pt);
266
while
(pd) {
267
if
(
GWEN_ProgressData_GetId
(pd)==
id
)
268
break
;
269
pd=GWEN_ProgressData_Tree_GetBelow(pd);
270
}
271
272
return
pd;
273
}
274
275
276
277
278
279
280
281
282
283
284
Generated on Tue Nov 12 2013 10:50:21 for gwenhywfar by
1.8.1.2