Permalink
Browse files

Refactor mythmiscutil.h splitting off date/time stuff into mythdate.h…

… and timezone stuff into mythtimezone.h
  • Loading branch information...
1 parent a7cf09d commit 4f028f388c38c1677b6c79c5efcc461f8b20cb4c @daniel-kristjansson daniel-kristjansson committed May 30, 2012
Showing with 971 additions and 869 deletions.
  1. +1 −1 mythplugins/mytharchive/mytharchive/archivesettings.cpp
  2. +1 −1 mythplugins/mytharchive/mytharchive/archiveutil.cpp
  3. +1 −1 mythplugins/mytharchive/mytharchive/importnative.cpp
  4. +1 −1 mythplugins/mytharchive/mytharchive/main.cpp
  5. +2 −1 mythplugins/mytharchive/mytharchive/mythburn.cpp
  6. +1 −1 mythplugins/mytharchive/mytharchive/recordingselector.cpp
  7. +3 −2 mythplugins/mytharchive/mytharchivehelper/main.cpp
  8. +1 −1 mythplugins/mythbrowser/mythbrowser/bookmarkeditor.cpp
  9. +1 −1 mythplugins/mythgallery/mythgallery/galleryfilterdlg.cpp
  10. +1 −1 mythplugins/mythgallery/mythgallery/galleryutil.cpp
  11. +1 −1 mythplugins/mythgallery/mythgallery/glsingleview.cpp
  12. +1 −1 mythplugins/mythgallery/mythgallery/glsingleview.h
  13. +2 −1 mythplugins/mythgallery/mythgallery/iconview.cpp
  14. +1 −1 mythplugins/mythgallery/mythgallery/singleview.cpp
  15. +1 −1 mythplugins/mythgallery/mythgallery/thumbgenerator.cpp
  16. +3 −6 mythplugins/mythgame/mythgame/gamehandler.cpp
  17. +1 −1 mythplugins/mythmusic/mythmusic/filescanner.cpp
  18. +2 −2 mythplugins/mythmusic/mythmusic/metadata.cpp
  19. +1 −1 mythplugins/mythmusic/mythmusic/smartplaylist.cpp
  20. +1 −1 mythplugins/mythnetvision/mythnetvision/netsearch.cpp
  21. +1 −1 mythplugins/mythnetvision/mythnetvision/nettree.cpp
  22. +1 −1 mythplugins/mythnetvision/mythnetvision/rsseditor.cpp
  23. +1 −1 mythplugins/mythnetvision/mythnetvision/treeeditor.cpp
  24. +8 −8 mythplugins/mythnews/mythnews/mythnews.cpp
  25. +1 −1 mythplugins/mythnews/mythnews/mythnewseditor.cpp
  26. +1 −1 mythplugins/mythnews/mythnews/newssite.cpp
  27. +1 −1 mythplugins/mythweather/mythweather/weather.cpp
  28. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
  29. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmconsole.cpp
  30. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmevents.cpp
  31. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmplayer.cpp
  32. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmsettings.cpp
  33. +1 −1 mythtv/libs/libmyth/audio/audiooutput.cpp
  34. +1 −1 mythtv/libs/libmyth/audio/audiooutputjack.cpp
  35. +2 −1 mythtv/libs/libmyth/audio/audiooutputoss.cpp
  36. +1 −1 mythtv/libs/libmyth/audio/audiopulsehandler.cpp
  37. +3 −1 mythtv/libs/libmyth/mythcontext.cpp
  38. +3 −1 mythtv/libs/libmyth/mythmediamonitor.cpp
  39. +1 −1 mythtv/libs/libmyth/mythrssmanager.cpp
  40. +1 −1 mythtv/libs/libmyth/mythwidgets.cpp
  41. +3 −2 mythtv/libs/libmyth/netgrabbermanager.cpp
  42. +1 −1 mythtv/libs/libmyth/netutils.cpp
  43. +9 −8 mythtv/libs/libmyth/programinfo.cpp
  44. +1 −1 mythtv/libs/libmyth/programinfo.h
  45. +1 −1 mythtv/libs/libmyth/programtypes.cpp
  46. +1 −1 mythtv/libs/libmyth/rssparse.cpp
  47. +2 −1 mythtv/libs/libmyth/schemawizard.cpp
  48. +1 −1 mythtv/libs/libmyth/storagegroupeditor.cpp
  49. +1 −1 mythtv/libs/libmyth/uitypes.cpp
  50. +1 −1 mythtv/libs/libmyth/uitypes.h
  51. +1 −1 mythtv/libs/libmyth/xmlparse.cpp
  52. +1 −0 mythtv/libs/libmythbase/dbutil.cpp
  53. +1 −1 mythtv/libs/libmythbase/hardwareprofile.cpp
  54. +3 −3 mythtv/libs/libmythbase/libmythbase.pro
  55. +1 −1 mythtv/libs/libmythbase/mythcdrom-linux.cpp
  56. +13 −5 mythtv/libs/libmythbase/mythcommandlineparser.cpp
  57. +148 −0 mythtv/libs/libmythbase/mythdate.cpp
  58. +52 −0 mythtv/libs/libmythbase/mythdate.h
  59. +1 −1 mythtv/libs/libmythbase/mythdbcon.cpp
  60. +1 −1 mythtv/libs/libmythbase/mythdownloadmanager.cpp
  61. +1 −600 mythtv/libs/libmythbase/mythmiscutil.cpp
  62. +33 −85 mythtv/libs/libmythbase/mythmiscutil.h
  63. +19 −0 mythtv/libs/libmythbase/mythsystem.cpp
  64. +2 −0 mythtv/libs/libmythbase/mythsystem.h
  65. +455 −0 mythtv/libs/libmythbase/mythtimezone.cpp
  66. +16 −0 mythtv/libs/libmythbase/mythtimezone.h
  67. +1 −1 mythtv/libs/libmythbase/remotefile.cpp
  68. +1 −1 mythtv/libs/libmythmetadata/metadataimagedownload.cpp
  69. +1 −1 mythtv/libs/libmythmetadata/mythuiimageresults.cpp
  70. +1 −1 mythtv/libs/libmythmetadata/mythuimetadataresults.cpp
  71. +1 −1 mythtv/libs/libmythmetadata/parentalcontrols.cpp
  72. +2 −1 mythtv/libs/libmythmetadata/videometadata.cpp
  73. +1 −1 mythtv/libs/libmythmetadata/videoscan.cpp
  74. +3 −1 mythtv/libs/libmythprotoserver/requesthandler/basehandler.cpp
  75. +3 −1 mythtv/libs/libmythprotoserver/requesthandler/fileserverhandler.cpp
  76. +2 −1 mythtv/libs/libmythtv/Bluray/bdringbuffer.h
  77. +1 −1 mythtv/libs/libmythtv/DVD/dvdringbuffer.h
  78. +1 −1 mythtv/libs/libmythtv/DeviceReadBuffer.h
  79. +1 −1 mythtv/libs/libmythtv/ThreadedFileWriter.cpp
  80. +1 −1 mythtv/libs/libmythtv/asistreamhandler.h
  81. +1 −1 mythtv/libs/libmythtv/cetonstreamhandler.h
  82. +1 −1 mythtv/libs/libmythtv/channelscan/paneexistingscanimport.h
  83. +1 −1 mythtv/libs/libmythtv/channelscan/scaninfo.cpp
  84. +2 −1 mythtv/libs/libmythtv/datadirect.cpp
  85. +1 −1 mythtv/libs/libmythtv/eitcache.cpp
  86. +1 −1 mythtv/libs/libmythtv/eithelper.cpp
  87. +7 −7 mythtv/libs/libmythtv/eitscanner.cpp
  88. +2 −1 mythtv/libs/libmythtv/fileringbuffer.cpp
  89. +1 −1 mythtv/libs/libmythtv/firewiresignalmonitor.h
  90. +1 −1 mythtv/libs/libmythtv/hdhrstreamhandler.h
  91. +1 −1 mythtv/libs/libmythtv/importrecorder.cpp
  92. +3 −1 mythtv/libs/libmythtv/jobqueue.cpp
  93. +2 −1 mythtv/libs/libmythtv/mpeg/atsctables.h
  94. +1 −1 mythtv/libs/libmythtv/mpeg/mpegstreamdata.h
  95. +1 −1 mythtv/libs/libmythtv/mpeg/mpegtables.cpp
  96. +1 −1 mythtv/libs/libmythtv/mpeg/sctetables.cpp
  97. +1 −1 mythtv/libs/libmythtv/mpeg/streamlisteners.h
  98. +1 −1 mythtv/libs/libmythtv/mpegrecorder.cpp
  99. +1 −0 mythtv/libs/libmythtv/mythccextractorplayer.cpp
  100. +1 −0 mythtv/libs/libmythtv/mythccextractorplayer.h
  101. +2 −1 mythtv/libs/libmythtv/mythplayer.cpp
  102. +5 −2 mythtv/libs/libmythtv/playercontext.h
  103. +2 −1 mythtv/libs/libmythtv/previewgenerator.cpp
  104. +1 −1 mythtv/libs/libmythtv/previewgenerator.h
  105. +1 −1 mythtv/libs/libmythtv/recorderbase.cpp
  106. +1 −0 mythtv/libs/libmythtv/recordinginfo.cpp
  107. +1 −1 mythtv/libs/libmythtv/recordingquality.cpp
  108. +1 −1 mythtv/libs/libmythtv/recordingrule.cpp
  109. +1 −1 mythtv/libs/libmythtv/remoteencoder.cpp
  110. +2 −1 mythtv/libs/libmythtv/ringbuffer.cpp
  111. +1 −1 mythtv/libs/libmythtv/signalmonitor.cpp
  112. +1 −1 mythtv/libs/libmythtv/sourceutil.cpp
  113. +1 −1 mythtv/libs/libmythtv/streamhandler.h
  114. +1 −0 mythtv/libs/libmythtv/tv_play.cpp
  115. +2 −1 mythtv/libs/libmythtv/tv_play.h
  116. +1 −1 mythtv/libs/libmythtv/tv_rec.cpp
  117. +1 −0 mythtv/libs/libmythtv/videooutwindow.cpp
  118. +1 −1 mythtv/libs/libmythupnp/httprequest.cpp
  119. +1 −1 mythtv/libs/libmythupnp/upnptasksearch.cpp
  120. +1 −1 mythtv/programs/mythbackend/autoexpire.cpp
  121. +1 −1 mythtv/programs/mythbackend/encoderlink.cpp
  122. +1 −1 mythtv/programs/mythbackend/filetransfer.cpp
  123. +2 −1 mythtv/programs/mythbackend/housekeeper.cpp
  124. +1 −1 mythtv/programs/mythbackend/httpstatus.cpp
  125. +1 −1 mythtv/programs/mythbackend/internetContent.cpp
  126. +1 −0 mythtv/programs/mythbackend/main.cpp
  127. +2 −0 mythtv/programs/mythbackend/main_helpers.cpp
  128. +5 −1 mythtv/programs/mythbackend/mainserver.cpp
  129. +1 −1 mythtv/programs/mythbackend/playbacksock.cpp
  130. +3 −1 mythtv/programs/mythbackend/scheduler.cpp
  131. +1 −1 mythtv/programs/mythbackend/services/capture.cpp
  132. +1 −1 mythtv/programs/mythbackend/services/content.cpp
  133. +4 −3 mythtv/programs/mythbackend/services/myth.cpp
  134. +1 −1 mythtv/programs/mythbackend/services/video.cpp
  135. +1 −1 mythtv/programs/mythbackend/upnpcdstv.cpp
  136. +1 −1 mythtv/programs/mythbackend/upnpcdsvideo.cpp
  137. +1 −0 mythtv/programs/mythcommflag/ClassicCommDetector.cpp
  138. +1 −1 mythtv/programs/mythcommflag/TemplateFinder.cpp
  139. +1 −0 mythtv/programs/mythcommflag/main.cpp
  140. +3 −4 mythtv/programs/mythfilldatabase/filldata.cpp
  141. +2 −1 mythtv/programs/mythfilldatabase/main.cpp
  142. +1 −1 mythtv/programs/mythfilldatabase/xmltvparser.cpp
  143. +2 −1 mythtv/programs/mythfrontend/backendconnectionmanager.cpp
  144. +1 −0 mythtv/programs/mythfrontend/grabbersettings.cpp
  145. +1 −1 mythtv/programs/mythfrontend/guidegrid.cpp
  146. +2 −0 mythtv/programs/mythfrontend/main.cpp
  147. +1 −1 mythtv/programs/mythfrontend/manualschedule.cpp
  148. +1 −1 mythtv/programs/mythfrontend/mediarenderer.cpp
  149. +1 −1 mythtv/programs/mythfrontend/mythfexml.cpp
  150. +1 −0 mythtv/programs/mythfrontend/networkcontrol.cpp
  151. +1 −1 mythtv/programs/mythfrontend/playbackbox.cpp
  152. +1 −1 mythtv/programs/mythfrontend/progdetails.cpp
  153. +1 −1 mythtv/programs/mythfrontend/proglist.cpp
  154. +1 −1 mythtv/programs/mythfrontend/proglist_helpers.cpp
  155. +1 −0 mythtv/programs/mythfrontend/setupwizard_general.cpp
  156. +2 −1 mythtv/programs/mythfrontend/statusbox.cpp
  157. +1 −1 mythtv/programs/mythfrontend/themechooser.cpp
  158. +1 −1 mythtv/programs/mythfrontend/videofilter.cpp
  159. +1 −1 mythtv/programs/mythfrontend/videolist.cpp
  160. +1 −1 mythtv/programs/mythlcdserver/lcdprocclient.cpp
  161. +1 −1 mythtv/programs/mythlcdserver/lcdserver.cpp
  162. +1 −1 mythtv/programs/mythshutdown/main.cpp
  163. +2 −1 mythtv/programs/mythtranscode/main.cpp
  164. +1 −1 mythtv/programs/mythtranscode/mpeg2fix.cpp
  165. +1 −1 mythtv/programs/mythtv-setup/checksetup.cpp
  166. +1 −1 mythtv/programs/mythtv-setup/importicons.cpp
