gwenhywfar  4.3.1
progressdata.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  begin       : Tue Feb 16 2010
00003  copyright   : (C) 2010 by Martin Preuss
00004  email       : martin@libchipcard.de
00005 
00006  ***************************************************************************
00007  *          Please see toplevel file COPYING for license details           *
00008  ***************************************************************************/
00009 
00010 
00011 #ifdef HAVE_CONFIG_H
00012 # include <config.h>
00013 #endif
00014 
00015 #define DISABLE_DEBUGLOG
00016 
00017 
00018 #include "progressdata_p.h"
00019 
00020 #include <gwenhywfar/misc.h>
00021 #include <gwenhywfar/debug.h>
00022 
00023 
00024 
00025 
00026 GWEN_TREE_FUNCTIONS(GWEN_PROGRESS_DATA, GWEN_ProgressData)
00027 
00028 
00029 
00030 
00031 GWEN_PROGRESS_DATA *GWEN_ProgressData_new(GWEN_GUI *gui,
00032                                           uint32_t id,
00033                                           uint32_t progressFlags,
00034                                           const char *title,
00035                                           const char *text,
00036                                           uint64_t total) {
00037   GWEN_PROGRESS_DATA *pd;
00038 
00039   GWEN_NEW_OBJECT(GWEN_PROGRESS_DATA, pd);
00040   GWEN_TREE_INIT(GWEN_PROGRESS_DATA, pd);
00041 
00042   pd->gui=gui;
00043   pd->id=id;
00044   pd->flags=progressFlags;
00045   if (title)
00046     pd->title=strdup(title);
00047   if (text)
00048     pd->text=strdup(text);
00049   pd->total=total;
00050 
00051   pd->logBuf=GWEN_Buffer_new(0, 1024, 0, 1);
00052   pd->startTime=time(0);
00053 
00054   return pd;
00055 }
00056 
00057 
00058 
00059 void GWEN_ProgressData_free(GWEN_PROGRESS_DATA *pd) {
00060   if (pd) {
00061     GWEN_TREE_FINI(GWEN_PROGRESS_DATA, pd);
00062     free(pd->title);
00063     free(pd->text);
00064     GWEN_Buffer_free(pd->logBuf);
00065     GWEN_FREE_OBJECT(pd);
00066   }
00067 }
00068 
00069 
00070 
00071 GWEN_GUI *GWEN_ProgressData_GetGui(const GWEN_PROGRESS_DATA *pd) {
00072   assert(pd);
00073   return pd->gui;
00074 }
00075 
00076 
00077 
00078 uint32_t GWEN_ProgressData_GetId(const GWEN_PROGRESS_DATA *pd) {
00079   assert(pd);
00080   return pd->id;
00081 }
00082 
00083 
00084 
00085 uint32_t GWEN_ProgressData_GetPreviousId(const GWEN_PROGRESS_DATA *pd) {
00086   assert(pd);
00087   return pd->previousId;
00088 }
00089 
00090 
00091 
00092 void GWEN_ProgressData_SetPreviousId(GWEN_PROGRESS_DATA *pd, uint32_t i) {
00093   assert(pd);
00094   pd->previousId=i;
00095 }
00096 
00097 
00098 
00099 uint32_t GWEN_ProgressData_GetFlags(const GWEN_PROGRESS_DATA *pd) {
00100   assert(pd);
00101   return pd->flags;
00102 }
00103 
00104 
00105 
00106 void GWEN_ProgressData_AddFlags(GWEN_PROGRESS_DATA *pd, uint32_t fl) {
00107   assert(pd);
00108   pd->flags|=fl;
00109 }
00110 
00111 
00112 
00113 void GWEN_ProgressData_SubFlags(GWEN_PROGRESS_DATA *pd, uint32_t fl) {
00114   assert(pd);
00115   pd->flags&=~fl;
00116 }
00117 
00118 
00119 
00120 const char *GWEN_ProgressData_GetTitle(const GWEN_PROGRESS_DATA *pd) {
00121   assert(pd);
00122   return pd->title;
00123 }
00124 
00125 
00126 
00127 const char *GWEN_ProgressData_GetText(const GWEN_PROGRESS_DATA *pd) {
00128   assert(pd);
00129   return pd->text;
00130 }
00131 
00132 
00133 
00134 uint64_t GWEN_ProgressData_GetTotal(const GWEN_PROGRESS_DATA *pd) {
00135   assert(pd);
00136   return pd->total;
00137 }
00138 
00139 
00140 
00141 uint64_t GWEN_ProgressData_GetCurrent(const GWEN_PROGRESS_DATA *pd) {
00142   assert(pd);
00143   return pd->current;
00144 }
00145 
00146 
00147 
00148 void GWEN_ProgressData_SetCurrent(GWEN_PROGRESS_DATA *pd, uint64_t i) {
00149   assert(pd);
00150   pd->current=i;
00151 }
00152 
00153 
00154 
00155 void GWEN_ProgressData_SetTotal(GWEN_PROGRESS_DATA *pd, uint64_t i) {
00156   assert(pd);
00157   pd->total=i;
00158 }
00159 
00160 
00161 
00162 GWEN_BUFFER *GWEN_ProgressData_GetLogBuf(const GWEN_PROGRESS_DATA *pd) {
00163   assert(pd);
00164   return pd->logBuf;
00165 }
00166 
00167 
00168 
00169 const char *GWEN_ProgressData_GetLogText(const GWEN_PROGRESS_DATA *pd) {
00170   assert(pd);
00171   return GWEN_Buffer_GetStart(pd->logBuf);
00172 }
00173 
00174 
00175 
00176 void GWEN_ProgressData_ClearLogText(GWEN_PROGRESS_DATA *pd) {
00177   assert(pd);
00178   GWEN_Buffer_Reset(pd->logBuf);
00179 }
00180 
00181 
00182 
00183 void GWEN_ProgressData_AddLogText(GWEN_PROGRESS_DATA *pd,
00184                                   GWEN_LOGGER_LEVEL level,
00185                                   const char *s) {
00186   assert(pd);
00187   GWEN_Buffer_AppendString(pd->logBuf, s);
00188 }
00189 
00190 
00191 
00192 int GWEN_ProgressData_GetAborted(const GWEN_PROGRESS_DATA *pd) {
00193   assert(pd);
00194   return pd->aborted;
00195 }
00196 
00197 
00198 
00199 void GWEN_ProgressData_SetAborted(GWEN_PROGRESS_DATA *pd, int i) {
00200   assert(pd);
00201   pd->aborted=i;
00202 }
00203 
00204 
00205 
00206 int GWEN_ProgressData_GetShown(const GWEN_PROGRESS_DATA *pd) {
00207   assert(pd);
00208   return pd->shown;
00209 }
00210 
00211 
00212 
00213 void GWEN_ProgressData_SetShown(GWEN_PROGRESS_DATA *pd, int i) {
00214   assert(pd);
00215   pd->shown=i;
00216 }
00217 
00218 
00219 
00220 time_t GWEN_ProgressData_GetStartTime(const GWEN_PROGRESS_DATA *pd) {
00221   assert(pd);
00222   return pd->startTime;
00223 }
00224 
00225 
00226 
00227 void GWEN_ProgressData_SetStartTime(GWEN_PROGRESS_DATA *pd, time_t t) {
00228   assert(pd);
00229   pd->startTime=t;
00230 }
00231 
00232 
00233 
00234 time_t GWEN_ProgressData_GetCheckTime(const GWEN_PROGRESS_DATA *pd) {
00235   assert(pd);
00236   return pd->checkTime;
00237 }
00238 
00239 
00240 
00241 void GWEN_ProgressData_SetCheckTime(GWEN_PROGRESS_DATA *pd, time_t t) {
00242   assert(pd);
00243   pd->checkTime=t;
00244 }
00245 
00246 
00247 
00248 GWEN_DIALOG *GWEN_ProgressData_GetDialog(const GWEN_PROGRESS_DATA *pd) {
00249   assert(pd);
00250   return pd->dialog;
00251 }
00252 
00253 
00254 
00255 void GWEN_ProgressData_SetDialog(GWEN_PROGRESS_DATA *pd, GWEN_DIALOG *dlg) {
00256   assert(pd);
00257   pd->dialog=dlg;
00258 }
00259 
00260 
00261 
00262 GWEN_PROGRESS_DATA *GWEN_ProgressData_Tree_FindProgressById(GWEN_PROGRESS_DATA_TREE *pt, uint32_t id) {
00263   GWEN_PROGRESS_DATA *pd;
00264 
00265   pd=GWEN_ProgressData_Tree_GetFirst(pt);
00266   while(pd) {
00267     if (GWEN_ProgressData_GetId(pd)==id)
00268       break;
00269     pd=GWEN_ProgressData_Tree_GetBelow(pd);
00270   }
00271 
00272   return pd;
00273 }
00274 
00275 
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284