1
0

UpdateTime.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "main.h"
  2. #include "api__ml_wire.h"
  3. #include "UpdateTime.h"
  4. __time64_t Update::times[] = {0, // TIME_MANUALLY
  5. 60 /* 1 minute */ * 60 /* 1 hour */ * 24 /* 1 day */ * 7 /* 1 week */, // TIME_WEEKLY
  6. 60 /* 1 minute */ * 60 /* 1 hour */ * 24 /* 1 day */, // TIME_DAILY
  7. 60 /* 1 minute */ * 60 /* 1 hour */, // TIME_HOURLY
  8. };
  9. const wchar_t *Update::GetTitle( int position, wchar_t *buffer, int bufferMax )
  10. {
  11. if ( NULL == buffer )
  12. return NULL;
  13. INT stringId = IDS_ERROR_FYEO;
  14. switch ( position )
  15. {
  16. case TIME_MANUALLY:
  17. stringId = IDS_UPD_MANUALLY;
  18. break;
  19. case TIME_WEEKLY:
  20. stringId = IDS_UPD_WEEK;
  21. break;
  22. case TIME_DAILY:
  23. stringId = IDS_UPD_DAY;
  24. break;
  25. case TIME_HOURLY:
  26. stringId = IDS_UPD_HOUR;
  27. break;
  28. }
  29. return WASABI_API_LNGSTRINGW_BUF( stringId, buffer, bufferMax );
  30. }
  31. bool Update::GetAutoUpdate(int selection)
  32. {
  33. if (selection == TIME_MANUALLY)
  34. return false;
  35. else
  36. return true;
  37. }
  38. __time64_t Update::GetTime(int selection)
  39. {
  40. if (selection >= 0 && selection < TIME_NUMENTRIES)
  41. return times[selection];
  42. else
  43. return 0;
  44. }
  45. int Update::GetSelection(__time64_t selTime, bool autoUpdate)
  46. {
  47. if (!autoUpdate)
  48. return TIME_MANUALLY;
  49. for (int i = TIME_WEEKLY;i < TIME_NUMENTRIES;i++)
  50. if (selTime >= times[i])
  51. return i;
  52. return TIME_DAILY;
  53. }