View
2 mythplugins/mytharchive/mytharchive/archivesettings.cpp
@@ -7,7 +7,7 @@
// myth
#include <mythcontext.h>
#include <mythdirs.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mytharchive
#include "archivesettings.h"
View
2 mythplugins/mytharchive/mytharchive/archiveutil.cpp
@@ -19,7 +19,7 @@ using namespace std;
#include <programinfo.h>
#include <mythmainwindow.h>
#include <mythdialogbox.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythsystem.h>
#include <exitcodes.h>
#include <mythlogging.h>
View
2 mythplugins/mytharchive/mytharchive/importnative.cpp
@@ -18,7 +18,7 @@
#include <mythdialogbox.h>
#include <mythsystem.h>
#include <exitcodes.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mytharchive
#include "importnative.h"
View
2 mythplugins/mytharchive/mytharchive/main.cpp
@@ -22,7 +22,7 @@ using namespace std;
#include <mythversion.h>
#include <mythplugin.h>
#include <mythcoreutil.h>
-#include <mythmiscutil.h>
+#include <mythsystem.h>
#include <myththemedmenu.h>
#include <mythuihelper.h>
#include <mythdialogbox.h>
View
3 mythplugins/mytharchive/mytharchive/mythburn.cpp
@@ -25,8 +25,9 @@
#include <mythuicheckbox.h>
#include <mythuibuttonlist.h>
#include <mythuiprogressbar.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythsystem.h>
+#include <mythmiscutil.h>
#include <exitcodes.h>
// mytharchive
View
2 mythplugins/mytharchive/mytharchive/recordingselector.cpp
@@ -25,7 +25,7 @@
#include <mythprogressdialog.h>
#include <mythdialogbox.h>
#include <mythlogging.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <netutils.h>
// mytharchive
View
5 mythplugins/mytharchive/mytharchivehelper/main.cpp
@@ -53,16 +53,17 @@ using namespace std;
// MythTV headers
#include <mythcommandlineparser.h>
-#include <mythcontext.h>
+#include <mythmiscutil.h>
#include <mythcoreutil.h>
+#include <mythcontext.h>
#include <mythversion.h>
#include <exitcodes.h>
#include <mythdb.h>
#include <programinfo.h>
#include <mythdirs.h>
#include <mythconfig.h>
#include <mythsystem.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythlogging.h>
extern "C" {
View
2 mythplugins/mythbrowser/mythbrowser/bookmarkeditor.cpp
@@ -1,7 +1,7 @@
// myth
#include <mythmainwindow.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythcontext.h>
#include <mythdbcon.h>
View
2 mythplugins/mythgallery/mythgallery/galleryfilterdlg.cpp
@@ -23,7 +23,7 @@ using namespace std;
#include <QList>
// MythTV headers
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdbcon.h>
#include <mythuibuttonlist.h>
#include <mythcontext.h>
View
2 mythplugins/mythgallery/mythgallery/galleryutil.cpp
@@ -23,7 +23,7 @@
// myth
#include <mythcontext.h>
#include <mythdbcon.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdirs.h>
#include <mythdb.h>
#include <mythuihelper.h>
View
2 mythplugins/mythgallery/mythgallery/glsingleview.cpp
@@ -38,7 +38,7 @@ using namespace std;
// MythTV plugin headers
#include <mythcontext.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythuihelper.h>
#include "mythlogging.h"
View
2 mythplugins/mythgallery/mythgallery/glsingleview.h
@@ -26,7 +26,7 @@
// MythTV plugin headers
#include <mythdialogs.h>
#include <mthread.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// MythGallery headers
#include "imageview.h"
View
3 mythplugins/mythgallery/mythgallery/iconview.cpp
@@ -35,9 +35,10 @@ using namespace std;
#include <QFileInfo>
// MythTV headers
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdbcon.h>
#include <httpcomms.h>
+#include <mythsystem.h>
#include <mythcontext.h>
#include <mythlogging.h>
#include <mythmainwindow.h>
View
2 mythplugins/mythgallery/mythgallery/singleview.cpp
@@ -36,7 +36,7 @@ using namespace std;
// MythTV plugin headers
#include <mythuihelper.h>
#include <mythcontext.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// MythGallery headers
#include "singleview.h"
View
2 mythplugins/mythgallery/mythgallery/thumbgenerator.cpp
@@ -33,7 +33,7 @@
#include <mythcontext.h>
#include <mythdirs.h>
#include <mthread.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mythgallery
#include "config.h"
View
9 mythplugins/mythgame/mythgame/gamehandler.cpp
@@ -8,21 +8,18 @@
#include <QDir>
#include <QList>
-
-#include <mythdbcon.h>
-#include <mythmiscutil.h>
#include <mythdb.h>
-
+#include <mythdbcon.h>
+#include <mythsystem.h>
#include <mythcontext.h>
#include <mythdialogs.h>
-
#include <mythuihelper.h>
#include <mythdialogbox.h>
#include <mythmainwindow.h>
+#include <mythprogressdialog.h>
#define LOC_ERR QString("MythGame:GAMEHANDLER Error: ")
#define LOC QString("MythGame:GAMEHANDLER: ")
-#include <mythprogressdialog.h>
static QList<GameHandler*> *handlers = NULL;
View
2 mythplugins/mythmusic/mythmusic/filescanner.cpp
@@ -6,7 +6,7 @@
#include <QDir>
// MythTV headers
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdb.h>
#include <mythcontext.h>
#include <mythdialogs.h>
View
4 mythplugins/mythmusic/mythmusic/metadata.cpp
@@ -7,13 +7,13 @@
// mythtv
#include <mythcontext.h>
#include <mythwidgets.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdb.h>
#include <mythdirs.h>
#include <mythprogressdialog.h>
#include <mythdownloadmanager.h>
#include <mythlogging.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mythmusic
#include "metadata.h"
View
2 mythplugins/mythmusic/mythmusic/smartplaylist.cpp
@@ -21,7 +21,7 @@ using namespace std;
#include <mythuispinbox.h>
#include <mythuicheckbox.h>
#include <mythdialogbox.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mythmusic
#include "smartplaylist.h"
View
2 mythplugins/mythnetvision/mythnetvision/netsearch.cpp
@@ -23,7 +23,7 @@
#include <metadata/videoutils.h>
#include <rssparse.h>
#include <mythcoreutil.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include "netsearch.h"
#include "netcommon.h"
View
2 mythplugins/mythnetvision/mythnetvision/nettree.cpp
@@ -4,7 +4,7 @@
#include <QtAlgorithms>
// myth
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythdb.h>
#include <mythcontext.h>
#include <mythdirs.h>
View
2 mythplugins/mythnetvision/mythnetvision/rsseditor.cpp
@@ -10,7 +10,7 @@
#include <mythuifilebrowser.h>
#include <mythmainwindow.h>
#include <mythdialogbox.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythcontext.h>
#include <mythdbcon.h>
#include <httpcomms.h>
View
2 mythplugins/mythnetvision/mythnetvision/treeeditor.cpp
@@ -11,7 +11,7 @@
#include <mythuibuttonlist.h>
#include <mythmainwindow.h>
#include <mythdialogbox.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythcontext.h>
#include <mythdbcon.h>
#include <mythdirs.h>
View
16 mythplugins/mythnews/mythnews/mythnews.cpp
@@ -13,18 +13,18 @@
#include <QUrl>
// MythTV headers
-#include <mythuitext.h>
-#include <mythuiimage.h>
-#include <mythdialogbox.h>
-#include <mythuibuttonlist.h>
#include <mythprogressdialog.h>
-
+#include <mythuibuttonlist.h>
#include <mythmainwindow.h>
-#include <mythmiscutil.h>
-#include <httpcomms.h>
+#include <mythdialogbox.h>
#include <mythcontext.h>
-#include <mythdb.h>
+#include <mythuiimage.h>
+#include <mythsystem.h>
+#include <mythuitext.h>
+#include <httpcomms.h>
+#include <mythdate.h>
#include <mythdirs.h>
+#include <mythdb.h>
// MythNews headers
#include "mythnews.h"
View
2 mythplugins/mythnews/mythnews/mythnewseditor.cpp
@@ -6,7 +6,7 @@
#include <mythuicheckbox.h>
#include <mythmainwindow.h>
#include <mythdialogbox.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythcontext.h>
#include <mythdbcon.h>
View
2 mythplugins/mythnews/mythnews/newssite.cpp
@@ -2,7 +2,7 @@
#include <QFile>
// MythTV headers
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include <mythlogging.h>
#include <mythdirs.h>
View
2 mythplugins/mythweather/mythweather/weather.cpp
@@ -11,7 +11,7 @@
#include <mythcontext.h>
#include <mythuitext.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// MythWeather headers
#include "weatherScreen.h"
View
2 mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
@@ -10,7 +10,7 @@
//myth
#include "mythcontext.h"
#include "mythdialogbox.h"
-#include <mythmiscutil.h>
+#include <mythdate.h>
#include "mythmainwindow.h"
#include "mythlogging.h"
View
2 mythplugins/mythzoneminder/mythzoneminder/zmconsole.cpp
@@ -23,7 +23,7 @@
#include <mythmainwindow.h>
#include <mythcontext.h>
#include <mythdbcon.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// zoneminder
#include "zmconsole.h"
View
2 mythplugins/mythzoneminder/mythzoneminder/zmevents.cpp
@@ -22,7 +22,7 @@
#include <mythcontext.h>
#include <mythdbcon.h>
#include <mythmainwindow.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// zoneminder
#include "zmevents.h"
View
2 mythplugins/mythzoneminder/mythzoneminder/zmplayer.cpp
@@ -28,7 +28,7 @@ using namespace std;
#include <mythdbcon.h>
#include <mythuihelper.h>
#include <mythmainwindow.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// zoneminder
#include "zmplayer.h"
View
2 mythplugins/mythzoneminder/mythzoneminder/zmsettings.cpp
@@ -6,7 +6,7 @@
// myth
#include <mythcontext.h>
-#include <mythmiscutil.h>
+#include <mythdate.h>
// mythzoneminder
#include "zmsettings.h"
View
2 mythtv/libs/libmyth/audio/audiooutput.cpp
@@ -10,7 +10,7 @@ using namespace std;
#include "mythconfig.h"
#include "audiooutput.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "compat.h"
#include "audiooutputnull.h"
View
2 mythtv/libs/libmyth/audio/audiooutputjack.cpp
@@ -14,7 +14,7 @@ using namespace std;
#include "mythcorecontext.h"
#include "audiooutputjack.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#define LOC QString("AOJack: ")
View
3 mythtv/libs/libmyth/audio/audiooutputoss.cpp
@@ -24,7 +24,8 @@ using namespace std;
#include "mythcorecontext.h"
#include "audiooutputoss.h"
-#include "mythmiscutil.h"
+#include "mythtimer.h"
+#include "mythdate.h"
AudioOutputOSS::AudioOutputOSS(const AudioSettings &settings) :
AudioOutputBase(settings),
View
2 mythtv/libs/libmyth/audio/audiopulsehandler.cpp
@@ -3,9 +3,9 @@
#include <QMutex>
#include "audiopulsehandler.h"
+#include "mythmiscutil.h"
#include "mythlogging.h"
#include "mthread.h"
-#include "mythmiscutil.h"
#define LOC QString("Pulse: ")
View
4 mythtv/libs/libmyth/mythcontext.cpp
@@ -14,7 +14,7 @@ using namespace std;
#include "config.h"
#include "mythcontext.h"
#include "exitcodes.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "remotefile.h"
#include "mythplugin.h"
#include "backendselect.h"
@@ -38,6 +38,8 @@ using namespace std;
#include "mythxmlclient.h"
#include "upnp.h"
#include "mythlogging.h"
+#include "mythsystem.h"
+#include "mythmiscutil.h"
#ifdef USING_MINGW
#include <unistd.h>
View
4 mythtv/libs/libmyth/mythmediamonitor.cpp
@@ -20,9 +20,11 @@ using namespace std;
#include "mythdialogs.h"
#include "mythconfig.h"
#include "mythdialogbox.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythlogging.h"
#include "mythmainwindow.h"
+#include "mythsystem.h"
+#include "mythmiscutil.h"
#ifdef USING_DARWIN_DA
#include "mediamonitor-darwin.h"
View
2 mythtv/libs/libmyth/mythrssmanager.cpp
@@ -3,7 +3,7 @@
#include <QFile>
#include <QDir>
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythdirs.h"
#include "mythcontext.h"
#include "mythlogging.h"
View
2 mythtv/libs/libmyth/mythwidgets.cpp
@@ -13,7 +13,7 @@ using namespace std;
#include "mythwidgets.h"
#include "mythcontext.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythdialogs.h"
#include "mythlogging.h"
#include "mythmainwindow.h"
View
5 mythtv/libs/libmyth/netgrabbermanager.cpp
@@ -8,8 +8,9 @@
#include "mythcontext.h"
#include "mythsystem.h"
#include "exitcodes.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythlogging.h"
+#include "mythsystem.h"
#include "netgrabbermanager.h"
#include "netutils.h"
@@ -282,7 +283,7 @@ void Search::executeSearch(const QString &script, const QString &query, uint pag
args.append("-S");
QString term = query;
- args.append(ShellEscape(term));
+ args.append(MythSystem::ShellEscape(term));
LOG(VB_GENERAL, LOG_DEBUG, LOC +
QString("Internet Search Query: %1 %2") .arg(cmd).arg(args.join(" ")));
View
2 mythtv/libs/libmyth/netutils.cpp
@@ -4,7 +4,7 @@
#include "mythdirs.h"
#include "mythdb.h"
#include "mythcontext.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "netutils.h"
View
17 mythtv/libs/libmyth/programinfo.cpp
@@ -21,18 +21,19 @@ using namespace std;
#include <QDir>
// MythTV headers
-#include "programinfo.h"
-#include "mythmiscutil.h"
+#include "programinfoupdater.h"
#include "mythcorecontext.h"
-#include "dialogbox.h"
+#include "mythscheduler.h"
+#include "mythmiscutil.h"
+#include "storagegroup.h"
+#include "mythlogging.h"
+#include "programinfo.h"
+#include "remotefile.h"
#include "remoteutil.h"
+#include "dialogbox.h"
+#include "mythdate.h"
#include "netutils.h"
#include "mythdb.h"
-#include "mythlogging.h"
-#include "storagegroup.h"
-#include "programinfoupdater.h"
-#include "mythscheduler.h"
-#include "remotefile.h"
#define LOC QString("ProgramInfo(%1): ").arg(GetBasename())
View
2 mythtv/libs/libmyth/programinfo.h
@@ -17,7 +17,7 @@
#include "programtypes.h"
#include "mythdbcon.h"
#include "mythexp.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
/* If NUMPROGRAMLINES gets updated following files need
updates and code changes:
View
2 mythtv/libs/libmyth/programtypes.cpp
@@ -4,7 +4,7 @@
#include <QMutex>
#include "programtypes.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
const char *kPlayerInUseID = "player";
const char *kPIPPlayerInUseID = "pipplayer";
View
2 mythtv/libs/libmyth/rssparse.cpp
@@ -12,7 +12,7 @@
#include "netutils.h"
#include "mythcontext.h"
#include "mythdirs.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
using namespace std;
View
3 mythtv/libs/libmyth/schemawizard.cpp
@@ -4,12 +4,13 @@
#include "dialogbox.h"
#include "mythcorecontext.h"
#include "schemawizard.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythtimer.h"
#include "mythlogging.h"
#include "mythmainwindow.h"
#include "mythuihelper.h"
+#include "mythmiscutil.h"
#include "mythdb.h"
View
2 mythtv/libs/libmyth/storagegroupeditor.cpp
@@ -8,7 +8,7 @@
#include "mythcorecontext.h"
#include "mythdb.h"
#include "mythlogging.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#define LOC QString("SGE(%1): ").arg(m_groupname)
View
2 mythtv/libs/libmyth/uitypes.cpp
@@ -16,7 +16,7 @@ using namespace std;
#include "mythdialogs.h"
#include "mythcontext.h"
#include "lcddevice.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythfontproperties.h"
#include "mythuihelper.h"
View
2 mythtv/libs/libmyth/uitypes.h
@@ -16,7 +16,7 @@ using namespace std;
#include "mythdeque.h"
#include "mythwidgets.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythdialogs.h"
#include "mythwidgets.h"
#include "mythfontproperties.h"
View
2 mythtv/libs/libmyth/xmlparse.cpp
@@ -11,7 +11,7 @@ using namespace std;
#include <QFile>
#include "xmlparse.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythcorecontext.h"
#include "mythfontproperties.h"
#include "mythuihelper.h"
View
1 mythtv/libs/libmythbase/dbutil.cpp
@@ -16,6 +16,7 @@
#include "mythcorecontext.h"
#include "storagegroup.h"
#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythdb.h"
#include "mythdirs.h"
#include "mythlogging.h"
View
2 mythtv/libs/libmythbase/hardwareprofile.cpp
@@ -11,7 +11,7 @@
#include "mythlogging.h"
#include "mythsystem.h"
#include "exitcodes.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
const QString SMOLT_SERVER_LOCATION =
QString("http://smolt.mythtv.org/");
View
6 mythtv/libs/libmythbase/libmythbase.pro
@@ -24,7 +24,7 @@ HEADERS += mythmiscutil.h mythhdd.h mythcdrom.h autodeletedeque.h dbutil.h
HEADERS += mythhttppool.h mythhttphandler.h mythdeque.h mythlogging.h
HEADERS += mythbaseutil.h referencecounter.h version.h mythcommandlineparser.h
HEADERS += mythscheduler.h filesysteminfo.h hardwareprofile.h serverpool.h
-HEADERS += plist.h bswap.h
+HEADERS += plist.h bswap.h mythtimezone.h mythdate.h
HEADERS += ffmpeg-mmx.h
SOURCES += mthread.cpp mthreadpool.cpp
@@ -40,7 +40,7 @@ SOURCES += mythhdd.cpp mythcdrom.cpp dbutil.cpp
SOURCES += mythhttppool.cpp mythhttphandler.cpp logging.cpp
SOURCES += referencecounter.cpp mythcommandlineparser.cpp
SOURCES += filesysteminfo.cpp hardwareprofile.cpp serverpool.cpp
-SOURCES += plist.cpp
+SOURCES += plist.cpp mythtimezone.cpp mythdate.cpp
win32:SOURCES += msocketdevice_win.cpp
unix {
@@ -67,7 +67,7 @@ inc.files += mythtranslation.h iso639.h iso3166.h mythmedia.h mythmiscutil.h
inc.files += mythcdrom.h autodeletedeque.h dbutil.h mythhttppool.h mythdeque.h
inc.files += referencecounter.h mythcommandlineparser.h mthread.h mthreadpool.h
inc.files += filesysteminfo.h hardwareprofile.h bonjourregister.h serverpool.h
-inc.files += plist.h bswap.h ffmpeg-mmx.h
+inc.files += plist.h bswap.h ffmpeg-mmx.h mythdate.h
# Allow both #include <blah.h> and #include <libmythbase/blah.h>
inc2.path = $${PREFIX}/include/mythtv/libmythbase
View
2 mythtv/libs/libmythbase/mythcdrom-linux.cpp
@@ -16,7 +16,7 @@
#include "mythcdrom-linux.h"
#include "mythconfig.h" // for HAVE_BIGENDIAN
#include "mythlogging.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#ifdef USING_LIBUDF
#include <cdio/udf.h>
View
18 mythtv/libs/libmythbase/mythcommandlineparser.cpp
@@ -20,14 +20,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iostream>
-#include <fstream>
-#include <stdio.h>
+// C headers
#include <stdlib.h>
-#include <algorithm>
-#include <sys/types.h>
+#include <stdio.h>
+
+// POSIX headers
#include <unistd.h>
+#include <signal.h>
+// System headers
+#include <sys/types.h>
#ifndef _WIN32
#include <sys/ioctl.h>
#include <pwd.h>
@@ -37,8 +39,13 @@
#endif
#endif
+// C++ headers
+#include <algorithm>
+#include <iostream>
+#include <fstream>
using namespace std;
+// Qt headers
#include <QDir>
#include <QFile>
#include <QFileInfo>
@@ -59,6 +66,7 @@ using namespace std;
#include "mythversion.h"
#include "logging.h"
#include "mythmiscutil.h"
+#include "mythdate.h"
#define TERMWIDTH 79
View
148 mythtv/libs/libmythbase/mythdate.cpp
@@ -0,0 +1,148 @@
+#include "mythcorecontext.h"
+#include "mythdate.h"
+
+namespace MythDate
+{
+
+QDateTime current(bool stripped)
+{
+ QDateTime rettime = QDateTime::currentDateTime().toUTC();
+ if (stripped)
+ rettime = rettime.addMSecs(-rettime.time().msec());
+ return rettime;
+}
+
+QString current_iso_string(bool stripped)
+{
+ return MythDate::current(stripped).toString(Qt::ISODate);
+}
+
+QDateTime as_utc(const QDateTime &old_dt)
+{
+ QDateTime dt(old_dt);
+ dt.setTimeSpec(Qt::UTC);
+ return dt;
+}
+
+QDateTime fromString(const QString &dtstr)
+{
+ QDateTime dt;
+ if (dtstr.isEmpty())
+ return as_utc(dt);
+
+ if (!dtstr.contains("-") && dtstr.length() == 14)
+ {
+ // must be in yyyyMMddhhmmss format
+ dt = QDateTime::fromString(dtstr, "yyyyMMddhhmmss");
+ }
+ else
+ {
+ dt = QDateTime::fromString(dtstr, Qt::ISODate);
+ }
+
+ return as_utc(dt);
+}
+
+MBASE_PUBLIC QDateTime fromString(const QString &str, const QString &format)
+{
+ QDateTime dt = QDateTime::fromString(str, format);
+ dt.setTimeSpec(Qt::UTC);
+ return dt;
+}
+
+MBASE_PUBLIC QDateTime fromTime_t(uint seconds)
+{
+ QDateTime dt = QDateTime::fromTime_t(seconds);
+ return dt.toUTC();
+}
+
+/** \fn toString(const QDateTime&,uint)
+ * \brief Returns a formatted QString based on the supplied QDateTime
+ *
+ * \param datetime The QDateTime object to use
+ * \param format The format of the string to return
+ */
+QString toString(const QDateTime &raw_dt, uint format)
+{
+ QString result;
+
+ // if no format is set default to UTC for ISO/file/DB dates.
+ if (!((format & kOverrideUTC) || (format & kOverrideLocal)))
+ {
+ format |= ((ISODate|kFilename|kDatabase) & format) ?
+ kOverrideUTC : kOverrideLocal;
+ }
+
+ QDateTime datetime =
+ (format & kOverrideUTC) ? raw_dt.toUTC() : raw_dt.toLocalTime();
+
+ if (format & kDatabase)
+ return datetime.toString("yyyy-MM-dd hh:mm:ss");
+
+ if (format & MythDate::ISODate)
+ return datetime.toString(Qt::ISODate);
+
+ if (format & kFilename)
+ return datetime.toString("yyyyMMddhhmmss");
+
+ if (format & kScreenShotFilename)
+ return datetime.toString("yyyy-MM-ddThh-mm-ss.zzz");
+
+ if (format & (kDateFull | kDateShort))
+ result += toString(datetime.date(), format);
+
+ if (format & kTime)
+ {
+ if (!result.isEmpty())
+ result.append(", ");
+
+ QString timeformat = gCoreContext->GetSetting("TimeFormat", "h:mm AP");
+ result += datetime.time().toString(timeformat);
+ }
+
+ return result;
+}
+
+/** \brief Returns a formatted QString based on the supplied QDate
+ *
+ * \param date The QDate object to use
+ * \param format The format of the string to return
+ */
+QString toString(const QDate &date, uint format)
+{
+ QString result;
+
+ if (format & (kDateFull | kDateShort))
+ {
+ QDate now = current().date();
+
+ QString stringformat;
+ if (format & kDateShort)
+ stringformat = gCoreContext->GetSetting("ShortDateFormat", "ddd d");
+ else
+ stringformat = gCoreContext->GetSetting("DateFormat", "ddd d MMMM");
+
+ if (format & kAddYear)
+ {
+ if (!stringformat.contains("yy")) // Matches both 2 or 4 digit year
+ stringformat.append(" yyyy");
+ }
+
+ if (format & ~kDateShort)
+ {
+ if ((format & kSimplify) && (now == date))
+ result = QObject::tr("Today");
+ else if ((format & kSimplify) && (now.addDays(-1) == date))
+ result = QObject::tr("Yesterday");
+ else if ((format & kSimplify) && (now.addDays(1) == date))
+ result = QObject::tr("Tomorrow");
+ }
+
+ if (result.isEmpty())
+ result = gCoreContext->GetQLocale().toString(date, stringformat);
+ }
+
+ return result;
+}
+
+}; // namespace MythDate
View
52 mythtv/libs/libmythbase/mythdate.h
@@ -0,0 +1,52 @@
+#ifndef _MYTH_DATE_H_
+#define _MYTH_DATE_H_
+
+#include <QDateTime>
+#include <QString>
+
+#include "mythbaseexp.h"
+
+namespace MythDate
+{
+
+typedef enum Formats
+{
+ ISODate = Qt::ISODate, // Default UTC
+ kFilename = 0x000100, // Default UTC, "yyyyMMddhhmmss"
+ kDateFull = 0x000200, // Default local time
+ kDateShort = 0x000400, // Default local time
+ kTime = 0x000800, // Default local time
+ kDateTimeFull = kDateFull | kTime, // Default local time
+ kDateTimeShort = kDateShort | kTime, // Default local time
+ kAddYear = 0x001000, // Add year to string if not included
+ kSimplify = 0x002000, // Do Today/Yesterday/Tomorrow transform
+ kDatabase = 0x004000, // Default UTC, database format
+ kScreenShotFilename = 0x8000, // "yyyy-MM-ddThh-mm-ss.zzz"
+ kOverrideUTC = 0x100000, // Present date/time in UTC
+ kOverrideLocal = 0x200000, // Present date/time in localtime
+} Format;
+
+/// Returns current Date and Time in UTC.
+/// \param stripped if true milliseconds are stripped
+MBASE_PUBLIC QDateTime current(bool stripped = false);
+/// Returns current Date and Time in UTC as a string.
+/// \param stripped if true milliseconds are stripped
+MBASE_PUBLIC QString current_iso_string(bool stripped = false);
+/// Returns copy of QDateTime with TimeSpec set to UTC.
+MBASE_PUBLIC QDateTime as_utc(const QDateTime &dt);
+
+/// Converts kFilename && kISODate formats to QDateTime
+MBASE_PUBLIC QDateTime fromString(const QString&);
+/// Converts dy in format to QDateTime
+MBASE_PUBLIC QDateTime fromString(const QString &dt, const QString &format);
+MBASE_PUBLIC QDateTime fromTime_t(uint seconds);
+/// Returns formatted string representing the time.
+MBASE_PUBLIC QString toString(
+ const QDateTime &datetime, uint format = MythDate::kDateTimeFull);
+/// Warning: this function can not convert to and from UTC
+MBASE_PUBLIC QString toString(
+ const QDate &date, uint format = MythDate::kDateFull);
+
+};
+
+#endif // _MYTH_DATE_H_
View
2 mythtv/libs/libmythbase/mythdbcon.cpp
@@ -20,7 +20,7 @@
#include "mythsystem.h"
#include "exitcodes.h"
#include "mthread.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#define DEBUG_RECONNECT 0
#if DEBUG_RECONNECT
View
2 mythtv/libs/libmythbase/mythdownloadmanager.cpp
@@ -22,7 +22,7 @@
#include "mythevent.h"
#include "mythversion.h"
#include "remotefile.h"
-#include "mythmiscutil.h"
+#include "mythdate.h"
#include "mythdownloadmanager.h"
#include "mythlogging.h"
View
601 mythtv/libs/libmythbase/mythmiscutil.cpp
@@ -36,6 +36,7 @@ using namespace std;
// Qt headers
#include <QReadWriteLock>
#include <QNetworkProxy>
+#include <QStringList>
#include <QFileInfo>
#include <QFile>
#include <QDir>
@@ -52,589 +53,6 @@ using namespace std;
#include "mythconfig.h" // for CONFIG_DARWIN
-namespace MythDate
-{
-
-QDateTime current(bool stripped)
-{
- QDateTime rettime = QDateTime::currentDateTime().toUTC();
- if (stripped)
- rettime = rettime.addMSecs(-rettime.time().msec());
- return rettime;
-}
-
-QString current_iso_string(bool stripped)
-{
- return MythDate::current(stripped).toString(Qt::ISODate);
-}
-
-QDateTime as_utc(const QDateTime &old_dt)
-{
- QDateTime dt(old_dt);
- dt.setTimeSpec(Qt::UTC);
- return dt;
-}
-
-QDateTime fromString(const QString &dtstr)
-{
- QDateTime dt;
- if (dtstr.isEmpty())
- return as_utc(dt);
-
- if (!dtstr.contains("-") && dtstr.length() == 14)
- {
- // must be in yyyyMMddhhmmss format
- dt = QDateTime::fromString(dtstr, "yyyyMMddhhmmss");
- }
- else
- {
- dt = QDateTime::fromString(dtstr, Qt::ISODate);
- }
-
- return as_utc(dt);
-}
-
-MBASE_PUBLIC QDateTime fromString(const QString &str, const QString &format)
-{
- QDateTime dt = QDateTime::fromString(str, format);
- dt.setTimeSpec(Qt::UTC);
- return dt;
-}
-
-MBASE_PUBLIC QDateTime fromTime_t(uint seconds)
-{
- QDateTime dt = QDateTime::fromTime_t(seconds);
- return dt.toUTC();
-}
-
-/** \fn toString(const QDateTime&,uint)
- * \brief Returns a formatted QString based on the supplied QDateTime
- *
- * \param datetime The QDateTime object to use
- * \param format The format of the string to return
- */
-QString toString(const QDateTime &raw_dt, uint format)
-{
- QString result;
-
- // if no format is set default to UTC for ISO/file/DB dates.
- if (!((format & kOverrideUTC) || (format & kOverrideLocal)))
- {
- format |= ((ISODate|kFilename|kDatabase) & format) ?
- kOverrideUTC : kOverrideLocal;
- }
-
- QDateTime datetime =
- (format & kOverrideUTC) ? raw_dt.toUTC() : raw_dt.toLocalTime();
-
- if (format & kDatabase)
- return datetime.toString("yyyy-MM-dd hh:mm:ss");
-
- if (format & MythDate::ISODate)
- return datetime.toString(Qt::ISODate);
-
- if (format & kFilename)
- return datetime.toString("yyyyMMddhhmmss");
-
- if (format & kScreenShotFilename)
- return datetime.toString("yyyy-MM-ddThh-mm-ss.zzz");
-
- if (format & (kDateFull | kDateShort))
- result += toString(datetime.date(), format);
-
- if (format & kTime)
- {
- if (!result.isEmpty())
- result.append(", ");
-
- QString timeformat = gCoreContext->GetSetting("TimeFormat", "h:mm AP");
- result += datetime.time().toString(timeformat);
- }
-
- return result;
-}
-
-/** \brief Returns a formatted QString based on the supplied QDate
- *
- * \param date The QDate object to use
- * \param format The format of the string to return
- */
-QString toString(const QDate &date, uint format)
-{
- QString result;
-
- if (format & (kDateFull | kDateShort))
- {
- QDate now = current().date();
-
- QString stringformat;
- if (format & kDateShort)
- stringformat = gCoreContext->GetSetting("ShortDateFormat", "ddd d");
- else
- stringformat = gCoreContext->GetSetting("DateFormat", "ddd d MMMM");
-
- if (format & kAddYear)
- {
- if (!stringformat.contains("yy")) // Matches both 2 or 4 digit year
- stringformat.append(" yyyy");
- }
-
- if (format & ~kDateShort)
- {
- if ((format & kSimplify) && (now == date))
- result = QObject::tr("Today");
- else if ((format & kSimplify) && (now.addDays(-1) == date))
- result = QObject::tr("Yesterday");
- else if ((format & kSimplify) && (now.addDays(1) == date))
- result = QObject::tr("Tomorrow");
- }
-
- if (result.isEmpty())
- result = gCoreContext->GetQLocale().toString(date, stringformat);
- }
-
- return result;
-}
-
-}; // namespace MythDate
-
-int calc_utc_offset(void)
-{
- QDateTime loc = QDateTime::currentDateTime();
- QDateTime utc = loc.toUTC();
- loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
- return utc.secsTo(loc);
-}
-
-static bool compare_zone_files(QFileInfo first_file_info,
- QFileInfo second_file_info)
-{
- if (!first_file_info.isFile() || !second_file_info.isFile() ||
- !first_file_info.isReadable() || !second_file_info.isReadable())
- return false;
-
- qint64 first_file_size = first_file_info.size();
- // sanity check - zoneinfo files should typically be less than
- // about 4kB, but leave room for growth
- if ((first_file_size > 200 * 1024) ||
- (second_file_info.size() != first_file_size))
- return false;
-
- QFile first_file(first_file_info.absoluteFilePath());
- QByteArray first_file_data;
- first_file_data.resize(first_file_size);
- QFile second_file(second_file_info.absoluteFilePath());
- QByteArray second_file_data;
- second_file_data.resize(first_file_size);
- if (first_file.open(QIODevice::ReadOnly))
- {
- QDataStream in(&first_file);
- if (in.readRawData(first_file_data.data(),
- first_file_size) != first_file_size)
- {
- first_file.close();
- return false;
- }
- first_file.close();
- }
- if (second_file.open(QIODevice::ReadOnly))
- {
- QDataStream in(&second_file);
- if (in.readRawData(second_file_data.data(),
- first_file_size) != first_file_size)
- {
- second_file.close();
- return false;
- }
- second_file.close();
- }
- if (first_file_data == second_file_data)
- return true;
-
- return false;
-}
-
-#ifndef USING_MINGW
-/* Helper function for getSystemTimeZoneID() that compares the
- zoneinfo_file_path (regular) file with files in the zoneinfo_dir_path until
- it finds a match. The matching file's name is used to determine the time
- zone ID. */
-static QString findZoneinfoFile(QString zoneinfo_file_path,
- QString zoneinfo_dir_path)
-{
- QString zone_id("UNDEF");
- QDir zoneinfo_dir(zoneinfo_dir_path);
- QFileInfoList dirlist = zoneinfo_dir.entryInfoList();
- QFileInfo info;
- QString basename;
- QFileInfo zoneinfo_file_info(zoneinfo_file_path);
-
- for (QFileInfoList::const_iterator it = dirlist.begin();
- it != dirlist.end(); ++it)
- {
- info = *it;
- // Skip '.' and '..' and other files starting with "." and
- // skip localtime (which is often a link to zoneinfo_file_path)
- basename = info.baseName();
- if (basename.isEmpty() || (basename == "localtime")) {
- continue;
- }
- if (info.isDir())
- {
- zone_id = findZoneinfoFile(zoneinfo_file_path,
- info.absoluteFilePath());
- if (zone_id != "UNDEF")
- return zone_id;
- }
- else if (compare_zone_files(zoneinfo_file_info, info))
- {
- zone_id = info.absoluteFilePath();
- break;
- }
- }
- return zone_id;
-}
-#endif
-
-/* helper fuction to find the zone ID in a configuration string
- allows NIS-format /etc/timezone , which contains extra information:
- <time zone ID> <host or NIS domain name> # optional comments
-*/
-static bool parse_zone_id_config_string(QString& zone_id)
-{
- bool found = false;
- QString zoneinfo_dir_path("/usr/share/zoneinfo/");
- QRegExp sep("\\s+");
- QFileInfo file_info;
-
- while (!found)
- {
- QString temp_zone_id = zone_id;
- temp_zone_id.replace(' ', '_');
- file_info.setFile(zoneinfo_dir_path + temp_zone_id);
- if (file_info.exists())
- {
- found = true;
- }
- else
- {
- zone_id = zone_id.section(sep, 0, -2);
- if (zone_id.isEmpty())
- break;
- }
- }
- return found;
-}
-
-/* helper fuction to read time zone id from a file
- Debian's /etc/timezone or Red Hat's /etc/sysconfig/clock */
-static bool read_time_zone_id(QString filename, QString& zone_id)
-{
- bool found = false;
- QFile file(filename);
- QFileInfo info(file);
- if (info.exists() && info.isFile() && info.isReadable())
- {
- if (file.open(QIODevice::ReadOnly | QIODevice::Text))
- {
- QString line;
- QTextStream in(&file);
- // Handle whitespace and quotes
- QRegExp re("^(?:ZONE\\s*=)?\\s*(['\"]?)([\\w\\s/-\\+]+)\\1\\s*(?:#.*)?$");
- re.setPatternSyntax(QRegExp::RegExp2);
- while (!in.atEnd())
- {
- line = in.readLine();
- if (re.indexIn(line) != -1)
- {
- zone_id = re.cap(2);
- if (parse_zone_id_config_string(zone_id))
- found = true;
- break;
- }
- }
- file.close();
- }
- }
- return found;
-}
-
-/* Helper function for getTimeZoneID() that provides an unprocessed time zone
- id obtained using system-dependent means of identifying the system's time
- zone. */
-static QString getSystemTimeZoneID(void)
-{
- QString zone_id("UNDEF");
-#ifdef USING_MINGW
- // typedef struct _TIME_ZONE_INFORMATION { ...
- // GetTimeZoneInformation();
- // ...
- // Sadly, Windows zone names are different to the (probably Unix)
- // backend's names - "AUS Eastern Standard Time" vs "Australia/Sydney".
- // Translation is not worthwhile. Leave it as UNDEF to check the offset.
-#else
- // Try to determine the time zone information by inspecting the system
- // configuration
- QString time_zone_file_path("/etc/timezone");
- QString clock_file_path("/etc/sysconfig/clock");
- QString zoneinfo_file_path("/etc/localtime");
- QString zoneinfo_dir_path("/usr/share/zoneinfo");
-
- // First, check time_zone_file_path (used by Debian-based systems)
- if (read_time_zone_id(time_zone_file_path, zone_id))
- return zone_id;
-
- // Next, look for the ZONE entry in clock_file_path (used by Red Hat-based
- // systems)
- if (read_time_zone_id(clock_file_path, zone_id))
- return zone_id;
-
- // Next check zoneinfo_file_path
- QFile zoneinfo_file(zoneinfo_file_path);
- QFileInfo info(zoneinfo_file);
-
- if (info.exists() && info.isFile())
- {
- QString tz;
- if (info.isSymLink())
- {
- // The symlink refers to a file whose name contains the zone ID
- tz = info.symLinkTarget();
- }
- else
- {
- // The zoneinfo_file is a copy of the file in the
- // zoneinfo_dir_path, so search for the same file in
- // zoneinfo_dir_path
- tz = findZoneinfoFile(zoneinfo_file_path, zoneinfo_dir_path);
- }
- if (tz != "UNDEF")
- {
- int pos = 0;
- // Get the zone ID from the filename
- // Look for the basename of zoneinfo_dir_path in case it's a
- // relative link
- QString zoneinfo_dirname = zoneinfo_dir_path.section('/', -1);
- if ((pos = tz.indexOf(zoneinfo_dirname)) != -1)
- {
- zone_id = tz.right(tz.size() - (pos + 1) -
- zoneinfo_dirname.size());
- }
- }
- else
- {
- // If we still haven't found a time zone, try localtime_r() to at
- // least get the zone name/abbreviation (as opposed to the
- // identifier for the set of rules governing the zone)
- char name[64];
- time_t t;
- struct tm *result = (struct tm *)malloc(sizeof(*result));
-
- if (result != NULL)
- {
- t = time(NULL);
- localtime_r(&t, result);
- if (result != NULL)
- {
- if (strftime(name, sizeof(name), "%Z", result) > 0)
- zone_id = name;
- free(result);
- }
- }
- }
- }
-
-#endif
- return zone_id;
-}
-
-/** \fn getTimeZoneID()
- * \brief Returns the zoneinfo time zone ID or as much time zone information
- * as possible
- */
-QString getTimeZoneID(void)
-{
- QString zone_id("UNDEF");
-#ifndef USING_MINGW
- // First, try the TZ environment variable to check for environment-specific
- // overrides
- QString tz = getenv("TZ");
- if (tz.isEmpty())
- {
- // No TZ, so attempt to determine the system-configured time zone ID
- tz = getSystemTimeZoneID();
- }
-
- if (!tz.isEmpty())
- {
- zone_id = tz;
- if (zone_id.startsWith("\"") || zone_id.startsWith("'"))
- zone_id.remove(0, 1);
- if (zone_id.endsWith("\"") || zone_id.endsWith("'"))
- zone_id.chop(1);
- if (zone_id.startsWith(":"))
- zone_id.remove(0, 1);
- // the "posix/" subdirectory typically contains the same files as the
- // "zoneinfo/" parent directory, but are not typically what are in use
- if (zone_id.startsWith("posix/"))
- zone_id.remove(0, 6);
- }
-
-#endif
- return zone_id;
-}
-
-/* Helper function for checkTimeZone() that compares zone ID's.
- In the event that the zone ID's differ, checks to see if the local
- zoneinfo database has both zone ID's and if they're equivalent. */
-static bool compare_zone_IDs(QString firstZoneID, QString secondZoneID)
-{
- // Some distros use spaces rather than underscores in the zone ID, so
- // allow matches where the only difference is space vs. underscore.
- firstZoneID.replace(' ', '_');
- secondZoneID.replace(' ', '_');
- if (firstZoneID == secondZoneID)
- return true;
-
- // Although the zone ID names don't match, they may refer to equivalent
- // rules, so compare the files
- QString zoneinfo_dir_path("/usr/share/zoneinfo");
- QFileInfo firstInfo(zoneinfo_dir_path + "/" + firstZoneID);
- QFileInfo secondInfo(zoneinfo_dir_path + "/" + secondZoneID);
- if (compare_zone_files(firstInfo, secondInfo))
- return true;
-
- return false;
-}
-
-static void print_timezone_info(QString master_zone_id, QString local_zone_id,
- int master_utc_offset, int local_utc_offset,
- QString master_time, QString local_time)
-{
- LOG(VB_GENERAL, LOG_NOTICE,
- QString("Detected time zone settings:\n"
- " Master: Zone ID: '%1', UTC Offset: '%2', Current Time: '%3'\n"
- " Local: Zone ID: '%4', UTC Offset: '%5', Current Time: '%6'\n")
- .arg(master_zone_id).arg(master_utc_offset).arg(master_time)
- .arg(local_zone_id).arg(local_utc_offset).arg(local_time));
-}
-
-/** \fn checkTimeZone()
- * \brief Verifies the time zone settings on this system agree with those
- * on the master backend
- */
-bool checkTimeZone(void)
-{
- return true;
-
- if (gCoreContext->IsMasterBackend())
- return true;
-
- QStringList master_settings(QString("QUERY_TIME_ZONE"));
- if (!gCoreContext->SendReceiveStringList(master_settings))
- {
- LOG(VB_GENERAL, LOG_CRIT,
- "Unable to determine master backend time zone "
- "settings. If those settings differ from local "
- "settings, some functionality will fail.");
- return true;
- }
-
- return checkTimeZone(master_settings);
-}
-
-/// This overloaded version allows for the use of an existing (not managed by
-/// MythContext) connection to the backend.
-bool checkTimeZone(const QStringList &master_settings)
-{
- return true;
-
- QDateTime local_time = QDateTime::currentDateTime();
- QString local_time_string = local_time.toString(Qt::ISODate);
-
- bool have_zone_IDs = true;
-
- QString master_time_zone_ID = master_settings[0];
- int master_utc_offset = master_settings[1].toInt();
- QString master_time_string = master_settings[2];
- QString local_time_zone_ID = getTimeZoneID();
- int local_utc_offset = calc_utc_offset();
-
- if (master_time_zone_ID == "UNDEF")
- {
- LOG(VB_GENERAL, LOG_CRIT,
- "Unable to determine master backend time zone "
- "settings. If local time zone settings differ "
- "from master backend settings, some functionality will fail.");
- have_zone_IDs = false;
- }
- if (local_time_zone_ID == "UNDEF")
- {
- LOG(VB_GENERAL, LOG_CRIT,
- "Unable to determine local time zone settings. "
- "If local time zone settings differ from "
- "master backend settings, some functionality will fail.");
- have_zone_IDs = false;
- }
-
- if (have_zone_IDs &&
- !compare_zone_IDs(master_time_zone_ID, local_time_zone_ID))
- {
- LOG(VB_GENERAL, LOG_CRIT, "Time zone settings on the master backend "
- "differ from those on this system.");
-
- print_timezone_info(master_time_zone_ID, local_time_zone_ID,
- master_utc_offset, local_utc_offset,
- master_time_string, local_time_string);
- return false;
- }
-
- // Verify offset
- if (master_utc_offset != local_utc_offset)
- {
- LOG(VB_GENERAL, LOG_CRIT, "UTC offset on the master backend differs "
- "from offset on this system.");
-
- print_timezone_info(master_time_zone_ID, local_time_zone_ID,
- master_utc_offset, local_utc_offset,
- master_time_string, local_time_string);
- return false;
- }
-
- // Verify current time
- if (master_time_string == "UNDEF")
- {
- LOG(VB_GENERAL, LOG_CRIT,
- "Unable to determine current time on the master "
- "backend . If local time or time zone settings "
- "differ from those on the master backend, some "
- "functionality will fail.");
- }
- else
- {
- QDateTime master_time = MythDate::fromString(master_time_string);
- uint timediff = abs(master_time.secsTo(local_time));
- if (timediff > 300)
- {
- LOG(VB_GENERAL, LOG_CRIT, "Current time on the master backend "
- "differs from time on this system.");
- print_timezone_info(master_time_zone_ID, local_time_zone_ID,
- master_utc_offset, local_utc_offset,
- master_time_string, local_time_string);
- return false;
- }
- else if (timediff > 20)
- {
- LOG(VB_GENERAL, LOG_CRIT,
- QString("Warning! Time difference between the master "
- "backend and this system is %1 seconds.")
- .arg(timediff));
- }
- }
-
- return true;
-}
-
/** \fn getUptime(time_t&)
* \brief Returns uptime statistics.
* \return true if successful, false otherwise.
@@ -1416,23 +834,6 @@ bool MythRemoveDirectory(QDir &aDir)
return(has_err);
}
-QString &ShellEscape(QString &string)
-{
- if (string.contains("\""))
- string = string.replace("\"", "\\\"");
-
- if (string.contains("\'"))
- string = string.replace("\'", "\\\'");
-
- if (string.contains(" "))
- {
- string.prepend("\"");
- string.append("\"");
- }
-
- return string;
-}
-
/**
* \brief Get network proxy settings from OS, and use for [Q]Http[Comms]
*
View
118 mythtv/libs/libmythbase/mythmiscutil.h
@@ -1,97 +1,45 @@
#ifndef MYTHMISCUTIL_H_
#define MYTHMISCUTIL_H_
+#include <stdint.h>
+
#include <algorithm>
using namespace std;
-#include <QStringList>
-#include <QDateTime>
+#include <QString>
#include <QDir>
-#include <stdint.h>
-#include <time.h>
-
#include "mythbaseexp.h"
-#include "mythtimer.h"
-#include "mythsystem.h"
-#include "mythevent.h"
+class QStringList;
class QFile;
-namespace MythDate
-{
-typedef enum Formats
-{
- ISODate = Qt::ISODate, // Default UTC
- kFilename = 0x000100, // Default UTC, "yyyyMMddhhmmss"
- kDateFull = 0x000200, // Default local time
- kDateShort = 0x000400, // Default local time
- kTime = 0x000800, // Default local time
- kDateTimeFull = kDateFull | kTime, // Default local time
- kDateTimeShort = kDateShort | kTime, // Default local time
- kAddYear = 0x001000, // Add year to string if not included
- kSimplify = 0x002000, // Do Today/Yesterday/Tomorrow transform
- kDatabase = 0x004000, // Default UTC, database format
- kScreenShotFilename = 0x8000, // "yyyy-MM-ddThh-mm-ss.zzz"
- kOverrideUTC = 0x100000, // Present date/time in UTC
- kOverrideLocal = 0x200000, // Present date/time in localtime
-} Format;
-
-/// Returns current Date and Time in UTC.
-/// \param stripped if true milliseconds are stripped
-MBASE_PUBLIC QDateTime current(bool stripped = false);
-/// Returns current Date and Time in UTC as a string.
-/// \param stripped if true milliseconds are stripped
-MBASE_PUBLIC QString current_iso_string(bool stripped = false);
-/// Returns copy of QDateTime with TimeSpec set to UTC.
-MBASE_PUBLIC QDateTime as_utc(const QDateTime &dt);
-
-/// Converts kFilename && kISODate formats to QDateTime
-MBASE_PUBLIC QDateTime fromString(const QString&);
-/// Converts dy in format to QDateTime
-MBASE_PUBLIC QDateTime fromString(const QString &dt, const QString &format);
-MBASE_PUBLIC QDateTime fromTime_t(uint seconds);
-/// Returns formatted string representing the time.
-MBASE_PUBLIC QString toString(
- const QDateTime &datetime, uint format = MythDate::kDateTimeFull);
-/// Warning: this function can not convert to and from UTC
-MBASE_PUBLIC QString toString(
- const QDate &date, uint format = MythDate::kDateFull);
-
-};
-
- MBASE_PUBLIC int calc_utc_offset(void);
-
- MBASE_PUBLIC QString getTimeZoneID(void);
- MBASE_PUBLIC bool checkTimeZone(void);
- MBASE_PUBLIC bool checkTimeZone(const QStringList &master_settings);
-
- MBASE_PUBLIC bool getUptime(time_t &uptime);
- MBASE_PUBLIC bool getMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM);
-
- MBASE_PUBLIC bool hasUtf8(const char *str);
-#define M_QSTRING_UNICODE(str) hasUtf8(str) ? QString::fromUtf8(str) : str
+MBASE_PUBLIC bool getUptime(time_t &uptime);
+MBASE_PUBLIC bool getMemStats(
+ int &totalMB, int &freeMB, int &totalVM, int &freeVM);
- MBASE_PUBLIC bool ping(const QString &host, int timeout);
- MBASE_PUBLIC bool telnet(const QString &host, int port);
+MBASE_PUBLIC bool hasUtf8(const char *str);
+#define M_QSTRING_UNICODE(str) hasUtf8(str) ? QString::fromUtf8(str) : str
- MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size = 0);
- MBASE_PUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXXX",
- bool dir = false);
- MBASE_PUBLIC void makeFileAccessible(QString filename);
+MBASE_PUBLIC bool ping(const QString &host, int timeout);
+MBASE_PUBLIC bool telnet(const QString &host, int port);
- MBASE_PUBLIC QString getResponse(const QString &query, const QString &def);
- MBASE_PUBLIC int intResponse(const QString &query, int def);
+MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size = 0);
+MBASE_PUBLIC QString createTempFile(
+ QString name_template = "/tmp/mythtv_XXXXXX", bool dir = false);
+MBASE_PUBLIC void makeFileAccessible(QString filename);
- MBASE_PUBLIC QString getSymlinkTarget(const QString &start_file,
- QStringList *intermediaries = NULL,
- unsigned maxLinks = 255);
+MBASE_PUBLIC QString getResponse(const QString &query, const QString &def);
+MBASE_PUBLIC int intResponse(const QString &query, int def);
- MBASE_PUBLIC void sendPlaybackStart();
- MBASE_PUBLIC void sendPlaybackEnd();
+MBASE_PUBLIC QString getSymlinkTarget(const QString &start_file,
+ QStringList *intermediaries = NULL,
+ unsigned maxLinks = 255);